Trouble sending ASCII serial

I am (supposed to be) programming an Omron PLC to communicate with a particle counter. The particle counter accepts ASCII commands over RS-232 serial with the following parameters (see attached): 4800bps, 7 data bits, 2 stop bits, even parity.

I don’t have access to the particle counter right now so I am programming an Arduino Uno to act as a particle counter simulator.

As a test, I am sending (2) 16-bit words (4 bytes) from the PLC (see attachment):

D100: 01100010 01100001 [b a]
D101: 01100011 01100100 [c d]

The PLC is configured to send least significant byte first no start code, and for an end code: CR,LF

I am trying to get the Arduino to receive these bytes and recognize them as ASCII, and print out in the serial monitor so I can confirm on the laptop that it is receiving the proper commands from the PLC.

I was not able to make this work (serial @ 7,E,2) using the normal softwareSerial library so I am using ledongthuc’s CustomSoftwareSerial and I am receiving data from the PLC but it doesn’t represent the bits I am sending. I was only getting garbledy-gook out of it.

I’m expecting “abdc” on the serial monitor but I’m getting “=;7rJV|”

#include <CustomSoftwareSerial.h> //import the custom software serial library
CustomSoftwareSerial* customSerial; //define serial port name

String myText;
boolean done = 0;

void setup() {
  Serial.begin(19200); //baud rate between Arduino and PC
  customSerial = new CustomSoftwareSerial(3, 2); // define rx & tx pins.
  customSerial->begin(4800, CSERIAL_7E2); //start software serial port with 4800baud, 7 bits, even parity, 2 stop bits.
}

void loop() {
 // this code prints out each character from the software serial port in binary. paste into void loop()
  while(customSerial->available() > 0){
    done = 0;
    delay(1);    //small delay to allow input buffer to fill
    char c = customSerial->read();  //gets one byte from serial buffer
    if (c == '\r') {
      break; //breaks out of capture loop to print readstring
          }  
    myText += c; //makes the string readString
  }
  if (done == 0){
    for(int i=0; i<myText.length(); i++){
       char myChar = myText.charAt(i);
       Serial.print(myChar);   
       Serial.println("");
    }
  }
  done = 1;
}

If I view the binary by making this change…

      Serial.print(myChar, BIN);

…I get this:

111101
111011
110111
1110010
1001010
1010110
1111100

When I was expecting this:

00001010 LF
00001101 CR
01100011 c [D101 most significant byte]
01100100 d [D101 least significant byte]
01100010 b [D100 most significant byte]
01100001 a [D100 least significant byte]

I think it must be something to do with the 7 bits versus 8, but I don’t know what to do. Any help would be greatly appreciated!

comms params.png

data memory areas.png

I've looked at the binary I'm getting and it's not even close to what it's supposed to be. Even reversed, inverted, or both, or shifted.

Here's what (I think) it's supposed to be [abdcCRLF]
011000010110001001100100011000110000110100001010 
Here's what I get (actual):
0111101011101101101111110010100101010101101111100
reversed
1011110110111011101100100111010100101101010011111
Inverted
1000010100010010010000001101011010101010010000011
Inverted + reversed
0100001001000100010011011000101011010010101100000

I don't see any pattern in the expected output which appears in any of the binary strings I listed

Disregard.
After a full 12 hours of banging my head against a wall, I discovered that the terminals on the Arduino shield I’m using are mislabeled and I had it wired wrong (per the labels).

Linksprite owes me 12 hours of lost time.

strantor:
Disregard.
After a full 12 hours of banging my head against a wall, I discovered that the terminals on the Arduino shield I'm using are mislabeled and I had it wired wrong (per the labels).

Linksprite owes me 12 hours of lost time.

Gosh! that has never happened to me before. Really when the labels are close together and are point to the pin below and I thought pin above.

Paul

Paul_KD7HB:
Gosh! that has never happened to me before. Really when the labels are close together and are point to the pin below and I thought pin above.

Paul

I've given myself my fair share of kicks in the rear end for missing little details. For once I am off the hook though; the board is definitely mislabeled.

I said this was RS232, and it is, or it will be. I don't have the RS232 option board for the PLC right now, I only have a RS485 option card. So I'm using a Linksprite RS485 V2.1 shield to communicate between PLC and arduino.

If you google "2-wire RS-485 wiring diagram" you'll see that A always goes to A and B always goes to B. You'll see a bunch of pictographical agreement that it goes like this:

...that is, unless you're linksprite. If you're linksprite, you make it backwards and provide a dearth of information on how your product works (REALLY! LOOK AT IT! PATHETIC!)

(see my pic - the working configuration)

Hahaha, their example of how to use it, they connect one linksprite shield (with backwards connector) to another linksprite shield (with backwards connector), and what do you, IT WORKS! AMAZING! Well everyone knows two wrongs make a right. I wonder if they ever tested it on anything other than itself.