Reputation: 3435
I'm using a Raspberry Pi 3 to try and control a brushless DC motor via a QBrain ESC.
To do this I use the RPI lightning drivers to create PWM DMA signals. Unfortunately nothing I do will get the motors turning.
Can someone advise what frequency and duty cycle I should be using to output to the ESC? Googling would suggest a PWM frequency of 50Hz with duty cycle between 0.05% and 0.1% (to a give a pulse between 1ms and 2ms), but this doesn't seem to work for me.
example code here (C# windows IoT):
var controllers = await PwmController.GetControllersAsync(LightningPwmProvider.GetPwmProvider());
var pwmController = controllers[1];
pwmController.SetDesiredFrequency(50);
int pin = 12;
var motor = pwmController.OpenPin(pin);
motor.Start();
do
{
double userInputThrust = ...value between 0 and 100 provided by user...
// scale user input from 0 to 100 to between 0.05 and 0.1
double thrust = ScaleBetween(userInputThrust, 0.05, 0.1);
motor.SetActiveDutyCyclePercentage(thrust);
} while (true);
Upvotes: 2
Views: 1849
Reputation: 320
The duty cycle expected for the QBrain can be adjusted during calibration. The 20ms window is the norm but the high and low values have some variance. Ideally you should calibrate for 1ms low and 2ms high.
The QBrain ESC uses an Atmel micro-controller and SimonK firmware. Therefore you should follow the calibration procedure for SimonK which can also be found online. The procedure is as follows:
Ensure that you never power on the ESC at full throttle or the ESC will reenter calibration mode. Powering on at low throttle is advised.
After calibration you should notice that the ESC will begin to turn the motor at with a 1070us high pulse for a 20ms period. (i.e. there is a dead zone between 1000us and 1070us)
If you are unsure as to what period the output pin is generating then you should scope it with an oscilloscope and measure it. The ESC can only do what it is told.
Upvotes: 1