April 22, 2013

Serial Port Programming RS232 / RS485

Using the serial port is a common task and there are a huge number of components for doing that.

I'm using TCiaComPort by Wilfried Mestdagh for years. It is a freeware with source code available at: http://www.mestdagh.biz/soft_components.html

Recently, I have updated the source code for Unicode enabled Delphi versions. I use it with Delphi XE3 but it should be OK starting from D2009.

My use is for industrial applications where I have to control devices using either RS232 or RS485. The same TCiaComPort may be used for both since programmatically both RS232 and RS485 appears as a serial COM port.

Just a little note about RS485: When using RS485 for multiple devices, the communication is done on a bus. That is only one device can talk at a time. You must be sure to respect that behaviour. Usually on the RS485 bus, there is one master (Frequently the PC) and one or more slaves (The devices). You have to study the communication protocol used by the devices. Frequently it is a command / response style protocol. The master send a command to one device which in turn replies. So it is easy to avoid communicating simultaneously: just wait for the reply before sending the next command.




Follow me on Twitter
Follow me on LinkedIn
Follow me on Google+
Visit my website: http://www.overbyte.be
This article is available from http://francois-piette.blogspot.be/2013/04/serial-port-programming-rs232-rs485.html

No comments: