Sample Programs
DI-159 PLC Hardware Manual
Comment
Extends the example above to include two timers, each running at a precise, independent, and
different rate. Each timer indirectly controls the state of a peripheral, in this case the two gen-
eral-purpose LEDs.
Example #4 Flash Both LEDs and Digital Outs
Object
Flash both LEDs at precisely different rates, LED1 at four times the rate of LED0, and control
digital outputs DO0 and DO1 in the same way.
Code
200 let led0 = 0
210 let led1 = 0
220 let o0 = 1
230 let o1 = 1
240 configure timer 0 for 1000 ms
250 configure timer 1 for 250 ms
260 on timer 0 do gosub flash_led0
270 on timer 1 do gosub flash_led1
280 while 1 do
290 endwhile
300 sub flash_led0
310 let led0 = !led0
320 let o0 = !o0
330 endsub
340 sub flash_led1
350 let led1 = !led1
360 let o1 = !o1
370 endsub
'begin with both LEDs on
'
'begin with both digital outputs on
'
'configure first of four timers for 1 sec interval
'configure second of four timers for 1/4 sec interval
'execute subroutine "flash_led0" when timer0 fires
'execute subroutine "flash_led1" when timer1 fires
'do nothing while waiting for the timers to fire
'
'end up here when timer0 fires
'invert the state of LED0 (turn off if on, and on if off)
'invert the state of digital out 0 (turn off if on, on if off)
'return to waiting for timers to fire again
'end up here when timer1 fires
'invert the state of LED1 (turn off if on, and on if off)
'invert the state of digital out 1 (turn off if on, on if off)
'return to waiting for timers to fire again
Comment
Extends the example above to include two timers, each running at a precise, independent, and
different rate. Each timer indirectly controls the state of a peripheral, in this case the two gen-
eral-purpose LEDs.
Example #5 BASIC's Bitwise Expression
Object
Use BASIC’s bitwise expressions to change the state of the LEDs in binary-count order from
00 (off, off) to 11 (on, on) each time the general-purpose pushbutton is pressed. Also intro-
duces BASIC’s FOR/NEXT block statement.
73
Содержание DI-159
Страница 51: ...StickOS DI 159 PLC Hardware Manual 4 is even _ 51...
Страница 76: ...DI 159 Block Diagram 76...
Страница 77: ...Dimensional Drawing 77...