Difference between revisions of "Modbus RTU"

From Electrical Age
Jump to: navigation, search
 
Line 1: Line 1:
 
The Modbus RTU is an entity that allows your real life electrical monitoring equipment to communicate with your in game circuits via the [[wikipedia:Modbus|Modbus]] protocol.
 
The Modbus RTU is an entity that allows your real life electrical monitoring equipment to communicate with your in game circuits via the [[wikipedia:Modbus|Modbus]] protocol.
  
== PDF documentation ==
+
It is necessary to enable it in the config before you can use it. The game will warn you if it is not enabled in the configuration file.
* [https://www.dropbox.com/s/q6zq6em7hne6rcy/Modbus%20RTU%20Manual.pdf?dl=0 Modbus RTU documentation] (pdf) (dead Jul 28th, 2019)
 
 
 
  
== modbus tools to experiment with==
+
== some references to other modbus software ==
 
* https://github.com/jSCADA (live Jul 28th, 2019)
 
* https://github.com/jSCADA (live Jul 28th, 2019)
 
* https://play.google.com/store/apps/details?id=modbus.tesla.scada (live Jul 28th, 2019)
 
* https://play.google.com/store/apps/details?id=modbus.tesla.scada (live Jul 28th, 2019)
 
* https://play.google.com/store/apps/details?id=tesla.scada2.android (live Jul 28th, 2019)
 
* https://play.google.com/store/apps/details?id=tesla.scada2.android (live Jul 28th, 2019)
 
* https://play.google.com/store/apps/details?id=com.bencatlin.modbusdroid (dead Jul 28th, 2019)
 
* https://play.google.com/store/apps/details?id=com.bencatlin.modbusdroid (dead Jul 28th, 2019)
 +
* [https://www.dropbox.com/s/q6zq6em7hne6rcy/Modbus%20RTU%20Manual.pdf?dl=0 Modbus RTU documentation] (pdf) (dead Jul 28th, 2019)
 +
 +
== example server side Python code ==
 +
 +
Note that you need to install the pymodbus pip package:
 +
 +
<pre style="background: #DDDDFF">
 +
pip install --user pymodbus
 +
</pre>
 +
 +
=== Code listing ===
 +
 +
<pre style="background: #FFFFDD">
 +
import time
 +
 +
from pymodbus.client.sync import ModbusTcpClient
 +
 +
client = ModbusTcpClient('127.0.0.1', 1502)
 +
 +
while True:
 +
    read = client.read_input_registers(10, 4).registers
 +
    print(read)
 +
    client.write_coil(15, read[3] > 1024*32)
 +
    time.sleep(0.1)
 +
 +
client.close()
 +
</pre>
 +
 +
You will also need to enable the Modbus RTU in the game config file. It only interacts with wireless signals at the time of writing, examples will be eventually provided.

Latest revision as of 03:44, 28 August 2019

The Modbus RTU is an entity that allows your real life electrical monitoring equipment to communicate with your in game circuits via the Modbus protocol.

It is necessary to enable it in the config before you can use it. The game will warn you if it is not enabled in the configuration file.

some references to other modbus software

example server side Python code

Note that you need to install the pymodbus pip package:

pip install --user pymodbus

Code listing

import time

from pymodbus.client.sync import ModbusTcpClient

client = ModbusTcpClient('127.0.0.1', 1502)

while True:
    read = client.read_input_registers(10, 4).registers
    print(read)
    client.write_coil(15, read[3] > 1024*32)
    time.sleep(0.1)

client.close()

You will also need to enable the Modbus RTU in the game config file. It only interacts with wireless signals at the time of writing, examples will be eventually provided.