fhood
Posts: 12
Joined: Thu May 22, 2014 8:00 pm
Location: United States
Contact: Website

GPIO vs USB serial rs232 problems

Thu May 22, 2014 8:09 pm

So i have a few pi's set up to do various tasks, one of which is to communicate with scientific instruments, all of which use rs232 connections. I have both usb and GPIO rs232 connections set up, but the GPIO connection will not talk to the instrument that I need it to and the USB connection will. I can promise that the baud rate and wiring for the GPIO port is correct. I have also successfully modified the two necessary files. The boards (I have multiple from multiple manufacturers, none work) uses the requisite MAX3232 chip. It will even talk to itself via wiring the second and third pins together. Thus the issue is why does the USB rs232 converter work perfectly and not the GPIO one?
System Automation, Long term aquatic probe de-fouling, Nutrient monitors, water quality systems
gescience.com

klricks
Posts: 6777
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: GPIO vs USB serial rs232 problems

Fri May 23, 2014 1:56 am

The power supply to the MAX3232 must be 3V3 not 5V.
Ground must be connected.
Try swapping TX & RX from GPIO to the RS232 board.
Does the equipment use 3 wire (TX, RX, GND) or 5 wire ( + CTS, RTS)?
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: GPIO vs USB serial rs232 problems

Fri May 23, 2014 2:22 am

Hi,
klricks wrote:Try swapping TX & RX from GPIO to the RS232 board.
I'd rather check the setup twice instead of blindly swap these signals.

When you're dealing with RS-232 signals, you can be more brave and take mentioned trial&error approach, because RS-232 drivers contain protection (shorting outputs of two transmitters will not destroy them). On the other hand, the mentioned signals between GPIO and the RS-232 board are generic TTL signals, without this protection. Handle them with care and avoid this trial&error technique.

About the initial question... a multimeter can be used here as a basic tool - check voltages. Good old analog multimeter is preferred here (its "nervous pointer" indicates data transfers).


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

User avatar
DeeJay
Posts: 2027
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK

Re: GPIO vs USB serial rs232 problems

Fri May 23, 2014 7:11 am

why does the USB rs232 converter work perfectly and not the GPIO one?
You don't mention which Operating System is running on your RPi, or whether you have disabled the default console session which runs on the GPIO uart under Raspbian.

Could it be that the instruments need hardware flow control, which may be implemented on the usb adaptor but will be absent on the 3-wire gpio connection?
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

User avatar
joan
Posts: 14668
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: GPIO vs USB serial rs232 problems

Fri May 23, 2014 7:17 am

What connections have you made between the Pi and the instrument?

Your promises aside, it's likely to be a wiring problem.

fhood
Posts: 12
Joined: Thu May 22, 2014 8:00 pm
Location: United States
Contact: Website

Re: GPIO vs USB serial rs232 problems

Fri May 23, 2014 2:33 pm

I acknowledge that wiring problems are usually at fault but as I mentioned I can talk successfully to myself by wiring pins 2 and 3 on the tty to rs232 board. I have also switched tx and rx multiple times. The device in question (I just talked to the guy who built it) does not require or use hardware flow control.
Connections are
rx to rx
vcc to 3V3
tx to tx
ground to ground

I am running rasbpian, which I downloaded in 2013 and have updated regularly.

The hardware in question is a set of 8 relays connected to a processor that interprets hex commands (baud rate: 38400). I would like to get this working because I hope that it will have a more reliable connection than the USB. I use these pis for long term system automation.

Assuming the changing the default console uart refers to removing sections of the cmdline.txt, and the other file (cant remember what its called) than yes I have done that properly. AS I MENTIONED I can communicate with myself, so it sends and receives properly on some level.
Last edited by fhood on Fri May 23, 2014 2:38 pm, edited 1 time in total.
System Automation, Long term aquatic probe de-fouling, Nutrient monitors, water quality systems
gescience.com

User avatar
joan
Posts: 14668
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: GPIO vs USB serial rs232 problems

Fri May 23, 2014 2:37 pm

We still don't know the connections you have made between the Pi and the other device.

A photo would be helpful.

fhood
Posts: 12
Joined: Thu May 22, 2014 8:00 pm
Location: United States
Contact: Website

Re: GPIO vs USB serial rs232 problems

Fri May 23, 2014 2:50 pm

Here are some pictures
Attachments
IMG_2337.jpg
IMG_2337.jpg (38.27 KiB) Viewed 4002 times
IMG_2336.jpg
IMG_2336.jpg (50.57 KiB) Viewed 4002 times
IMG_2335.jpg
IMG_2335.jpg (37.64 KiB) Viewed 4002 times
System Automation, Long term aquatic probe de-fouling, Nutrient monitors, water quality systems
gescience.com

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: GPIO vs USB serial rs232 problems

Fri May 23, 2014 2:57 pm

Hi,
fhood wrote:I hope that it will have a more reliable connection than the USB.
With latest USB driver update (released approx. three weeks ago) the USB communication seems rock-solid. I performed some freehand stress testing by transferring large files in parallel via Ethernet and WiFi + communicating to one USB I/O board with several millions query-response data packets without a single error.
It might happen that the communication stalls for a moment, but it quickly recovers and everything continues without any intervention needed.

USB has nice feature of automatic CRC check & retry mechanism, so you can rely (with this new driver) that without additional effort the data will be delivered and is not corrupted (if suitable USB mode is picked).


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

fhood
Posts: 12
Joined: Thu May 22, 2014 8:00 pm
Location: United States
Contact: Website

Re: GPIO vs USB serial rs232 problems

Fri May 23, 2014 3:03 pm

Your right and I have noticed that it fixes connection stalls pretty fast, but I still see weird errors that don't get thrown up by a pc with an rs232 port. It looks almost like I am losing 1 byte in some of the communications, and when you need to get a 55 and you only get a 5 that causes some problems. THe errors are one in 500 runs of the script I am using but they are still there.
System Automation, Long term aquatic probe de-fouling, Nutrient monitors, water quality systems
gescience.com

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: GPIO vs USB serial rs232 problems

Fri May 23, 2014 3:31 pm

Hi,
fhood wrote:I still see weird errors ...THe errors are one in 500 runs of the script I am using but they are still there.
I wrote about native USB communication, not wrapped communication established on top of it (eg. your RS-232).

According to the pictures and your description, you don't use hardware flow control. Do you use any software flow control, or you just hope that data receiving is handled fast enough ?


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

fhood
Posts: 12
Joined: Thu May 22, 2014 8:00 pm
Location: United States
Contact: Website

Re: GPIO vs USB serial rs232 problems

Fri May 23, 2014 4:28 pm

The USB errors are unimportant as I handle them in my code. What I really want to know is why the tty to rs232 will not talk to my machine, even using cutecom or putty.
System Automation, Long term aquatic probe de-fouling, Nutrient monitors, water quality systems
gescience.com

User avatar
joan
Posts: 14668
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: GPIO vs USB serial rs232 problems

Fri May 23, 2014 5:08 pm

The wiring looks OK.

Have you buzzed the lines through? Checked the voltages at the MAX3232?

You say you've done a loopback test.

Have you a scope? Does one ends RX change when the other end sends?

fhood
Posts: 12
Joined: Thu May 22, 2014 8:00 pm
Location: United States
Contact: Website

Re: GPIO vs USB serial rs232 problems

Fri May 23, 2014 6:10 pm

I haven't checked the voltages, because I assumed that that was irrelevant if the loopback test worked. I will do that.
I am not entirely sure what you mean by scope.
System Automation, Long term aquatic probe de-fouling, Nutrient monitors, water quality systems
gescience.com

User avatar
DeeJay
Posts: 2027
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK

Re: GPIO vs USB serial rs232 problems

Fri May 23, 2014 6:12 pm

fhood wrote:I am not entirely sure what you mean by scope.
In this context it is an abbreviation for 'oscilloscope' - a device that gives a trace similar to the writer's avatar.
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

User avatar
mikronauts
Posts: 2740
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: GPIO vs USB serial rs232 problems

Fri May 23, 2014 6:20 pm

I think you meant pins 2-3 wired together on the DB9 connector, right?

Perhaps you need a null modem adapter? RS232 connectors come in two flavors:

DCE - data communications equipment (modems, etc)
DTE - data terminal equipment (terminals, computer)

A null modem changes 2-3 so they cross, instead of connect directly.

Hope this helps!

Bill
fhood wrote:I acknowledge that wiring problems are usually at fault but as I mentioned I can talk successfully to myself by wiring pins 2 and 3 on the tty to rs232 board. I have also switched tx and rx multiple times. The device in question (I just talked to the guy who built it) does not require or use hardware flow control.
Connections are
rx to rx
vcc to 3V3
tx to tx
ground to ground

I am running rasbpian, which I downloaded in 2013 and have updated regularly.

The hardware in question is a set of 8 relays connected to a processor that interprets hex commands (baud rate: 38400). I would like to get this working because I hope that it will have a more reliable connection than the USB. I use these pis for long term system automation.

Assuming the changing the default console uart refers to removing sections of the cmdline.txt, and the other file (cant remember what its called) than yes I have done that properly. AS I MENTIONED I can communicate with myself, so it sends and receives properly on some level.
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

fhood
Posts: 12
Joined: Thu May 22, 2014 8:00 pm
Location: United States
Contact: Website

Re: GPIO vs USB serial rs232 problems

Fri May 23, 2014 7:58 pm

I tried crossing the rx tx pins by hand and that showed no improvements so I doubt a null modem will help.
System Automation, Long term aquatic probe de-fouling, Nutrient monitors, water quality systems
gescience.com

User avatar
mikronauts
Posts: 2740
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: GPIO vs USB serial rs232 problems

Fri May 23, 2014 8:02 pm

Dumb question - did you connect pin 5 to pin 5? (GND)
fhood wrote:I tried crossing the rx tx pins by hand and that showed no improvements so I doubt a null modem will help.
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

fhood
Posts: 12
Joined: Thu May 22, 2014 8:00 pm
Location: United States
Contact: Website

Re: GPIO vs USB serial rs232 problems

Fri May 23, 2014 8:04 pm

Yup remember I can send and receive data when I connect pin 2 to pin 3 so the connections are correct insofar as I can discern.
System Automation, Long term aquatic probe de-fouling, Nutrient monitors, water quality systems
gescience.com

User avatar
joan
Posts: 14668
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: GPIO vs USB serial rs232 problems

Fri May 23, 2014 8:14 pm

fhood wrote:Yup remember I can send and receive data when I connect pin 2 to pin 3 so the connections are correct insofar as I can discern.
For a loopback test (TX-RX) the local ground is used. It doesn't indicate if the local ground is connected to the remote ground.

fhood
Posts: 12
Joined: Thu May 22, 2014 8:00 pm
Location: United States
Contact: Website

Re: GPIO vs USB serial rs232 problems

Fri May 23, 2014 9:20 pm

SOLVED: needed a null modem, turns out there is a difference between crossing the rx and tx wires and a null modem. Props to whoever suggested it.
System Automation, Long term aquatic probe de-fouling, Nutrient monitors, water quality systems
gescience.com

User avatar
joan
Posts: 14668
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: GPIO vs USB serial rs232 problems

Fri May 23, 2014 9:44 pm

fhood wrote:SOLVED: needed a null modem, turns out there is a difference between crossing the rx and tx wires and a null modem. Props to whoever suggested it.
I didn't think there was a difference between a null modem and swapping RX/TX in your case. There are no handshake lines so swapping TX/RX should be the same as using a null modem.

klricks
Posts: 6777
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: GPIO vs USB serial rs232 problems

Fri May 23, 2014 10:19 pm

joan wrote:
fhood wrote:SOLVED: needed a null modem, turns out there is a difference between crossing the rx and tx wires and a null modem. Props to whoever suggested it.
I didn't think there was a difference between a null modem and swapping RX/TX in your case. There are no handshake lines so swapping TX/RX should be the same as using a null modem.
ON THE RS232 side, there is no difference between either swapping TX/RX (pin 2 &3) or adding a NULL modem adapter.
HOWEVER the RS232 (Pin 2 & 3) crossover CANNOT be fixed by swapping TX / RX on the TTL side.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

Return to “Troubleshooting”