Correct parameters for reading input registers.

2,523 views
Skip to first unread message

s s

unread,
Jan 27, 2014, 3:30:56 AM1/27/14
to pymo...@googlegroups.com
Hi,
I have a Raspberry Pi connected to an SDM630 smart meter and I'm trying to setup a serial modbus communication.
However, I'm not an expert in the modbus protocol and I'm not entirely sure what parameters should I use.
This is the modbus documentation for the device http://www.ausboard.net.au/index_files/Eastron/Eastron%20Modbus%20Registers.pdf
In the table "Input Registers" I can see the following:


---------------------------+-----------------------------+-------------------------------------------------+-------------------------------------------------
Address  (Register)    |   Parameter Number    |   SDM630 Input Register Parameter       |    Modbus Protocol Start Address Hex 
---------------------------+-----------------------------+-------------------------------------------------+-----------------------+------------------------
                                   |                                      |   Description                           |   Units   |     Hi Byte               |            Lo Byte
---------------------------+------------------------------+-------------------------------------+----------+-----------------------+------------------------
30001                        |                1                      | Phase 1 line to neutral volts. |    Volts   |       00                    |          00
---------------------------+------------------------------+-------------------------------------+----------+-----------------------+------------------------
30003                         |               2                      | Phase 2 line to neutral volts. |    Volts   |       00                    |           02
---------------------------+------------------------------+-------------------------------------+----------+-----------------------+------------------------
30005                        |                3                      | Phase 2 line to neutral volts. |    Volts   |       00                    |           04
---------------------------+------------------------------+-------------------------------------+----------+-----------------------+------------------------
...
...
...

And here is my code:

#!/usr/bin/env python

from pymodbus.client.sync import ModbusSerialClient as ModbusClient
import logging

logging.basicConfig()
log = logging.getLogger()
log.setLevel(logging.DEBUG)

client = ModbusClient(method='rtu', port='/dev/ttyAMA0', timeout=10)
client.connect()

rr = client.read_input_registers(30001, 2)
print rr

client.close()


And this is the output:
DEBUG:pymodbus.transaction:Running transaction 1
# 10 seconds delay which matches my timeout
DEBUG:pymodbus.transaction:getting transaction 1
None


So my question is what parameters should I supply to the read_input_registers() if I want to read the electric potential on phase 1? I know the value is contained in two registers.
Also what is "Modbus Protocol Start Address Hex" and how is it different than "Address  (Register)"?

Thank you.



Jurek Kędra

unread,
May 5, 2014, 9:13:52 AM5/5/14
to pymo...@googlegroups.com
Hello,
I guess you need slave address to be supplied (unit=).
Try to use read_holding_registers instead as in an example below:

rr = client.read_holding_registers(0, count=8, unit=0x01)

Good luck,
Jurek

Jeroen van Wouwen

unread,
Jul 26, 2014, 4:57:46 PM7/26/14
to pymo...@googlegroups.com
Hi,

I have the same config and I wonder if you have the script running or finished?

When i run your data that I change a bit, I get output but I have no idea what to do with the data.

Can you help me with the script so I can use it to monitor the kwh meter.
I spend more than 20 hours on the config but still no luck.

I hope you can sent me in the right direction.

# python ./test.py
DEBUG:pymodbus.transaction:Running transaction 1
DEBUG:pymodbus.factory:Factory Response[4]
[31179, 17254, 24898, 17254, 48006, 0, 0, 0, 0, 0, 0, 16562, 2525, 16550, 6507, 16539, 47336, 16572, 64062, 16560, 29765, 16551, 15818, 0, 0, 0, 0, 0, 0, 16256, 0, 16256, 0, 16238, 24029, 16796, 48708, 16797, 52424, 16811, 8670, 17254, 34695, 0, 0, 0, 0, 0, 0, 0, 0, 16761, 60952, 0, 0, 16773, 10163, 0, 0, 49335, 59877, 16256, 0, 0, 0, 16801, 39708, 0, 0, 16968, 14017, 16138, 15729, 0, 0, 15639, 36176, 15878, 9437, 15855, 40370, 16138, 40824, 16766, 3044, 16768, 65146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16774]

#!/usr/bin/env python

from pymodbus.client.sync import ModbusSerialClient as ModbusClient
import logging

logging.basicConfig()
log = logging.getLogger()
log.setLevel(logging.DEBUG)

client = ModbusClient(method='rtu', port='/dev/ttyUSB0', baudrate=9600, timeout=1)
client.connect()

rr = client.read_input_registers(1,100, unit=0x01)#For debugging

print rr.registers


client.close()


Op maandag 27 januari 2014 09:30:56 UTC+1 schreef s s:

MemyselfandI

unread,
Oct 30, 2014, 7:58:31 AM10/30/14
to pymo...@googlegroups.com
Hello @all,

did you solve the poblem?

Oytun Oktay

unread,
Mar 28, 2016, 11:23:17 AM3/28/16
to pymodbus
The resulting array composed of 16bit data which should be used to get their corresponding 32bit float representation.https://en.wikipedia.org/wiki/Floating_point

Tushar Borhade

unread,
May 18, 2017, 11:00:04 AM5/18/17
to pymodbus
I am getting this at output!
Need help

True
DEBUG:pymodbus.transaction:Running transaction 1
DEBUG:pymodbus.client.sync:will sleep to wait for 3.5 char
DEBUG:pymodbus.transaction:recv: 0x1 0x4 0x10 0x3 0xef 0xfe 0xff 0xcf 0x40 0x10 0x2 0x7c 0xbf 0xff 0x80 0xe8 0xff
DEBUG:pymodbus.factory:Factory Response[1]
DEBUG:pymodbus.transaction:adding transaction 0
DEBUG:pymodbus.transaction:getting transaction 1
Traceback (most recent call last):
  File "test8.py", line 26, in <module>
    print result.registers 
AttributeError: 'ReadCoilsResponse' object has no attribute 'registers'
Reply all
Reply to author
Forward
0 new messages