Go Down

Topic: Modbus RTU (Read 2309 times) previous topic - next topic

mtoko

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

ellepiu

http://www.biemmeitalia.net/blog/en

mtoko

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?

JT007

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.


ellepiu

right
You'll find the modbus library used in the project at http://code.google.com/p/simple-modbus/.

elle
http://www.biemmeitalia.net/blog/en

mtoko

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

ellepiu

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
http://www.biemmeitalia.net/blog/en

OZ_Willy

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=

veseo

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.
Souliss - Open-source Distributed Home Automation with Arduino and Android

http://www.souliss.net
Follow at @soulissteam

@veseotech

Go Up