2
votes

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);
1
Please post the relevant code in your question. It's hard to tell what is wrong otherwise.Munir
This is just guesswork, but I assume you mean between 1ms and 2ms rather than between 1000ms and 2000ms. If that's the case then your code should read ScaleBetween(userInputThrust, 0.05, 0.1);, assuming ScaleBetween 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
You are correct, 1ms to 2ms, typo there. I'd really like to get a scope set up, but don't have one unfortunately.Slicc
I've corrected the post to the correct values nowSlicc

1 Answers

1
votes

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:

  1. Send a 2ms high pulse with 20ms period to the ESC; Then, power it on.
  2. Wait for a beeping sequence to take place.
  3. Send a 1ms high pulse with a 20ms window to the ESC.
  4. Wait for a beeping sequence to take place.
  5. Power off the ESC.

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.