@gtcn 用3号口
M
mcr3
@mcr3
0
声望
11
楼层
344
资料浏览
0
粉丝
0
关注
mcr3 发布的帖子
-
RE: 自带的modbus示例程序如何更改成master模式?
@kidswong999 那就是说用modbus库函数默认是slave模式,必须要主机发送请求才可以?问题是我现在要给传送的数据它也是从机,这种情况怎么办?
-
自带的modbus示例程序如何更改成master模式?
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_ms(100) modbus.REGISTER[0] = 1000 modbus.REGISTER[1] += 1 modbus.REGISTER[3] += 3 #print(modbus.REGISTER[10:15]) # image processing in there
-
RE: H7 Plus如何通过modbus把数据传输下图0x0000里面?
import sensor, image, time, pyb from pyb import UART from modbus import ModbusRTU uart = UART(1,9600, parity=None, stop=2, timeout=1, timeout_char=4) modbus = ModbusRTU(uart, slave_id=1, register_num=9999) sensor.reset() sensor.set_pixformat(sensor.RGB565) #GRAYSCALE,RGB565 sensor.set_framesize(sensor.QQVGA) sensor.skip_frames(time = 2000) clock = time.clock() led = pyb.LED(3) while(True): clock.tick() img = sensor.snapshot().lens_corr(1.8) for c in img.find_circles(threshold = 3500, x_margin = 10, y_margin = 10, r_margin = 10,r_min = 2, r_max = 100, r_step = 2): img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0)) if modbus.any(): modbus.handle(debug=True) else: led.on() time.sleep_ms(100) modbus.REGISTER[0] = ('%d' % c.x()) modbus.REGISTER[2] = ('%d' % c.y()) led.off() print(modbus.REGISTER[0],modbus.REGISTER[2],sep=" ")
这是我写的一个查找圆中心传送到modbus的代码,请问是否正确