I am trying to use ESCs that require a 0% duty cycle for full reverse, 50% for stopped, and 100% for full forward to control my DC thrusters. The flight controller that I am using is a Pixhawk 4. What is the best way to go about accomplishing this? Do I need to edit the ArduSub code? That is what I have been trying to do so far but haven’t had any luck.
The PWM outputs on a Pixhawk are generally intended for servo-style controls (which operate on pulse-duration microseconds), and may not be able to achieve full 0% or 100% duty-cycle signals. You could try modifying the
RC_SPEED parameters to set a 0µs minimum, and a maximum that matches the period of the frequency defined in
RC_SPEED, but I’m not certain whether it would work.
In addition, ArduSub currently has the neutral/stopped value for motors hardcoded to 1500µs pulse-duration. If your ESCs don’t have a set signal frequency requirement then that could still be workable by setting
RC_SPEED to ~333 and
MOT_PWM_MAX to 3000µs, but otherwise you’ll definitely need to use a modified version of ArduSub.
Thanks for the quick reply. I was just able to get my ESCs working with a modified version of ardusub. I’m not achieving a full 0%-100% duty cycle range, more like 15%-85%, but this should be fine for my application.
I do have one follow up question. Do you know if it would be possible to change the PWM output frequency from the default of 200 Hz to a value of around 20 kHz? This is the frequency recommended by the manufacturer of the ESCs I am using to minimize motor noise.
The PWM output frequency is settable via the
RC_SPEED parameter, but 20 kHz seems more like the frequency for ESC output updates, not their inputs. I don’t expect that will work (it seems way too high), but you can try it and see what happens.
Note that a 20kHz frequency has a 50µs period, so you’ll need to do additional modifications to ArduSub to avoid the current hardcoded 1500µs pulse-durations used for the neutral/stopped signal (as I mentioned initially).