arduino modbus slave - jpmzometa

2
jpmzometa Navegación Home arduino modbus rtu arduino modbus master arduino modbus slave examples Contact Info Sitemap arduino modbus rtu > arduino modbus slave This is a modbus RTU slave implementation for the arduino board. Below you will find an open source Arduino sketch/library that turns the microcontroller board into a Modbus RTU slave. Only functions 3, read holding registers, 6, preset_single_register, and 16, preset multiple registers, of the Modbus RTU slave over serial line have been implemented. The Arduino's Serial class has been used for communication. There are some known issues about the compliance with the Modbus specifications of this implementation. Below you will find the following code: modbus_rtu_slave.pde is an almost-ready-to-use sketch written in C. Just open it on the Arduino environment and tune it up to fit your needs. ModbusSlave.tar.gz is a library written in C++. Install it and import it into your code. Both programs offer exactly the same functionality. You can find some examples on how to use the code here. A small list of systems on which it has been successfully tested follows: Linux RTU master, USB-Interface 115200bps, using several Modbus implementations freely available on the internet. PLC ABB AC500 using the MAX485 interface chip (tested by Samuel Marco). Mango, open source M2M (by Andras Tucsni, http://www.tucsni.nl/jee/) Windows RTU master using a USB-to-RS485 Adapter (ADAM 4561) coupled to slave Arduino UNO together with a MAX485 chip in a analog-to-digital converter (by Jonathan McCrohan). Mach3 as master in a nice Laser power control via modbus application (by Bart Dring). This implementations does not fully comply with the Modbus over serial line specification in the following issues: In this implementation the character frame format can be an 11-bit 8E1 (8 bits, even parity, and one stop bit), 8O1 or a 10-bit 8N1. The specification requires that if no parity is used it must have 2 stop bits to fill out the 11-bit character frame. Furthermore, when using even or odd parity, be aware that the Arduino's Serial library does not check for parity errors. The hardware correctly appends the parity bit when sending a character, though (in other words, only the MB Master will be able to detect parity errors). 1. You can only write 59 consecutive registers with a single preset_multiple_registers command. The arduino buffer takes only that much. If you send more than that, the modbus telegram will be truncated and the slave will not send any reply. The modbus spec sets the limit to 123 registers. 2. Only functions 3, 6, and 16 have been implemented. 3. NOTES: * Thanks to Samuel Marco by solving the interframe delay (T35) problem, implementing the RS485 functionality, and by adding several other enhancements to the code. * Thanks to Andras Tucsni for adding function 3 and for making other improvements to the code. arduino modbus slave - jpmzometa https://sites.google.com/site/jpmzometa/arduino-mbrt/arduino-modbus-slave 1 de 2 20/6/2013 22:41

Upload: rachel-rowland

Post on 03-Jan-2016

336 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Arduino Modbus Slave - Jpmzometa

jpmzometaNavegación

Homearduino modbus rtu

arduino modbusmasterarduino modbusslaveexamples

Contact InfoSitemap

arduino modbus rtu >

arduino modbus slave

This is a modbus RTU slave implementation for the arduino board. Below you will find anopen source Arduino sketch/library that turns the microcontroller board into a Modbus RTUslave. Only functions 3, read holding registers, 6, preset_single_register, and 16, presetmultiple registers, of the Modbus RTU slave over serial line have been implemented. TheArduino's Serial class has been used for communication. There are some known issuesabout the compliance with the Modbus specifications of this implementation.

Below you will find the following code:

modbus_rtu_slave.pde is an almost-ready-to-use sketch written in C. Just open iton the Arduino environment and tune it up to fit your needs.ModbusSlave.tar.gz is a library written in C++. Install it and import it into yourcode.

Both programs offer exactly the same functionality. You can find some examples on how touse the code here. A small list of systems on which it has been successfully tested follows:

Linux RTU master, USB-Interface 115200bps, using several Modbusimplementations freely available on the internet.PLC ABB AC500 using the MAX485 interface chip (tested by Samuel Marco).Mango, open source M2M (by Andras Tucsni, http://www.tucsni.nl/jee/)Windows RTU master using a USB-to-RS485 Adapter (ADAM 4561) coupled toslave Arduino UNO together with a MAX485 chip in a analog-to-digital converter (byJonathan McCrohan).Mach3 as master in a nice Laser power control via modbus application (by BartDring).

This implementations does not fully comply with the Modbus over serial line specificationin the following issues:

In this implementation the character frame format can be an 11-bit 8E1 (8 bits, evenparity, and one stop bit), 8O1 or a 10-bit 8N1. The specification requires that if noparity is used it must have 2 stop bits to fill out the 11-bit character frame.Furthermore, when using even or odd parity, be aware that the Arduino's Seriallibrary does not check for parity errors. The hardware correctly appends the paritybit when sending a character, though (in other words, only the MB Master will beable to detect parity errors).

1.

You can only write 59 consecutive registers with a single preset_multiple_registerscommand. The arduino buffer takes only that much. If you send more than that, themodbus telegram will be truncated and the slave will not send any reply. Themodbus spec sets the limit to 123 registers.

2.

Only functions 3, 6, and 16 have been implemented.3.

NOTES:* Thanks to Samuel Marco by solving the interframe delay (T35) problem, implementing theRS485 functionality, and by adding several other enhancements to the code.* Thanks to Andras Tucsni for adding function 3 and for making other improvements to thecode.

arduino modbus slave - jpmzometa https://sites.google.com/site/jpmzometa/arduino-mbrt/arduino-modbus-slave

1 de 2 20/6/2013 22:41

Page 2: Arduino Modbus Slave - Jpmzometa

Fazer login | Denunciar abuso | Imprimir página | Remover acesso | Tecnologia Google Sites

ModbusSlave.tar.gz jpmzometa ., ďv.3…

modbus_rtu_slave.pde jpmzometa ., ďv.12…

arduino modbus slave - jpmzometa https://sites.google.com/site/jpmzometa/arduino-mbrt/arduino-modbus-slave

2 de 2 20/6/2013 22:41