Mar 31, 2014 0 Comments in Learning, Misc, MODBUS by
The MODBUS utils

Modbus is a serial communications protocol originally published by Modicon (now Schneider Electric) in 1979 for use with its programmable logic controllers (PLCs). Simple and robust, it has since become a de facto standard communication protocol, and it is now a commonly available means of connecting industrial electronic devices.

The main reasons for the use of Modbus in the industrial environment are:

  • developed with industrial applications in mind
  • openly published and royalty-free
  • easy to deploy and maintain
  • moves raw bits or words without placing many restrictions on vendors

Modbus enables communication between many (approximately 240) devices connected to the same network, for example a system that measures temperature and humidity and communicates the results to a computer. [Modbus from Wikipedia]

By using the libmodbus library I implemented simple tools to read/write registers from a MODBUS client connected with a Cosino based board like the Mega 2560 extension. However these tools are GNU/Linux generic and you can run them on a generic GNU/Linux system too. First of all you need a running Debian OS on your Cosino then you need the modbus-utils project from our github site. But let's install needed programs first!

Package git-core is need to clone our code, in fact now you must clone the Cosino's modbus-utils project from GitHUB:

here what you should get after cloning:

To compile the tools just use:

when finished you should have three new programs named modbus-dump, modbus-set and modbus-get.

modbus-dump

By using this program you can easily dump several MODBUS client's registers at once! You must simply provide client's MODBUS address and first/last register to display. For instance if you wish to dump registers from 1 to 4 of MODBUS client at address 10, just use:

warning Note: on Mega 2560 extension you must specify /dev/ttyS1 as serial device.

To get a simple usage help just run the program with option -h:

modbus-set & modbus-get

These two utilities are needed to set&get MODBUS client's registers. Usage is quite simple, below is an example about how to read register 13 from MODBUS client at address 10 and then how to modify it.

warning Note: on Mega 2560 extension you must specify /dev/ttyS1 as serial device.

For further info see the modbus-utils project from our github site.

Facebooktwitterlinkedin
Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *

44 − 41 =