Modbus RTU

I am starting a project to build a Modbus RTU slave using a MAX485 and an UNO. I have seen all the projects available on the web but all seem to be outdated. Any information or code to get started would be appreciated

Hi
I hope this tutorial http://www.biemmeitalia.net/blog/android-touchscreen-communicates-with-arduino-using-modbus-rs485 might help you.

elle

Thanks for the information the project looks great

I have tried to compile your code and the original SImpleModbusSlave example and both give the same error

SimpleModbusSlaveExample.ino: In function 'void setup()':
SimpleModbusSlaveExample:85: error: 'modbus_configure' was not declared in this scope
SimpleModbusSlaveExample.ino: In function 'void loop()':
SimpleModbusSlaveExample:95: error: 'modbus_update' was not declared in this scope

There is some information that this is related to the version of Arduino and I ahve compiled in 1.01 and the error is the same

Any ideas?

looks like you dont have the modbus rtu library installed.
the code is making refference to it but its not there.
find your arduinos program directory - look for a folder called libraries and see if its in there, if not do a google search for it, download it and add it to this folder - restart the arduino application.
and it should be ok.

right
You'll find the modbus library used in the project at Google Code Archive - Long-term storage for Google Code Project Hosting..

elle

Thanks for the help I am making some progress. I have got the slave communicating with a master using the SimpleSlaveModbus example. When I try to use the code from the Android/Arduino project there is an error on line 34. I have tried to find the problem from the reference but no solution as yet.

sketch_feb09a.ino: In function 'void setup()':
sketch_feb09a:34: error: expected ;' before 'pinMode' sketch_feb09a:34: error: expected )' before ';' token
sketch_feb09a.ino: At global scope:
sketch_feb09a:38: error: expected constructor, destructor, or type conversion before '(' token
sketch_feb09a:39: error: expected constructor, destructor, or type conversion before '(' token
sketch_feb09a:40: error: expected constructor, destructor, or type conversion before '(' token
sketch_feb09a:41: error: expected constructor, destructor, or type conversion before '(' token
sketch_feb09a:44: error: expected constructor, destructor, or type conversion before '(' token
sketch_feb09a:47: error: expected constructor, destructor, or type conversion before '(' token
sketch_feb09a:50: error: expected unqualified-id before 'for'
sketch_feb09a:50: error: expected constructor, destructor, or type conversion before '<' token
sketch_feb09a:50: error: expected constructor, destructor, or type conversion before '++' token
sketch_feb09a:53: error: expected declaration before '}' token

Sorry mtoko, there was a minor issue with the website so that the source code was not correctly displayed. Now it should work.
Thank you for point it out!

Remember: the two parts of the code (the one with the setup and the other with loop function) belong to the same Arduino sketch, so they must be together

elle

Use this library. It is so simple and works.

http://code.google.com/p/arduino-modbus-slave/downloads/detail?name=MODBUS.zip&can=2&q=

Hi,

I've build a C code for Modbus TCP/RTU included in an open source project called Souliss, you can get the code from there.

If you need any help to get it out, just ask.

Regards,
Dario.

Hello, I hope the code can help you
This is the example code project about Modbus TCP, Modbus RTU

Read coil status.
Read input status.
Read holding registers.
Read input registers.
Write single coil.
Write single register.
Write multiple registers.
Write multiple coils.
...
See full the code here