30
T h e I O V a r i a b l e
After configuring the I/O by means of the IOS variable, we
need to be able to do two things with the I/O.
1]
Write to an output, or group of outputs,
thus setting or changing its (their) state.
2]
Read the states of either inputs or outputs.
We can use this information to either
display those states to our terminal, or to set up conditions
for branches and subroutine calls within a program.
In the example program in
IOS Exercise #4
we used both of these methods of
using the IO variable. First we used it to write to the state of I/O line 21,
which was set up as a general purpose output. Second, we used it to read the
state of I/O line 22, which was set up as a general purpose input, to call up a
subroutine within our program.
We can also use this command to write or read the state of an entire I/O
group.
R e a d / W r i t e a S i n g l e I / O L i n e
To read the state of a single input or output, the following would be typed into
the terminal:
PRINT IO 21
The response from this would be 1 or 0, depending on the state of the line.
The state of an input or output in a program can be used to direct events within a
MicroLYNX program by either calling up a subroutine using the “CALL”
instruction, or conditionally branching to another program address using the
“BR” instruction. This would be done in the following fashion:
CALL MYSUB, IO 22=1
This would call up a subroutine labled “MYSUB” when I/O line 21 is active.
BR 200, IO 22=0
This would branch to address 200 when I/O line 22 is inactive.
Writing to an output is accomplished by entering the following into a terminal or
program:
IO 21=1
IO 21=0
This would change the state of I/O line 21.
R e a d / W r i t e a n I / O G r o u p
When using the IO variable to read the state of a group of inputs/outputs or
write to a group of outputs, you would first want to configure the entire I/O
group to be general purpose inputs or outputs using the IOS variable. In this case
the response or input won’t be a logic state of 1 or 0, but rather the decimal
equivalent (0 to 63) of the 6 bit binary number represented by the entire group.
You can only use the IO
variable to write to
general purpose outputs!
If you attempt to write
to a dedicated output
type, or any input,
an error will occur!
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
Downloaded from
Downloaded from