|
|
Last updated 2010/01/10
Some C code for a PIC chip to run up to 9 servos smoothly, simultaneously, and very importantly, in the background of the main program. It uses two interrupts to do the timing of the pulse widths. There are two slightly different versions. The first, and more basic, allows you to control the absolute angle of the n'th servo using set_angle(int8 ang, int8 n). Everything else is dealt with by the two interrupts. The second version requires an extra timer. In addition to the set_angle function, there is the set_move(signed int8 m, int8 n) function, which sets the movement variable of the n'th servo. This variable is then added to the absolute angle of the n'th servo every movement interrupt. This allows for smooth, constant speed rotation with minimal effort elsewhere in the program.
|