Problems with serial port (RS232) sensor

We have a sensor working @ 115200 bauds with a RS232 output, and we want to control it with arduino MEGA 2560. The ultimate goal is to control it wirelessly with two XBee modules.

We are facing the following problems:

  1. When we connect to the computer RS232 connector directly, it works perfectly.

  2. When we connect the sensor to a MAX232 (to convert levels). The MAX232 to Arduino MEGA, and Arduino to the computer via USB (with virtual serial port). We can connect to the sensor but the program gives some errors.

3)Via wireless nothing works.

Do you think it is a problem of the baud rate being too high maybe (115200)?

I attach the code of the program in case it is a software error:

byte incomingByte;      // a variable to read incoming serial data into
byte incomingByte2;      // a variable to read incoming serial data into
//const int ledPin = 13; // the pin that the LED is attached to
 
void setup() 
{//pinMode(ledPin, OUTPUT);
  Serial.begin(115200);
  Serial1.begin(115200);
}
 
void loop() 
{
  // read from port 0, send to port 1:
  if (Serial.available()) 
  {
    incomingByte = Serial.read();
    Serial1.print(incomingByte, BYTE); 
  }
   //read from port 1, send to port 0:
  if (Serial1.available()) 
  {
    incomingByte2 = Serial1.read();
    Serial.print(incomingByte2, BYTE); 
  }
}
  1. When we connect to the computer RS232 connector directly, it works perfectly.

What software on the computer is reading the data?

  1. When we connect the sensor to a MAX232 (to convert levels). The MAX232 to Arduino MEGA, and Arduino to the computer via USB (with virtual serial port). We can connect to the sensor but the program gives some errors.

The code shown does not "give some errors". The data read from the device may not be what you expect, but that is not necessarily an error in the code. It could be an error in the wiring or in your expectations.

How is the sensor wired?

3)Via wireless nothing works.

Nowhere near enough data has been provided to even comment on this. What kind of XBees are you using? How have you configured them? Have you got them talking to each other with some other sketch running?

Do you think it is a problem of the baud rate being too high maybe (115200)?

We have a sensor working @ 115200 bauds with a RS232 output

What do you think? Is 115200 incorrect?

What software on the computer is reading the data?

The software used is TeraTerm. When you connect the sensor to the computer it receives the data correctly (via RS232)

The code shown does not "give some errors". The data read from the device may not be what you expect, but that is not necessarily an error in the code. It could be an error in the wiring or in your expectations.

How is the sensor wired?

This is the wiring of the sensor.

Zoom of the MEGA

Nowhere near enough data has been provided to even comment on this. What kind of XBees are you using? How have you configured them? Have you got them talking to each other with some other sketch running?

The XBees are connected in this way: 1 is connected directly onto the arduino, as you can see in the image. The other xbee is connected directly to the computer via USB to communicate one with another via wireless. However the data are corrupt on the teraterm, strange characters appear on teraterm.

The XBees are configuration is 115200 bauds. We have tested the XBees independently and they work when connected each one. However, it is more important to get it working via RS232 first.

What do you think? Is 115200 incorrect?

I think that maybe some component is not suitable for this high speed, maybe the arduino MEGA.

bump anyone?

Have you verified that the MAX232 output is good?

What do you get if you just Serial.print() the sensor data?

When you get good data from Serial.print then you can start blaming the Xbees and maybe drop the data rate and see if that works.


Rob

These condensator seem to me HUGE !

try by removing the condensator between VCC and ground. It gives success with me by doing it.

Thank you very much for your replies. I don't have the circuit right now because it is at work. I will try on monday and post again :smiley:

You may need to test your circuits seperately to see that they are working. You should be able to test the max232 by connecting it to the computer, connecting the ttl tx/rx pins on it, and see if what is sent is echoed back to the computer. If that works, then put the mega beween the max232 and the computer and see if you can get something to work there. Work thru the hardware until problems are encountered. If you think the baud rate might be an issue, then try the setup at 9600 and see if that works.