Modbus: Wrong response from the slave

Question:

I am trying to write data to DVP28SS2 controller using minimalmodbus in ascii mode. I have received a responce from thr controller but it seems wrong. In particular bits, corresponding to slave address and the function code don’t match them.
The request is: 3A 30 31 31 30 30 30 32 38 30 30 30 31 30 32 30 30 36 34 36 30 0D 0A
(:01100028000102006460rn)
The response is: 3A 30 B1 39 30 30 B2 36 44 8D 0A
(:0±900²6Dx8dn)
Correct response for a request (as an example) should look like this:
enter image description here

Please, help me to find out what is going on…

I paste my code below


import minimalmodbus
import serial

D40 = 4096 + 40
instrument = minimalmodbus.Instrument(port = 'COM5',mode = 'ascii', slaveaddress = 1,  debug = True)  # port name, slave address (in decimal)

instrument.serial.baudrate = 9600        # Baud
instrument.serial.bytesize = 7
instrument.serial.parity   = serial.PARITY_EVEN
instrument.serial.stopbits = 1
instrument.serial.timeout  = 0.05         # seconds

## Write  ##
data_to_write = 100
instrument.write_register(registeraddress=D40, value=data_to_write,number_of_decimals=0)  

As a result I have recived:

MinimalModbus debug mode. Create serial port COM5
MinimalModbus debug mode. Will write to instrument (expecting 17 bytes back): 3A 30 31 31 30 30 30 32 38 30 30 30 31 30 32 30 30 36 34 36 30 0D 0A (23 bytes)
MinimalModbus debug mode. Clearing serial buffers for port COM5
MinimalModbus debug mode. No sleep required before write. Time since previous read: 45037250.00 ms, minimum silent period: 4.01 ms.
Traceback (most recent call last):
  File "G:ПроектыPythonNeurolumber_utilsutilsModbusWriter.py", line 15, in <module>
    instrument.write_register(registeraddress=D40, value=data_to_write,number_of_decimals=0)  # Registernumber, value, number of decimals for storage
  File "C:UsersИван МалаховAppDataLocalProgramsPythonPython39libsite-packagesminimalmodbus.py", line 550, in write_register
    self._generic_command(
  File "C:UsersИван МалаховAppDataLocalProgramsPythonPython39libsite-packagesminimalmodbus.py", line 1245, in _generic_command
    payload_from_slave = self._perform_command(functioncode, payload_to_slave)
  File "C:UsersИван МалаховAppDataLocalProgramsPythonPython39libsite-packagesminimalmodbus.py", line 1329, in _perform_command
    payload_from_slave = _extract_payload(
  File "C:UsersИван МалаховAppDataLocalProgramsPythonPython39libsite-packagesminimalmodbus.py", line 1825, in _extract_payload
    raise InvalidResponseError(
minimalmodbus.InvalidResponseError: Did not find footer ('rn') as end of ASCII response. The plain response is: ':0±900²6Dx8dn'
MinimalModbus debug mode. Response from instrument: 3A 30 B1 39 30 30 B2 36 44 8D 0A (11 bytes), roundtrip time: 0.1 ms. Timeout for reading: 50.0 ms.
Asked By: Ivan Malakhov

||

Answers:

Colleagues told me that the controller that I use has problems with the ASCII standard. When I changed the mode to "RTU", everything worked.

Answered By: Ivan Malakhov
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.