Trying to set up an 'afterrun' timer

MikeGyver

Senior Member
Hi guys, I just discovered these picaxe controllers and I'm trying to figure out some coding for a project.

My goal is to make an Outpin pulse high (only once) when power is lost at a pin, effectively creating an 'afterrun' timer.

Am I on the right track thinking I need to use the FOR...NEXT command and create a loop that runs only once? :confused:
 

hippy

Technical Support
Staff member
Your code could be pretty simplistic ...

1) Wait for power present
2) Wait for power not present
3) Pulse out pin high
4) Stop / Or repeat from beginning

That could in real code terms be ...

- Do : While pin0 = 0
- Do : While pin0 = 1
- PulsOut pin1, 100
- End

The exact code would depend on -

How long you need the out pin pulse for and what to do after issuing it.

Whether you want to pulse on an immediate loss of power or whether you want it be resilient to glitches where power may be lost but come back in a very short period of time.

Whether you want any delay after loss of power before the pulse is given.

You should certainly be able to do what you want with a PICAXE, you just need a more detailed and exact operational description of what it has to do.
 

MikeGyver

Senior Member
I just trying to get a single 10 second pulse at pin5 immediately when power is lost at pin1.

A short (100ms) buffer that would ignore any glitches would be nice to play around with, although it's probably not necissary.
 
Last edited:

Dippy

Moderator
Hasn't hippy given enough clues?
Do : While pin0 = 1
high
pause for 10 second
low

Why not stick a little R/C on the input to act as a debounce? That'll filter out some glitches.
 

hippy

Technical Support
Staff member
My mistake, should be "Do : Loop While pin0 = 1" and so on. Pin number will depend on your own hardware of course.
 
Top