H7 Plus如何通过modbus把数据传输下图0x0000里面?
-
-
https://singtown.com/learn/50806/
这个代码OpenMV是slave模式,不是master模式。
-
此回复已被删除!
-
@kidswong999 那我应该怎么编写程序呢?
-
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的代码,请问是否正确
-
不正确, modbus.REGISTER[0] = ('%d' % c.x()),不应该是字符串。
参考:https://book.openmv.cc/example/32-Modbus/modbus-apriltag.html