Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

"sleep" timer idea with 4060 help

Status
Not open for further replies.

pigman

New Member
Hey guys I am trying to build a "sleep" timer that would basically set an output high as soon as a momentary pushbutton is pressed and hold it high for 6 hours, then releasing the output and remaining low until the pushbutton is pressed again.

After some research I came up with the 4060 timer IC however all I can seem to figure out is how to make the thing go high after the timed interval, IE high after 6 hours as opposed to what I need high straight away (on pushing "sleep button") and then back to low after the "sleep" time has elapsed.
This was helpful http://www.reuk.co.uk/Timer-Circuits-With-4060B.htm

any ideas or assistance is greatly appreciated. Cheers
 
hi,
Have you considered a HEF4013 dual F/F.

Latch High output on button press and Reset when the 4060, 6hr pin goes high.?
 
Interesting concept, I've also never used the HEF4013 :( hahaha I've been hiding under a rug. So on the button push it will trigger the 4060 timmer and the 4013's input which will hold the output high until either the button is pushed again (triggering the output to go low) or the 4060 timer ends and goes high?

If I understand the 4013 correctly it will trigger high and low on it's output with either a high to low or low to high trigger event or short pulse on it's input?
 
OK. I think I might have an option for a solution. I can use a HEF4070 XOR to take two outputs from the HEF4060 (Q4 and Q13). As the 4060 will set say Q4 high after ~80seconds followed by Q13 at ~6hours it will set the output of the HEF4070 high because while Q4 will be high Q13 will still be low. So the HEF4070 triggers the event and when Q13 comes high after the delay of 6 hours the HEF4070 will set the output low ending the event.

The delay of ~80seconds to starting the sleep mode is something that would be good to avoid tho, any ideas on how to bypass that?
 
Interesting concept, I've also never used the HEF4013 :( hahaha I've been hiding under a rug. So on the button push it will trigger the 4060 timmer and the 4013's input which will hold the output high until either the button is pushed again (triggering the output to go low) or the 4060 timer ends and goes high?

If I understand the 4013 correctly it will trigger high and low on it's output with either a high to low or low to high trigger event or short pulse on it's input?

hi,
The 4013 has direct Set/Reset pins, also the Clk can change the output state.
So I would, push button,,, restart the 4060 and Set the 4013 output high..
At the 6hr time the 4060 high out clocks the 4013 output low.
The 'D' input is connected to 0V.
 
Not sure what your desired accuracy is, but you can rig up a 6hour +/-1% timer using a single 60c 8-pin DIP microcontroller. If you're interested, I can program one up for ya.

If you need better accuracy, you can add a crystal to a slightly more expensive microcontroller.
 
dougy, Thats an interesting idea mate! would a 10F206 work? I ask because it is the cheapest one I can find :p. Maybe a programmed chip would be the best bet, smallest footprint, least number of components and can be programmed to do exactly what is needed :) it only needs to do the following:-

1. push button triggers an output to go high on a 6 hour timed delay. to go low after the timer ends and remain low until button is pushed again
2. IF push button is pressed during the timed delay 6 hour interval it will cancel the timed delay and return the output back to low. then rest waiting for the push button again
3. Would be awesome if there could be a second output that was always high but would pulse high and low when the timer mode is running, IE a power LED that is solid ON normally but flashes on and off when the timer is operating, say 1sec on 1sec off?

What do you think? Is that spec possible?
 
You must be working WA hours or something. Anyway, here's the files, .hex compiled for 10f206. I added a ~1second 'done' pulse at the end of the 6 hours on GP2 for a bell or something (or ignore it).

Pinout is as per c file:

PULSE GP0 // the output 6-hour pulse
ALIVE GP1 // alive LED
DONE GP2 // done pulses for a second at the end of the 6 hours
BUTTON GP3 // the input button - pull to VSS (GND) to start or stop the timing period

Best of luck & tell me if it works.
 

Attachments

  • 6hour-timer.hex
    959 bytes · Views: 136
  • 6hour-timer.c
    3.1 KB · Views: 160
Thanks heaps mate! One question will it work with a 12f675 for testing? I have a few of them laying around and can test it out today if it will. I will order the 10f206 today but won't see that till next week now :(
Cheers
 
No, it won't work as is for the 12f675.

I'll see what needs changing and see if I can get a new version to you.

Not sure if it will work - feel free to have a go though with the attached hex compiled for the '675
 

Attachments

  • 6hour-timer.hex
    918 bytes · Views: 139
Last edited:
dougy,

thanks for that mate, I'l give it a go now.
One quick question, I'm trying to compile the c file and I can find the stdint.h standard file using the picc.exe compiler in MPLAB however I think it is having trouble with the defined pic.h file? Is this a custom file you have or could you point me in the right direction to get the compiler working?

Thanks heaps.
 
Ok I've just tested the 12F675 hex you provided.
Here are the results

PWR on
* GP0 goes high
* GP1 flashes

GP3 Pushed (used 10k to VDD to float high so solid low push)
* GP0 goes LOW
* GP1 continues to flash

Would it be the 12F675 causing the issues? Or is there a problem in the program?

It should be

PWR ON
* GP0 stays LOW
* GP1 stays HIGH (no flashing)

GP3 Pushed
* GP0 goes HIGH (for 6 hours)
* GP1 flashes (for 6 hours) before going back to solid HIGH

Hope its just the 12F675 I/O's or something :(
 
It works fine with a 10f222 at this end. On powerup:
Nothing on: gp0 low, gp1 high

while holding GP3 to gnd: gp0 high, gp1 low
after release of GP3: gp0 high, gp1 flashing @~0.5Hz (this will keep going for a long time)

if pull GP3 to gnd again: gp0 low, gp1 high
on release, no change.

if pull GP3 to gnd & release: gp0 high, gp1 flashing

That's what I think you asked for. Sorry, I don't have any 12f675s around, but I'll have a quick look at the code to see what the changes should likely be & posted any corrections if I can find any.
 
Doughy, that's awesome! Thanks mate.

I think there is some tricks to the 12F675 to be able to use the MCLR pin as an I/O and whatnot (GP3) so probably some potential issues there maybe.

I just ordered a handfull of 10F206 and 10f222 chips in :)

Any ideas on the compiling issue? What C compiler do you use? and could I grab the pic.h and stdint.h files? Or a shove in the right direction on that :)
 
Yeah, I'm not sure. The usual problems are caused by forgetting to disable the analogue bits i.e. ADC and comparator, which take over the pins by default, but they're disabled. MCLR/GP3 is set as an IO pin in the config bits. Its pull-up is enabled in one of the first lines in the prog. Have you got a decoupling capacitor across the supply?

As far as compiling the c file, just use the MPLAB project wizard & select the appropriate part & toolsuite (HiTech PICC universal compiler - I'm using 9.82). The pic.h & stdint.h should be found automatically if this is done I think. Then press F10 and it builds.
 
hmm, I tried again with a new project and get the following. timer.c; 4.19 can't open include file "stdint.h": No such file or directory
I'm using v9.80
 
Strange. The only stuff I'm using from stdint.h is:

typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned long uint32_t;

EDIT: you can just paste that in place of the #include <stdint.h> line
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top