Difference between revisions of "Transclusion: IOT-GATE-iMX8: Modbus"

From Compulab Mediawiki
Jump to: navigation, search
imported>Uri.mashiach
(Modbus Communication Example)
 
Line 1: Line 1:
 
Modbus is a standard communication protocol and is a commonly available means of connecting industrial electronic devices.
 
Modbus is a standard communication protocol and is a commonly available means of connecting industrial electronic devices.
 
IOT-GATE-iMX8 RS485 ports can be used to implement the Modbus protocol.</br>
 
IOT-GATE-iMX8 RS485 ports can be used to implement the Modbus protocol.</br>
It is recommended to use the '''mbpoll''' Modbus utility preinstalled in the IOT-GATE-iMX8 Debian Linux package.
+
It is recommended to use the '''modpoll''' - a command line based Modbus master simulator and test utility.
 +
Download and install the modpoll utility:
 +
<pre>
 +
compulab@iot-gate-imx8:~$ wget https://www.modbusdriver.com/downloads/modpoll.tgz -/tmp/
 +
...
 +
compulab@iot-gate-imx8:~$ sudo tar -xvf /tmp/modpoll.tgz -C /opt/
 +
...
 +
</pre>
  
 
== Modbus Communication Example ==
 
== Modbus Communication Example ==
Line 25: Line 32:
 
* Read temperature once:
 
* Read temperature once:
 
<pre>
 
<pre>
root@iot-gate-imx8:~# mbpoll -b 9600 -p none -t 3 -c 1 -r 2 -1 /dev/ttymxc0
+
root@iot-gate-imx8:~# /opt/modpoll/arm-linux-gnueabihf/modpoll -b 9600 -p none -t 3 -c 1 -r 2 -1 /dev/ttymxc0
 
-- Polling slave...
 
-- Polling slave...
 
[2]: 284
 
[2]: 284
 
</pre>
 
</pre>
 +
 
* Read humidity once:
 
* Read humidity once:
 
<pre>
 
<pre>
root@iot-gate-imx8:~# mbpoll -b 9600 -p none -t 3 -c 1 -r 3 -1 /dev/ttymxc0
+
root@iot-gate-imx8:~# /opt/modpoll/arm-linux-gnueabihf/modpoll -b 9600 -p none -t 3 -c 1 -r 3 -1 /dev/ttymxc0
 +
 
 
-- Polling slave...
 
-- Polling slave...
 
[3]: 453
 
[3]: 453
 
</pre>
 
</pre>

Revision as of 13:15, 24 January 2023

Modbus is a standard communication protocol and is a commonly available means of connecting industrial electronic devices. IOT-GATE-iMX8 RS485 ports can be used to implement the Modbus protocol.
It is recommended to use the modpoll - a command line based Modbus master simulator and test utility. Download and install the modpoll utility:

compulab@iot-gate-imx8:~$ wget https://www.modbusdriver.com/downloads/modpoll.tgz -/tmp/
...
compulab@iot-gate-imx8:~$ sudo tar -xvf /tmp/modpoll.tgz -C /opt/
...

Modbus Communication Example

[XY-MD02] is a high-precision temperature and humidity sensor. XY-MD02 uses the RS485 hardware interface and protocol layer compatible with standard industrial Modbus RTU protocol.

  • Connect the XY-MD02 sensor to the IOT-GATE-iMX8, RS485 port:
    • Connect power lines to a DC power supply 5V-30V
    • Connect RS485 lines
--------------------                                   
|                  |                                   
|                  *--(+)---< <------------- 5V-30V    
|                  |                                   
|                  *--(-)---< <-------------- GND     ------------------------  
| XY-MD02 (RS485)  |                                  |                      |
|                  *--(A+)--< <---...---> >--(P7/2)---*-----                 |
|                  |                                  | P7 |  IOT-GATE-iMX8  |
|                  *--(B-)--< <---...---> >--(P7/1)---*-----                 |
|                  |                                  |                      |
--------------------                                  ------------------------ 
  • Read temperature once:
root@iot-gate-imx8:~# /opt/modpoll/arm-linux-gnueabihf/modpoll -b 9600 -p none -t 3 -c 1 -r 2 -1 /dev/ttymxc0
-- Polling slave...
[2]: 284
  • Read humidity once:
root@iot-gate-imx8:~# /opt/modpoll/arm-linux-gnueabihf/modpoll -b 9600 -p none -t 3 -c 1 -r 3 -1 /dev/ttymxc0

-- Polling slave...
[3]: 453