rasprasp
Posts: 3
Joined: Fri Sep 23, 2016 11:01 am

UART Communication receives wrong data

Fri Sep 23, 2016 11:40 am

Hi everyone,

I'm new to the whole Linux and Raspberry world, but I have programming experience. Now I want to establish a communication between a raspberry 2, with Raspbian (Jessie) installed, and the system control of my solar installation. So the system control only puts out data (text as ASCII signs, voltage level 5V) every 60s. This data has to be collected by the raspberry and stored on an usb device.
If I test the UART communication by connecting RX and TX on the pi, everything works fine, but when I connect the system control on the raspberry (control TX to RX on pi (through voltage divider as level shifter) and GND to GND; control RX and raspberry TX are not connected -> raspberry only has to read) the raspberry counts the right amount of bytes (92 Bytes), but the data is totally wrong. For example a sent 's' is received as a 'F', a sent 'm' as a 'I' but there is no specific offset... This problems appears with my own code and with minicom.
I also tried reading this data with my notebook with an usb to rs232 converter (and this connected over a cable to UART on the system control). This works as expected using the tool "hterm" for windows 7. But when I connect this pc setup over a voltage divider to the raspberry, the same problem appears as with the system control. The baudrate is 4800 with one stop bit and ignoring the parity, so 4800 8N1. These parameters are set on all devices. The console is also disabled for the UART Port, so there is no output during boot.

I read a lot of posts in this forum containing a similar problem, but nothing seems to be solved or fits to my case. The UART settings on the raspberry should be correct, because of the flawless testing when connecting the raspberry pins RX and TX.

I would be really glad if someone could help me out.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 22733
Joined: Sat Jul 30, 2011 7:41 pm

Re: UART Communication receives wrong data

Fri Sep 23, 2016 1:52 pm

Does sound like a mismatch in voltage levels note RS232 is -12 to +12, the Pi UART is 0-3.3v (?).

You probably need one of these..

http://www.ebay.co.uk/itm/MAX232-RS232- ... SwT6pVo7wL
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

rasprasp
Posts: 3
Joined: Fri Sep 23, 2016 11:01 am

Re: UART Communication receives wrong data

Fri Sep 23, 2016 2:57 pm

Thanks for your fast answer !

I'm using this device for usb to rs232 conversion https://www.startech.com/Cards-Adapters ... ICUSB2321X
But this is just a passive device, so there are only 5V Output and not +/-12V, correct me if I'm wrong.
To get 3V3 out of 5V I use two resistors as a voltage divider.

drgeoff
Posts: 9373
Joined: Wed Jan 25, 2012 6:39 pm

Re: UART Communication receives wrong data

Fri Sep 23, 2016 4:13 pm

I'm with jamesh on this one. I certainly expect something like that with a DB9 connector to be pukka RS-232 levels. Until proven that it is not, IMHO you risk damaging the RPi by connecting it directly to this.

(And BTW you don't seem to understand what "passive" means.)

User avatar
tadd
Posts: 15
Joined: Wed Dec 17, 2014 5:15 am
Location: Raleigh, NC
Contact: Website

Re: UART Communication receives wrong data

Fri Sep 23, 2016 5:09 pm

passive means there is no MAX232 chip or equivalent. That would mean that the outputs of the DE9 would be at USB levels. I'm not sure that this USB to RS232 device works that way.
I recommend checking the outputs on the DE9 with an oscilloscope and not assuming it is at 5v.
Also make sure Parity and # of bits is set correctly.

drgeoff
Posts: 9373
Joined: Wed Jan 25, 2012 6:39 pm

Re: UART Communication receives wrong data

Fri Sep 23, 2016 9:56 pm

tadd wrote:passive means there is no MAX232 chip or equivalent. That would mean that the outputs of the DE9 would be at USB levels.
Passive means no active devices ie only resistors, capacitors and inductors. Diodes? Transistors and ICs definitely not.

It is impossible to make a USB to RS232 interface (even if the RS232 levels are "USB levels") without using at least one active device.

WXN
Posts: 4
Joined: Fri Sep 23, 2016 11:59 pm

Re: UART Communication receives wrong data

Sat Sep 24, 2016 12:13 am

Look at the digikey website for the silicon labs cp210n development board. It works with the raspberry pi 3 with Windows 10 iot core anniversary edition is. I tried it with a loop back plug and it works. It is the only rs232 converter that I know of until other manufacturers come out with a compatible rs232 to use converter.

User avatar
tadd
Posts: 15
Joined: Wed Dec 17, 2014 5:15 am
Location: Raleigh, NC
Contact: Website

Re: UART Communication receives wrong data

Sat Sep 24, 2016 12:33 am

that is a very good point.

rasprasp
Posts: 3
Joined: Fri Sep 23, 2016 11:01 am

Re: UART Communication receives wrong data

Mon Sep 26, 2016 5:51 am

Thank you guys for your answers !

Yeah I meant "passive" as a sort of device, without MAX232 chip or equivalent, but correctly it is "not including active parts, for example transitors, operational amplifiers, ..."
I will go now and check the output of the USB to RS232 converter to check if it's on USB level or not. (But it worked with the control, which has also 5V level output ? )

Return to “Troubleshooting”