Serial and RS485 Programming Tutorials
Serial Port Programming
This is a collection of articles on programming the serial port of a x86 PC using C,CSharp (C#) and Python.The tutorials covers programming the serial port using native API's like Win32 API on Windows or termios/ioctl() API on Linux. The tutorial also explains how to program the serial port using C# on .NET framework (Windows) . For Cross platform applications you can use the open source Python module PySerial for writing code on Windows and Linux.Since PySerial is available for Mac OSX ,the code provided here can run on Macs too(I have not tested it ).A short description about building an RS485 network is also provided.
The code presented in the tutorials are written using opensource or freely downloadable softwares like GCC,Microsoft Visual Studio Express Edition,Active Python,SharpDevelop etc.The codes are tested on a Windows 7 and a Ubuntu/Linux Mint PC.In the case of Python,seperate code is provided for Python2.7 and Python 3.x to accomadate the differences.
Most PC companies have stopped including hardware based DB9 serial ports in their computers and most laptops never had any to begin with.In this tutorial most of the examples are tested using USB to Serial Converters like USB2SERIAL.You can use any USB to Serial Converters, only requirement is that you should be able to access the RXD ,TXD ,RTS and DTR pins of the module(which are brought out in USB2SERIAL to bergs).
RS485 Programming Tutorials
Some times we have to communicate with systems that are several 100's of meters away like a remote data acqisition system or a robot, in such cases serial (RS232) will not cut it. You have to use some thing known as a RS485 protocol that can communicate over several Kilo Meters.
One problem with standard PC's is that they dont come with a RS485 port,you can use USB2SERIAL which already have a MAX485 based RS485 tranciever that you can use to implement such a network.check out the below link if you are interested in building an RS485 communication network.You can buy the hardware here .Sample codes are available in C ,Csharp (C#) and Python for Windows and Linux platforms.
Communicating with a Robot over an RS485 link
Remote DAQ system using MSP430