<< Previous | Next >> | |
|
void servo_gear( int count0, int count1, int slave0, int slave1 );
Description
- NOTE: this function is currently not efficient enough for production use (owing to use of long multiplication and division). It is provided as an example of the use of callbacks from the ISR.
- If two servos are in use, couple or cross-couple their positioning. This only works if
NUM_SERVOS
is 2, and both servos are in closed loop mode.
- There are four possible sub-modes of operation, which depend on the slave0/1 parameters.
- Call this function with count0 or count1 zero, or both slave0 and slave1 zero, to exit from gear mode. When a servo that was slaved is set to normal mode, its velocity is set to zero.
Parameters
- count0
- Encoder increment for the first servo which results from count1 increments of the second servo.
- count1
- Encoder increment for the second servo which results from count0 increments of the first servo.
- Together, count0 and count1 determine the gearing ratio. Neither value should be set to a magnitude greater than about 500, to avoid internal arithmetic overflow. In any gear mode, the total movement of either servo should be limited to less than about 2M counts in either direction from the point at which gear mode was set. If a smaller range of movement is acceptable, then the maximum of either count parameter may be increased proportionally. The value of count0/count1 or count1/count0 should not have a magnitude greater than about 10 to avoid encoder quantization problems, especially in cross-coupled mode.
- slave0
- 1 if first servo slaved to second, else zero.
- slave1
- 1 if second servo slaved to first, else zero.
Library
- SERVO.LIB
See Also
- servo_closedloop, servo_torque
Dynamic C Functions | << Previous | Next >> | rabbit.com |