32 bit RS 485 Coms driver ??

M

Thread Starter

Mark Hill

Hi all;

I've written an application that recovers data from a Flash Ram card
that was recorded by a small PLC. I now need to communicate with the PLC in real time using RS485.

Can someone please point me towards, or provide me with an example RS485
driver written in C that I can expand upon.

TIA

Mark Hill, President, Intelligent SCADA Solutions
[email protected]
 
K

kalpak dabir

I assume this is one time job and you want to make this PLC talk to a regular PC. In which case the RS-232 port of your PC will suffice as it is, and any good 232/485 convert outside will take care of things, like enabling etc. Some of the built in PC add on cards for rs-485 come with free drivers/DLLs, which again you can call in your code. But I think a more detailed description of your problem might help in a more focused reply.
kalpak dabir. [email protected]
 
Mark,

RS485 is more or less an eletrical standard to extend the TX an RX transmission distance of RS232 and not a communications prototcol. Many drivers already exist for most of the PLC's out there.

Frank
 
A

Alex Pavloff

> I've written an application that recovers data from a Flash Ram card
> that was recorded by a small PLC. I now need to communicate with the PLC in real time using RS485.

Realtime over a 485 link? What exactly do you mean by real time here?

> Can someone please point me towards, or provide me with an
> example RS485 driver written in C that I can expand upon.

A RS485 driver is mostly the same as a RS232 driver. The only difference is dealing with the raising and dropping of the transmit line, and that depends entirely on the hardware that you're running on. Sometimes the RS485 logic is in software, sometimes in hardware.

Alex Pavloff
Software Engineer
Eason Technology


 
C

Chuck Miller

If you don't need a multi point communication, only point-to-point,(look at: http://www.bb-elec.com/technical_library.asp)than you simply need an RS232-RS485 converter and no special software. You can simply use the device driver provided by the operating system and open it like you would do it with a file

fp fopen("/dev/ttyS0", "r+");

and use fprintf() or whatever you want to write to the serial port.
Change communication parameters with ioctl(2) or call the stty(1) program before calling your own one to set communication parameters.

There is an excellent document describing all the things: hardware, software, and where you can find other resources....
http://www.linuxdoc.org/HOWTO/Serial-HOWTO.html
But in the simplest case, you need really only some lines (see above)

If you are interested in the basics, how the driver talks to the serial chip, look into the kernel sources.

Heinz

Heinz-Jorgen Oertel
port GmbH phone +49 345 77755-0
Regensburger Str. 7c fax +49 345 77755-20
D-06132 Halle/Saale mailto:[email protected]
Germany http://www.port.de
 
Top