MDrive Example Program
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | 'MDRIVE DEMO PROGRAM 'Last modified 08/25/2016 'Sample test program for demonstration purposes only 'Not tested or verified for safety or any function CP 'preclear program memory 'CODE DESCRIPTION 'Parameter Setup S1=2,0 'set input 1 as positive limit, low true S2=3,0 'set input 2 as negative limit, low true Ee=1 'enable encoder Sm=0 'have motor stop on a stall detect '=================================================== 'Program PG 1 'enter program mode at address 1 LB su 'reserved startup label OE j2 'on any error call sub j2 LB aa 'label aa Vm=30000 'set max velocity to 30000 steps/sec MA 102400 'move positive 102400 steps 'close switch at input 1 to 'stop motion in the positive direction 'and cause an error 83 'NOTE: PROGRAM CONTINUES TO EXECUTE 'leave switch open and program runs normal H 'hold program execution until motion complete H 250 'hold program execution for 250 millisecond MA 0 'move to absolute 0 'close switch at input 2 to 'stop motion in the negative direction 'and cause an error 84 'NOTE: PROGRAM CONTINUES TO EXECUTE H 'hold program execution until motion complete H 250 'hold program execution for 250 millisecond BR aa 'branch to label aa E 'end program '======================================================== 'On_Error Handler Subroutine LB j2 PR "Error " Er 'print the error BR se, Er=86 'if a stall jump to se BR lp, Er=83 'jump if limit plus to lp BR Ln, Er=84 'jump if limit minus to ln LB ue 'end program if error unknown PR "Undefined Error" PR "Ending Program!" E LB Ln 'limit minus - return to main pgm PR "Limit Minus" Er=0 'clear the error flag RT LB lp 'limit plus - return to main pgm PR "Limit Plus" Er=0 RT 'clear the error flag LB se 'stall detected - end pgm PR "Stall" PR "Ending Program!" E PG 'exit program mode 'hit "Esc" key to stop program |