You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've run into an issue w PWMOut on RP2040 Pico board while using adafruit_motor. Seems that setting the PWM pins to full duty cycle of 0xFFFF fails to turn the motor, but 0xFFFE turns it just fine. This means the adafruit_motor throttle = 1.0 or throttle = -1.0 values don't work. I found that throttle = 0.9999998 works, but 0.9999999 does not.
I'm using GP28 and GP27 on the Pico.
Running adafruit-circuitpython-raspberry_pi_pico-en_US-20210212-08f30fe.uf2
Library from this bundle adafruit-circuitpython-bundle-6.x-mpy-20210212
here's the code I'm running:
# This example uses an L9110 H-bridge driver to run a DC Motor.
# https://www.adafruit.com/product/4489
# Hardware setup:
# DC motor via L9110 H-bridge driver on two PWM pins that are on their own channels
# e.g., RP2040 Pico pins GP28, GP27
import time
import board
import pwmio
from adafruit_motor import motor
PWM_PIN_A = board.GP28 # pick any pwm pins on their own channels
PWM_PIN_B = board.GP27
# DC motor setup
pwm_a = pwmio.PWMOut(PWM_PIN_A, frequency=50)
pwm_b = pwmio.PWMOut(PWM_PIN_B, frequency=50)
motor1 = motor.DCMotor(pwm_a, pwm_b)
print("Forwards slow")
motor1.throttle = 0.5
print("throttle:", motor1.throttle)
print(hex(pwm_a.duty_cycle), hex(pwm_b.duty_cycle)+"\n")
time.sleep(1)
print("Stop")
motor1.throttle = 0
print("throttle:", motor1.throttle)
print(hex(pwm_a.duty_cycle), hex(pwm_b.duty_cycle)+"\n")
time.sleep(1)
print("Forwards")
motor1.throttle = 1.0 # 0.9999998 works, 0.9999999 does not
print("throttle:", motor1.throttle)
print(hex(pwm_a.duty_cycle), hex(pwm_b.duty_cycle)+"\n")
time.sleep(1)
print("Stop")
motor1.throttle = 0
print("throttle:", motor1.throttle)
print(hex(pwm_a.duty_cycle), hex(pwm_b.duty_cycle)+"\n")
time.sleep(1)
print("Backwards")
motor1.throttle = -1.0
print("throttle:", motor1.throttle)
print(hex(pwm_a.duty_cycle), hex(pwm_b.duty_cycle)+"\n")
time.sleep(1)
print("Stop")
motor1.throttle = 0
print("throttle:", motor1.throttle)
print(hex(pwm_a.duty_cycle), hex(pwm_b.duty_cycle)+"\n")
time.sleep(1)
print("Backwards slow")
motor1.throttle = -0.5
print("throttle:", motor1.throttle)
print(hex(pwm_a.duty_cycle), hex(pwm_b.duty_cycle)+"\n")
time.sleep(1)
print("Stop")
motor1.throttle = 0
print("throttle:", motor1.throttle)
print(hex(pwm_a.duty_cycle), hex(pwm_b.duty_cycle)+"\n")
time.sleep(1)
print("Spin freely")
motor1.throttle = None
print("throttle:", motor1.throttle)
print(hex(pwm_a.duty_cycle), hex(pwm_b.duty_cycle)+"\n")
print('pwmio test 0XFFFF \n')
pwm_a.duty_cycle = 0xFFFF
pwm_b.duty_cycle = 0x0000
time.sleep(4)
print('pwmio test 0XFFFE \n')
pwm_a.duty_cycle = 0xFFFE
pwm_b.duty_cycle = 0x0000
time.sleep(4)
The text was updated successfully, but these errors were encountered:
I've run into an issue w PWMOut on RP2040 Pico board while using adafruit_motor. Seems that setting the PWM pins to full duty cycle of
0xFFFF
fails to turn the motor, but0xFFFE
turns it just fine. This means the adafruit_motorthrottle = 1.0
orthrottle = -1.0
values don't work. I found thatthrottle = 0.9999998
works, but0.9999999
does not.I'm using GP28 and GP27 on the Pico.
Running adafruit-circuitpython-raspberry_pi_pico-en_US-20210212-08f30fe.uf2
Library from this bundle adafruit-circuitpython-bundle-6.x-mpy-20210212
here's the code I'm running:
The text was updated successfully, but these errors were encountered: