User Manual

MCP Series
Brushed DC Motor Controllers
MCP Series User Manual
156
DIST
Syntax
dist motor,speed,accel,distance,buffer
Motor - is a variable, constant or expression that species which motor to access.
Speed - is a variable, constant or expression that sets the speed to run the motor at.
Accel - 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.
Distance - 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 DIST command is used to control a motor using an encoder with a Velocity PID control
algorithm. The user must have tuned the Velocity PID settings for the motor before using the
DIST command. With a properly tuned Velocity PID accurate relative movments can be made
by the motor. Note that multiple DIST 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 specic motor are correctly tuned.
main
dist 0,12000,12000,12000,0
dist 0,-12000,12000,12000,0
;wait until second command has started to execute and repeat
while(MOTORBUFFER(0)&0x7F<>0)
wend
goto main