User Manual

MCP Series
Brushed DC Motor Controllers
MCP Series User Manual
157
DIST2
Syntax
dist speed1,accel1,distance1,speed2,accel2,distance2,buffer
Speed1 & Speed2 - is a variable, constant or expression that sets the speed to run the
motor at.
Accel1 & Accel2 - is a variable, constant or expression that sets the acceleration/decceleration
to use when the motor speeds up or slows down to the specied speed.
Distance1 & Distance2 - is a variable, constant or expression that species the distance
to move the motor.
Buffer - is a variable, constant or expression that determines if the command will be buffered(0)
or execute immediately(1) overriding any currently running command on the motor.
Description
The DIST2 command is used to control both motors using encoders with a Velocity PID control
algorithm. The user must have tuned the Velocity PID settings for both motors before using the
DIST2 command. With a properly tuned Velocity PID accurate relative movments can be made
by the motor. Note that multiple DIST2 commands can be chained together by buffering the
commands. As each command nishes the next will start executing.
;code assumes the velcoity PID settings for the motors are correctly tuned.
main
dist2 12000,12000,12000,-12000,12000,12000,0
dist2 -12000,12000,12000,12000,12000,21000,0
;wait until second command has started to execute and repeat
while(MOTORBUFFER(0)&0x7F<>0)
wend
goto main