Hello all kindly please help, I have a problem which is related to rs232(serial) and UART(ttl) from a device if which has an rs232 female port, I connected a USB to Serial converter and read it from the PC and data expected were good. But when I use a UART to Serial converter (max232) from the device to my arduiono I cannot get expected result. I monitored the data coming in from the device and the data being seen by the arduino by connecting the receive terminal of a USB to serial converter to the transmit pin of the arduino and then the receive terminal of the arduino to the ttl output of rs232 converter and rs232 converter to the female db9 of the device, this way I can see the data being processed by the arduino. And sure enough it was garbled.
expected data : 6.227 +NG
received data: Garbled 6.''7s %
Etc
//code
String a;
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
Serial.println("Program begins");
}
void loop() {
while(Serial.available()) {
a= Serial.readString();// read the incoming data as string
Serial.println(a);// print the string received from the device
Serial.flush();
}
Make a pencil drawing showing how the RS232 - ttl device is connected between the Device (what is it?) and the Arduino and post a photo of the drawing.
Hello Robin, Thanks for the reply and sorry for my late response. Please see attachment for your reference. I used 9600 baud rates since its the default baud rate of the device (host).
Thank you Robin for the guide link and sorry robtillaart for the double post. Kindly please see the image I attached to illustrate the connections.
I missed to illustrate that on the second circuit connection illustration, if I remove the arduino 168 and will connect the max232 to the USB to serial directly then to the laptop, the data received were also OK.
It was only when the arduino processed the data that it became garbled ( I programmed the arduino to forward the data it received from the device). The reason for me doing that is to check if what is the data being seen by the arduino because I cant see the expected result. Like if I see a "-NG" from the message stream coming from the device it will light a certain LED, etc.
You are still not showing the individual wires. How many connections are there on a MAX 232? I want to see how each of them is connected to something else.
And there can be different wiring arrangements inside a DB9 plug or socket - so you need to know what is inside it / them.
I want YOU to figure out the wiring in detail and make a drawing showing the details.
Look at the drawing I have in this Thread. But there is no need for colour. See how all the connections points are identified and lines drawn between them.
That is the sort of thing you need to produce.
Are those photos from the D Connectors taken from your actual connectors? If not, don't rely on them.
Hello Robin I used the connection in order for me to monitor the data going in into the mega 2560, anyway the problem was solved already I made the baudrate of mega 2650 to 10000 instead of 9600 and boom no more garbled message. Thank you very much for your time on trying to help. I appreciate it so much.