Skip to content

Commit 9cd52ed

Browse files
committed
doc: Update README
1 parent b2bced6 commit 9cd52ed

File tree

1 file changed

+36
-16
lines changed

1 file changed

+36
-16
lines changed

README.md

+36-16
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ Allows your Arduino to communicate via Modbus protocol
2121
The Modbus is a master-slave protocol used in industrial automation and can be used in other areas, such as home automation.
2222

2323
The Modbus generally uses serial RS-232 or RS-485 as physical layer (then called Modbus Serial) and
24-
TCP/IP via Ethernet or WiFi (Modbus TCP).
24+
TCP/IP via Ethernet or WiFi (Modbus TCP). But it is also possible to associate the Modbus application protocol on any other physical layer, such as the radio for example (with [MobdusRadio](https://github.com/epsilonrt/modbus-radio) for example).
25+
26+
![Modbus Stack](https://github.com/epsilonrt/modbus-arduino/raw/master/extras/modbus-stack.png)
2527

2628
In the current version the library allows the Arduino operate **as a slave**, supporting Modbus Serial and
2729
Modbus over IP. For more information about Modbus see:
@@ -31,16 +33,7 @@ Modbus over IP. For more information about Modbus see:
3133
* [MODBUS Messaging on TCP/IP Implementation Guide](http://www.modbus.org/docs/Modbus_Messaging_Implementation_Guide_V1_0b.pdf)
3234
* [MODBUS over serial line specification and implementation guide ](http://www.modbus.org/docs/Modbus_over_serial_line_V1_02.pdf)
3335

34-
**Author's note (motivation and thanks):**
35-
36-
It all started when I found the Modbus RTU Arduino library of Juan Pablo Zometa. I had extend the
37-
library to support other Modbus functions.
38-
39-
After researching several other Modbus libraries I realized strengths and weaknesses in all of them.
40-
I also thought it would be cool have a base library for Modbus and derive it for each type of physical layer used.
4136

42-
I appreciate the work of all the authors of the other libraries, of which I used several ideas to compose the modbus-arduino.
43-
At the end of this document is a list of libraries and their authors.
4437

4538
## Features
4639

@@ -58,11 +51,20 @@ At the end of this document is a list of libraries and their authors.
5851
* 0x10 - Write Multiple Registers
5952
* 0x11 - Report Server ID
6053

54+
A set of examples is available for each of the Modbus-derived classes, for example:
55+
* [Lamp](https://github.com/epsilonrt/modbus-serial/blob/master/examples/Lamp/Lamp.ino): Use a coil to turn on and off a LED (0x05 and 0x01 functions)
56+
* [LampDimmer](https://github.com/epsilonrt/modbus-serial/blob/master/examples/LampDimmer/LampDimmer.ino): Use a holding register to control the brightness of a LED (0x06 and 0x03 functions)
57+
* [Switch](https://github.com/epsilonrt/modbus-serial/blob/master/examples/Switch/Switch.ino): Use a discrete input to read the state of a switch (0x02 function)
58+
* [TempSensor](https://github.com/epsilonrt/modbus-serial/blob/master/examples/TempSensor/TempSensor.ino): Use a input register to read the temperature from a sensor (0x04 function)
59+
* [Servo](https://github.com/epsilonrt/modbus-radio/blob/master/examples/Servo/Servo.ino): Use a holding register to control the position of a servo motor (0x06 an 0x03 function). Show how to define boundaries for the register.
60+
* [LampEncrypted](https://github.com/epsilonrt/modbus-radio/blob/master/examples/LampEncrypted/LampEncrypted.ino): Use a coil to turn on and off a LED (0x05 and 0x01 functions) with encrypted communication.
61+
62+
All examples show the use of 0x11 function to report the slave ID.
63+
64+
6165
**Notes:**
6266

63-
1. The offsets for registers are 0-based. So be careful when setting your supervisory system or your testing software. For example, in ScadaBR (http://www.scadabr.com.br)
64-
offsets are 0-based, then, a register configured as 100 in the library is set to 100 in ScadaBR. On the other hand, in the CAS Modbus Scanner
65-
(http://www.chipkin.com/products/software/modbus-software/cas-modbus-scanner/) offsets are 1-based, so a register configured as 100 in library should be 101 in this software.
67+
1. The offsets for registers are 0-based. So be careful when setting your supervisory system or your testing software. If offsets are 1-based, so a register configured as 100 in library should be 101 in this software.
6668

6769
2. Early in the library Modbus.h file there is an option to limit the operation
6870
to the functions of Holding Registers, saving space in the program memory.
@@ -76,19 +78,37 @@ Thus, only the following functions are supported:
7678
* 0x06 - Write Single Register
7779
* 0x10 - Write Multiple Registers
7880

81+
You may test the library using the [MbPoll](https://github.com/epsilonrt/mbpoll) software. For example, to turn on the led in the Lamp example, just do:
82+
83+
$ mbpoll -m rtu -b38400 -a10 -t0 /dev/tnt1 1
84+
mbpoll 1.5-2 - ModBus(R) Master Simulator
85+
Copyright (c) 2015-2023 Pascal JEAN, https://github.com/epsilonrt/mbpoll
86+
This program comes with ABSOLUTELY NO WARRANTY.
87+
This is free software, and you are welcome to redistribute it
88+
under certain conditions; type 'mbpoll -w' for details.
89+
90+
Protocol configuration: ModBus RTU
91+
Slave configuration...: address = [10]
92+
start reference = 1, count = 1
93+
Communication.........: /dev/tnt1, 38400-8E1
94+
t/o 1.00 s, poll rate 1000 ms
95+
Data type.............: discrete output (coil)
96+
97+
Written 1 references.
98+
7999
## How to
80100

81-
There are four classes corresponding to five headers that may be used:
101+
There are five classes corresponding to six headers that may be used:
82102

83103
* Modbus-Arduino - Base Library (this repository)
84104
* [Modbus-Serial](https://github.com/epsilonrt/modbus-serial) - Modbus Serial RTU Library
85105
* [Modbus-Ethernet](https://github.com/epsilonrt/modbus-ethernet) - Modbus TCP Library (standard Ethernet Shield)
86106
* [Modbus-EtherCard](https://github.com/epsilonrt/modbus-ethercard) - Modbus TCP Library (for ENC28J60 chip)
87107
* [Modbus-Esp8266AT](https://github.com/epsilonrt/modbus-esp8266at) - Modbus IP Library (for ESP8266 chip with AT firmware)
108+
* [Modbus-Radio](https://github.com/epsilonrt/modbus-radio) - Modbus Radio Library (RadioHead compatible chips)
88109

89-
By opting for Modbus Serial or Modbus TCP you must include in your sketch the corresponding header and the base library header, eg:
110+
By opting for Modbus Serial, TCP or Radio you must include in your sketch the corresponding header :
90111

91-
#include <Modbus.h>
92112
#include <ModbusSerial.h>
93113

94114

0 commit comments

Comments
 (0)