• 免费好用的星瞳AI云服务上线!简单标注,云端训练,支持OpenMV H7和OpenMV H7 Plus。可以替代edge impulse。 https://forum.singtown.com/topic/9519
  • 我们只解决官方正版的OpenMV的问题(STM32),其他的分支有很多兼容问题,我们无法解决。
  • 如果有产品硬件故障问题,比如无法开机,论坛很难解决。可以直接找售后维修
  • 发帖子之前,请确认看过所有的视频教程,https://singtown.com/learn/ 和所有的上手教程http://book.openmv.cc/
  • 每一个新的提问,单独发一个新帖子
  • 帖子需要目的,你要做什么?
  • 如果涉及代码,需要报错提示全部代码文本,请注意不要贴代码图片
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • pixformat is not supported是怎么回事?



    • import pyb, sensor, image, math, time, utimesensor.reset()#openmv初始化sensor.set_framesize(sensor.QVGA)#设置图像大小sensor.set_pixformat(sensor.GRAYSCALE)from pyb import Pinwave_echo_pin = Pin('P7', Pin.IN , Pin.PULL_NONE)wave_trig_pin = Pin('P8', Pin.OUT_PP, Pin.PULL_DOWN)wave_distance = 0tim_counter = 0flag_wave = 0#超声波启动def wave_start(): wave_trig_pin.value(1) utime.sleep_us(15) wave_trig_pin.value(0)#超声波距离计算def wave_distance_calculation(): #全局变量声明 global tim_counter #频率f为0.2MHZ 高电平时间t=计数值1/f wave_distance = tim_counter5*0.017 #输出最终的测量距离(单位cm) print('wave_distance',wave_distance)#超声波数据处理def wave_distance_process(): global flag_wave if(flag_wave == 0): wave_start() if(flag_wave == 2): wave_distance_calculation() flag_wave = 0#配置定时器tim =pyb.Timer(1, prescaler=720, period=65535) #相当于freq=0.2M#外部中断配置def callback(line): global flag_wave,tim_counter #上升沿触发处理 if(wave_echo_pin.value()): tim.init(prescaler=720, period=65535) flag_wave = 1 #下降沿 else: tim.deinit() tim_counter = tim.counter() tim.counter(0) extint.disable() flag_wave = 2#中断配置extint = pyb.ExtInt(wave_echo_pin, pyb.ExtInt.IRQ_RISING_FALLING, pyb.Pin.PULL_DOWN, callback)while(True): wave_distance_process() time.sleep(100) for i in range(10): img = sensor.snapshot() for j in range(100): img.draw_string(50, 0, "space:",color=[255,0,0]) img.draw_string(50, 10, str(wave_distance),color=[255,0,0]) img.draw_string(100, 10, "CM",color=[255,0,0])



    • 定时器使用错误,请查看OpenMV的定时器分配。
      0_1521207298639_47bf4edd-6908-4b1c-8ff2-c326946b57b1-image.png

      参考资料:



    • 另外,代码请使用格式上传,具体请看 玩转星瞳论坛



    • 基本上确定是中断的问题,你运行hello world看看



    • @yuan
      超声波测距print出来的全部是0,就算没加屏幕显示都不对,这是啥原因呢?