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:
- The ability to output BCD via the I/O group.
- The ability to use and manipulate numeric data and perform operations based upon that data.
- MCode OS
- MDrive Linear Actuator
- MDrive Plus
'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
'******Global Setup Parameters****
S1=16,1,0 'O1-4 Set as GP, High Active, Sinking
CL xx, R1<15 'Call sub xx R1 less than 15
CL zz, R1=15 'Call sub zz R1 equal 15
LB xx 'sub increments R1, moves motor
R1=R1+1 'multiple of R1 value
Ol=R1 'sets output group to R1
LB zz 'sub resets R1 to 0
R1=0 'to restart process
'keep this line