# Timer project

Status
Not open for further replies.

#### Dannibou

##### New Member
I need a schematic circuit for a timer. I want it to power a relay for one second about 5 to 10 seconds after power is applied to the circuit. Any suggestions? Thanks.

#### gophert

##### Well-Known Member
When you say "one second", I assume you mean "about one second" which is about +/-10%.

How will this circuit be used? What application?

#### AnalogKid

##### Well-Known Member
That is two timers in series, one for the 5-10 second delay and one for the 1 second activation. There are many ways to do this. For starters, download and read the NE555 or LMC555 datasheet.

ak

#### Dannibou

##### New Member
I have the Forest Mims book about the 555 and it has a lot of diagram but not what I want. However, your suggestion about using a 556 seems logic. Tnx

#### Dannibou

##### New Member
Thanks Ramussons. The first link is exactly what I need but the second require a ground at pin 2. The first circuit give a + voltage at it's output. Should I use a transistor as an inverter between both circuits or if there is another way to do this?

#### gophert

##### Well-Known Member
Thanks Ramussons. The first link is exactly what I need but the second require a ground at pin 2. The first circuit give a + voltage at it's output. Should I use a transistor as an inverter between both circuits or if there is another way to do this?
You have to be careful because 555 tend to trigger when they are first powered up. Note the complaints in the comments section of the link provided above. Some circuits tend to trigger the first time it has been off for a while by work the second, third and so on while you are testing since the cap is charged to 1/3 of the supply voltage. Other circuits (variation on this theme) tend to do the opposite - not trigger at power up the first test but work fine for subsequent tests (unless it sits for a long time).

#### rjenkinsgb

##### Well-Known Member
How about a 4017 counter/decoder, with a free-running 555 running at about 1 Hz.
Use the next to last output (or earlier) as the timed signal and the last output to lock out the 555 so the whole sequence does not repeat.

eg. A transistor or FET that shorts the 555 pin 7 to ground when the last output goes high, or use a resistor in line with teh clock in to the 4017 and clamp the clock in pin with the transistor/fet.

You can reset the 4017 at power on with a simple RC circuit.

That should avoid any possible stray signals and guarantee a "clean" delayed output.

Last edited:

#### ronsimpson

##### Well-Known Member
How about a 4017 counter/decoder, with a free-running 555 running at about 1 Hz.
Using a 555, not shown, make a 1hz clock.
connect "9" and "clock inhibit" to stop the 4017 after 9 clocks.
Connect diodes, as shown at the top, to program when you want the out put to be on/off.

#### MikeMl

##### Well-Known Member
I need a schematic circuit for a timer. I want it to power a relay for one second about 5 to 10 seconds after power is applied to the circuit. Any suggestions? Thanks.
Trying to keep the parts count down...

here is something that would work with a 12V automotive "sugar-cube" relay which has a coil resistance of ~80 Ohms (or higher). The 555 always wakes up triggered. The initial delay is determined by R1-C1. The ~1s relay pulse comes from C2 and the base current of Q1. V1 and Ds simulate a make-break connection to a 12.7V power supply. Ds is required for the simulation just to make sure that C1 and C2 quickly reset for a new cycle. Reset time depends on the timer being a bipolar 555, not a CMOS one.

Can anyone else do it with only seven components (not counting the relay)?

#### Attachments

• 1.9 KB Views: 3
Last edited:

#### AnalogKid

##### Well-Known Member
How about a 4017 counter/decoder, with a free-running 555 running at about 1 Hz.
OR, a CD4060 amd no 555. The 4060 is an oscillator and 14-stage divider all in one chip. As with most CMOS parts, you will need an external transistor to drive any load over a few mA. The nice thing about the 4060 is that the capacitor used to set the output periods is 8000 times smaller than the equivalent capacitor for a 555 circuit. This eliminates leakage current and accuracy problems caused by the much larger value electrolytic capacitors.

If the delay is 8 seconds and the output is one second, the output decoding takes 3 small diodes.

1 - CD4060
1 - 2N7000 output transistor
3 - 1N4148 signal diodes
4 - resistors (one for power-on reset (POR))
3 - capacitors (one for decoupling, one for POR, one for timing

ak

#### gophert

##### Well-Known Member
To eliminate triggering on power-up, the RC filter is used.

A SPDT switch is used to turn off power so capacitors are immediately drained through the diodes in case you may need to retrigger the circuit again shortly after the first on-off cycle (or an interrupted cycle).

Blue trace shows left 555 which still fires fine immediately after an aborted cycle.

View attachment 114434

#### DrG

##### Active Member

Code:
#include <xc.h>
#define _XTAL_FREQ 4000000
#pragma config MCLRE = OFF, config CP = OFF, WDTE = OFF

void main(void) {
GPIO = 0b000000;
TRIS=0b111101; // GPIO1 as output

// wait 5 seconds
__delay_ms(1000);
__delay_ms(1000);
__delay_ms(1000);
__delay_ms(1000);
__delay_ms(1000);
GPIO = 0b000010; // Turn relay on
// wait 1 second
__delay_ms(1000);
GPIO = 0b000000; // Turn relay off
SLEEP();
return;
}

#### gophert

##### Well-Known Member
View attachment 114437
Code:
#include <xc.h>
#define _XTAL_FREQ 4000000
#pragma config MCLRE = OFF, config CP = OFF, WDTE = OFF

void main(void) {
GPIO = 0b000000;
TRIS=0b111101; // GPIO1 as output

// wait 5 seconds
__delay_ms(1000);
__delay_ms(1000);
__delay_ms(1000);
__delay_ms(1000);
__delay_ms(1000);
GPIO = 0b000010; // Turn relay on
// wait 1 second
__delay_ms(1000);
GPIO = 0b000000; // Turn relay off
SLEEP();
return;
}
And now he needs a programmer, instructions to download software, install, select microcontroller, compile your code, build a circuit so he can connect programmer to the chip, transfer said code to the PIC, then build the circuit you propose.

I'm not sure it is easier than using a few extra non-programmable parts. At the price of a PicKit, it certainly won't be cheaper.

#### DrG

##### Active Member
And now he needs a programmer, instructions to download software, install, select microcontroller, compile your code, build a circuit so he can connect programmer to the chip, transfer said code to the PIC, then build the circuit you propose.

I'm not sure it is easier than using a few extra non-programmable parts. At the price of a PicKit, it certainly won't be cheaper.
You certainly have a point and I expected somebody to raise that issue. I think that it all depends how you look at and the specifics of the individual's current and future needs...and interests.

On the face of it, however, it is certainly on-topic with regard to the TS's request.
I need a schematic circuit for a timer. I want it to power a relay for one second about 5 to 10 seconds after power is applied to the circuit. Any suggestions? Thanks.
1. "now he needs a programmer" - Yep, and he can expect to use it over and over again. If it is a modern programmer, let's say a PICKIT-4 he can pay some $40 is it? (maybe$30 on sale?). In that case, he can use it to program pretty much any pic around...and I think it has some debugging functions. If he can settle for a PICKIT3 [clone maybe] it is under $20 https://www.newegg.com/Product/Prod...Vk4qzCh29pA_lEAkYByABEgJURPD_BwE&gclsrc=aw.ds and there are programmers for under$10, like this one https://www.newegg.com/Product/Prod...Vk4qzCh29pA_lEAkYByABEgJURPD_BwE&gclsrc=aw.ds.

Of course, he can build one.

2. "instructions to download software, install, select microcontroller, compile your code" Again, yes, but that does not sound particularly brutal but does involve some clicking and cutting and pasting.

3. "build a circuit so he can connect programmer to the chip" Umm no, he simply makes the connections from the programmer to the PIC with no ther components - no need to do "in-circuit programming".

4. "then build the circuit you propose." Well, yeah, but he has to build the circuit that anyone proposes.

Here are some advantages. He can change from 5 sec after power up to 15 sec or 60 sec after power up in just a few minutes and then go back to 5 sec or 2 sec and so on and so forth...using the same 10F202. The same goes for the duration of relay on time. If he doesn't know exactly what those delays need to be in the end, he has a great deal of flexibility.

He can also specify those delays with a good deal of accuracy if he needs to - e.g., 12.3 seconds is really no more difficult than 12.0 seconds.

Then he could add more to it, if he wanted to, because he has unused GPIO (including some kind of safety feature to determine if the relay is stuck?).

For expense...well a pic10f202 is what, 50 cents? If he buys a \$10 programmer and makes 20 such projects...or similar ones...he is down to a buck a chip. The software can be free and includes an non-noptimized C compiler and a decent assembler and IDE (there are other options apart from Microchip).

But that is just for simple 10f202 projects - as you well know, there are a whole lot of other projects that can be done with a whole lot of different pics.

Again, I think that it depends on the individual's current and future needs (and whether they have any interest in a hardware programming approach, of course). So, that's my story and I'm sticking to it

BTW:

Although #pragma config MCLRE = OFF, config CP = OFF, WDTE = OFF builds and programs fine [mplabxide 5.05, xc8 1.45] it is supposed to be
#pragma config MCLRE = OFF, CP = OFF, WDTE = OFF

Last edited:

#### Nigel Goodwin

##### Super Moderator
For a cheap, and easy, solution how about the PICAXE, there's a nice small 8 pin version, and you just need a programming lead to program it - I presume you could even make a lead, for even less money (I imagine it's just an FTDI USB lead?.

#### Pommie

##### Well-Known Member
If we're considering programmable options than an Arduino Nano plus cable for a couple of pounds is all you need.

Mike.

#### AnalogKid

##### Well-Known Member
PDP-11's are cheap these days.

ak

#### rjenkinsgb

##### Well-Known Member
connect "9" and "clock inhibit"
I'd forgotten about the "clock inhibit" on the 4017, it's a very long time since I've actually used one for anything.