I am trying to use my RPi PICO to control a BLDC ESC. Using a servo tester it works perfectly, but I want to be able to use this with my PICO and with a trigger/spring potentiometer. Basically it will take the readings from the POT and send the proper signal to the ESC to control the speed.
EDIT: I was able to get the motor/ESC to work but only at 500hz. Then when I throttle all the way up, the motor maxes out for a few seconds then turns off. When the throttle/pot is all the way at zero, the ESC beeps indicating no throttle signal. So I believe the duty cycle is off or does not detect the signal at the frequency. None of this happens with the servo tester. Any thoughts on how to fine tune the frequency/duty cycle?
import board
import analogio
import pwmio
import digitalio
from adafruit_motor import servo
import time
potentiometer = analogio.AnalogIn(board.GP26)
pwm_sig = pwmio.PWMOut(board.GP14, frequency=500)
#Just to see if my PICO is powered on during VSYS
red_led = digitalio.DigitalInOut(board.GP11)
red_led.direction = digitalio.Direction.OUTPUT
red_led.value=True
while True:
pwm_sig.duty_cycle = potentiometer.value
I configured the pulse rate between 800-2200 at 50hz frequency. Then the angle (my_servo.angle = angle) of the servo is the throttle control, a value between 0-180. I took the pot valued (0-65535), re-scaled it to a value between 0-1870 to control the speed. Works perfectly. Thanks for the help.
– vm1988 Nov 07 '22 at 22:51