I am currently working on controlling servo motors with an ATtiny85. I have a hard time understanding how to achieve a fine granularity for the angles of the servo.
I am using a similar technique as the one stated by KyranF.
A servo angle is determined by the pulse width between 1-2ms of an 50Hz PWM.
I am using Timer 1 with a prescaler of 1 with a 8 Mhz clock. This means a timer overflow(tick) takes (1/8MHz) * 256 = 32 microseconds.
A 20ms period takes 625 overflows. This means my 1ms granularity is 625/20ms = 31,25 = ~31 ticks per ms.
Because a servo angle is controlled by setting the pulse width somewhere between 1-2ms, I can only have a precision of 31/180°= ~6 degrees.
Is there a way to achieve 1° precision ?