Go Down

Topic: Servo Twitching (Read 724 times) previous topic - next topic



I'm working a robotic car project that uses one servo to steering, an ESC, and a tach that uses an interrupt (in addition to other analog and digital inputs).  I've found that if I either rotate the wheels manually (and therefore getting output from the tach) or let the motor turn the wheels, it causes some pretty significant twitching of the servo and ESC control.  From doing some searching around, I've found out that there can be some servo timing problems when using a longer interrupt routine, but that these can be avoided using the older servo library that uses only pins 9 and 10, which is fine for me since I only need two servo outputs.  My question is this, a lot of what I've seen is from older posts and some things lead me to believe that if I use the current servo library with pins 9 and 10 that it will use the functionality that isn't impacted by the interrupts, is this correct or should I just use the older servo version?  Another option, I'm using interrupt pin 0, would it make any difference if I use interrupt pin 1 instead?

Thank you for your help


Another fix is to use very short Interrupt Service Routines.
What are you doing in your ISR?


I'm doing the actual speed calculation in the interrupt, including some logic to filter (ie smooth out) the output.  I realize that it would be better to just record the pulse time and number of pulses between reads in the interrupt routine and then calculate the speed only when I call for it, but this was giving me trouble if the routine got called when I was in the middle of the calculating the speed, so I may start with a time from before the pulse and finish using the number of pulses from after the routine (do I make sense here?).  If this is the only way to get around the problem I think I can figure out how to do it, but I only need the two servos, so I don't really see a downside to using the different version of the controller.


Go Up