Hello !
This is my first post here. I'm quite new to PICAXE and i've been very enthusiastic so far. Please note that I live in France and my English is sometimes a bit lame. (yeah, I know, there is a french picaxe forum, but this one seems more active, and it helps me to practice my English...)
I've made a gadget in order to measure the time taken to solve a rubik's cube (a request from a friend)...
here it is, and as you can see, it works : http://www.youtube.com/watch?v=wi_8xX92SiQ (with a cup of water as a mass because I couldn't find any cube at the moment)
there is a moving plate and a spring, and a home made contactor made with 2 nice hemispherical brass nails. Hopefully they commute quite nicely and I haven't had too much bouncing so far.
I had to make it quick and easy, so i'm using a commercial chronometer instead of designing my own. Its buttons were hacked and replaced by opto-isolators, they works nicely.
so when the plate is low (with a mass on it) we have +Vcc on Input 1 of the 08M2. (I use 10k pull down resistors too), and 0v otherwise.
the goal is to make an impulsion on Output 2 when PinC.1 changes to 0, so i use an interrupt in this way. But i also want that it waits for the plate to be lowered once before starting immediately the chronometer at Picaxe start-up.
then the interrupt is changed to wait for a 0 to 1 change, whenever it happens another pulse is produced on PinC.2 to stop the clock, and after that the program loops and waits for reset.
Sometimes, there is a micro-bouncing on the contacts, or maybe dust, and the chrono fails to start, so it ends up running when the plate is low and stopping when it's high (the contrary of what's expected). To solve it, one may push the reset button (on pinC.3) for a longer moment, and the 08M2 is then sending a stop pulse on PinC.2 before the (two) reset pulses on pinC.4. This isn't very elegant, but does the job.
finally (hopefully !) here is the problem :
sometimes, the entire system just freezes completely. No response when moving the plate, and not either when pushing reset. I have to do a hard reset to solve the problem.
That's quite annoying, and it's happening often enough to be noticed. Besides, sometimes a reset doesn't solve the problem and I have to put power off and on twice. But I guess this is caused by the capacitor in parallel over the supply pins, which need a bit more time to discharge.
Could it be the result of the program interrupting constantly and backing to main although the interrupt cause wasn't cleared, when powering on for example ?
I would be very happy to hear suggestions to improve the program, as I said I'm a beginner.
Thanks a lot !
Jean-François
here is the program :
This is my first post here. I'm quite new to PICAXE and i've been very enthusiastic so far. Please note that I live in France and my English is sometimes a bit lame. (yeah, I know, there is a french picaxe forum, but this one seems more active, and it helps me to practice my English...)
I've made a gadget in order to measure the time taken to solve a rubik's cube (a request from a friend)...
here it is, and as you can see, it works : http://www.youtube.com/watch?v=wi_8xX92SiQ (with a cup of water as a mass because I couldn't find any cube at the moment)
there is a moving plate and a spring, and a home made contactor made with 2 nice hemispherical brass nails. Hopefully they commute quite nicely and I haven't had too much bouncing so far.
I had to make it quick and easy, so i'm using a commercial chronometer instead of designing my own. Its buttons were hacked and replaced by opto-isolators, they works nicely.
so when the plate is low (with a mass on it) we have +Vcc on Input 1 of the 08M2. (I use 10k pull down resistors too), and 0v otherwise.
the goal is to make an impulsion on Output 2 when PinC.1 changes to 0, so i use an interrupt in this way. But i also want that it waits for the plate to be lowered once before starting immediately the chronometer at Picaxe start-up.
then the interrupt is changed to wait for a 0 to 1 change, whenever it happens another pulse is produced on PinC.2 to stop the clock, and after that the program loops and waits for reset.
Sometimes, there is a micro-bouncing on the contacts, or maybe dust, and the chrono fails to start, so it ends up running when the plate is low and stopping when it's high (the contrary of what's expected). To solve it, one may push the reset button (on pinC.3) for a longer moment, and the 08M2 is then sending a stop pulse on PinC.2 before the (two) reset pulses on pinC.4. This isn't very elegant, but does the job.
finally (hopefully !) here is the problem :
sometimes, the entire system just freezes completely. No response when moving the plate, and not either when pushing reset. I have to do a hard reset to solve the problem.
That's quite annoying, and it's happening often enough to be noticed. Besides, sometimes a reset doesn't solve the problem and I have to put power off and on twice. But I guess this is caused by the capacitor in parallel over the supply pins, which need a bit more time to discharge.
Could it be the result of the program interrupting constantly and backing to main although the interrupt cause wasn't cleared, when powering on for example ?
I would be very happy to hear suggestions to improve the program, as I said I'm a beginner.
Thanks a lot !
Jean-François
here is the program :
Code:
low C.2
low C.4
b2=0
setint %00000000,%00000010
main:
pause 50
low C.2
low C.4
if PinC.1=1 then gosub activation
goto main
activation:
pause 50
if PinC.1=1 then
let b2=1
end if
return
interrupt:
if b2=1 and PinC.1=1 then gosub impufrontdescendant
if b2=1 and PinC.1=0 then gosub impufrontmontant
if b2=0 and PinC.1=1 then gosub attente
if b2=0 and PinC.1=0 then gosub attente
return
attente:
setint %00000000,%00000010
return
impufrontmontant:
high C.2
pause 60
low C.2
setint %00000010,%00000010
return
impufrontdescendant:
high C.2
pause 60
low C.2
let b2=0
setint %00000000,%00000010
do while pinC.3=0
pause 1
loop
pause 300
if pinC.3=0 then
high C.4
pause 50
low C.4
pause 50
high C.4
pause 50
low C.4
elseif pinC.3=1 then
high C.2
pause 50
low C.2
pause 50
high C.4
pause 50
low C.4
pause 50
high C.4
pause 50
low C.4
endif
do while pinC.1=0
low C.4
loop
return
Last edited: