Servo skeleton with fast & slow interrupts

From Mech
Revision as of 11:48, 21 February 2008 by Lynch (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Check out the Pololu.c code [1]. This is very simple code to control two motors to run at the same speed. A 1 ms interrupt service routine (ISR) is used to check the encoders of two motors to see if the motors have moved. Note that if your encoder pulses come too quickly, you will miss counts by this simple polling, so this code is only appropriate for low encoder pulse rates. A 13.1 ms ISR calculates a control law: if encoder 1 is ahead of encoder 2, slow motor 1 and speed motor 2, and vice-versa.