DI-159 PLC Hardware Manual
StickOS
Frequency Output
Digital Output pins (Do0 to Do3) may be used as Frequency Outputs.
A pin is configured for frequency output, and a variable bound to that pin, with the following
statement:
dim
varpin
as pin
pinname
for frequency output
If a pin is configured for frequency output, then writing
varpin
with a hertz (Hz) value will set
the frequency output pin to the specified frequency. Reading the variable
varpin
will return the
output frequency, in hertz (Hz).
Example
The DI-159 PLC can perform frequency output as simply as digital I/O or analog input.
The following BASIC program generates a 1kHz square wave on a frequency output pin
“dtin0” for 1 second:
>
new
>
10 dim audio as pin dtin0 for frequency output
>
20 let audio = 1000
>
30 sleep 1 s
>
40 let audio = 0
>
run
> _
Note that frequency outputs are represented by integers in units of hertz (Hz).
Note that almost all statements that can be run in a program can also be run in “immediate”
mode, at the command prompt. For example, after having run the above program, the “audio”
variable (and dtin0 pin) remain configured, so you can type:
>
print "audio is now", audio
audio is now 0
>
let audio = 2000
>
print "audio is now", audio
audio is now 2000
> _
This also demonstrates how you can examine or manipulate variables (or pins!) at the com-
mand prompt during program debug.
64
Содержание DI-159
Страница 51: ...StickOS DI 159 PLC Hardware Manual 4 is even _ 51...
Страница 76: ...DI 159 Block Diagram 76...
Страница 77: ...Dimensional Drawing 77...