Remote Processing CAMBASIC User Manual

Page 204

Advertising
background image

Event Multitasking - 15

executed and then go low.

The PU LSE function r eturns the rem aining time of each stage. The exam ple below dem onstrates this.

10 PULSE 0,0,1,.05,1
30 A = PULSE(0):IF A=0 THEN STOP
40 PRINT A
50 GOTO 30

RUN

.03
.02
.02
.02
.01
.01
.01
5E-03
5E-03
5E-03

STOP

Operation o f a Multiple P ulsed Outpu ts
The real power of the PULSE operation comes when it is combined with the ON INP tasking statement and multiple timed
outputs are required. The application could involve pneumatic valves, injection molding steps or other sequence– oriented
operation s. T he following (lame) ex ample sim ulates a dru m time r by tur ning on outputs w hen a pr evious time d pulse is
complete. The job here is a bag sealing operation. A pre-heater is started and sealing head is brought down when the start
switch is pressed. After the pr e-heater is timed out, the heater is turned on fo r a second. The head is dow n for 4 seconds.
When the head is done, an interrupt is generated which moves the package to the next place. Opto rack positions 0-4 are
used to control a sealing head, pre-heater, heater, and pusher.

CONFIG PIO 1,0,0,0,0,0
'Detect start switch
ON INP 0,0,1,1 GOSUB ..start
'
'Detect emergency or STOP switch
on inp 1,0,2,2 gosub ..emergency
'
'Generate interrupt when head goes up
on inp 2,2,2,1 GOSUB ..headup
'
'Generate interrupt when pre-heat done
on inp 3,1,1,2 gosub ..preheat
'
'rest of program
'
'
..start
'Start switch was pushed. Now start sequence
bit 2,4,1

:'reset bag pusher

pulse 0,2,0,2,0

:'turn on pre-heat for 2 seconds

pulse 1,2,1,4,0

:'Bring down sealing head for 4 seconds

return
'

Advertising