After spending a few hours looking for this information I figure I might not be the only one wishing more information was out there.
# Simple code to read the first 100 MI
from pyModbusTCP.client import ModbusClient
from pyModbusTCP import utils
def read_registers():
host_ip = 'x.x.x.x' # Change to your device IP
port_number = 502 # Change to your device Port
c = ModbusClient(
host=host_ip,
port=port_number,
unit_id=1,
auto_open=True,
timeout='2' # Increase timeout if needed
)
register = 0x0000 # Change acording to the list below the code block
data = c.read_holding_registers(register,100) # change 100 to how ever many registers you wish to read
print(data)
read_registers()
# Coils
#------------------------
# 0x0000 mb
# 0x3000 xb
# 0x4000 o
# 0x5000 sb
# 0x6000 i
# 0x7000 t
# 0x8000 c
# Registers ( any long or double word uses 2 registers when pulling data )
#------------------------
# 0x0000 mi
# 0x3000 xi
# 0x9000 si
# 0x5000 xl
# 0x6000 xdw
# 0x7000 ml
# 0xA000 sl
# 0x8000 mdw
# 0xB000 sdw
# 0xC000 timer preset
# 0xD000 timer current
# 0x4000 mf
Additional information on Long and Double words: The first register is 0 through its bit register (ML is 65,536). Any number after this is returned to 0 and incrementing the second register by 1.
Example1: 70,000 = 4,464 + (1 = 65,536 * 1)
Example2: 170,000 = 38,928 + (2 = 65,536 * 2 = 131,072 + 38,928 = 170,000)