[Python] Why can't I read registers using pymodbus from my Oriental Motor AZD-AD?

Discussão em 'Python' iniciado por Stack, Julho 22, 2025.

  1. Stack

    Stack Membro Participativo

    I'm attempting to use pymodbus to drive Oriental Motor's AZD-AD. I can drive it with no issue - the code below moves the motor as I expect it to.

    import time
    from pymodbus.client import ModbusSerialClient


    client = ModbusSerialClient(port="COM3",
    baudrate=115200,
    timeout=8,
    parity='E',
    stopbits=1,
    bytesize=8)

    client.connect()

    client.write_register(address=0x501, value=0x0007, slave=1) # set continuous operation
    client.write_register(address=0x481, value=0x1388, slave=1) # set speed to 5000 Hz
    client.write_register(address=0x601, value=0x0adc, slave=1) # acceleration of operation unit 1X10^-3 ms^-1/kHz
    client.write_register(address=0x681, value=0x0adc, slave=1) # deceleration of operation unit 1X10^-3 ms^-1/kHz
    client.write_register(address=0x401, value=0x0BB7, slave=1) # set number of steps (3000 steps between each position)
    client.write_register(address=0x07D, value=0x0010, slave=1) # send ZHOME command
    print("home")

    time.sleep(5)

    client.write_register(address=0x501, value=0x0002, slave=1) # set absolute positioning

    client.write_register(address=0x07D, value=0x0000) # stop
    client.write_register(address=0x07D, value=0x0008) # start

    res = client.read_holding_registers(address=0x07D, slave=1, count=1)
    print("response: ", res)

    client.close()



    The issue is, whenever I attempt to read data from any of the registers, my response looks like this:

    response: ReadHoldingRegistersResponse(dev_id=1, transaction_id=0, address=0, count=0, bits=[], registers=[], status=1)


    I should also add that I'm using a BB-USPTL4 USB to RS485 adapter between the PC and AZD-AD since my PC has no RS-485 port.

    I've tried changing the count to 1-16 and looking at different registers, but the result is always the same "ReadHoldingRegistersResponse". With the AZD-AD powered off, I still get the same response which tells me that pymodbus isn't really getting data from the device.

    Using MEXE02, the companion software to the AZD-AD, I ensured that the ID is indeed 1, and that my baud rate, timeout, parity, and stopbit settings all match between the software and hardware.

    What am I missing? Thanks in advance.

    Continue reading...

Compartilhe esta Página