{\rtf1\ansi\ansicpg1252\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fmodern\fprq1 Swiss;}{\f3\fmodern\fprq1 Courier New;}{\f4\fswiss\fprq2 System;}} {\colortbl\red0\green0\blue0;\red0\green240\blue240;\red0\green0\blue255;\red0\green128\blue128;\red1\green1\blue1;} \deflang1033\pard\plain\f2\fs26\cf2 ' This is a 16 Position Pre-select Program \par ' It allows you to place 16 positions \par ' into an array and select them via \par ' binary coded 4 bit input. \par ' It has been set up as follows: \par 'Port A\tab binary bit 1 \par 'Port B\tab binary bit 2 \par 'Port C\tab binary bit 4 \par 'Port D\tab binary bit 8 \par 'Port E\tab Enable Input\tab \tab 'Program will look for it to be grounded \par 'Port F\tab Busy or Fault Output\tab (Goes high under any fault) \par '(Note, it has been set-up to go high durring move as well) \par 'Port G\tab Go Input\tab \tab (Starts Move) \par \par '--------------------------------- \par 'Setting up ports \par UAI\tab 'setting Port A as input \par UBI \par UCI \par UDI \par UEI \par UFO UF=1\tab 'Setting Port F as output (to 5VDC) \par UGI \par '--------------------------------- \par 'Example Data, numbers are in encoder counts \par v=100000\tab 'Example Speed \par a=1000\tab 'Example Accel \par al[0]=0 \par al[1]=1000 \par al[2]=2000 \par al[3]=3000 \par al[4]=4000 \par al[5]=5000 \par al[6]=6000 \par al[7]=7000 \par al[8]=8000 \par al[9]=9000 \par al[10]=10000 \par al[11]=11000 \par al[12]=12000 \par al[13]=13000 \par al[14]=14000 \par al[15]=15000 \par '--------------------------------- \par \par \plain\f2\fs26\cf3 WHILE\plain\f2\fs26\cf2 UEI==1 \plain\f2\fs26\cf3 LOOP\plain\f2\fs26\cf2 \tab 'Do nothing without enable \par \tab UF=1 \par \tab GOSUB0\tab 'Goto Home Subfunction \par \tab UF=0\tab \tab 'Set Port F to zero after reaching home. \par \par MP\tab \tab 'Positon Mode \par V=v\tab \tab 'Set Speed\tab \par A=a\tab \tab 'Set Accel \par P=0\tab \tab 'Set Command Register to position Zero \par G\tab \tab 'Go \par UF=1\tab \tab 'Set output on "busy" \par TWAIT\tab 'Do nothing until move is complete \par UF=0\tab \tab 'Set to zero after move. \par \par \par 'Main Program Loop \par '--------------------------------- \par \plain\f2\fs26\cf3 WHILE\plain\f2\fs26\cf2 Bo\tab \tab \tab \tab 'While motor is not off \par \tab \plain\f2\fs26\cf3 WHILE\plain\f2\fs26\cf2 UEI==1 \plain\f2\fs26\cf3 LOOP\plain\f2\fs26\cf2 \tab 'Do nothing without enable \par \tab \plain\f2\fs26\cf3 IF\plain\f2\fs26\cf2 UGI==0\tab \tab \tab 'If told to go \par \tab \tab GOSUB1\tab \tab 'Go to motor move subroutine \par \tab \plain\f2\fs26\cf3 ENDIF\plain\f2\fs26\cf2 \par \plain\f2\fs26\cf3 LOOP\plain\f2\fs26\cf2 \par '--------------------------------- \par UF=1\tab 'SET PORT F TO 1, ERROR OCCURED \par 'The above WHILE Loop is conditional to the status bit Bo. \par 'The is the Motor OFF Status Bit. There are only two reasons \par 'it would not be zero: The OFF command was used or there was an error. \par '--------------------------------- \par END \par '--------------------------------- \par '--------------------------------- \par C0 \par 'PLACE HOME SUBROUTINE CODE HERE \par RETURN \par '--------------------------------- \par \par '--------------------------------- \par C1\tab \par ' This sub looks at inputs and sends motor to proper position \par 'Generating a decimal number from a 4 channel input binary equivelent \par b=UBI*2\tab 'second bit \par a=UAI+b\tab 'adding first bit to it \par c=UCI*4\tab 'third bit \par d=UDI*8\tab 'forth bit \par p=a+c\tab 'adding bits together \par p=p+d \par P=al[p]\tab \tab \tab 'Setting Position command register value \par G\tab \tab \tab \tab 'Initiating move \par UF=1\tab \tab \tab \tab 'Activate Busy/error Output \par \plain\f2\fs26\cf3 WHILE\plain\f2\fs26\cf2 Bt\tab \tab \tab \tab \tab 'While buzy moving to commanded position \par \tab \plain\f2\fs26\cf3 IF\plain\f2\fs26\cf2 UEI==1\tab \tab \tab \tab 'If enable lost \par \tab \tab S\tab \tab \tab \tab 'STOP motor \par \tab \tab \plain\f2\fs26\cf3 WHILE\plain\f2\fs26\cf2 UEI==1 \plain\f2\fs26\cf3 LOOP\plain\f2\fs26\cf2 \tab 'Do nothing until enable returns \par \tab \plain\f2\fs26\cf3 ENDIF\plain\f2\fs26\cf2 \par \plain\f2\fs26\cf3 LOOP\plain\f2\fs26\cf2 \par \plain\f2\fs26\cf3 WHILE\plain\f2\fs26\cf2 UGI==0 \plain\f2\fs26\cf3 LOOP\plain\f2\fs26\cf2 \tab 'PREVENTS DOUBLE TRIGGER from Go signal sticking or left active low \par RETURN\tab \par '--------------------------------- \par \par \par \par \par \par \par }