Page 1 of 1

Modbus slave Library support

Posted: Wed Sep 19, 2018 7:30 pm
by rajeshktym
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

Re: Modbus slave Library support

Posted: Thu Sep 20, 2018 2:18 am
by kwagyeman
Can you bitbang the modbus protocol in an interrupt handler? This would be the easiest way to do it.

Re: Modbus slave Library support

Posted: Fri Aug 07, 2020 4:02 pm
by Fr0sty
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]?

Code: Select all

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

Re: Modbus slave Library support

Posted: Fri Aug 07, 2020 5:55 pm
by kwagyeman
I didn't write that library. It's user contributed. You should debug from the library source.