Reading registers with pimodbus

I am very new to Modbus and PyModBus, but I spent a lot of time reading and experimenting with it. If anyone could point me in the right direction, I would appreciate ...


I have a drive with distance, speed, acceleration and deceleration on registers 40001, 40003, 40005 and 40007 (respectively). At first I managed to write to the distance register using client.write_register (0000, n). After you tried to record the speed, the drive began to work with an error and vibrate, and the rotation was 10x as fast as it should be. However, reading registers are a real priority. I am trying to read data from these registers and have zero luck. I tried using

request = client.read_holding_registers(0000,4) response = client.execute(request) print response 


However, all I get is "ReadRegisterResponse (0)".

So, my big priority is trying to read the values ​​from these registers ... any tips? (By the way, this is TCP)

+6
source share
3 answers

Try:

  response = client.read_holding_registers(0x00,4,unit=1) 

where the device value is the device identifier of the slave device.

To print everything:

 print response.registers 

You can also directly get one value (for example, the third register):

 print response.getRegister(2) 

or

 print response.registers[2] 
+10
source

you can independently analyze the answer, the following code fragment:

  result = client.read_input_registers(0x01,1, unit=0x01) #print result t = result.registers[0] print "current temperature:", t, " ", float(t/100.0) 
+5
source

,,,,,, gy553uy35quq3u36yu3w5y35w5uy35u36u4u46uw6uwuw

-2
source

Source: https://habr.com/ru/post/972602/


All Articles