Reading multiple registers using Modbus urcap

Hello guys,

I, have build and installed the modbus urcap provided here GitHub - EbbeFuglsang/Modbus_URCap: A tool modbus RTU URCap by @Ebbe .
I modify the tool_modbus_read() inside modbus_xmlrpc.py to support multiple register reading opertation:

def tool_modbus_read(register_address, register_number):
  global value
  try:
    global instrument
    value = instrument.read_registers(register_address, register_number, functioncode=4)
  except Exception as e:
    Logger.error("Error in modbus read method", exc_info=True)
    value = str(e)
  return value

Unfortunately, when I execute the command tool_modbus_read(0,2), I get the exception “No communication with the instrument (no answer)” . However, when I run a debug script inside the robot controller directly with the command instrument.read_registers(0, 2, functioncode=4), I do get the value from the registers.

Can anyone please suggest what might be the issue here?

Thanks in advance!

Hi @gargsonu0414

Does this mean that you are running it from the CLI on the robot?

Another question: Are you sure that you URCap deployment is resulting in an update of the python daemon?

Ebbe

Hi @Ebbe

Thank you for the reply.

The issue was related to the difference in the minimalmodbus default baud rate and the baud rate setting of the sensor I am using.

Garg

1 Like