Yes, you're right, there is also a problem of understanding each other as my explanations are not very clear.
here is the code what I use... of course there is a return which would finally be hit after the interrupt, but it is in attente1 or attente2, not directly in the interrupt, that's what I was trying to say :
Code:
#PICAXE 08M2
SYMBOL CubeDetect = pinC.1
SYMBOL CubeReset = pinC.3
SYMBOL StartStop = C.2
SYMBOL TimerReset = C.4
SYMBOL CubeOn = 1 ; when cube is on the plate
SYMBOL CubeOff = 0 ; when the plate is empty
SYMBOL Delai1 = 20
SYMBOL Delai2 = 10
Init:
low StartStop
low TimerReset
b2=0
setint %00000000,%00000010 ; interrupt on Input C.1 (CubeDetect) low/off
main:
DO
pause 50
low StartStop
low TimerReset
IF CubeDetect = CubeOn AND b2 = 0 THEN
PAUSE 50
IF CubeDetect = CubeOn THEN
b2 = 1
ENDIF
ENDIF
LOOP
interrupt:
IF b2= 0 THEN attente1
if CubeDetect = CubeOn then
pause Delai2
if CubeDetect = CubeOn then impufrontdescendant
goto attente2
endif
if CubeDetect = CubeOff then
pause Delai1
if CubeDetect = CubeOff then impufrontmontant
goto attente1
endif
attente1:
setint %00000000,%00000010 ; interrupt on Input C.1 low
return
attente2:
setint %00000010,%00000010 ; interrupt on Input C.1 high
return
impufrontmontant:
high StartStop 'start chronometer
pause 60
low StartStop
setint %00000010,%00000010 ; interrupt on Input C.1 high
return
impufrontdescendant:
high StartStop 'stop chronometer
pause 60
low StartStop
do while CubeReset = 0
pause 1
loop
pause 300
if CubeReset= 1 then ; test if it is a longer reset press
high StartStop
pause 60
low StartStop ; if so activate the start stop again
pause 50
endif
high TimerReset
pause 60
low TimerReset ; now reset the timer
pause 50
high TimerReset
pause 60
low TimerReset; and a second time to be sure
do while CubeDetect = CubeOff
low TimerReset
loop
let b2=0
setint %00000000,%00000010 ; interrupt on Input C.1 low
return
thank you again for the interest you have on this topic, I find this very interesting because it helps to get all the tricks (and also some basics that I lack) of picaxe programming, but don't worry too much as the whole gadget is working properly... Delai1 and delai2 are delays I added for debouncing the switch.
Thanks ! JF
Bookmarks