-1
\$\begingroup\$

I'm trying to build a drone with my Raspberry Pi 3. I'm using Windows 10 IoT and C#.

I've bought a DJI E300 pack (motor + ESC + Propeller) and in the data sheet it says that the ESC works with signals in 30 to 450 Hertz. It also says that if you hear a single Beep on an interval (which I'm hearing) it means that the input signal is abnormal.

This is how I'm providing the signal:

public sealed partial class MainPage : Page
{
    PwmPin motorPin;
    PwmController pwmController;

    public MainPage()
    {
        this.InitializeComponent();
        Init();
    }

    public async void Init()
    {
        if (LightningProvider.IsLightningEnabled)
        {
            LowLevelDevicesController.DefaultProvider = LightningProvider.GetAggregateProvider();
        }

        pwmController = (await PwmController.GetControllersAsync(LightningPwmProvider.GetPwmProvider()))[1];
        motorPin = pwmController.OpenPin(21);
        pwmController.SetDesiredFrequency(50);
        motorPin.SetActiveDutyCyclePercentage(0);
        motorPin.Start();
    }

    private void M1_Slider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)
    {
        M1_Label.Text = $"M1 ({e.NewValue})";
        motorPin.SetActiveDutyCyclePercentage(((double)e.NewValue / 100.0));
    }
}

First I used this code to dim a LED and it worked, so I know that the PWM is working fine. But I don't know what else is required for the ESC to work.

\$\endgroup\$
  • \$\begingroup\$ says that the ESC works with signals in 30 to 450 Hertz. So what frequency are you sending? \$\endgroup\$ – StainlessSteelRat Aug 10 at 1:36
1
\$\begingroup\$

The ESC almost certainly comes from the RC plane heritage, which means that it's not designed to respond to the average on-time of the PWM, but rather that it expects a 1ms to 2ms pulse.

Moreover, most ESCs are designed with the assumption that there's a human holding a transmitter. They won't arm unless the PWM is below some threshold (usually 1.1 to 1.2ms).

To make such an ESC work, your PWM needs to do the following:

  • Choose a rate. The original radios ran at a frame rate of 50-60Hz.
  • Control the PMW by on time. 1ms is 0% throttle, 2ms is 100% throttle. The ESC may use a narrower range (i.e. 1.1 - 1.9ms).
  • Start at 0% throttle (1ms pulses) for as long as it takes for the ESC to be happy. This is probably a second or so.
\$\endgroup\$
  • \$\begingroup\$ I wish you could show me these steps in code \$\endgroup\$ – Sasan Aug 7 at 17:01
  • \$\begingroup\$ I'm using 50Hz and my initial value for PWM signal is 0 (as you can see in the code above) \$\endgroup\$ – Sasan Aug 7 at 17:07
  • \$\begingroup\$ I would suggest a search on "drive a servo from Raspberry Pi". The ESC thinks its a servo. \$\endgroup\$ – TimWescott Aug 7 at 18:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.