Corrupted Serial Communication with Arduino Mega

Hello all, I am trying to read data from a display monitor using serial communication with my Arduino Mega. The monitor uses call/response serial communication so I am writing a command and receiving a response from the device. The issue is that the response appears to be corrupted data with lots of backwards question marks. I know what the response is supposed to look like because I have a different type of monitor from the same manufacturer that I have been able to communicate with and they use the same data format (PAX2C). The issue has been repeated with nothing on the Arduino besides the components listed below.

Your help is very much appreciated! I can't seem to crack this issue.

Hardware:
Arduino Mega
CUB5 display with serial card, COMM connected to Arduino GRD (otherwise no data transferred)
TTL-RS232 converter

Code:

boolean newData = false;

void setup() {
  Serial.begin(9600);
  Serial1.begin(9600);
}

void loop() {
  Serial1.write("TA$"); // comand to transmit the value displayed on the monitor
  Serial.println("Command transferred.");
  delay(50);
  if (Serial1.available() > 0) {
    Serial.println("Message received.");
    getData();
  }
  Serial.println("Transmission done.");
  Serial.println();
  delay(1000);
}

void getData() {
  static byte ndx = 0;
  char endMarker = '\n';
  char rc;
  const byte numChars = 32;
  char receivedChars[numChars];
  
  Serial.println(Serial1.available());
  while (Serial1.available() > 0 && newData == false) {
    rc = Serial1.read();
    Serial.println(rc);
    if (rc != endMarker) {
      receivedChars[ndx] = rc;
      ndx++;
      if (ndx >= numChars) {
        ndx = numChars - 1;
      }
    } else {
      Serial.println("Endmarker.");
      receivedChars[ndx] = '\0'; // terminate the string
      ndx = 0;
      newData = true;
    }
  }

  if (newData == true) {
    newData = false;
    Serial.println(receivedChars);
  }
}

Output:

Command transferred.
Message received.
17
 
 
 
I
⸮
⸮
 
 
 
⸮
2
4
⸮
⸮
8


⸮
Transmission done.

Actual data expected (known from value on monitor and data format confirmed from other display device and manual):
INP -24.98

Things I have tried:
Using Serial2 or Serial3
Using 3.3V instead of 5V to power TTL-RS232 converter
Using identical model, different display monitor (same serial card though)
Ensuring baud rate on monitor is set to 9600
Printing the data to Serial in a different format (int, byte)
Using a longer delay (100 ms)
Attaching a 4.7k ohm resistor between Arduino RX pin and GRD

Did you set up the Display RS232 to be exactly like the other one you have?
The Display's R232 is configurable.

Thanks for your response. The display is programmable with two buttons and I just entered the settings for data format - it was set to 7-bit and when I changed it to 8-bit my data is coming through properly now!!! Thanks so much :smiley:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.