
28
I O S E x e r c i s e # 2 B : S e t t i n g a D e d i c a t e d I n p u t A c t i v e H i g h
In this example we are going to use the same
type of switch and LED configuration as in the
previous example,
except
, instead of connecting
the switch between I/O 22 and I/O GND, we
will connect the switch between I/O 22 and V
PULL. As before, we will use the switch to Soft
Stop the motor.
Connect the switch as shown. Since we will be
pulling the I/O line to +5VDC using the push
button switch to activate it, we move the pull-
up switch for line 22 to the OFF position.
Enter the following into the terminal:
IOS 22 = 10,0,1
As before, the line is a Soft Stop (10) input (0), only this time we have set it to be
active HIGH (1) instead of LOW, now the line will be active when it sees +5V.
Slew the motor to test the setup. When the switch is depressed the motor should
stop and the LED
turn off
.
Leave the LED and switch connected for the next two examples.
I O S E x e r c i s e # 3 : S e t t i n g a G e n e r a l P u r p o s e O u t p u t
In this example we are going to use the LED connected to I/O line 21 and write a
small program that will cause the LED to illuminate following a short move,
wait for two seconds, turn the LED off, then repeat.
Enter the following program into the text editor window of the LYNX Terminal
software. It isn’t necessary to type in the comments, which are preceded by the
apostophe (‘). These are there to explain each line of code. In actual program
development they are a troubleshooting aid.
IOS 21 = 0,1,0
'set I/O line 21 = gen. purpose out, active low
PGM 200
'start program at address 200
LBL IO_TEST
'name program IO_TEST
MOVR 51200
'index to relative position 51200
HOLD 2
'hold program execution 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_TEST
'loop to beginning of program
END
PGM
When completed, download the program to your
MicroLYNX by clicking the menu item “Transfer > Down-
load” on the LYNX Terminal’s menu bar. Select “Edit Win-
dow” as the source type on the download dialog, click down-
load. The program will transfer to your MicroLYNX.
Test your program by entering “EXEC IO_TEST” into the
terminal window. The motor should move 51200 microsteps
These small example programs
also serve to introduce you
to the LYNX programming
language. They introduce common
commands that will be covered
later in this document
I/O LIN E 22
P U S H B U T TO N
S W IT C H
V P U L L
Figure 8.5: IOS Exercise #2B
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from