Difference between revisions of "Modbus Service"

From ESS-WIKI
Jump to: navigation, search
Line 77: Line 77:
 
== <span style="font-size:x-large;">Configuration</span> ==
 
== <span style="font-size:x-large;">Configuration</span> ==
  
=== '''<span style="font-size:large;">Config Modbus Connection</span>''' ===
+
=== <span style="font-size:medium;">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;">1. Open File Explorer and change target folder to the Modbus Service installation folder.</span>
Line 87: Line 87:
 
<span style="font-size:medium;">2.2 Set the Protocol.</span>
 
<span style="font-size:medium;">2.2 Set the Protocol.</span>
  
<span style="font-size:medium;">'''<u>For the modbus TCP devices:</u>'''</span>
+
<span style="font-size:medium;"></span>
 +
 
 +
<span style="font-size:medium;"><u>For the modbus TCP devices:</u></span>
  
 
<span style="font-size:medium;">Protocol=Modbus_TCP</span>
 
<span style="font-size:medium;">Protocol=Modbus_TCP</span>
Line 116: Line 118:
  
  
 +
 +
<span style="font-size:medium;">'''<u></u>'''</span>
  
 
<span style="font-size:medium;">'''<u>For the modbus RTU&nbsp;devices:</u>'''</span>
 
<span style="font-size:medium;">'''<u>For the modbus RTU&nbsp;devices:</u>'''</span>
Line 134: Line 138:
  
 
<span style="font-size:medium;">'''Example:'''</span>
 
<span style="font-size:medium;">'''Example:'''</span>
<pre>[Platform]
+
<pre>
 +
[Platform]
 
Name=EKI-XXXX
 
Name=EKI-XXXX
 
Protocol=Modbus_RTU
 
Protocol=Modbus_RTU
Line 158: Line 163:
  
  
<span style="font-size:large;"></span>
 
  
=== '''<span style="font-size:large;">Config Modbus Devices &&nbsp;Sensors</span>''' ===
+
 
 +
=== <span style="font-size:large;">Config Modbus Devices &&nbsp;Sensors</span> ===
  
 
<span style="font-size:medium;">Modbus_Device0.ini Example:</span>
 
<span style="font-size:medium;">Modbus_Device0.ini Example:</span>
Line 244: Line 249:
 
<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:medium;">NOTE! For type of "32-bit unsigned int", the maximum support range in 0 ~ 2,147,483,647.</span>
  
<span style="font-size:larger;"></span>
 
  
=== <span style="font-size:large;">'''LUA Conversion'''</span> ===
+
 
 +
=== <span style="font-size:large;">LUA Conversion</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:medium;">You can do a simple&nbsp;mathematic&nbsp;operation by add a&nbsp;forms in the LUA conversion string, for example:</span>
  
 
Example1: To convert a 16-bit unsigned integer&nbsp;value to 16-bit signed value.
 
Example1: To convert a 16-bit unsigned integer&nbsp;value to 16-bit signed value.
 
+
<br/>
 
+
<pre>
<span style="font-size:larger;"></span>
+
[Holding Registers]
[Holding Registers]<br/>numberOfR=1<br/>R0=0,To_Signed_by_LUA,-1000000,1000000,1,V,0,"(modbus_val>32767) and (modbus_val-65536) or modbus_val"
+
numberOfR=1
 
+
R0=0,To_Signed_by_LUA,-1000000,1000000,1,V,0,"(modbus_val>32767) and (modbus_val-65536) or modbus_val"
 
+
</pre>
  
 
Example2: To do a mathematic forms&nbsp;operation.
 
Example2: To do a mathematic forms&nbsp;operation.
 
+
<br/>
[Holding Registers]<br/>numberOfR=2<br/>R0=0,Voltage0,0,5,0.001,V,0,"modbus_val*2-10"<br/>R1=1,Voltage1,0,5,0.001,V,0,"math.pow(modbus_val,1/2)+10-2.5"
+
<pre>
 
+
[Holding Registers]
<span style="font-size:larger;"></span>
+
numberOfR=2
 
+
R0=0,Voltage0,0,5,0.001,V,0,"modbus_val*2-10"<br/>R1=1,Voltage1,0,5,0.001,V,0,"math.pow(modbus_val,1/2)+10-2.5"
<span style="font-size:larger;"></span><span style="font-size:larger;"></span>
+
</pre>
  
 
== Docker version ==
 
== Docker version ==

Revision as of 09:00, 27 November 2018

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 ata 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

1. Double click Agent_Modbus_Handler_2.0.0.exe 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.

For the modbus TCP devices:

Protocol=Modbus_TCP

ClientIP=(IP address of Modbus TCP devices)

ClientPort=(Port of Modbus TCP devices)  

Modbus_Handler.ini 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


For the modbus RTU devices:

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

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,""



The format and sensor address definition of sensors:

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

tag Type Base Address

B 00001-->Coils

IB 10001-->Discrete Inputs

IR 30001-->Input Registers

R 40001-->Holding Registers



The data type definition of sensors:

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,To_Signed_by_LUA,-1000000,1000000,1,V,0,"(modbus_val>32767) and (modbus_val-65536) or modbus_val"

Example2: To do a mathematic forms operation.

[Holding Registers]
numberOfR=2
R0=0,Voltage0,0,5,0.001,V,0,"modbus_val*2-10"<br/>R1=1,Voltage1,0,5,0.001,V,0,"math.pow(modbus_val,1/2)+10-2.5"

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
1 v2.0.0 2018/5/17 x86_64 CPU Windows  Agent_Modbus_Handler Release Note v2.0.0
2 v2.0.1 2018/9/6 x86_64 CPU
Windows
Agent_Modbus_Handler Release Note v2.0.1