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);
ScaleBetween(userInputThrust, 0.05, 0.1);
, assumingScaleBetween
does what it says it does. To debug this sort of thing, you'll probably save yourself a lot of headache by hooking a scope to pin 12 and seeing what sort of signal it's outputting. Trial and error only gets you so far. – Sean Cline