Today is...
Thursday, October 19, 2017
Welcome to Control.com, the global online
community of automation professionals.
Featured Video...
Featured Video
Wiring and programming your servos and I/O just got a lot easier...
Our Advertisers
Help keep our servers running...
Patronize our advertisers!
Visit our Post Archive
MODBUS - RTU Implementation Using AVR ATMEGA32A Controllers and RS485
Simple MODBUS - RTU implementation using AVR ATMEGA32A controllers and RS485 as the electrical layer.

Greetings!

I am an intern and I am currently working on the task of implementing MODBUS-RTU protocol with RS485 as the electrical layer.

I have constructed a simple circuit for 1 master and 2 slaves to communicate serially using the RS485 protocol and have tested it successfully.

Now, I wish to implement the MODBUS protocol for this simple circuit and then use that as a base for complex MODBUS implementations involving larger number of participating devices. For this, I have a acquired good idea of the MODBUS - RTU protocol by going through Modbus_Application_Protocol , Modbus_over_serial_line and Modicon Modbus Implementation Reference Guides - all official documents.

However, now that I have started constructing my code for the slave and master, I am unable to do so easily. Hence, I was looking for guidance on the same. If anyone has implemented the same and can help me with guidance in terms of the code, it would be great. I have been on this since a month and I post this now, because after many efforts I feel the need for some well directed guidance.

In case anyone wished to contact me personally, here is my id - kshitijcircuits@gmail.com

Really appreciate the help.
Thank you!
Have a nice day!

There is simple pascal code for a Modbus master (RTU) here:
http://www.ctrlterm.com/custom.htm

You can get a nice free Windows slave simulator here:
http://www.peakhmi.com/

Select Downloads then "PeakHMI Slave Simulators"

Refer the following users manual about MODBUS master and slave. This could be helpful for your implementation.
http://www.colwaysolutions.com/usermanual.htm

Also, there is a free MODBUS protocol tester master application available for download. This could be helpful for testing your MODBUS slave.
http://www.colwaysolutions.com/download.php

Also you can find a Modbus RTU and TCP slave or master implementation in 'C' source code form at http://www.colwaysolutions.com.

Since the implementation is in ANSI 'C' you can port it easily to PIC too. The vendor also provides ports to a few popular micro controller cores like 8051, ARM, Coldfire etc. including for some RTOS kernels (OS9, MQX, uc-OS). The library is very light weight consuming negligible RAM and ROM space.