Serial Communications


3 posts
by n1mie » Tue Dec 18, 2012 2:57 am
I have a project but how to approach one piece is baffling me. I want to use the rpi to collect data. Then process the data. Then finally to connect to a TNC (ham radio device very similar to an old telephone modem) and send the data. So the question is how do I connect to the TNC. It has a DB25 that expects to connect to a serial port on a computer. On my normal (non-pi) computer I would use a USB-serial dongle with appropriate adapter (I have a db25-db9 cable). I'm wondering if I could use the GPIO port to connect to the TNC. I suppose there is also the USB port and the dongle on the rpi, but I've heard rumors there are driver issues with them.

So what is a guy to do?
-- Chip / N1MIE
User avatar
Posts: 2
Joined: Wed Aug 15, 2012 1:48 am
Location: Southeastern CT
by gordon@drogon.net » Tue Dec 18, 2012 9:21 am
n1mie wrote:I have a project but how to approach one piece is baffling me. I want to use the rpi to collect data. Then process the data. Then finally to connect to a TNC (ham radio device very similar to an old telephone modem) and send the data. So the question is how do I connect to the TNC. It has a DB25 that expects to connect to a serial port on a computer. On my normal (non-pi) computer I would use a USB-serial dongle with appropriate adapter (I have a db25-db9 cable). I'm wondering if I could use the GPIO port to connect to the TNC. I suppose there is also the USB port and the dongle on the rpi, but I've heard rumors there are driver issues with them.

So what is a guy to do?


You can use the exact same USB serial dongle on the Pi. That's the easy way to do it. The serial device will come up as /dev/ttyUSB0 (or maybe another number if you have more plugged in), or sometimes /dev/ttyACM0, depending on the chipset insisde the USB dongle.

After that, it's just another serial device as far as Linux is concerned.

If you want to use the on-board serial port on the Pi, then it's /dev/ttyAMA0, however you will need level shifter(s) as the Pi's serial is 3.3v and that won't drive standard rs232.

I'd stick to the USB dongles...

As for driver issues - I've not found any when connecting my Pi's up to USB serial devices - Arduinos, other PCs and some other serial devices I have...


-Gordon
--
Gordons projects: https://projects.drogon.net/
User avatar
Posts: 1536
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
by SiriusHardware » Tue Dec 18, 2012 6:46 pm
I've used the PI's built in serial port without any problems. The first step is to stop the Pi's OS from using it, so that you can use it for your own purposes.

Second step is (as Gordon said) to insert an RS232 level-shifter circuit in between the PI's 3.3V logic-level RX and TX data pins and the TNC.

Both steps are described here:-

http://raspberrypihobbyist.blogspot.co. ... -port.html

HOWEVER, the circuit in that article (using a MAX232 running from 5V) is bad practice for the Pi, as it means that the logic-level data output from the MAX232 will output 5V into the Pi's RX input pin. No external device should ever feed more than 3.3V into any of the Pi's GPIO pins.

There are some very small, neat RS232 level shifters available on Ebay ready-made for typically about 3-4 British Pounds, possibly a little more in US Dollars. The ones I bought recently are so small they fit easily inside a DB9 plug/socket shell.

Avoid those which use the MAX232 chip as it can only run reliably on 5V, choose one which uses the 3V-compatible MAX3232 chip - and run it from the 3.3V supply output pin on the Pi's GIO port, not from the 5V supply.

If you'd rather build your own, build the circuit shown on the page in the link above, but use a MAX3232 chip instead of a MAX232, and power the circuit from 3.3V, not from 5V as shown.

Although USB - RS232 cables may work just fine (like you, I've read that people have had a few problems with them) USB ports and USB bandwidth are a precious commodity on the Pi, so I would tend to go with the onboard serial interface as that consumes neither and leaves them free for other purposes.
Posts: 438
Joined: Thu Aug 02, 2012 9:09 pm
Location: UK