I need to use 4 pwm outputs for 4 ESC regulators on my quadcopter. There are 2 8-bits timers and only 1 16-bits timer. It is really impossible to control quadcopter with only 255 resolution points! So my question is: is it possible to get bigger resolution?
For example: ESC need 1ms (throtle down) to 2ms (full gas) pulses. With 8bit counter I can only increase time by aprox 4us and thats too much.
And in addition: 255 values is too small also for servo - why it is so small on Arduino Uno? I'm really confused from this...
UKHeliBob: are you sure with it? You can write 1000 values to that function but how do you know it is working properly? (not only for 255 values on timer1 and tumer2)
RC servos work by responding to pulses between 1000 and 2000 microseconds to move between 0 and 180 degrees. So by using the writeMicroseconds() method you can have 1000 different servo positions, assuming that is that the servo is mechanically able to provide such a resolution.
ESCs work in the same way but of course they do not move but produce the requisite outputs to drive brushless motors which is what I assume you are using.
The servo library users a timer to time the pulses not to produce 255 different PWM values.
Well, I connect osciloscop to the PWM outpusts and with WriteMicroseconds() I really see that difference between 1000, 1001, 1002. So it really works. But how is it possible? In addition when I attach D2 which is not PWM output it also works. How? That Servo library must make some bypass above that PWM registers...
So in fact I have 1000 points resolution for control motors speed at my quadcopter. It's not so bad but more will be better. On the other hand quadcopter also fly with just 2us resolution - I tested it but it was not such smooth.
Well and isn't it problem to control quadcopter by Servo when it isn't using PWM? My osciloscope sometimes show about 4us lags in signal generated by Servo.
There are very well respected flight controllers based on the Arduino, such as the ArduCopter, for which the source code is freely available. Perhaps you could look at how they achieve what they do.
jurass17:
Well and isn't it problem to control quadcopter by Servo when it isn't using PWM?
This does not make sense.
The phrase PWM is used in 2 different contexts. It is the output produced by analogWrite() which is used to control the speed of DC motors or the brightness of LEDS.
The pulses used to tell a servo what position to adopt are also, strictly speaking, PWM signals but the way they are used is quite different from the way the other signals are used to control the speed of a motor. The servo is only concerned with the absolute width of the pulses whereas a DC motor controller also uses the width of the gap between the pulses as part of the speed control system - it is the relative width of the pulse to the width of the gap that matters.
The Atmega chips have special features to enable them to produce in the background the type of PWM needed for a DC motor while the rest of the CPU gets on with other stuff.