Go Down

Topic: IMU RS232 communication (Read 467 times) previous topic - next topic

dresnu1

Hello I'm trying to read data from an IMU (http://www.aviotech.it/pg007.html) which uses an RS232 interface. The serial communication specs are 8N1@115200. I'm using a max232 chip to adapt the voltage levels of the RS232 to TTL. The typical string data has this format: "$R <number with sign>, P <number with sign, Y<number with sign>, A <number with sign>, S9000*<some two digit number>\r\n".

I'm using an arduino mega 2560 in order to use one of the "free" serial communication pins (i.e. not the one connected to the FTDI) and I' trying to capture and display the symbols on the Serial monitor.

The very simple code I use is the following:

Code: [Select]
int incomingByte = 0;   // for incoming serial data

void setup() {
       Serial.begin(115200);      // opens serial port, sets data rate to 115200 bps
       Serial3.begin(115200);    // opens serial port, sets data rate to 115200 bps
}

void loop() {

       // send data only when you receive data:
       if (Serial3.available() > 0) {
               // read the incoming byte:
               incomingByte = Serial3.read();

               // say what you got:
               Serial.print("I received: ");
               Serial.println(incomingByte, DEC);
               
       }        
}


The problem is that on the serial monitor I can only see some strange characters and not the typical string I am expecting. I can see some repetition though, so that makes me think that maybe these are actually characters coming from the IMU but maybe the arduino is not interpreting them correctly.

Could you please point out any ideas? It's not a baud rate fault and the max232 is working correctly, for that I'm sure. Thank you

wwbrown

The serial monitor speed is 9600 by default so if you do not change the baudrate of the serial monitor or the Arduino you will get nonsense characters.  This is a pretty common mistake.

dresnu1

I have set the correct speed in the dropdown menu on the serial monitor window if that is what you 're referring to.

Go Up