Hi,
I have a beer bottle filler with a beverage flow meter and a valve to start and stop flow of beer into the bottle. The beer flow stops when the correct volume of beer has passed through the flow meter.
When a "programming" switch is cosed on power up the beer valve opens there is a setint command to use interupt and increment pulses from the flowmeter until the switch is open again. This is for the user to use the write command to store how much beer/how many pulses are to flow through the meter by filling a bottle and releasing the switch when the liquid reachs the right level in the bottle. The required volume for main use has been determined.
The program then has a main section where the interupt is used again to determine how many pulses there have been when the beer valve opens. When the incremented pulses exceed the number written to memory the beer valve closes.
The problem I have is that there are duplicate interupt labels even though the first interupt is not needed as part of the main program. Once the inital pulse count is done and written to the memory it is not part of the rest of the program and not needed. I could have 2 chips but is there a simple solution?
Many thanks
Phil
#slot 0
init: pause 500
Symbol Cylinder = b.1
Symbol CO2 = b.2
Symbol Purge = b.3
symbol Beerin = b.4
Symbol Startbutton = Pinc.1
Symbol Program = Pinc.4
Symbol Flow = pinc.0
Start:
low b.1
low b.2
low b.3
lowb.4
let b0 = 0
if Program = 1 then goto Preset ;preset the desired pulses/volume of beer
if Program = 0 then goto Main ; go to main filling program
Preset:
setint %00000001,%00000001,C ; interrupt when pinC.0 flow goes high
Preset2:
high B.4 ; switch output B.4 beerin high
if Program = 0 then goto Main
goto Preset2 ; loop back to start
interrupt: Let b0 = b0+1 ; increment b0 with each interupt
write b0, w2 ; write pulses to memory
setint %00000001,%00000001,C ; re-activate interrupt
return ; return from sub
Main:
If Pinc.1 = 1 then goto Main1
If Pinc.1 = 0 then goto Main
Main1:
setint %00000001,%00000001,C ; interrupt when pinC.0 goes high
Main2:
high B.4 ; switch output B.4 beerin high
goto Main2 ; loop back to start
interrupt: Let b1 = b1+1 ; increment b0 with each interupt
if b1 > w2 then low B.4:goto Main endif ;if current pulses exceed save memory pulses then turn off beer flow
setint %00000001,%00000001,C ; re-activate interrupt
return ; return from sub
I have a beer bottle filler with a beverage flow meter and a valve to start and stop flow of beer into the bottle. The beer flow stops when the correct volume of beer has passed through the flow meter.
When a "programming" switch is cosed on power up the beer valve opens there is a setint command to use interupt and increment pulses from the flowmeter until the switch is open again. This is for the user to use the write command to store how much beer/how many pulses are to flow through the meter by filling a bottle and releasing the switch when the liquid reachs the right level in the bottle. The required volume for main use has been determined.
The program then has a main section where the interupt is used again to determine how many pulses there have been when the beer valve opens. When the incremented pulses exceed the number written to memory the beer valve closes.
The problem I have is that there are duplicate interupt labels even though the first interupt is not needed as part of the main program. Once the inital pulse count is done and written to the memory it is not part of the rest of the program and not needed. I could have 2 chips but is there a simple solution?
Many thanks
Phil
#slot 0
init: pause 500
Symbol Cylinder = b.1
Symbol CO2 = b.2
Symbol Purge = b.3
symbol Beerin = b.4
Symbol Startbutton = Pinc.1
Symbol Program = Pinc.4
Symbol Flow = pinc.0
Start:
low b.1
low b.2
low b.3
lowb.4
let b0 = 0
if Program = 1 then goto Preset ;preset the desired pulses/volume of beer
if Program = 0 then goto Main ; go to main filling program
Preset:
setint %00000001,%00000001,C ; interrupt when pinC.0 flow goes high
Preset2:
high B.4 ; switch output B.4 beerin high
if Program = 0 then goto Main
goto Preset2 ; loop back to start
interrupt: Let b0 = b0+1 ; increment b0 with each interupt
write b0, w2 ; write pulses to memory
setint %00000001,%00000001,C ; re-activate interrupt
return ; return from sub
Main:
If Pinc.1 = 1 then goto Main1
If Pinc.1 = 0 then goto Main
Main1:
setint %00000001,%00000001,C ; interrupt when pinC.0 goes high
Main2:
high B.4 ; switch output B.4 beerin high
goto Main2 ; loop back to start
interrupt: Let b1 = b1+1 ; increment b0 with each interupt
if b1 > w2 then low B.4:goto Main endif ;if current pulses exceed save memory pulses then turn off beer flow
setint %00000001,%00000001,C ; re-activate interrupt
return ; return from sub