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 | '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 'Example program to show how to use one 'momentary input to toggle between 'different functions '****Declare Variables**** S1=0,0,0 'I/O 1 Input VA V1=0 'Declare Variable V1 VA V2=0 'Declare Variable V1 '****Program**** PG 1 LB P1 BR L1, I1=1 'Branch to Label L1 if Input 1 is active H 10 'Hold 10ms CL L4, I1=0 'Branch to Label L4 if Input 1 is active BR P1 'Loop back LB L1 'Set Output Routine H 10 BR P1, V2=1 'Only run sub on 1st iteration of Input CL L2,V1=0 'Call L2 if first toggle CL L3,V1=1 'Call L3 if second toggle V1=!V1+2 'Toggle Variable BR P1 'Return to Main Loop LB L2 SL 50000 'Jog V2=1 'Set active bit for debounce RT LB L3 SL 0 ' Close Position V2=1 'Set active bit for debounce RT LB L4 V2=0 RT E PG S 'keep line |