I am experiencing servo buzz related to a millis() timer in the same function
Basically a I’m using writeMicroseconds and a miilis() timer to step a servo very slowly up and down. Steadiness is important for my project and the timer is making my servos very jittery.
I read that it is possible to generate your own PWM for the Servo pins but I do not understand the code, and I do not recognize the functions from the example I was looking at. I am hoping someone here can help me make sense of the example, or make me an example I could use. Either way I would appreciate the knowledge
Heres the page I was looking at - http://electronics.stackexchange.com/questions/77502/is-there-a-way-to-stop-servos-from-shaking
When using the Servo library on an Arduino, a common source of servo buzz is that the interrupt-driven servo routines don't actually give a very stable output pulse. Because the AVR takes interrupts for servicing the millis() clock and other things in the Arduino runtime, the jitter in the Servo library is on the order of several microseconds, which translates to a lot of movement in the servo. The fix for this is to write your own pulse. Something like this: cli(); long start = micros(); digitalWrite(PIN, HIGH); while (micros() - start < duration) ; digitalWrite(PIN, LOW); sei(); This will turn off other interrupts, and generate a much cleaner PWM pulse. However, it will make the "millis() timer miss some clock ticks. (The "micros()" function may be called something else -- I forget exactly what.)
Hope you can help