'*** This program will demonstrate the ability to execute '*** various subroutines depending on the binary value '*** of inputs 1-3 while masking all I/O above Input 3. 'System Configuration S1=0,1 'set up IO points 1-4 and 9-12 as general purpose user S2=0,1 S3=0,1 S4=0,1 S9=0,1 'you need a plus2 unit to set S9-S12 S10=0,1 S11=0,1 S12=16,0 'set IO 12 as general purpose output D1=50 'debounce I1-I3 50mS D2=50 D3=50 Ms=256 'set global motion variables Vi=20000 Vm=1000000 A=500000 D=A Hc=20 Rc=75 'Main Program PG 1 LB Su R1=0 'R1 is used to store sub call number R2=0 'R2 is used for comparison to avoid looping calls. 'to same subroutine P=0 'set position counter to 0 LB g1 'ex gl starts program CL xx 'call binary read subroutine CL k0,R1=0 'Sub calls based on results of mask CL k1,R1=1 CL k2,R1=2 CL k3,R1=3 CL k4,R1=4 CL k5,R1=5 CL k6,R1=6 CL k7,R1=7 H 100 BR g1 E 'end of program '*** Subroutines LB k0 R2=R1 'Set R2 for wa sub comparison PR "Logic 000" MR 0*51200 'move 0 turns H H 100 CL wa 'label to wait until input change RT LB k1 R2=R1 PR "Logic 001" MR 1*51200 'move 1 turn H H 100 CL wa RT LB k2 R2=R1 PR "Logic 010" MR 2*51200 'move 2 turns H H 100 CL wa RT LB k3 R2=R1 PR "Logic 011" MR 3*51200 'move 3 turns H H 100 CL wa RT LB k4 R2=R1 PR "Logic 100" MR 4*51200 'move 4 turns H H 100 CL wa RT LB k5 R2=R1 PR "Logic 101" MR 5*51200 'move 5 turns H H 100 CL wa RT LB k6 R2=R1 PR "Logic 110" MR 6*51200 'move 6 turns H H 100 CL wa RT LB k7 R2=R1 PR "logic 111" MR 7*51200 'move 7 turns H H 100 CL wa RT 'Binary read and mask sub LB xx R1=In 'capture input value to register 1 R1=R1 & 7 'binary mask 00000111=7 H 200 RT 'Test for input change before return LB wa H 100 CL xx 'read binary inputs H 100 BR wa, R1=R2 'loop here if no input change H 100 RT PG S