RS485 Software serial 9600 181N not working?

I’ve been struggling for a week now and can’t find my mistake.

I’ve got my plc, pc and Arduino connected to an rs485 line.
When my plc send data, my pc will get it correct but my Arduino keeps on getting the same faulty data.

When my plc sends 00 31 54 03, I see this on my screen on my pc com port monitor. My Arduino say’s it got 127 103 85 63

I’ve checked my settings in my plc more than once: 1 start bit, 8 data bits, 1 stop bit, even parity, 9600

RO of the 485 module go’s to pin8
RI of the 485 module go’s to 12
RE and DE to pin 7

Send → received by arduino

00 31 54 03 → 127 103 85 0
00 32 54 03 → 127 179 85 0
00 33 54 03 → 127 108 85 0
00 34 54 03 → 127 217 85 0
00 35 54 03 → 127 101 85 0
00 36 54 03 → 127 178 85 0
00 37 54 03 → 127 100 85 0
00 38 54 03 → 127 236 149 0
00 39 51 03 -->127 99 87 126

Every third byte is a 54 → 85 except the 8th line
Every last byte is a 03 → 0 except the last line

I can send it time after time with the same result

Anyone a clue what is going on?

I’m using the code below for testing.

/*-----( Import needed libraries )-----*/
#include <SoftwareSerial.h>
/*-----( Declare Constants and Pin Numbers )-----*/
#define SSerialRX        8  //Serial Receive pin
#define SSerialTX        12  //Serial Transmit pin

#define SSerialTxControl 7   //RS485 Direction control
#define RS485Transmit    HIGH
#define RS485Receive     LOW

#define Pin13LED         A4

/*-----( Declare objects )-----*/
SoftwareSerial RS485Serial(SSerialRX, SSerialTX); // RX, TX

/*-----( Declare Variables )-----*/
int byteReceived;
int byteSend;

void setup()   /****** SETUP: RUNS ONCE ******/
{
  // Start the built-in serial port, probably to Serial Monitor
  Serial.begin(9600);
  Serial.println("SerialRemote");  // Can be ignored
  
  pinMode(Pin13LED, OUTPUT);   
  pinMode(SSerialTxControl, OUTPUT);  
  
  digitalWrite(SSerialTxControl, RS485Receive);  // Init Transceiver
  
  // Start the software serial port, to another device
  RS485Serial.begin(9600);   // set the data rate 
}//--(end setup )---


void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{
  //Copy input data to output  
  if (RS485Serial.available()) 
  {
    byteSend = RS485Serial.read();   // Read the byte 
    
    digitalWrite(Pin13LED, HIGH);  // Show activity
    delay(10);              
    digitalWrite(Pin13LED, LOW);   
    
   // digitalWrite(SSerialTxControl, RS485Transmit);  // Enable RS485 Transmit    
   // RS485Serial.write(byteSend); // Send the byte back
   // delay(100);   
   // digitalWrite(SSerialTxControl, RS485Receive);  // Disable RS485 Transmit 
    Serial.println(byteSend);
//    delay(100);
  }// End If RS485SerialAvailable
  
}//--(end main loop )---

/*-----( Declare User-written Functions )-----*/
//NONE

//*********( THE END )***********

NoBoot: I've been struggling for a week now and can't find my mistake.

I've got my plc, pc and Arduino connected to an rs485 line. When my plc send data, my pc will get it correct but my Arduino keeps on getting the same faulty data.

It looks like you have A and B reversed in your circuit.

0 being seen as 127. { the start bit is being interpreted as a zero bit}

How is the RS485 converter wired to the Arduino.

If you are using _T/R to control a MAX485 you will need a pullup resistor on the RX pin. When you switch to TX mode, the RX (din) goes to tri-state, on my Mega's this cause a false character to be received.

Here is a functioning Circuit:

|500x227

Chuck.