Hi,
I have done a lot of research and reading the last 2 days about 8bit timers and controlling hobby servos. I understand that a 16Bit timer gives you much better resolution, but my intent is to use an attiny85 to simply reverse 1 servo signal. So in essence, 1ms in comes from the rc receiver, and 2ms comes out of the attiny. This is specifically for controlling a rock crawler with rear wheel steering. The rear servo must operate opposite of the front servo. I have already designed and built a 555 circuit that accomplishes this but it is susceptible to temperature fluctuations that cause servo center instability. IE jitter or drift from center. Many people have eluded to the way that it would be done, but no one has DIRECTLY spelled out the exact math or mental process for implementing a better resolution 8bit PWM signal. From what i can glean from all my reading is this:
1: use a combination of F_CPU and Prescaler to get a clock frequency of 125K-Start with a F_CPU of either 1MHZ with a prescaler of 8 or a F_CPU of 8Mhz and a prescaler of 64. So, this gives you 8uS per clock instruction. Multiplied by 250 cycles gives you a 2mS pulse.
2: Take this 2ms pulse (now of which there are 128 steps between 1mS and 2mS) and every time this timer overflows (just thought that it might need to be 249 cycles to account for the overflow because it resets on zero.) increment a variable to count 10. This will give you a 20mS pulse, which is the 50hz pulse necessary for the servo.
3: Once the counter gets to 10, now you need to generate the required control pulse-so, i need to implement a timer loop to give me the required 1-2mS pulse.
at this point i need to figure out how to invert the incoming signal. I am planning on using the pulsein() to grab the control pulse from the receiver, store that value, but from here i need some help. The way i am accomplishing this in my other circuit is i am generating a 3ms reference pulse with one 555 and then subtracting the incoming pulse from the receiver. this gives me exactly what i need. 3mS reference - 1ms = 2mS and 3mS - 2 mS = 1mS.
What i am looking for is for someone to confirm my solution to the 8bit timer to control a servo so that others like me can benefit from the knowledge (I considered asking the guys over at AVR Freaks but they would flame me for sure, i read a ton of posts over there and they are pretty hash on people. that is why i am coming prepared with some knowledge and a plan). Also, any solutions on handing (inverting) the incoming servo pulse.
Thank you in advance to anyone who can help or verify my theories. My programming skills are not bad, but i really hate timers and banging registers.
Jason