Difference between revisions of "Modbus Service"

From ESS-WIKI
Jump to: navigation, search
(Created page with "'''<span style="font-size:x-large;">Installation</span>''' <span style="font-size:large;">1. Double click Agent_Modbus_Handler_2.0.0.exe to start installation.</span> <span...")
 
 
(171 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''<span style="font-size:x-large;">Installation</span>'''
+
= Introduction =
  
<span style="font-size:large;">1. Double click Agent_Modbus_Handler_2.0.0.exe to start installation.</span>
+
<span style="font-size:large;">Modbus enables communication among many devices connected to the same network, for example, a system that measures temperature and humidity and communicates the results to a computer. Modbus is often used to connect a supervisory computer with a remote terminal unit (RTU) in supervisory control and data acquisition (SCADA) systems.</span>
 +
 
 +
<span style="font-size:large;">Many of the data types are named from its use in driving relays: a single-bit physical output is called a coil, and a single-bit physical input is called a discrete input or a contact.</span>
 +
 
 +
<span style="font-size:large;">Modbus Service is a Windows/Linux system service for WISE Agent to read&nbsp;sensor data from Modbus device or write data into Modbus device. After sensor data are acquired, WISE Agent will upload the data to the WISE-PaaS Cloud.</span>
 +
 
 +
 
 +
 
 +
= Modbus Service =
 +
 
 +
== JSON Format for upload data ==
 +
<pre>{
 +
&nbsp; &nbsp;"Modbus_Handler":{
 +
&nbsp; &nbsp; &nbsp; "Platform":{
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"bn":"Platform",
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"e":[{"n":"Version","sv":"2.0.0"},
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {"n":"Description","sv":"This service is Modbus Service"},
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {"n":"Protocol","sv":"Modbus_TCP"},
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {"n":"Name","sv":"WISE-4012E"},
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {"n":"ClientIP","sv":"127.0.0.1"},
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {"n":"ClientPort","sv":"502"},
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {"n":"Connection","bv":true}]
 +
&nbsp; &nbsp; &nbsp; },
 +
&nbsp; &nbsp; &nbsp; "Modbus_Device0":{
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"bn":"Modbus_Device0",
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"e":[{"n":"UnitID","sv":"1"}],
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"Coils":{
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "bn":"Coils",
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "e":[{"n":"LED0","bv":true},
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{"n":"LED1","bv":true},
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{"n":"LED2","bv":false}]
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
 +
&nbsp; &nbsp; &nbsp; },
 +
&nbsp; &nbsp; &nbsp; "Modbus_Device1":{
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"bn":"Modbus_Device1",
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"e":[{"n":"UnitID","sv":"2"}],
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"Discrete Inputs":{
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "bn":"Discrete Inputs",
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "e":[{"n":"Switch0","bv":false},
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{"n":"Switch1","bv":true},
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{"n":"Switch2","bv":false}]
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
 +
&nbsp; &nbsp; &nbsp; }
 +
&nbsp; &nbsp;}
 +
}</pre>
 +
 
 +
 
 +
 
 +
= How To =
 +
 
 +
== Installation ==
 +
 
 +
<span style="font-size:large;">'''Prerequisited packages''':</span>
 +
 
 +
<span style="font-size:large;">1.&nbsp;WISE Agent</span>
 +
 
 +
<span style="font-size:large;">&nbsp; &nbsp;Please download installer from EdgeSense or DeviceOn portal.</span>
 +
 
 +
 
 +
 
 +
<span style="font-size:large;">2.&nbsp;MQTT Broker</span>
 +
 
 +
<span style="font-size:large;">&nbsp; &nbsp; You can download installer from this link:&nbsp;[https://mosquitto.org/download/ https://mosquitto.org/download/]</span>
 +
 
 +
 
 +
 
 +
 
 +
<span style="font-size:large;">'''Modbus Service Setup:'''</span>
 +
 
 +
<span style="font-size:large;">1. Double click Agent_Modbus_Handler_2.0.x.exe ([http://ess-wiki.advantech.com.tw/view/Modbus_Service#Release Download]) to start installation.</span>
  
 
<span style="font-size:large;">2. Click "Next" on the Welcome screen.</span>
 
<span style="font-size:large;">2. Click "Next" on the Welcome screen.</span>
  
<span style="font-size:large;">[[File:Agent modbus handler 02.png|800x600px]]</span>
+
<span style="font-size:large;">[[File:Agent modbus handler 02.png|640x480px|Agent modbus handler 02.png]]</span>
 +
 
 +
 
 +
 
 +
<span style="font-size:large;">3. Select Installation Folder and then click "Next" to continue.</span>
  
<span style="font-size:large;"></span>
+
<span style="font-size:large;">[[File:Agent modbus handler 03.png|640x480px|Agent modbus handler 03.png]]</span>
  
<span style="font-size:large;"></span><span style="font-size:large;">3. Select Installation Folder and then click "Next" to continue.</span>
 
  
<span style="font-size:large;">[[File:Agent modbus handler 03.png|800x600px]]</span>
 
  
<span style="font-size:large;"></span>
+
<span style="font-size:large;">4. Click "Install" on the Ready to Install screen to continue.</span>
  
<span style="font-size:large;">4. Click "Install" on the Ready to Install screen to continue.<br/></span>
+
[[File:Agent modbus handler 04.png|640x480px|Agent modbus handler 04.png]]
  
<span style="font-size:large;"></span>[[File:Agent modbus handler 04.png|800x600px]]
 
  
<span style="font-size:large;"><br/></span>
 
  
 
<span style="font-size:large;">5. Installation completed, click "Finish" button to exit the Setup Wizard.</span>
 
<span style="font-size:large;">5. Installation completed, click "Finish" button to exit the Setup Wizard.</span>
  
<span style="font-size:large;">[[File:Agent modbus handler 06.png|800x600px]]</span>
+
<span style="font-size:large;">[[File:Agent modbus handler 06.png|640x480px|Agent modbus handler 06.png]]</span>
 +
 
 +
== <span style="font-size:x-large;">Configuration</span> ==
 +
 
 +
=== <span style="font-size:large;">Config Modbus Connection</span> ===
 +
 
 +
<span style="font-size:medium;">1. Open File Explorer and change target folder to the Modbus Service installation folder.</span>
 +
 
 +
<span style="font-size:medium;">2. Open and edit the file Mobus_Handler.ini</span>
 +
 
 +
<span style="font-size:medium;">2.1 Give a Name for the platform.</span>
 +
 
 +
<span style="font-size:medium;">2.2 Set the Protocol.</span>
 +
 
 +
 
 +
 
 +
<span style="font-size:medium;"><u>Modbus TCP Connection:</u></span>
 +
 
 +
<span style="font-size:medium;">Protocol=Modbus_TCP</span>
 +
 
 +
<span style="font-size:medium;">ClientIP=(IP address of Modbus TCP devices)</span>
 +
 
 +
<span style="font-size:medium;">ClientPort=(Port of Modbus TCP devices)&nbsp;&nbsp;</span>
 +
 
 +
 
 +
 
 +
<span style="font-size:medium;">'''Example:'''</span>
 +
<pre>[Platform]
 +
Name=WISE-4012E
 +
Protocol=Modbus_TCP
 +
ClientIP=127.0.0.1
 +
ClientPort=502
 +
 
 +
Interval=3
 +
#Interval: The time interval of modbus data access/report cycle in second.
 +
Delay=0
 +
#Delay: The time delay between two modbus address R/W in millisecond.
 +
#Delay=0 means no delay.
 +
Log=0
 +
 
 +
[Devices]
 +
numberOfDevices=2
 +
Device0=Modbus_Device0.ini
 +
Device1=Modbus_Device1.ini
 +
</pre>
 +
 
 +
 
 +
 
 +
<span style="font-size:medium;"><u>Modbus RTU Connection:</u></span>
 +
 
 +
<span style="font-size:medium;">Protocol=Modbus_RTU</span>
 +
 
 +
<span style="font-size:medium;">SlavePort=(The serial port's device node of the Gateway which connect to Modbus RTU devices)</span>
 +
 
 +
<span style="font-size:medium;">Baud=(The baud rate for the serial port to communicate&nbsp;with Modbus RTU device)</span>
 +
 
 +
<span style="font-size:medium;">Parity=(The parity of the serial port)</span>
 +
 
 +
<span style="font-size:medium;">DataBits=(The data bits of the serial port)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span>
 +
 
 +
<span style="font-size:medium;">StopBits=(The stop bits of the serial port)&nbsp;</span>
 +
 
 +
 
 +
 
 +
<span style="font-size:medium;">'''Example:'''</span>
 +
<pre>[Platform]
 +
Name=EKI-XXXX
 +
Protocol=Modbus_RTU
 +
SlavePort=COM1
 +
Baud=19200
 +
Parity=None
 +
DataBits=8
 +
StopBits=1
 +
 
 +
Interval=3
 +
#Interval: The time interval of modbus data access/report cycle in second.
 +
Delay=0
 +
#Delay: The time delay between two modbus address R/W in millisecond.
 +
#Delay=0 means no delay.
 +
Log=0
 +
 
 +
[Devices]
 +
numberOfDevices=2
 +
Device0=Modbus_Device0.ini
 +
Device1=Modbus_Device1.ini
 +
</pre>
 +
 
 +
<br/>
 +
<br/>
 +
 
 +
=== <span style="font-size:large;">Config Modbus Devices &&nbsp;Sensors</span> ===
 +
 
 +
<span style="font-size: medium;">1. DeviceInfo session:</span>
 +
 
 +
<span style="font-size: medium;">&nbsp; &nbsp; [DeviceInfo]</span>
 +
 
 +
<span style="font-size:medium;">&nbsp; &nbsp; UnitId: The UnitID is a device ID&nbsp;for a&nbsp;Modbus TCP device.</span>
 +
 
 +
<span style="font-size:medium;">&nbsp; &nbsp; SlaveID: The SlaveID is a device ID for a Modbus RTU device.</span>
 +
 
 +
 
 +
 
 +
<span style="font-size:medium;">2. Coils session</span>
 +
 
 +
<span style="font-size:medium;">&nbsp; &nbsp; [Coils]</span>
 +
 
 +
<span style="font-size:medium;">&nbsp; &nbsp; NumberOfB: The number of Coils.</span>
 +
 
 +
<span style="font-size:medium;">&nbsp; &nbsp; Bn:&nbsp;The sensors definitation of Coils.</span>
 +
 
 +
 
 +
 
 +
<span style="font-size:medium;">3. Discrete Inputs session</span>
 +
 
 +
<span style="font-size:medium;">&nbsp; &nbsp; [Discrete Inputs]</span>
 +
 
 +
<span style="font-size:medium;">&nbsp; &nbsp; NumberOfIB: The number of Descrete Inputs.</span>
 +
 
 +
<span style="font-size:medium;">&nbsp; &nbsp; IBn:&nbsp;The sensors definitation of Descrete Inputs.</span>
 +
 
 +
 
 +
 
 +
<span style="font-size:medium;">4.&nbsp;Holding Registers session</span>
 +
 
 +
<span style="font-size:medium;">&nbsp; &nbsp; [Holding Registers]</span>
 +
 
 +
<span style="font-size:medium;">&nbsp; &nbsp; NumberOfR: The number of Holding Registers.</span>
 +
 
 +
<span style="font-size:medium;">&nbsp; &nbsp; Rn:&nbsp;The sensors definitation of Holding Registers.</span>
 +
 
 +
 
 +
 
 +
<span style="font-size:medium;">5.&nbsp;Input Registers session</span>
 +
 
 +
<span style="font-size:medium;">&nbsp; &nbsp; [Input Registers]</span>
 +
 
 +
<span style="font-size:medium;">&nbsp; &nbsp; NumbrtOfIR: The number of Input Registers.</span>
 +
 
 +
<span style="font-size:medium;">&nbsp; &nbsp; IRn:&nbsp;The sensors definitation of Input Registers.</span>
 +
 
 +
 
 +
 
 +
<span style="font-size:medium;">6.&nbsp;Coils Block session</span>
 +
 
 +
<span style="font-size:medium;">&nbsp; &nbsp; NumberOfBB: The number of Coils Block.</span>
 +
 
 +
<span style="font-size:medium;">&nbsp; &nbsp;&nbsp;BBn:&nbsp;The sensors definitation of Coils Block.</span>
 +
 
 +
 
 +
 
 +
<span style="font-size:medium;">7. Discrete Input Block session</span>
 +
 
 +
<span style="font-size:medium;">&nbsp; &nbsp; NumberOfIBB: The number of Descrete Inputs Block.</span>
 +
 
 +
<span style="font-size:medium;">&nbsp; &nbsp; IBBn:&nbsp;The sensors definitation of Descrete Inputs Block.</span>
 +
 
 +
 
 +
 
 +
<span style="font-size:medium;">8. Input Register Block session</span>
 +
 
 +
<span style="font-size:medium;">&nbsp; &nbsp; NumbrtOfIRB: The number of Input Registers&nbsp;Block.</span>
 +
 
 +
<span style="font-size:medium;">&nbsp; &nbsp; IRBn:&nbsp;The sensors definitation of Input Registers Block.</span>
 +
 
 +
 
 +
 
 +
<span style="font-size:medium;">9. Holding Register session</span>
 +
 
 +
<span style="font-size:medium;">&nbsp; &nbsp; NumberOfRB: The number of Holding Registers&nbsp;Block.</span>
 +
 
 +
<span style="font-size:medium;">&nbsp; &nbsp; RBn:&nbsp;The sensors definitation of Holding Registers Block.</span>
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
<span style="color:#000000;">'''<span style="font-size:medium;">NOTE!&nbsp;The maximum length of sensor name&nbsp;is 30 characters.</span>'''</span>
 +
 
 +
 
 +
 
 +
 
 +
 
 +
<span style="font-size:medium;">Modbus_Device0.ini Example:</span>
 +
<pre>[DeviceInfo]
 +
# For Modbus_TCP
 +
UnitID=1
 +
# For Modbus_RTU
 +
#SlaveID=1
 +
 
 +
[Coils]
 +
numberOfB=3
 +
B0=0,LED0
 +
B1=1,LED1
 +
B2=2,LED2
 +
</pre>
 +
 
 +
 
 +
 
 +
<span style="font-size:medium;">Modbus_Device1.ini Example:</span>
 +
<pre>[DeviceInfo]
 +
# For Modbus_TCP
 +
UnitID=2
 +
# For Modbus_RTU
 +
#SlaveID=2
 +
 
 +
[Discrete Inputs]
 +
numberOfIB=3
 +
IB0=0,Switch0
 +
IB1=1,Switch1
 +
IB2=2,Switch2
 +
 
 +
[Input Registers]
 +
numberOfIR=3
 +
IR0=0,Data0,-1000000,1000000,1,V,0,""
 +
IR1=1,Data1,-1000000,1000000,1,V,0,""
 +
IR2=2,Data2,-1000000,1000000,1,V,0,""
 +
 
 +
</pre>
 +
 
 +
<br/>
 +
<br/>
 +
 
 +
=== <span style="font-size:large;">Config Address and Data Types</span> ===
 +
 
 +
<span style="font-size:medium;">The format and sensor address definition of sensors:</span>
 +
 
 +
<span style="font-size:medium;">1. Single Data&nbsp;Format:</span>
 +
 
 +
<span style="font-size:medium;">'''Tag = offset, name, min, max, precision, unit, data type, lua script'''</span>
 +
 
 +
 
 +
 
 +
<span style="font-size:medium;">2. Block Data&nbsp;Format:</span>
 +
 
 +
<span style="font-size:medium;">'''Block = offset, length, name'''</span>
 +
 
 +
 
 +
 
 +
<span style="font-size:medium;">3.&nbsp;Tag's type, address and&nbsp;offset Mapping</span>
 +
 
 +
<span style="font-size:medium;">Single Data:</span>
 +
 
 +
{| border="1" cellspacing="1" cellpadding="1" style="width: 553px;"
 +
|-
 +
| style="width: 70px; text-align: center;" | <span style="font-size:medium;">'''Tag'''</span>
 +
| style="width: 179px;" | <span style="font-size:medium;">'''Type'''</span>
 +
| style="width: 145px; text-align: center;" | <span style="font-size:medium;">'''Address'''</span>
 +
| style="width: 141px; text-align: center;" | <span style="font-size:medium;">'''Offset'''</span>
 +
|-
 +
| style="width: 70px; text-align: center;" | <span style="font-size:medium;">B</span>
 +
| style="width: 179px;" | <span style="font-size:medium;">Coils</span>
 +
| style="width: 145px; text-align: center;" | <span style="font-size:medium;">00001 ~ 09999</span>
 +
| style="width: 141px; text-align: center;" | <span style="font-size:medium;">0~9998</span>
 +
|-
 +
| style="width: 70px; text-align: center;" | <span style="font-size:medium;">IB</span>
 +
| style="width: 179px;" | <span style="font-size:medium;">Descrete Inputs</span>
 +
| style="width: 145px; text-align: center;" | <span style="font-size:medium;">10001 ~ 19999</span>
 +
| style="width: 141px; text-align: center;" | <span style="font-size:medium;">0~9998</span>
 +
|-
 +
| style="width: 70px; text-align: center;" | <span style="font-size:medium;">IR</span>
 +
| style="width: 179px;" | <span style="font-size:medium;">Input Registers</span>
 +
| style="width: 145px; text-align: center;" | <span style="font-size:medium;">30001 ~ 39999</span>
 +
| style="width: 141px; text-align: center;" | <span style="font-size:medium;">0~9998</span><br/>
 +
|-
 +
| style="width: 70px; text-align: center;" | <span style="font-size:medium;">R</span>
 +
| style="width: 179px;" | <span style="font-size:medium;">Holding Registers</span>
 +
| style="width: 145px; text-align: center;" | <span style="font-size:medium;">40001 ~ 49999</span>
 +
| style="width: 141px; text-align: center;" | <span style="font-size:medium;">0~9998</span><br/>
 +
|}
 +
 
 +
 
 +
 
 +
<span style="font-size:medium;">Block Data:</span>
 +
 
 +
{| border="1" cellspacing="1" cellpadding="1" style="width: 553px;"
 +
|-
 +
| style="width: 70px; text-align: center;" | <span style="font-size:medium;">'''Block'''</span>
 +
| style="width: 179px;" | <span style="font-size:medium;">'''Type'''</span>
 +
| style="width: 145px; text-align: center;" | <span style="font-size:medium;">'''Address'''</span>
 +
| style="width: 141px; text-align: center;" | <span style="font-size:medium;">'''Offset'''</span>
 +
|-
 +
| style="width: 70px; text-align: center;" | <span style="font-size:medium;">BB</span>
 +
| style="width: 179px;" | <span style="font-size:medium;">Coils Block</span><br/>
 +
| style="width: 145px; text-align: center;" | <span style="font-size:medium;">00001 ~ 09999</span><br/>
 +
| style="width: 141px; text-align: center;" | <span style="font-size:medium;">0~9998</span>
 +
|-
 +
| style="width: 70px; text-align: center;" | <span style="font-size:medium;">IBB</span>
 +
| style="width: 179px;" | <span style="font-size:medium;">Descrete Inputs Block</span><br/>
 +
| style="width: 145px; text-align: center;" | <span style="font-size:medium;">10001 ~ 19999</span><br/>
 +
| style="width: 141px; text-align: center;" | <span style="font-size:medium;">0~9998</span><br/>
 +
|-
 +
| style="width: 70px; text-align: center;" | <span style="font-size:medium;">IRB</span>
 +
| style="width: 179px;" | <span style="font-size:medium;">Input Registers Block</span><br/>
 +
| style="width: 145px; text-align: center;" | <span style="font-size:medium;">30001 ~ 39999</span><br/>
 +
| style="width: 141px; text-align: center;" | <span style="font-size:medium;">0~9998</span><br/>
 +
|-
 +
| style="width: 70px; text-align: center;" | <span style="font-size:medium;">RB</span>
 +
| style="width: 179px;" | <span style="font-size:medium;">Holding Registers Block</span><br/>
 +
| style="width: 145px; text-align: center;" | <span style="font-size:medium;">40001 ~ 49999</span><br/>
 +
| style="width: 141px; text-align: center;" | <span style="font-size:medium;">0~9998</span><br/>
 +
|}
 +
 
 +
 
 +
 
 +
<span style="font-size:medium;">4.&nbsp;min and max:</span>
 +
 
 +
<span style="font-size:medium;">&nbsp; &nbsp; The minimal and maximal range of the sensor.</span>
 +
 
 +
 
 +
 
 +
<span style="font-size:medium;">5. Precision:</span>
 +
 
 +
<span style="font-size:medium;">&nbsp; &nbsp; The value to denormalize&nbsp;a normalized sensor value become a floating point number.</span>
 +
 
 +
 
 +
 
 +
<span style="font-size:medium;">6. Unit:</span>
  
<span style="font-size:large;"></span><span style="font-size:large;"><br/></span>
+
<span style="font-size:medium;">&nbsp; &nbsp; The unit for the sensor value.</span>
  
'''<span style="font-size:x-large;">Configuration</span>'''
 
  
<span style="font-size:x-large;"></span><span style="font-size:large;">1. Open File Explorer and change target folder to the Modbus Service installation folder.</span>
 
  
<span style="font-size:large;"></span><span style="font-size:large;">2. Open and edit the file Mobus_Handler.ini</span>
+
<span style="font-size:medium;">7.&nbsp;The data type definition of sensors:</span>
  
<span style="font-size:large;">&nbsp; &nbsp; 2.1 Give a Name for the platform.</span>
+
{| border="1" cellspacing="1" cellpadding="1" style="width: 425px;"
 +
|-
 +
| style="width: 108px; text-align: center;" | <span style="font-size:medium;">'''Data Type'''</span>
 +
| style="width: 304px;" | <span style="font-size:medium;">'''&nbsp;Description'''</span>
 +
|-
 +
| style="width: 108px; text-align: center;" | <span style="font-size:medium;">0</span>
 +
| style="width: 304px;" | <span style="font-size:medium;">16-bit operation</span><br/>
 +
|-
 +
| style="width: 108px; text-align: center;" | <span style="font-size:medium;">1</span>
 +
| style="width: 304px;" | <span style="font-size:medium;">32-bit float no swap</span><br/>
 +
|-
 +
| style="width: 108px; text-align: center;" | <span style="font-size:medium;">2</span>
 +
| style="width: 304px;" | <span style="font-size:medium;">32-bit float byte and word swap</span><br/>
 +
|-
 +
| style="width: 108px; text-align: center;" | <span style="font-size:medium;">3</span>
 +
| style="width: 304px;" | <span style="font-size:medium;">32-bit float byte swap</span><br/>
 +
|-
 +
| style="width: 108px; text-align: center;" | <span style="font-size:medium;">4</span>
 +
| style="width: 304px;" | <span style="font-size:medium;">32-bit float word swap</span><br/>
 +
|-
 +
| style="width: 108px; text-align: center;" | <span style="font-size:medium;">5</span>
 +
| style="width: 304px;" | <span style="font-size:medium;">32-bit unsigned int no swap</span><br/>
 +
|-
 +
| style="width: 108px; text-align: center;" | <span style="font-size:medium;">6</span>
 +
| style="width: 304px;" | <span style="font-size:medium;">32-bit unsigned int word swap</span><br/>
 +
|-
 +
| style="width: 108px; text-align: center;" | <span style="font-size:medium;">7</span>
 +
| style="width: 304px;" | <span style="font-size:medium;">32-bit signed int no swap</span><br/>
 +
|-
 +
| style="width: 108px; text-align: center;" | <span style="font-size:medium;">8</span>
 +
| style="width: 304px;" | <span style="font-size:medium;">32-bit signed int word swap</span><br/>
 +
|}
  
<span style="font-size:large;">&nbsp; &nbsp; 2.2 Set the Protocol.</span>
 
  
'''<span style="font-size:large;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<u>For the modbus TCP devices:</u></span><br/>'''
 
  
<span style="font-size:large;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Protocol=Modbus_TCP</span>
+
'''<span style="font-size:medium;">NOTE! For type of "32-bit unsigned int", the maximum support range in 0 ~ 2,147,483,647.</span>'''
  
<span style="font-size:large;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ClientIP=(IP address of Modbus TCP devices)</span>
+
== <span style="font-size:x-large;">LUA Conversion</span> ==
  
<span style="font-size:large;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ClientPort=(Port of Modbus TCP devices)</span>
+
<span style="font-size:medium;">You can do a simple&nbsp;mathematic&nbsp;operation by add a&nbsp;forms in the LUA conversion string, for example:</span>
  
<span style="font-size:large;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span>
+
Example1: To convert a 16-bit unsigned integer value to 16-bit signed value
 +
<pre>[Holding Registers]
 +
numberOfR=1
 +
R0=0,Data0,-32768,32767,1,V,0,"(modbus_val>32767) and (modbus_val-65536) or modbus_val"
 +
</pre>
  
'''<span style="font-size:large;">''&nbsp; &nbsp; &nbsp; &nbsp; Example:''</span>'''
 
  
<span style="font-size:large;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span>[[File:Agent modbus handler 07.png|800x480px]]<span style="font-size:large;"></span>
 
  
&nbsp;<span style="font-size:large;">&nbsp; &nbsp;&nbsp;</span>
+
Example2: To do a mathematic forms&nbsp;operation.
<span style="font-size:large;"></span>
+
<pre>[Holding Registers]
'''<span style="font-size:large;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<u>For the modbus RTU&nbsp;devices:</u></span>'''
+
numberOfR=1
 +
R0=0,Voltage0,0,5,0.001,V,0,"modbus_val*2-10"
 +
</pre>
  
<span style="font-size:large;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Protocol=Modbus_RTU</span>
+
<span style="color:#FF0000;">'''NOTE: If both precision and LUA string are assigned, LUA string&nbsp;will be calculated with modbus value first, then the new value multiply with assigned precision.'''</span>
  
<span style="font-size:large;"></span><span style="font-size:large;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SlavePort=(The serial port's device node of the gateway which connect to Modbus RTU devices)</span>
 
  
<span style="font-size:large;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Baud=(The baud rate of the serial port)</span>
 
  
<span style="font-size:large;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Parity=(The parity of the serial port)</span>
+
LUA functions list:<br/>[https://www.kancloud.cn/thinkphp/lua-guide/43807 https://www.kancloud.cn/thinkphp/lua-guide/43807]
  
<span style="font-size:large;"></span>&nbsp; &nbsp;<span style="font-size:large;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DataBits=(The data bits of the serial port)</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
 
  
<span style="font-size:large;"></span>&nbsp; &nbsp;<span style="font-size:large;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;StopBits=(The stop bits of the serial port)</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
 
  
 +
== <span style="font-size:larger;">Docker version</span> ==
  
 +
To config&nbsp;Modbus Service and Restart Service in EdgeSense v1.0.2 Docker version:
 +
<pre>$cd ${Installed path}/Installer/packages/Plugins/docker-edgesense-image-x86/EdgeSense/EService-Modbus/config
 +
$sudo vim Modbus_Handler.ini
 +
$sudo docker restart service-modbus
 +
</pre>
  
'''<span style="font-size:large;">''&nbsp; &nbsp; &nbsp; &nbsp; Example:''</span>'''
 
  
<span style="font-size:large;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[[File:Agent modbus handler 08.png|800x460px]]</span>
 
  
<span style="font-size:large;"><br/></span>
+
= [[Modbus_Handler_2.0_Real_Application_Case|Real Application Case: ADAM-4117]] =
  
<span style="font-size:large;"><br/></span>
+
= Release =
<span style="font-size:large;"></span>
 
<span style="font-size:large;">&nbsp; &nbsp; 2.3&nbsp;Set the number of modbus devices and device detail information file.</span>
 
  
<span style="font-size:large;"></span>'''<span style="font-size:large;">''&nbsp; &nbsp; &nbsp; &nbsp; Example:''</span>'''<span style="font-size:large;"></span>
+
<span style="font-size:larger;">This is an overview that displays Modbus Service&nbsp;versions and some stats and numbers for each release.</span>
  
<span style="font-size:large;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[[File:Agent modbus handler 09.png|800x400px]]</span>
+
{| border="1" cellspacing="1" cellpadding="1" style="width: 1065px;"
 +
|-
 +
| style="width: 47px; text-align: center;" | <span style="font-size:larger;">Index</span>
 +
| style="width: 63px; text-align: center;" | <span style="font-size:larger;">Version</span>
 +
| style="width: 72px; text-align: center;" | <span style="font-size:larger;">Date</span>
 +
| style="width: 71px; text-align: center;" | <span style="font-size:larger;">Platform</span>
 +
| style="width: 76px; text-align: center;" | <span style="font-size:larger;">OS</span>
 +
| style="width: 415px; text-align: center;" | <span style="font-size:larger;">Release Note</span>
 +
| style="width: 291px; text-align: center;" | <span style="font-size:larger;">Installer</span>
 +
|-
 +
| style="width: 47px; text-align: center;" | <span style="font-size: 15.6px;">1</span>
 +
| style="width: 63px; text-align: center;" | <span style="font-size:larger;">v2.0.1</span>
 +
| style="width: 72px; text-align: center;" | <span style="font-size:larger;">2018/9/6</span>
 +
| style="width: 71px; text-align: center;" | <span style="font-size:larger;">x86_64 CPU</span><br/>
 +
| style="width: 76px; text-align: center;" | <span style="font-size:larger;">Windows</span><br/>
 +
| style="width: 415px; text-align: center;" | <span style="font-size:larger;">[[Media:Agent_Modbus_Handler_ReleaseNote_2.0.1.txt|Release Note]]</span>
 +
| style="width: 291px; text-align: center;" |
 +
<span style="font-size:larger;">&nbsp;[file:////eossfs/ESS-Release/EdgeSense/Release/Windows/Modbus_Handler/2.0.1/ Agent_Modbus_Handler_2.0.1.zip]</span>
  
<span style="font-size:large;"></span>
+
|-
 +
| style="width: 47px; text-align: center;" | <span style="font-size: 15.6px;">2</span>
 +
| style="width: 63px; text-align: center;" | <span style="font-size:larger;">v2.0.2</span>
 +
| style="width: 72px; text-align: center;" | <span style="font-size:larger;">2020/7/3</span>
 +
| style="width: 71px; text-align: center;" | <span style="font-size:larger;">x86_64 CPU</span><br/>
 +
| style="width: 76px; text-align: center;" | <span style="font-size:larger;">Windows</span><br/>
 +
| style="width: 415px;" |
 +
*<span style="font-size:medium; text-align: left;">Filter out non modbus handler&nbsp;auto report enable request.</span>
  
<span style="font-size:large;">&nbsp; &nbsp; 2.4&nbsp;Set the content of device detail information.</span>
+
| style="width: 291px; text-align: center;" | <span style="font-size:larger;">&nbsp;[file://eossfs/ESS-Release/EdgeSense/Release/Windows/Modbus_Handler/2.0.2 Agent_Modbus_Handler_2.0.2.zip]</span>
 +
|}
  
<span style="font-size:large;"></span>'''<span style="font-size:large;">''&nbsp; &nbsp; &nbsp; &nbsp; Example:''</span>'''
+
<span style="font-size:larger;">How to download:</span>
  
<span style="font-size:large;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[[File:Agent modbus handler 10.png|640x120px]]</span>
+
<span style="font-size:larger;">Above files are available at local server only, please copy file's url and paste the url in File Explorer&nbsp;to download the&nbsp;file.</span>
  
<span style="font-size:large;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[[File:Agent modbus handler 11.png|800x600px]]</span>
+
<span style="font-size:larger;">1. Right click on Installer file's&nbsp;url and copy file's url.</span>
  
<span style="font-size:large;"></span><span style="font-size:large;"></span><span style="font-size:large;"></span><span style="font-size:large;"><br/></span>
+
<span style="font-size:larger;">2. Open File Explorer and paste file's&nbsp;url in File Explorer.</span>
  
<span style="font-size:large;"><br/></span>
+
<span style="font-size:larger;">Example:</span>
  
<span style="font-size:large;"><br/></span>
+
<span style="font-size:larger;">([[EdgeSense_FAQ|How to access to EOSSFS file server]]&nbsp;)</span>

Latest revision as of 10:16, 23 December 2021

Introduction

Modbus enables communication among many devices connected to the same network, for example, a system that measures temperature and humidity and communicates the results to a computer. Modbus is often used to connect a supervisory computer with a remote terminal unit (RTU) in supervisory control and data acquisition (SCADA) systems.

Many of the data types are named from its use in driving relays: a single-bit physical output is called a coil, and a single-bit physical input is called a discrete input or a contact.

Modbus Service is a Windows/Linux system service for WISE Agent to read sensor data from Modbus device or write data into Modbus device. After sensor data are acquired, WISE Agent will upload the data to the WISE-PaaS Cloud.


Modbus Service

JSON Format for upload data

{
   "Modbus_Handler":{
      "Platform":{
         "bn":"Platform",
         "e":[{"n":"Version","sv":"2.0.0"},
              {"n":"Description","sv":"This service is Modbus Service"},
              {"n":"Protocol","sv":"Modbus_TCP"},
              {"n":"Name","sv":"WISE-4012E"},
              {"n":"ClientIP","sv":"127.0.0.1"},
              {"n":"ClientPort","sv":"502"},
              {"n":"Connection","bv":true}]
      },
      "Modbus_Device0":{
         "bn":"Modbus_Device0",
         "e":[{"n":"UnitID","sv":"1"}],
         "Coils":{
            "bn":"Coils",
            "e":[{"n":"LED0","bv":true},
                 {"n":"LED1","bv":true},
                 {"n":"LED2","bv":false}]
         }
      },
      "Modbus_Device1":{
         "bn":"Modbus_Device1",
         "e":[{"n":"UnitID","sv":"2"}],
         "Discrete Inputs":{
            "bn":"Discrete Inputs",
            "e":[{"n":"Switch0","bv":false},
                 {"n":"Switch1","bv":true},
                 {"n":"Switch2","bv":false}]
         }
      }
   }
}


How To

Installation

Prerequisited packages:

1. WISE Agent

   Please download installer from EdgeSense or DeviceOn portal.


2. MQTT Broker

    You can download installer from this link: https://mosquitto.org/download/



Modbus Service Setup:

1. Double click Agent_Modbus_Handler_2.0.x.exe (Download) to start installation.

2. Click "Next" on the Welcome screen.

Agent modbus handler 02.png


3. Select Installation Folder and then click "Next" to continue.

Agent modbus handler 03.png


4. Click "Install" on the Ready to Install screen to continue.

Agent modbus handler 04.png


5. Installation completed, click "Finish" button to exit the Setup Wizard.

Agent modbus handler 06.png

Configuration

Config Modbus Connection

1. Open File Explorer and change target folder to the Modbus Service installation folder.

2. Open and edit the file Mobus_Handler.ini

2.1 Give a Name for the platform.

2.2 Set the Protocol.


Modbus TCP Connection:

Protocol=Modbus_TCP

ClientIP=(IP address of Modbus TCP devices)

ClientPort=(Port of Modbus TCP devices)  


Example:

[Platform]
Name=WISE-4012E
Protocol=Modbus_TCP
ClientIP=127.0.0.1
ClientPort=502

Interval=3
#Interval: The time interval of modbus data access/report cycle in second.
Delay=0
#Delay: The time delay between two modbus address R/W in millisecond.
#Delay=0 means no delay.
Log=0

[Devices]
numberOfDevices=2
Device0=Modbus_Device0.ini
Device1=Modbus_Device1.ini


Modbus RTU Connection:

Protocol=Modbus_RTU

SlavePort=(The serial port's device node of the Gateway which connect to Modbus RTU devices)

Baud=(The baud rate for the serial port to communicate with Modbus RTU device)

Parity=(The parity of the serial port)

DataBits=(The data bits of the serial port)              

StopBits=(The stop bits of the serial port) 


Example:

[Platform]
Name=EKI-XXXX
Protocol=Modbus_RTU
SlavePort=COM1
Baud=19200
Parity=None
DataBits=8
StopBits=1

Interval=3
#Interval: The time interval of modbus data access/report cycle in second.
Delay=0
#Delay: The time delay between two modbus address R/W in millisecond.
#Delay=0 means no delay.
Log=0

[Devices]
numberOfDevices=2
Device0=Modbus_Device0.ini
Device1=Modbus_Device1.ini



Config Modbus Devices & Sensors

1. DeviceInfo session:

    [DeviceInfo]

    UnitId: The UnitID is a device ID for a Modbus TCP device.

    SlaveID: The SlaveID is a device ID for a Modbus RTU device.


2. Coils session

    [Coils]

    NumberOfB: The number of Coils.

    Bn: The sensors definitation of Coils.


3. Discrete Inputs session

    [Discrete Inputs]

    NumberOfIB: The number of Descrete Inputs.

    IBn: The sensors definitation of Descrete Inputs.


4. Holding Registers session

    [Holding Registers]

    NumberOfR: The number of Holding Registers.

    Rn: The sensors definitation of Holding Registers.


5. Input Registers session

    [Input Registers]

    NumbrtOfIR: The number of Input Registers.

    IRn: The sensors definitation of Input Registers.


6. Coils Block session

    NumberOfBB: The number of Coils Block.

    BBn: The sensors definitation of Coils Block.


7. Discrete Input Block session

    NumberOfIBB: The number of Descrete Inputs Block.

    IBBn: The sensors definitation of Descrete Inputs Block.


8. Input Register Block session

    NumbrtOfIRB: The number of Input Registers Block.

    IRBn: The sensors definitation of Input Registers Block.


9. Holding Register session

    NumberOfRB: The number of Holding Registers Block.

    RBn: The sensors definitation of Holding Registers Block.




NOTE! The maximum length of sensor name is 30 characters.



Modbus_Device0.ini Example:

[DeviceInfo]
# For Modbus_TCP
UnitID=1
# For Modbus_RTU
#SlaveID=1

[Coils]
numberOfB=3
B0=0,LED0
B1=1,LED1
B2=2,LED2


Modbus_Device1.ini Example:

[DeviceInfo]
# For Modbus_TCP
UnitID=2
# For Modbus_RTU
#SlaveID=2

[Discrete Inputs]
numberOfIB=3
IB0=0,Switch0
IB1=1,Switch1
IB2=2,Switch2

[Input Registers]
numberOfIR=3
IR0=0,Data0,-1000000,1000000,1,V,0,""
IR1=1,Data1,-1000000,1000000,1,V,0,""
IR2=2,Data2,-1000000,1000000,1,V,0,""



Config Address and Data Types

The format and sensor address definition of sensors:

1. Single Data Format:

Tag = offset, name, min, max, precision, unit, data type, lua script


2. Block Data Format:

Block = offset, length, name


3. Tag's type, address and offset Mapping

Single Data:

Tag Type Address Offset
B Coils 00001 ~ 09999 0~9998
IB Descrete Inputs 10001 ~ 19999 0~9998
IR Input Registers 30001 ~ 39999 0~9998
R Holding Registers 40001 ~ 49999 0~9998


Block Data:

Block Type Address Offset
BB Coils Block
00001 ~ 09999
0~9998
IBB Descrete Inputs Block
10001 ~ 19999
0~9998
IRB Input Registers Block
30001 ~ 39999
0~9998
RB Holding Registers Block
40001 ~ 49999
0~9998


4. min and max:

    The minimal and maximal range of the sensor.


5. Precision:

    The value to denormalize a normalized sensor value become a floating point number.


6. Unit:

    The unit for the sensor value.


7. The data type definition of sensors:

Data Type  Description
0 16-bit operation
1 32-bit float no swap
2 32-bit float byte and word swap
3 32-bit float byte swap
4 32-bit float word swap
5 32-bit unsigned int no swap
6 32-bit unsigned int word swap
7 32-bit signed int no swap
8 32-bit signed int word swap


NOTE! For type of "32-bit unsigned int", the maximum support range in 0 ~ 2,147,483,647.

LUA Conversion

You can do a simple mathematic operation by add a forms in the LUA conversion string, for example:

Example1: To convert a 16-bit unsigned integer value to 16-bit signed value

[Holding Registers]
numberOfR=1
R0=0,Data0,-32768,32767,1,V,0,"(modbus_val>32767) and (modbus_val-65536) or modbus_val"


Example2: To do a mathematic forms operation.

[Holding Registers]
numberOfR=1
R0=0,Voltage0,0,5,0.001,V,0,"modbus_val*2-10"

NOTE: If both precision and LUA string are assigned, LUA string will be calculated with modbus value first, then the new value multiply with assigned precision.


LUA functions list:
https://www.kancloud.cn/thinkphp/lua-guide/43807


Docker version

To config Modbus Service and Restart Service in EdgeSense v1.0.2 Docker version:

$cd ${Installed path}/Installer/packages/Plugins/docker-edgesense-image-x86/EdgeSense/EService-Modbus/config
$sudo vim Modbus_Handler.ini
$sudo docker restart service-modbus


Real Application Case: ADAM-4117

Release

This is an overview that displays Modbus Service versions and some stats and numbers for each release.

Index Version Date Platform OS Release Note Installer
1 v2.0.1 2018/9/6 x86_64 CPU
Windows
Release Note

 Agent_Modbus_Handler_2.0.1.zip

2 v2.0.2 2020/7/3 x86_64 CPU
Windows
  • Filter out non modbus handler auto report enable request.
 Agent_Modbus_Handler_2.0.2.zip

How to download:

Above files are available at local server only, please copy file's url and paste the url in File Explorer to download the file.

1. Right click on Installer file's url and copy file's url.

2. Open File Explorer and paste file's url in File Explorer.

Example:

(How to access to EOSSFS file server )