Modbus slave Library support

OpenMV related project discussion.
rajeshktym
Posts: 33
Joined: Wed Mar 07, 2018 7:04 pm
Location: KOCHI
Contact:

Modbus slave Library support

Postby rajeshktym » Wed Sep 19, 2018 7:30 pm

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,

Thanks
Rajesh Kumar
User avatar
kwagyeman
Posts: 4458
Joined: Sun May 24, 2015 2:10 pm

Re: Modbus slave Library support

Postby kwagyeman » Thu Sep 20, 2018 2:18 am

Can you bitbang the modbus protocol in an interrupt handler? This would be the easiest way to do it.
Nyamekye,
Fr0sty
Posts: 1
Joined: Tue Jul 07, 2020 10:54 am

Re: Modbus slave Library support

Postby Fr0sty » Fri Aug 07, 2020 4:02 pm

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)

while(True):
    if modbus.any():
        modbus.handle(debug=True)
    else:
        time.sleep(100)
        modbus.REGISTER[0] = 1000
        modbus.REGISTER[1] += 1
        modbus.REGISTER[3] += 3
        #print(modbus.REGISTER[10:15])
        # image processing in there
        
User avatar
kwagyeman
Posts: 4458
Joined: Sun May 24, 2015 2:10 pm

Re: Modbus slave Library support

Postby kwagyeman » Fri Aug 07, 2020 5:55 pm

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

Return to “Project Discussion”

Who is online

Users browsing this forum: No registered users and 5 guests