Binary Counter

The following program addresses the lower output bank as a group using the OL variable. A subroutine sets the Output group from a Register value, which is incremented each time the subroutine runs and then moves the motor based upon a multiple of the output group state.

When the register reaches a count of 15, a subroutine will run to reset it to zero, restarting the process.

The 4-bit binary number will display on the LED bank as the device counts up.

Enter “EX 1” into the terminal to run the program. The program will automatically begin to count up in binary, while the motor will move a distance that is a multiple of that count.

This illustrates the following functions:

1. The ability to output BCD via the I/O group.
2. The ability to use and manipulate numeric data and perform operations based upon that data.

'******Global Setup Parameters****   
S1=16,1,0	'O1-4 Set as GP, High Active, Sinking]
S2=16,1,0
S3=16,1,0
S4=16,1,0

'******Main Program*********
PG 1
LB aa
CL xx, R1<15 'Call sub xx R1 less than 15
CL zz, R1=15 'Call sub zz R1 equal 15
BR aa

'******Subroutines*********
LB xx          'sub increments R1, moves motor
R1=R1+1        'multiple of R1 value
Ol=R1          'sets output group to R1
H 1000
MR R1*100000
H
RT

LB zz          'sub resets R1 to 0
R1=0           'to restart process
RT
E
PG

 

Download Binary Counter .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