Binary Mask

This program demonstrates the ability to call eight subroutines using three digital inputs. Another feature includes an input change detection subroutine to avoid repeated prints to the terminal. A program similar to this would be useful when incorporating a thumbwheel switch or other BCD input device to execute desired program functions.

'*** 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

Download Binary Mask .mxt file
(color-coded in IMS Terminal)

[Return to Motion Control Sample Code Index]


IMS Logo Wide

370 N. Main St., P.O. Box 457
Marlborough, CT 06447 U.S.A.
Phone: 860 / 295-6102
Fax: 860 / 295-6107
Email: info@imshome.com

Contact

TECHNICAL SUPPORT (U.S.A.)
Phone: 860 / 295-6102
Fax: 860 / 295-6107
E-mail: etech@imshome.com

IMS ASIA PACIFIC OFFICE
30 Raffles Pl., 23-00 Chevron House
Singapore 048622
Phone: +65 / 6233 / 6846
Fax: +65 / 6233 / 5044
E-mail: wllee@imshome.com

IMS EUROPEAN SALES MGT.
4 Quai Des Etroits
69005 Lyon, France
Phone: +33 / 4 7256 5113
Fax: +33 / 4 7838 1537
E-mail: bmartinez@imshome.com

IMS UK Ltd
.
25 Barnes Wallis Road
Segensworth East
Fareham, Hampshire, UK  PO15 5TT
Phone: +44 / 0 1489-889825
Fax:: +44 / 0 1489-889857
E-mail: mcheckley@imshome.com

U.S.A. SALES OFFICES
Eastern Region 

Phone: 973 / 661-1270
Fax: 973 / 661-1275
E-mail: jroake@imshome.com

Central Region
Phone: 260 / 402-6016
Fax: 419 / 858-0375
E-mail: dwaksman@imshome.com

Western Region
Phone: 602 / 578-7201
E-mail: dweisenberger@imshome.com