Countdown timer

dbarry722

Member
Hi folks.

I'm a members of our local inshore lifeboat crew (RNLI) and whilst out on exercise last week, came across an problem that with so much going on, has the potential to cause issues if not acted on.

Basically, every 15 minutes, the crew has to radio in to the coastguard an 'ops normal' call to let them know that everything is okay. Unfortunately, with the best will in the world, time can pass by quickly and what I was looking at was a way of developing a small countdown timer that will activate a flashing led and buzzer. This will be situated on the 'A-Frame' console that will be visible to the crew - especially the helmsman.

It needs to have a bright led indicating that the 15 minutes has elapsed plus it needs to have an audible sound plus needs to be relatively waterproof (or splash proof).

What I'd like to know is what is the best chip to use and what battery voltage would be best suited to working with the buzzer in terms of long life. Is it possible to build into the circuit a low battery led indicator for safety measures.

At the moment, I'm at the exploratory stages but have got good feedback from my colleagues. This circuit could also be used in our all weather boat but timing would be increased to 30 minutes

Many thanks

Declan
 

nick12ab

Senior Member
It needs to have a bright led indicating that the 15 minutes has elapsed plus it needs to have an audible sound plus needs to be relatively waterproof (or splash proof).

What I'd like to know is what is the best chip to use
...
This circuit could also be used in our all weather boat but timing would be increased to 30 minutes
08M2. An output for the LED, an output for the audible warning device and the remaining inputs can be used for switches which set the time.

and what battery voltage would be best suited to working with the buzzer in terms of long life. Is it possible to build into the circuit a low battery led indicator for safety measures.
It's not just a matter of voltage, but also current. However, if the voltage you are using is to be above 5V then you should use a switching regulator to convert this into the forward voltage of the LED(s) - probably 2.8-3.5V and this can also power the PICAXE.
 

boriz

Senior Member
Easy to do with a Picaxe. I'd suggest a 12v Gel SLA for power, unless you can connect to the boats power system? Built into a Tupperware box and bungeed under the dash.
 

hippy

Ex-Staff (retired)
Any PICAXE could do the job but it might be worth considering one which supports HPWM as that can produce two inverse signals which can drive a piezo sounder harder and louder. A MAX232 style driver can go even louder. A commercial outdoor klaxton may be best as you just need to provide a trigger signal.

For visual warnings; a commercial outdoor xenon strobe unit could be ideal.

Checkout what fire and burglar alarm equipment is available. You can get combined klaxtons and strobes.

For power supply; whatever best suits charging abilities back at base is probably best.
 

techElder

Well-known member
I made something one time that used the same batteries that the radios used. The group had many spare battery packs on charge all the time.

... For power supply; whatever best suits charging abilities back at base is probably best.
 

dbarry722

Member
Hi Folks.

At the moment, it really needs to be a self contained unit running off its own PSU until I would get permission from the powers that be to use the internal power system on the lifeboat.

I have a number of ideas but am going to start small with just an led and piezo buzzer. The potential is there to add in a mechanism such as an LED display to give a better visualisation of time remaining. Just need to work out power consumptions etcs.

Just managed to wangle the technology department into giving a bit of a hand. Its amazing what leverage you have when a dodgy HD is presented to you full off important files that need recovered :p

Declan
 

dbarry722

Member
Well folks..

Played around with a program we have in the school here (Circuit Wizard) and have been able to develop a circuit which seems to do what I want to do but then realised I had tripped myself up after looking back on previous post.

I thought Circuit Wizard was able to output the code for the program so that I could learn from it but alas not plus, it uses slightly different chips.

I have attached a pdf of the flowchart I created and was wondering if folk could give me a hand with the conversion to code. I've think I have got the concept correct. Okay, I could just leave as it and plug in a GENIE Pic and upload the flowchart to the Genie chip and all is done....but... I'm a glutton for punishment. I like to know what is actually going on.

The circuit is switched on and then a reset button is pressed to start the program which switches on a green led for 8 minutes then turns it off and switches to a yellow led. This starts the two subroutines flashing a slowish 1 second flash for 5 minutes then changes to a faster flash on the 2 minute sequence then changes over to a the flashing red led with peize buzzer. Pressing the reset switch restarts the program.


Just downloading the manuals as we speak.

Declan
 

Attachments

nick12ab

Senior Member
I have attached a pdf of the flowchart I created and was wondering if folk could give me a hand with the conversion to code. I've think I have got the concept correct. Okay, I could just leave as it and plug in a GENIE Pic and upload the flowchart to the Genie chip and all is done....but... I'm a glutton for punishment. I like to know what is actually going on.
Anything GENIE can do, PICAXE can do better (apart from the gimmickey polyphonic music).

Here's an untested conversion:
Code:
main:
    if pinC.3 = 0 then main
    high C.0
    wait 60
    wait 60
    wait 60
    wait 60
    wait 60
    wait 60
    wait 60
    wait 60
    low C.0,C.1,C.2,C.4
    gosub fivemin
    gosub twomin
    low C.0,C.1,C.2,C.4
jump:
    toggle C.2
    pause 200
    tune C.0, 8,($04)
    tune C.0, 8,($29)
    if pinC.3 = 1 then main
    goto jump

fivemin:
    for w0 = 0 to 300
        toggle C.1
        pause 1000
    next w0
    return
    
twomin:
    for w0 = 0 to 120
        toggle C.1
        pause 200
    next w0
    return
Change the pins the tune commands are on to whatever pins the GENIE uses.
 

dbarry722

Member
Hi Nick12ab.

Cheers. I've just been playing with your code and seems to work okay (changed wait values to shorter times for testing but do you know if there is a way of incorporating a master reset into the code?

One other question though.

Rather than switching the unit off to reset the program midway through a cycle, how would you incorporate code into the program in such a way that if the start/reset button is held down for 3 seconds, everything resets as if the unit was just switched on.

I've loaded Logicator onto my laptop and have created a flowchart which outputs the basic code so now I can reference flowchart to code which is great.

Regards

Declan
 

nick12ab

Senior Member
Cheers. I've just been playing with your code and seems to work okay (changed wait values to shorter times for testing but do you know if there is a way of incorporating a master reset into the code?
You could use 'goto main' or if you really need a master reset, the reset command.

Rather than switching the unit off to reset the program midway through a cycle, how would you incorporate code into the program in such a way that if the start/reset button is held down for 3 seconds, everything resets as if the unit was just switched on.
You could use the timer.:
Code:
if pinC.3 = 1 then
if timer = 3 then : reset : end if
else
timer = 0
end if
Place this code wherever you want to give this option.
 

hippy

Ex-Staff (retired)
You could use the timer.:
Code:
if pinC.3 = 1 then
if timer = 3 then : reset : end if
else
timer = 0
end if
Place this code wherever you want to give this option.
On a PICAXE M2 you can take advantage of multi-tasking and put that entire routine in a separate task and in a loop and it will be active no matter what the main program task is doing. That gives a sort of polled-interrupt routine without the interrupt.

Id change the 'IF timer = 3 THEN' to 'IF timer >= 3 THEN" just to be sure, in case the timer ever skips from 2 to 4 when that routine is not running. It shouldn't happen but then it doesn't matter if it does ...

Code:
Start1:
  Do
    If pinC.3 = 1 Then
      If timer >= 3 Then : Reset : End If
    Else
      timer = 0
    End If
  Loop
 

dbarry722

Member
Hi Guys..

What way do I fit that bit of 'reset' code into the program?

Many thanks

Declan



Code:
'BASIC converted from Logicator for PICAXE flowsheet:
'E:\PICaxe\RNLI Timer.plf
'Converted on 16/5/2012 at 13:32:27

symbol varA = b0
symbol varB = b1
symbol varC = b2
symbol varD = b3
symbol varE = b4
symbol varF = b5
symbol varG = b6
symbol varH = b7
symbol varI = b14
symbol varJ = b15
symbol varK = b16
symbol varL = b17
symbol varM = b18
symbol varN = b19
symbol varO = b20
symbol varP = b21
symbol varQ = b22
symbol varR = b23
symbol varS = b24
symbol varT = b25
symbol timer = time


let dirsC = %00010111


main:
label_71:
		if pinC.3 = 1 then label_4	'Decision command
		goto label_71

label_4:	high 0
		pause 10000	'Wait command
		low 0
		for varH = 1 to 3	'Do procedure 3 times
		gosub prc_MIN-5	'Do Procedure 
		next varH
		for varH = 1 to 5	'Do procedure 5 times
		gosub prc_MIN-2	'Do Procedure 
		next varH
		low 0
label_23:	toggle 2
		sound 0,(96,10)
		sound 0,(114,10)
		if pinC.3 = 1 then label_71	'Decision command
		goto label_23

prc_MIN-2:
		high 1
		pause 200	'Wait command
		low 1
		pause 200	'Wait command
		return		'Return 

prc_MIN-5:
		high 1
		pause 1000	'Wait command
		low 1
		pause 1000	'Wait command
		return		'Return
 

hippy

Ex-Staff (retired)
What way do I fit that bit of 'reset' code into the program?
If using an M2 PICAXE and taking advantage of multi-tasking, as per post #11, then simply create it under a new "Start" block as a parallel program / task in Logicator.
 

boriz

Senior Member
START needs more exposure in the manuals.

I can find START if I search for that word, but if I search for TASK assuming that will lead me to some explanation of Picaxe multi-tasking I get many references, but none to the START command.
 

nick12ab

Senior Member
Hi Hippy..

I added the code in but it just keeps going round in a loop without the rest of the program running.

Declan
Sorry for the late reply, I had completely forgotten about this thread but have just noticed that no one else has answered your question.

This could be caused by two things:
  • Failure to use '#simtask all' at the beginning of your program - this won't cause the program to not work correctly on the real PICAXE
  • Failure to use a separate start label for each task you want to run at the same time - this will cause the program to not work correctly on the real PICAXE
 
Top