Hi, I'm building my first quad and am having problems getting the ESCs to arm. I have followed the ESC calibration instructions, several times, but no luck. On the APM (loaded with the latest code V2.1.0) I get a solid green light indicating it is armed. Radio has been calibrated. I attached a Fluke Scopemeter to the ESC drive pins on the APM to see what was going on and found everything OK, once the APM is armed I get pulses ranging from about 1.00ms to 1.80ms as the throttle is advanced. The pulse repetition rate (frequency) was 400Hz. To test the ESC I used a pulse generator and found that the ESC will not arm at any frequency above  150Hz (1.0ms pulse width). The ESC arms correctly when connected directly to my radio receiver (50Hz rep rate, 1.0ms pulse width).

The ESC is a E-flite 30 Amp Pro. Eflite technical phone support couldn't offer any suggestions.

As I see it I have two options, buy different ESCs and hope for the best or use the ones I have and change the ESC drive frequency to 150Hz in software and reprogram the APM.

Does anyone know where in the code I can change the frequency? I am not a programmer but can usually tinker with existing code to make things work.

Any ideas or suggestion would be welcome, thanks....

Views: 2654

Reply to This

Replies to This Discussion

Yes, we use 400Hz to overdrive the ESCs for better performance. Yours are the first I've heard of that don't like that. 

The function is called INSTANT_PWM. Here's the relevant code in the motors.pde file for whatever frame you're using:


        #if INSTANT_PWM == 0
        ICR5 = 5000;    // 400 hz output        CH 1, 2, 9
        ICR1 = 5000;    // 400 hz output        CH 3, 4, 10
        ICR3 = 5000;    // 400 hz output         CH 7, 8, 11

5000 is the timer setting for 400hz
40000 is the timer setting for 50hz

Thanks Chris, I'll set it up for around 150Hz to start with.

Try putting 


in your apm_config file and see if that solves your problems, it worked for me


Spent most of the morning figuring out how to use the Arduino IDE, my first experience with this. Downloaded the older 0023 version, set up the directories as suggested and initialy got tonnes of errors compiling the unmodified code(Arducopter 2.1). Anyway, it is now compiling with only a few warnings which I will assume are not critical.

Next: To modify the code to produce a lower ESC drive frequency.

I opened the "motors_quad.pde" file and looked for the INSTANT_PWM line and found this:

static void init_motors_out()
#if INSTANT_PWM == 0
APM_RC.SetFastOutputChannels( MSK_CH_1 | MSK_CH_2 | MSK_CH_3 | MSK_CH_4 );

but didn't find the following code you suggested:

#if INSTANT_PWM == 0
ICR5 = 5000; // 400 hz output CH 1, 2, 9
ICR1 = 5000; // 400 hz output CH 3, 4, 10
ICR3 = 5000; // 400 hz output CH 7, 8, 11

Following the reference to "APM_RC.SetFastOutputChannels" in the library folder "APM_RC" didn't help. Though it does look like there is a provision to easily change the frequency to either 50hz, 200hz or 400hz, I just can't figure out where or how. Suggestions?

Jason, thanks, will this set the frequency to something slower than the default 400Hz?

Rick, you need to use the modified Arduino ("mrelex") in our downloads section. Ideally, you won't have to change the code at all. Just try Jason's suggestion of adding "# define INSTANT_PWM ENABLED" to your apm_config.h file and recompile.

Yes, the first is for PCs and the second is for Macs.


     I think there's actually two ways to slow down the update rate to your servos.  You can do as Jason Wise suggests and add the #define INSTANT_PWM ENABLED ... what that will actually do is give the main code loop control over when it updates the message to the ESCs.  So the main code loop runs at something like 200 or 250 (i forget which) so turning enabling that will slow it down to that rate.


     A better way to do it is to use the atmel's built in timer.  So like Chris was mentioning above, change the 5000 to 40000 and you'll find the update rate to the escs slows from 400 to 50.  I think the formula to get the rate is:

      magic number = 200,000 / desired hz


Chris, Jason

Thanks for the help.  

After adding the line to the apm_config.h and uploading to the APM the ESCs now arm.  When first powering up the frequency is 50Hz and the ESCs arm, then, after arming the APM with the transmitter, the frequency changes to about 200Hz.  Motors run up as they should.

I'm also having problems with arming my turnigy plush 40 ESCs. Was the higher frequency just recently introduced? My last successful flight was on apm1 running 2.0.50. Now attempting apm2 with 2.1

200,000/400 = 500... should it read 2,000,000 ?


    Yes, i think you're right!  thanks for that.

      magic number = 2,000,000 / desired hz

Reply to Discussion


© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service