You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+36-16
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,9 @@ Allows your Arduino to communicate via Modbus protocol
21
21
The Modbus is a master-slave protocol used in industrial automation and can be used in other areas, such as home automation.
22
22
23
23
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).
In the current version the library allows the Arduino operate **as a slave**, supporting Modbus Serial and
27
29
Modbus over IP. For more information about Modbus see:
@@ -31,16 +33,7 @@ Modbus over IP. For more information about Modbus see:
31
33
*[MODBUS Messaging on TCP/IP Implementation Guide](http://www.modbus.org/docs/Modbus_Messaging_Implementation_Guide_V1_0b.pdf)
32
34
*[MODBUS over serial line specification and implementation guide ](http://www.modbus.org/docs/Modbus_over_serial_line_V1_02.pdf)
33
35
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.
41
36
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.
44
37
45
38
## Features
46
39
@@ -58,11 +51,20 @@ At the end of this document is a list of libraries and their authors.
58
51
* 0x10 - Write Multiple Registers
59
52
* 0x11 - Report Server ID
60
53
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
+
61
65
**Notes:**
62
66
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.
66
68
67
69
2. Early in the library Modbus.h file there is an option to limit the operation
68
70
to the functions of Holding Registers, saving space in the program memory.
@@ -76,19 +78,37 @@ Thus, only the following functions are supported:
76
78
* 0x06 - Write Single Register
77
79
* 0x10 - Write Multiple Registers
78
80
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:
0 commit comments