29
(1 revolution for a 1.8° stepper motor with the MicroLYNX at the default
microstep resolution of 256), the LED will illuminate for 2 seconds, turn off, and
the process will repeat itself until the escape key is pressed.
At this point you will want to clear and restore your MicroLYNX, this is done
by entering the following in the terminal window:
CP 1,1
DVF ,,1
IP
IOS Exercise # 4: Setting a General Purpose Input
In this next example we will build on the last one and do something a little more
complex. In this example the program will run as in the previous one except we
will add a subroutine that will change the delay from 2 seconds to .5 seconds and
move the motor 25,700 microsteps in the opposite direction, repeating this until
the switch is released.
Enter the following program into the text editor window of the LYNX Termi-
nal software:
IOS 21 = 0,1,0 'set I/O line 21 = gen purpose out, active low
IOS 22 = 0,0,1 'set I/O line 22 = gen. purpose in, active high
PGM 200 'start program at address 200
LBL IO_TEST2 'name program IO_TEST2
CALL ON_IN, IO 22=1 'call sub ON_IN when I/O 22 is active
MOVR 51200 'index to relative position 51200
HOLD 2 'suspend program until motion completes
IO 21 = 1 'set I/O line 21 active
DELAY 2000 'wait 2 seconds
IO 21 = 0 'set I/O line 21 inactive
BR IO_TEST2 'loop to beginning of program
LBL ON_IN 'declare sub ON_IN
MOVR -25700 'index 25,700 in neg. direction
HOLD 2 'suspend program until motion completes
IO 21 = 1 'set I/O line 21 active
DELAY 500 'wait 0.5 seconds
IO 21 = 0 'set I/O line 21 inactive
BR ON_IN, IO 22=1 'loop to ON_IN while I/O line 22 is active
RET 'return from subroutine
END
PGM
Download the program to your MicroLYNX. Test its operation by entering
“EXEC 200” or “IO_TEST2” in the terminal window. The motor and LED
should operate as it did in the previous example, however, when you depress and
hold the switch, the motor will move half a revolution in the opposite direction
and only delay 0.5 seconds between moves. This should repeat as long as the
switch is held. When released the MicroLYNX should return to the main program
and execute it until either the switch is depressed again or the escape key is struck.
Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.Downloaded from Arrow.com.