Modbus slave Library support

Hi, Anybody tried openMV with modbus communication, I m planning to use this module as guiding sensor. for this, it need to send x position value of a particular sized blob from each frame. communication should be industrial standard RS485 Modbus RTU protocol slave. pls share some tips like which library used etc if anybody tried the same before,

Rajesh Kumar

Can you bitbang the modbus protocol in an interrupt handler? This would be the easiest way to do it.

I was wondering if this is easier to do now that we have the modbus_rtu_slave example code? I have a couple quick questions on how this example code works.

  1. when you set register_num=9999, what exactly is that setting? Below is the example code for reference.
  2. If I wanted to send an integer over the 4x10 register, would I just write to modbus.REGISTER[40010]?
import time
from pyb import UART
from modbus import ModbusRTU
uart = UART(3,115200, parity=None, stop=2, timeout=1, timeout_char=4)
modbus = ModbusRTU(uart, register_num=9999)

    if modbus.any():
        modbus.REGISTER[0] = 1000
        modbus.REGISTER[1] += 1
        modbus.REGISTER[3] += 3
        # image processing in there

I didn’t write that library. It’s user contributed. You should debug from the library source.