Community
OpenEnergyMonitor

Community

Autometers DDSD285 Smart Meter Modbus RS485 interfacing and monitoring

smartmeter
modbus
rs485
Tags: #<Tag:0x00007f13e681efb0> #<Tag:0x00007f13e681ee70> #<Tag:0x00007f13e681ed30>

(Anthony Smith) #21

Paul,

Many thanks.

I have now hit a blocker as I cannot seem to get any comms from the device. There is continuity on the wires at the terminals on the meter and usb connector block. I have tried reversing the wires I started with 23 TX+ to A and 24 TX- to B called my very simple program and as you can see no comms.

No idea how to test the usb adaptor. It seems to be recognised and configured as /dev/ttyUSB0. From the DDSD285 spec sheet it says that EVEN parity, 1 Stop Bit is required and 9600 baud. The print statement looks correct to open the port with the correct parameters (not sure if there would be an error if it could not open the port) then trying to talk to the meter using the instrument.read.float calls results in no comms, this device seems to use mode 4 for read and 6 for write.

[email protected]:~/DDSD285 $ lsusb
**Bus 001 Device 007: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light**
Bus 001 Device 005: ID 045e:07a5 Microsoft Corp. Wireless Receiver 1461C
Bus 001 Device 006: ID 0424:7800 Standard Microsystems Corp. 
Bus 001 Device 003: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Result of running the very simple program.

[email protected]:~/DDSD285 $ python ddsd285-test.py
minimalmodbus.Instrument<id=0x76aae580, address=1, mode=rtu, close_port_after_each_call=False, precalculate_read_size=True, debug=False, serial=Serial<id=0x76acdef0, open=True>(port='/dev/ttyUSB0', baudrate=9600, bytesize=8, parity='E', stopbits=1, timeout=0.05, xonxoff=False, rtscts=False, dsrdtr=False)>
Traceback (most recent call last):
  File "ddsd285-test.py", line 29, in <module>
    main()
  File "ddsd285-test.py", line 25, in main
    get_data()
  File "ddsd285-test.py", line 18, in get_data
    TOTAMPS  = round(instrument.read_float(31537), 4) # Total Amps AMPS
  File "/usr/local/lib/python2.7/dist-packages/minimalmodbus.py", line 392, in read_float
    return self._genericCommand(functioncode, registeraddress, numberOfRegisters=numberOfRegisters, payloadformat='float')
  File "/usr/local/lib/python2.7/dist-packages/minimalmodbus.py", line 697, in _genericCommand
    payloadFromSlave = self._performCommand(functioncode, payloadToSlave)
  File "/usr/local/lib/python2.7/dist-packages/minimalmodbus.py", line 795, in _performCommand
    response = self._communicate(request, number_of_bytes_to_read)
  File "/usr/local/lib/python2.7/dist-packages/minimalmodbus.py", line 930, in _communicate
    raise IOError('No communication with the instrument (no answer)')
IOError: No communication with the instrument (no answer)

The program:

#!/usr/bin/python
# -*- coding: utf-8 -*-
import minimalmodbus
instrument = minimalmodbus.Instrument("/dev/ttyUSB0", 1)
instrument.serial.baudrate = 9600
#instrument.serial.bytesize = 8
instrument.serial.parity = minimalmodbus.serial.PARITY_EVEN
#instrument.serial.parity   = 'E'
instrument.serial.stopbits = 1
instrument.serial.timeout  = 0.05   # seconds
#instrument.address = 1    # this is the slave address number
#instrument.mode = minimalmodbus.MODE_RTU   # rtu or ascii mode

print instrument

def get_data():

  TOTAMPS  = round(instrument.read_float(31537), 4) # Total Amps AMPS
  TOTPWR = round(instrument.read_float(31539), 4) # Total Power WATTS
  TOTAPPWR = round(instrument.read_float(31541), 4) # Total Apparent Power KVA

  print('{} Amps {} Watts {} Kva\n'.format(TOTAMPS,TOTPWR,TOTAPPWR))

def main():
  get_data()

if __name__ == '__main__':
    main()
    exit()

Any idea what I might be doing wrong or how to test of the USB device is actually working?

Hardware checks seem to look fine. If I unplug the USB device and replug it seems to be enumerated correctly.

Feb 4 21:55:14 emonpi kernel: [ 4023.118365] cp210x 1-1.2:1.0: device disconnected
Feb 4 21:55:20 emonpi kernel: [ 4029.298476] usb 1-1.2: new full-speed USB device number 9 using dwc_otg
Feb 4 21:55:20 emonpi kernel: [ 4029.433207] usb 1-1.2: New USB device found, idVendor=10c4, idProduct=ea60
Feb 4 21:55:20 emonpi kernel: [ 4029.433224] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Feb 4 21:55:20 emonpi kernel: [ 4029.433233] usb 1-1.2: Product: CP2104 USB to UART Bridge Controller
Feb 4 21:55:20 emonpi kernel: [ 4029.433241] usb 1-1.2: Manufacturer: Silicon Labs
Feb 4 21:55:20 emonpi kernel: [ 4029.433250] usb 1-1.2: SerialNumber: 018DF162
Feb 4 21:55:20 emonpi kernel: [ 4029.437095] cp210x 1-1.2:1.0: cp210x converter detected
Feb 4 21:55:21 emonpi kernel: [ 4029.440705] usb 1-1.2: cp210x converter now attached to ttyUSB0

There appears to be a valid kernel module for it:

[email protected]:~/DDSD285 $ lsmod | grep cp210
cp210x 24576 0
usbserial 40960 1 cp210x

Cheers
Tony


(Paul) #22

That timeout looks a bit brutal, forget my comments above when trying to get it up and running for the first time. I use a 0.3s timeout, but in this instance you could use maybe 0.5 just to be sure, right now you are just trying to get a connection, the efficiency is not a worry yet.

I do not know what the minimalmodbus defaults are offhand without looking it up, but I have yet to set anything other than timeout and baud eg

    try:
        device = minimalmodbus.Instrument("/dev/ttyUSB0", 1)
        device.serial.timeout = 0.3
        device.serial.baudrate = 9600
        device.debug = True
    except Exception as e:
        print(Setup Error: " + str(e))

try setting debug true to get a more verbose output.

Actually! I don’t think your instrument is being created as the code is outside of the if __name__ = '__main__': Try this (below) I’ve just wrapped the instrument creation in a “setup()” function and called it before “get_data()” .

#!/usr/bin/python
# -*- coding: utf-8 -*-
import minimalmodbus

def setup():
    instrument = minimalmodbus.Instrument("/dev/ttyUSB0", 1)
    instrument.serial.baudrate = 9600
    #instrument.serial.bytesize = 8
    instrument.serial.parity = minimalmodbus.serial.PARITY_EVEN
    #instrument.serial.parity   = 'E'
    instrument.serial.stopbits = 1
    instrument.serial.timeout  = 0.05   # seconds
    #instrument.address = 1    # this is the slave address number
    #instrument.mode = minimalmodbus.MODE_RTU   # rtu or ascii mode

    print instrument

def get_data():

  TOTAMPS  = round(instrument.read_float(31537), 4) # Total Amps AMPS
  TOTPWR = round(instrument.read_float(31539), 4) # Total Power WATTS
  TOTAPPWR = round(instrument.read_float(31541), 4) # Total Apparent Power KVA

  print('{} Amps {} Watts {} Kva\n'.format(TOTAMPS,TOTPWR,TOTAPPWR))

def main():
  get_data()

if __name__ == '__main__':
    setup()
    main()
    exit()

(Anthony Smith) #23

Paul,

Running your program:

#!/usr/bin/python
# -*- coding: utf-8 -*-
import minimalmodbus

def setup():
    instrument = minimalmodbus.Instrument("/dev/ttyUSB0", 1)
    instrument.serial.baudrate = 9600
    #instrument.serial.bytesize = 8
    instrument.serial.parity = minimalmodbus.serial.PARITY_EVEN
    #instrument.serial.parity   = 'E'
    instrument.serial.stopbits = 1
    instrument.serial.timeout  = 0.05   # seconds
    #instrument.address = 1    # this is the slave address number
    #instrument.mode = minimalmodbus.MODE_RTU   # rtu or ascii mode

    print instrument

def get_data():

  TOTAMPS  = round(instrument.read_float(31537), 4) # Total Amps AMPS
  TOTPWR = round(instrument.read_float(31539), 4) # Total Power WATTS
  TOTAPPWR = round(instrument.read_float(31541), 4) # Total Apparent Power KVA

  print('{} Amps {} Watts {} Kva\n'.format(TOTAMPS,TOTPWR,TOTAPPWR))

def main():
  get_data()

if __name__ == '__main__':
    setup()
    main()
    exit()

I get:

[email protected]:~/DDSD285 $ python ddsd285-test.py
minimalmodbus.Instrument<id=0x76b00648, address=1, mode=rtu, close_port_after_each_call=False, precalculate_read_size=True, debug=False, serial=Serial<id=0x76b21f30, open=True>(port='/dev/ttyUSB0', baudrate=9600, bytesize=8, parity='E', stopbits=1, timeout=0.05, xonxoff=False, rtscts=False, dsrdtr=False)>
Traceback (most recent call last):
  File "ddsd285-test.py", line 31, in <module>
    main()
  File "ddsd285-test.py", line 27, in main
    get_data()
  File "ddsd285-test.py", line 20, in get_data
    TOTAMPS  = round(instrument.read_float(31537), 4) # Total Amps AMPS
NameError: global name 'instrument' is not defined

Confused!

Cheers
Stephen


(Paul) #24

Ok try trimming it right back to something simpler. The debug setting should give you more info than the print instrument

#!/usr/bin/python
import minimalmodbus


instrument = minimalmodbus.Instrument("/dev/ttyUSB0", 1)
instrument.serial.baudrate = 9600
instrument.serial.timeout  = 0.3
instrument.debug = True

TOTAMPS  = round(instrument.read_float(31537), 4) # Total Amps AMPS
TOTPWR = round(instrument.read_float(31539), 4) # Total Power WATTS
TOTAPPWR = round(instrument.read_float(31541), 4) # Total Apparent Power KVA

print('{} Amps {} Watts {} Kva\n'.format(TOTAMPS,TOTPWR,TOTAPPWR))

exit()

(Anthony Smith) #25

Paul,

New program had no response until I included the correct serial parameters so program is now:

#!/usr/bin/python
# -*- coding: utf-8 -*-

import minimalmodbus

instrument = minimalmodbus.Instrument("/dev/ttyUSB0", 1)
instrument.serial.baudrate = 9600
instrument.serial.parity = minimalmodbus.serial.PARITY_EVEN
instrument.serial.stopbits = 1
instrument.serial.timeout  = 0.3
instrument.debug = True

TOTAMPS  = round(instrument.read_float(31537), 4) # Total Amps AMPS
TOTPWR = round(instrument.read_float(31539), 4) # Total Power WATTS
TOTAPPWR = round(instrument.read_float(31541), 4) # Total Apparent Power KVA

print('{} Amps {} Watts {} Kva\n'.format(TOTAMPS,TOTPWR,TOTAPPWR))

exit()

And response is now:

[email protected]:~/DDSD285 $ python ddsd285-test1.py

MinimalModbus debug mode. Writing to instrument (expecting 9 bytes back): '\x01\x03{1\x00\x02\x8d ' (01 03 7B 31 00 02 8D 20)
MinimalModbus debug mode. No sleep required before write. Time since previous read: 1549319390563.0 ms, minimum silent period: 4.01 ms.
MinimalModbus debug mode. Response from instrument: '\x01\x84\x01\x82\xc0' (01 84 01 82 C0) (5 bytes), roundtrip time: 300.5 ms. Timeout setting: 300.0 ms.

Traceback (most recent call last):
  File "ddsd285-test1.py", line 13, in <module>
    TOTAMPS  = round(instrument.read_float(31537), 4) # Total Amps AMPS
  File "/usr/local/lib/python2.7/dist-packages/minimalmodbus.py", line 392, in read_float
    return self._genericCommand(functioncode, registeraddress, numberOfRegisters=numberOfRegisters, payloadformat='float')
  File "/usr/local/lib/python2.7/dist-packages/minimalmodbus.py", line 697, in _genericCommand
    payloadFromSlave = self._performCommand(functioncode, payloadToSlave)
  File "/usr/local/lib/python2.7/dist-packages/minimalmodbus.py", line 798, in _performCommand
    payloadFromSlave = _extractPayload(response, self.address, self.mode, functioncode)
  File "/usr/local/lib/python2.7/dist-packages/minimalmodbus.py", line 1092, in _extractPayload
    receivedFunctioncode, functioncode, response))
ValueError: Wrong functioncode: 132 instead of 3. The response is: '\x01\x84\x01\x82\xc0'

Not sure why function code is not getting set as 4 (read resgisters)

These are the valid function codes for the device:

4
Autometers Modbus Protocol Specification
MODBUS Function Codes
The Autometers Modbus RTU and Modbus ASCII protocols uses a subset of the standard
Modbus function codes to provide access to measurement and information registers. These
standard function codes provide basic support for IEEE 32-bit floating point numbers, 16 bit
integer and 8 bit char values.
Function Code Name Usage
0x04 Read Input Registers Used for reading floating point and 16 bit integer measurements
0x06 Write Single Register Used for writing floating point and 16 bit integer values to a single register
0x10 Write Multiple Registers Used for writing floating point and 16 bit integer values to multiple registers
0x11 Report Device ID Used for reading device information including device ID, description, software version etc
Read Device Identification Used for reading device identification and additional information

Cheers
Tony


(Paul) #26

No you’re using read_float() which defaults to “3”

https://minimalmodbus.readthedocs.io/en/master/apiminimalmodbus.html#minimalmodbus.Instrument.read_float

you would need to change your code to

TOTAMPS  = round(instrument.read_float(31537,4), 4)

for functioncode 4


(Paul) #27

That’s bizarre as the defaults for parity and stop bits are PARITY_NONE and 1, I just looked them up

https://minimalmodbus.readthedocs.io/en/master/apiminimalmodbus.html#module-minimalmodbus

neither of those lines should have any impact.

[edit - my bad, just noticed you are setting PARITY_EVEN not PARITY_NONE]


(Anthony Smith) #28

Paul,

From a known test reading from the manual.

7.2
Request Energy
Commands to request the Energy Register, 30353, the return value is a 32 bit
floating point number. See the IEEE section for the format.
modbus resistor command
Read 32 bits from 30353 (0x0160)
read request from meter with Modbus Address of 01
01 04 01 60 00 02 CRC CRC
response
01 04 04 00 00 00 00 CRC CRC

I sent:

TOTAMPS = instrument.read_float(30353,4)

and got:
[email protected]:~/DDSD285 $ python ddsd285-test1.py

MinimalModbus debug mode. Writing to instrument (expecting 9 bytes back): ‘\x01\x04v\x91\x00\x02:n’ (01 04 76 91 00 02 3A 6E)
MinimalModbus debug mode. No sleep required before write. Time since previous read: 1549320603718.9 ms, minimum silent period: 4.01 ms.
MinimalModbus debug mode. Response from instrument: ‘\x01\x84\x02\xc2\xc1’ (01 84 02 C2 C1) (5 bytes), roundtrip time: 300.5 ms. Timeout setting: 300.0 ms.

Traceback (most recent call last):
File “ddsd285-test1.py”, line 14, in
TOTAMPS = instrument.read_float(30353,4) # Total Amps AMPS
File “/usr/local/lib/python2.7/dist-packages/minimalmodbus.py”, line 392, in read_float
return self._genericCommand(functioncode, registeraddress, numberOfRegisters=numberOfRegisters, payloadformat=‘float’)
File “/usr/local/lib/python2.7/dist-packages/minimalmodbus.py”, line 697, in _genericCommand
payloadFromSlave = self._performCommand(functioncode, payloadToSlave)
File “/usr/local/lib/python2.7/dist-packages/minimalmodbus.py”, line 798, in _performCommand
payloadFromSlave = _extractPayload(response, self.address, self.mode, functioncode)
File “/usr/local/lib/python2.7/dist-packages/minimalmodbus.py”, line 1088, in _extractPayload
raise ValueError(‘The slave is indicating an error. The response is: {!r}’.format(response))
ValueError: The slave is indicating an error. The response is: ‘\x01\x84\x02\xc2\xc1’

I have highlighted the translated address it should be 01 04 01 60 00 02 CRC CRC so something is not right when converting the 30353 register address it seems.

Cheers
Tony


(Paul) #29

Try

TOTAMPS = instrument.read_float(352,4)

this is the “address(hex)” 0x0160 in decimal = 352

so your original code should become

TOTAMPS  = round(instrument.read_float(1536), 4) # Total Amps AMPS
TOTPWR = round(instrument.read_float(1538), 4) # Total Power WATTS
TOTAPPWR = round(instrument.read_float(1540), 4) # Total Apparent Power K

(Paul) #30

further to the parity comments, from the pdf page10

Even parity is required, other modes ( odd parity, no parity ) may also be used. In order to
ensure a maximum compatibility with other products, it is recommended to support also No
parity mode. The default parity mode must be even parity.
Remark : the use of no parity requires 2 stop bits.

So far all of the devices I’ve tested have worked out of the box with PARITY_NONE. For multiple devices to share the same bus they must be using the same settings so this needs reviewing further.


(Anthony Smith) #31

Manuals states :slight_smile:
Conversion of address (hex) number to register (decimal) number.
To convert the address number to the register number, convert the address from hexadecimal
to decimal and add 30001.

Seems to be nonsense.

Code now:
#!/usr/bin/python

-- coding: utf-8 --

import minimalmodbus

instrument = minimalmodbus.Instrument("/dev/ttyUSB0", 1)
instrument.serial.baudrate = 9600
instrument.serial.parity = minimalmodbus.serial.PARITY_EVEN
instrument.serial.stopbits = 1
instrument.serial.timeout = 0.3
instrument.debug = True

TOTKWH = round(instrument.read_float(352,4),4) # Total Energy KWHs

print(’{} KWHs\n’.format(TOTKWH ))

exit()

Results!!!
[email protected]:~/DDSD285 $ python ddsd285-test1.py

MinimalModbus debug mode. Writing to instrument (expecting 9 bytes back): ‘\x01\x04\x01`\x00\x02p)’ (01 04 01 60 00 02 70 29)
MinimalModbus debug mode. No sleep required before write. Time since previous read: 1549322067129.6 ms, minimum silent period: 4.01 ms.
MinimalModbus debug mode. Response from instrument: ‘\x01\x04\x04?\x02\x8f\2Y’ (01 04 04 3F 02 8F 5C 32 59) (9 bytes), roundtrip time: 125.6 ms. Timeout setting: 300.0 ms.

0.51 KWHs

So register addresses supposedly as per manual hex to dec + 30001 do not work and need to use on hex to dec for the address.

Also if I do not set parity as EVEN tehn there is no comms.

You are a superstar :grinning::star_struck:

Cheers
Tony


(Paul) #32

If you get the chance, can you try

instrument.serial.parity = minimalmodbus.serial.PARITY_EVEN
instrument.serial.stopbits = 2

Yes and no, the minimalmodbus functions ask for the register address in decimal, not the register number. So “irrelevant” (to us) maybe rather than “nonsense” perhaps?

Check out the times in the debug printout

roundtrip time: 125.6 ms. Timeout setting: 300.0 ms

Even with just the one read, this would have timed out with your original (default) value of 0.05s (50ms), a safe timeout for this one value would probably be 0.2. You can keep an eye on that roundtrip value as you increase your reads, when it read the same(ish) as the timeout setting, it has timed out, it just won’t tell you so.


(Anthony Smith) #33

Paul,

Maybe i can set the baud rate to much higher there is a register that is a 16bit integer it seems.

0x0524 31317 2 Change Modbus Slave Address Number(2) R/W 16 bit Address
0x0525 31318 2 Change Modbus Slave Baud rate R/W 16bit Baud
0x0526 31319 2 Modbus Terminal Resistor R/W 16bit State(3)

And in the earlier section it states:
2.3
19
Data Signal Rates
An Autometers Slave device supports the following baud rates
Baud
Rate
Comments
1200
2400
4800
9600
19200
38400
56000
115000
Every implemented baud rate must be respected better than 1% in transmission situation,
and must accept an error of 2% in reception
situation.

So I would need to send:

SETBAUD = instrument.write_register((31318-30001),38400,0,6)

But then not sure if that would be immediate for require some kind of power off cycle and would then be persistent at 38,400.

But,

Before I do this I thought I would read the register this is what I got:
TOTKWH = round(instrument.read_float((32001-30001),4),4) # Total Energy KWHs
BAUDRATE = instrument.read_register((31318-30001),0,4)

Results:
[email protected]:~/DDSD285 $ python ddsd285-test1.py

MinimalModbus debug mode. Writing to instrument (expecting 9 bytes back): ‘\x01\x04\x07\xd0\x00\x02qF’ (01 04 07 D0 00 02 71 46)
MinimalModbus debug mode. No sleep required before write. Time since previous read: 1549323920849.6 ms, minimum silent period: 4.01 ms.
MinimalModbus debug mode. Response from instrument: ‘\x01\x04\x04?\x07\xae\x14:>’ (01 04 04 3F 07 AE 14 3A 3E) (9 bytes), roundtrip time: 127.0 ms. Timeout setting: 300.0 ms.

MinimalModbus debug mode. Writing to instrument (expecting 7 bytes back): ‘\x01\x04\x05%\x00\x01 \xcd’ (01 04 05 25 00 01 20 CD)
MinimalModbus debug mode. No sleep required before write. Time since previous read: 5.3 ms, minimum silent period: 4.01 ms.
MinimalModbus debug mode. Response from instrument: ‘\x01\x04\x02\x96\x00\xd6\x90’ (01 04 02 96 00 D6 90) (7 bytes), roundtrip time: 128.0 ms. Timeout setting: 300.0 ms.

0.53 KWHs 38400 Baudrate

BTW setting stop bits to 2 didn’t seem to affect anything it still worked.

So how are we talking to it at 9600!

[email protected]:~/DDSD285 $ python ddsd285-test1.py
minimalmodbus.Instrument<id=0x76a93468, address=1, mode=rtu, close_port_after_each_call=False, precalculate_read_size=True, debug=True, serial=Serial<id=0x76ab2e10, open=True>(port=’/dev/ttyUSB0’, baudrate=9600, bytesize=8, parity=‘E’, stopbits=2, timeout=0.3, xonxoff=False, rtscts=False, dsrdtr=False)>

MinimalModbus debug mode. Writing to instrument (expecting 9 bytes back): ‘\x01\x04\x07\xd0\x00\x02qF’ (01 04 07 D0 00 02 71 46)
MinimalModbus debug mode. No sleep required before write. Time since previous read: 1549324213451.7 ms, minimum silent period: 4.01 ms.
MinimalModbus debug mode. Response from instrument: ‘\x01\x04\x04?\x07\xae\x14:>’ (01 04 04 3F 07 AE 14 3A 3E) (9 bytes), roundtrip time: 130.3 ms. Timeout setting: 300.0 ms.

MinimalModbus debug mode. Writing to instrument (expecting 7 bytes back): ‘\x01\x04\x05%\x00\x01 \xcd’ (01 04 05 25 00 01 20 CD)
MinimalModbus debug mode. No sleep required before write. Time since previous read: 5.2 ms, minimum silent period: 4.01 ms.
MinimalModbus debug mode. Response from instrument: ‘\x01\x04\x02\x96\x00\xd6\x90’ (01 04 02 96 00 D6 90) (7 bytes), roundtrip time: 128.0 ms. Timeout setting: 300.0 ms.

0.53 KWHs 38400 Baudrate

Cheers
Tony


(Paul) #34

Yeah, sorry my bad, I wanted to know if PARITY_NONE worked with 2 stop bits and forgot to edit the parity setting, that should have read

instrument.serial.parity = minimalmodbus.serial.PARITY_NONE
instrument.serial.stopbits = 2

That’s bizarre! Is it possible you have already issued the write command?

You currently have the baud set to 9600 in the script and although the pdf doesn’t say what the default is, the meter spac pdf states the baud IS 9600 (rather than listing the options) and 9600 is the assumed default (like using id1).

coulkd it be you have set the baud register to 38400 but that change has not been picked up yet as you are still using 9600, perhaps a power cycle would break the current working script until you change the baud in the script?


(Paul) #35

Actually, that seems odd in more ways than one. How would a baud of 115000 be set in a 16bit int? 65536 max value.

edit - Ah, look at the hex data in that last response, is that 96 00 just coincidence?

MinimalModbus debug mode. Response from instrument: '\x01\x04\x02 \x96\x00 \xd6\x90’ (01 04 02 96 00 D6 90) (7 bytes), roundtrip time: 128.0 ms. Timeout setting: 300.0 ms.

I’m not going to try and decypher that tonight, I’m amazed I got this far in my current state, time to hit the hay!


(Greebo) #36

9600 hex is 38400 decimal… unless those numbers being output are actually decimal despite the \x being there? [edit] or they’re a complete coincidence :slight_smile:


(Anthony Smith) #37

Paul,

Yep thank you so much for taking the time to help a noob out. Now i have comms it is just a case of writing a class for this device I think. More reading to do so I can then call it and do thinsg like get_kwhs() etc.

Not sure we are there yet with stable comms but I can talk to it. Trail and erro onwhich registers are available on this device. Can’t seem to get a manual for the specific unit showing which registers rather than the general protocol guide for all devices.

BTW tried PARITY_NONE with 1 and 2 stop bits and no comms. So the only config seesm to be 9600,E,1

Also I have not written to the device at all. SO never tried to set the baudrate. I think it may have 2 modbuses one internal and one external at 9600.

Cheers
Tony


(Paul) #38

That makes sense, thanks @Greebo. although I still wonder how 115000 is set, 0x115000 is not going to fit in a 16bit int. (1134592 decimal ???)


(Paul) #39

Thanks for trying anyways

I think we’ve sussed the baud may be straight hex, see above.


(Anthony Smith) #40

Greebo,

Documentation suggests that the answer in this register should be the Baud. Any reasonable person would expect that to be a recognised integer e.g. 38400, 115200 etc. The register is documented as 2 bytes long.

You seem to be suggesting this register contains a 16bit Hex value x9600 Dec 38400 . Looks like a reasonable deduction and is the only explanation that fits.

So to set the baud to say 115200 we would need to write x1c200 but as the register is stated as being 2 bytes long we cannot and max should be 65535 xFFFF 16bit 1111 1111 1111 1111

It would be good to get the comms speed up but not feeling confident to write to this device and potentially disable it.

Cheers
Tony