RS-485 -----> converter -----> USB --------> Linux

What I need to study to make a program that reads data from a converted RS-485 output? Is Linux environment and Language C.

Reply to
Christiano
Loading thread data ...

RS232 to usb to linux should be trivial. Can you translate 485 to 232?

Reply to
mike

Sounds like you will learn a lot by doing it. Have fun.

--
Mike McGinn	KD2CNU 
"More kidneys than eyes."
Reply to
Mike McGinn

Use an Ethernet/serial(RS-485) converter and it will work from any operating system (and any operating system version) supporting socket (TCP) or even only UDP connections.

Reply to
upsidedown

Be careful with serial port numeration issues if you have two identical adapters.

While conversion from RS-232 to RS-422 would be trivial, just make the voltage translation. For 2 wire RS-485 the situation is more complicated, since you need the data direction control (basically transmit enable).

For big and heavy operating systems like Linux or Windows, turning on and off the RS-485 with explicit commands by the host over USB may be far too unreliable (unpredictable latencies), so the USB converter itself must generate the transmit enable signal.

Especially the transmit disabling is critical since if the transmitter is on too long after the frame, the other part may start the reply and cause a bus conflict.

Reply to
upsidedown

Get a USB dongle that either includes RS-485 hardware support or an RS-232 USB dongle that supports automatic half-duplex RTS toggle under Linux (that way it will work properly with an RS-232RS485 converter). Alternatively, you can sometimes find RS-485 converters that handle line direction automatically and don't require RTS to be toggled -- but converters like that are hard to find and usually expensive.

I do a lot of serial programming on Linux, and if I were you instead of C I'd use Python and either PosixSerial or pyserial, but it's your funeral.

formatting link
formatting link
formatting link

PosixSerial is a very thin wrapper around the Posix/Linux API that has been tested only on Linux. pyserial has much better documentation and is portable across Linux, Windows and MacOS (the Linux support in pyserial is based on PosixSerial). PosixSerial supports only Python

2.x, I'm not sure about pyserial.

If you really want to use C, then get a copy of "Serial Programming Guide for POSIX Operating Systems" by Michael Sweet. There are old copies available for free

formatting link
formatting link

It looks like you have to pay for more recent versions.

formatting link

Do NOT pay any attention to the TLDP serial programming HOWTO:

formatting link

It has many errors and omissions.

--
Grant Edwards               grant.b.edwards        Yow! HUGH BEAUMONT died 
                                  at               in 1982!! 
                              gmail.com
Reply to
Grant Edwards

FWIW, I just updated PosixSerial so it works with Python 3.2

--
Grant Edwards               grant.b.edwards        Yow! Are you mentally here 
                                  at               at Pizza Hut?? 
                              gmail.com
Reply to
Grant Edwards

There's USB to RS485 adapters out there. I've been out of the game for too long to know who the players are any more, but a quick web search should be helpful. Black Box used to be one of the go-to places; they had everything, albeit it steep prices.

--

Tim Wescott 
Wescott Design Services 
http://www.wescottdesign.com
Reply to
Tim Wescott

Please check the galvanic isolation issue, if the RS-485 network is larger than one room.

Reply to
upsidedown

Another reason to go with an Ethernet attached serial port: you get galvanic isolation for free (unless the designer was foolish enough to connect signal ground to earth ground inside the 'converter').

--
Grant
Reply to
Grant Edwards

pyserial is how I do these things too. Python is often easier for this sort of thing, especially when playing around and learning. And if I wanted to do it in C, I'd start by looking at the pyserial implementation for clues.

FTDI make nice USB-to-UART chips, and nice cables with the chips neatly embedded - they are always my first choice for something like this.

Learn a little about udev rules if you want to use more than one cable in a system - it can help you get predictable names for the different cables (I have rules that give fixed name links to cables on different ports of a USB hub - so I refer to /dev/ttySerial_hub3 rather than /dev/ttyUSB2, etc. You can also fix names based on serial numbers or other features of the device).

Reply to
David Brown

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.