导航

    • 登录
    • 搜索
    • 版块
    • 产品
    • 教程
    • 论坛
    • 淘宝
    1. 主页
    2. mpkh
    3. 楼层
    M
    • 举报资料
    • 资料
    • 关注
    • 粉丝
    • 屏蔽
    • 帖子
    • 楼层
    • 最佳
    • 群组

    mpkh 发布的帖子

    • RE: OpenMV 使用Timer.PWM,有问题,怎么解决其他PWM输出?
      # This work is licensed under the MIT license.
      # Copyright (c) 2013-2023 OpenMV LLC. All rights reserved.
      # https://github.com/openmv/openmv/blob/master/LICENSE
      #
      # Timer Control Example
      #
      # This example shows how to use a timer for callbacks.
      
      import time,pyb,machine
      from pyb import LED,Pin,Timer,PWM
      
      
      LEDR = LED(1)
      LEDG = LED(2)
      LEDB = LED(3)
      
      #pwm = PWM(Pin("P7"), freq=50, duty=0)
      #pwm.duty(7)
      
      ## we will receive the timer object when being called
      # Note: 回调函数不允许分配内存
      def tick(tim):
          LEDR.toggle()
      
      tim = Timer(14, freq=10) 
      tim.callback(tick)  
      
      tim = Timer(4, freq=1000)  # Frequency in Hz.
      ch1 = tim.channel(1, Timer.PWM, pin=Pin("P7"), pulse_width_percent=50)
      
      #tim.init(freq=100)
      #tim = Timer(2, freq=1000)  # 设置定时器在1000Hz触发
      #chA = tim.channel(1, Timer.ENC_A, pin=Pin("P6"))
      #chB = tim.channel(4, Timer.ENC_B, pin=Pin("P5"))
      
      
      # 初始化编码器
      #encoder1 = pyb.Encoder(pyb.Pin('P5'), pyb.Pin('P6'))
      
      # 读取编码器的旋转位置
      #position1 = encoder1.position()
      
      while True:
          time.sleep_ms(500)
      #    LEDB.toggle()
      
      
      
      
      
      发布在 OpenMV Cam
      M
      mpkh
    • RE: OpenMV 使用Timer.PWM,有问题,怎么解决其他PWM输出?

      使用machine 导入PWM也会提示同样的问题,IDE版本4.1.5,OpenMV固件版本OpenMV v4.5.3; MicroPython v1.22-omv.r17;

      发布在 OpenMV Cam
      M
      mpkh
    • OpenMV 使用Timer.PWM,有问题,怎么解决其他PWM输出?

      0_1711355764826_08dbbeff-bd63-4010-bf66-bf9736075f06-image.png
      0_1711355769994_0738dd18-7756-4fc7-bb87-de202bef5851-image.png
      例程方法输出50Hz,可调脉冲在1ms 到2ms,但占空比数值在5-10左右,可调区间太小,使用PWM 16位提示无法加载该PWM模块?
      还有就是看了手册说可以读取编码器值,但请问这个操作如和,英文版复制的例程,提示无该模块,导入失败,需要安装还是怎么操作?

      发布在 OpenMV Cam
      M
      mpkh