{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fmodern\fprq1 Swiss;}{\f1\fmodern\fprq1\fcharset0 Swiss;}} {\colortbl ;\red0\green0\blue255;\red0\green128\blue128;} \viewkind4\uc1\pard\cf1\f0\fs24 'The following code takes an analog reading, \par 'places a "no-change" deadband on it and uses it to command \par 'a velocity to a given trajectory. \par \par \par 'The WHILE loop assumes a previous \par 'move or velocity mode has been issued. \par \par d=10\tab\tab 'this is the deadband in A/D counts of the analog signal\f1 (This can be tweeked to cancel electrical noise)\f0 \par o=512\tab 'this is an offset which allows negative swings in value\f1 (This helps center a POT if running bidirectional)\f0 \par m=40\tab\tab 'this is a multiplier used as a span adjust to the speed\f1 \f0 \par w=10\tab\tab 'this is the delay time between reads\f1 (this can be changed to tweek response time)\f0 \par \par \f1 A=1000\tab 'Set some accel (Note that this will alos change response to velocity change) \par MV\f0 \par \cf2 WHILE\cf1 1==1 \par a=UCA-o\tab 'take analog readiong of PORT C \par x=a-b\tab 'This is a way to check for changes in the \par \tab 'Pot value and give a deadband \par \par 'The following code waits until the analog value \par 'changes by +/- the deadband prior to sending \par 'a new SPEED to the motor. \par \cf2 IF\cf1 x>d\tab \par V=b*m 'multiplier for Pot input to position \par G \par \cf2 ELSEIF\cf1 x<-d \par V=b*m \par G \par \cf2 ENDIF\cf1 \par \par b=a 'update d for prevention of hunting in place \par WAIT=w \par \par \cf2 LOOP\cf1 \par END \par }