Hi all, no need to strictly stick to 50Hz, because 60HZ works well on most of servo and ESC.
Setting 60HZ pwm signal is easy.
I have a good brand name hobby RC transmitter receiver and I have tested it outputs 60HZ pwm signal to esc, not 50hz, so it looks like most of servo and ESC should handle 60HZ signal pretty well.
Also there are so many cheap $2 ESC/Servo tester out there they work well, many of those just use a NE555 to produce a signal to test servo or ESC, which frequency varies depends the On time, it’s not fixed to one frequency.
Setting 60HZ pwm for arduino is quite easy
TCCR2A = ((1<<WGM20) | (1<<WGM21))
#define TCCRB_INIT_MASK_60HZ ((1<<CS22)|(1<<CS20)|(1<<CS21)) // 1/1024 prescaler for 60HZ
TCCR2B = TCCRB_INIT_MASK_60HZ
OCR2A = 25 //set pwm =25
the only problem is for Pin11 the 8Bit timer 2 resolution is not that good, we only have about 9 levels of PWM output for servo(one dir) or ESC
One pwm period is 1000ms/60hz=16.6ms, there are only about 9 pwm level falls in the 1.5ms to 2ms range (for ESC)
On Time from 1.5ms to 2.0ms is valid, 1.5ms=0 output, 2ms=100% output for ESC
PWM ms on time ms
23 16.66666667 1.50 9.0%
24 16.66666667 1.57 9.4%
25 16.66666667 1.63 9.8%
29 16.66666667 1.90 11.4%
30 16.66666667 1.96 11.8%
31 16.66666667 2.03 12.2%
so we can either use other tricks to make the on time have more values but that complicates things,
or use the 16bit timer time1 when it’s available.
Today I also tested a brushless ESC for Drone, so it gets interesting.
It looks like for RC car ESC, from 1.5ms to 2ms on time is valid for motor moving forward.
but for drone ESC, it starts from 1ms, then it has wide range which is good,
And there is more, the drone ESC (a no brand name cheap one, black, 30A) accepts signal frequency up to 600hz…so we can easy use 244 or even 488Hz with the 8bit timer2 Pin11,
and the pwm output has 60+levels which is very good.
PWM ms period of 244hz, on time ms
62 4.098360656 1.00 24.3%
125 4.098360656 2.01 49.0%
for 244hz TCCR2B = ((1<<CS22)|(1<<CS21))