DI-159 PLC Hardware Manual
StickOS
If a pin is configured for digital output, then writing
varpin
with a 0 value will set the digital
output pin to a low level, and writing it with a non-0 value will set the digital output pin to a
high level. Reading the variable
varpin
will return the value 0 if the digital output pin is cur-
rently at a low level, or 1 if the digital output pin is currently at a high level.
Examples
As a simple example, the following BASIC program generates a 1 Hz square wave on the
"dtin0" pin:
>
10 dim square as pin dtin0 for digital output
>
20 while 1 do
>
30 let square = !square
>
40 sleep 500 ms
>
50 endwhile
>
run
<Ctrl-C>
STOP at line 40!
> _
Press
<Ctrl-C>
to stop the program.
Line 10 configures the "dtin0" pin for digital output, and creates a variable named "square"
whose updates are reflected at that pin. Line 20 starts an infinite loop (typically DI-159 PLC
programs run forever). Line 30 inverts the state of the dtin0 pin from its previous state -- note
that you can examine as well as manipulate the (digital or analog or servo or frequency) output
pins. Line 40 just delays the program execution for one half second. And finally line 50 ends
the infinite loop.
If we want to run the program in a slightly more demonstrative way, we can use the "trace on"
command to show every executed line and variable modification as it occurs:
>
trace on
>
run
10 dim square as pin dtin0 for digital output
20 while 1 do
30 let square = !square
let square = 0
40 sleep 500 ms
50 endwhile
20 while 1 do
30 let square = !square
let square = 1
40 sleep 500 ms
50 endwhile
60
Содержание DI-159
Страница 51: ...StickOS DI 159 PLC Hardware Manual 4 is even _ 51...
Страница 76: ...DI 159 Block Diagram 76...
Страница 77: ...Dimensional Drawing 77...