Skip to main content
Bumped by Community user
Bumped by Community user
new tags
Link
Source Link

ESC, BLDC control with pigpio: set_PWM_dutycycle or set_servo_pulsewidth, and other ESC questions

I am new to Raspberry Pis. I am using a Raspberry Pi 4.

I am trying to control a BLDC motor from the BLHeli_32 ESC, using PWM signals output from GPIO pin 18.

For this project, I need the motor to go at only ONE speed, which i will find out later, and I need to make two Python functions to turn the motor on or off.

I am wondering if I should use set_PWM_dutycycle or set_servo_pulsewidth for this purpose.

For example, for set_PWM_dutycycle I was thinking some functions like this to run it at 50% dutycycle (does this mean 50% speed of motor?)

def start_motor():
        pi = pigpio.pi()
        pi.set_PWM_range(18, 100)
        pi.set_PWM_dutycycle(18, 50)

def stop_motor():
        pi = pigpio.pi()
        pi.set_PWM_dutycycle(18, 0)

and then for set_servo_pulsewidth I would just have similar code to this link pigpio ESC (Electronic speed control) problem

I'm wondering if theres anything to consider about the difference to these two approaches? Because I'm not using a servo motor. and the dutycycle is the % of the pulse width over the pulse period so could i get the same effect with these two functions?

Do I have to care about the frequency as well? It seems that my GPIO pin 18 is operating at frequency 800 HZ. The BL Heli 32 manual states: "Input signal rates up to at least 32kHz are supported. But please note that higher input signal rates put a heavier load on the MCU, and will reduce the maximum erpm that the ESC can handle. "

I know this seems like a very basic question, but I am asking this because I set one of these on fire yesterday with the pigs library so i want to make sure i understand exactly what i am doing.

Thank you!