Delay timer - will this work for a 2 second switch off delay?

I am trying to design a two stage 12v circuit on my breadboard which works like this:

  1. I turn on a toggle switch and 12v is supplied to two circuits (stage 1 and stage 2). When I turn the toggle switch off, I want the stage 1 circuit to turn off immediately, but the stage 2 circuit to stay live for about 2 seconds before powering off. This is to allow time for my arduino controlled circuit to save to EEPROM, then run a shutdown sequence to re-home stepper motors. The stage 1 circuit is pretty much just a signal so very low load, whereas stage 2 drives the whole Arduino board with LEDs and things, with a max load of around 2 amps.

After some research, I've come up with the following circuit:

A couple of questions:

  1. I'm planning to use this NPN transistor. It seems to work with 12v but it says the base to emitter is 5v - does this mean I can't drive it with a 12v signal like I have shown above?
  2. Is the circuit fit for purpose? It's just for test purposes at the moment to emulate a staged 12v supply I will have in my car at a later date so I'm trying to keep it as simple as possible...

You are not driving it with 12V, the 12V is applied to the 100k resistor, not to the transistor base, and the collector is not at 0V. Bi-polar transistors are current driven. The base - emitter voltage for a silicon transistor is about 0V6 when forward biased, as you have it. That you ask this question makes me think you need to learn Ohm's law - Wikipedia

The 5V base - emitter voltage will be for the B-E junction reverse biased. If you get 5V on the base with it forward biased then the transistor will work best in that round filing cabinet under your desk.

The configuration you have is called an emitter follower because the emitter voltage follows the base voltage minus the 0V6 B-E voltage drop, so the output will always be at least 0V6 below the collector voltage. You don't really need the resistor at all as the base current flows in the load via the emitter. Most of the load current will be from the collector, with a small contribution from the base. Because of this the time delay will depend to some extent on the load. Also note that the voltage at the emitter will fall away slowly, not suddenly drop to zero after some time period.

It would be wise to have a resistor to limit the charge current of the capacitor, as it is now the capacitor is dumped across the 12V supply when the switch is closed.

Is the circuit fit for purpose?

I doubt it, but build it and play around with it and see what it does, it is certainly fit for use to learn about transistors and Ohms law.

I don't think that circuit will work as you want it to.

I'm assuming that you are expecting the RC time constant of 100kΩ and 22μF (2.2s) to give you your 2 second delay.

However you have the transistor configured as an emitter follower.

An emitter follower has a high input resistance, so it will not discharge the capacitor as quickly as you were expecting. The output voltage going to stage 2 will follow the voltage on the capacitor and slowly drop off to zero, which is probably not desirable.

This might be a good circuit to slowly dim a lamp/LED.

I think you would be better with a circuit where an npn transistor drives a pnp transistor (or an n channel FET switching a p channel FET), this will give you a better switching speed.

You could even do away with the R and C, and get the Arduino to switch its self off after it has completed all its required tasks.

Thanks both for your input. The overall point of this circuit is that this will be used as a dash instrument pod. In the car, I will have two 12v feeds running to the pod, one which powers the pod, including LEDs, stepper motors, the aruduinos etc. The other is simply a signal from the power distribution system that the system is on. When the car starts, both lines will go high to turn on the pod. When the ignition is switched off, the signal line will switch off immediately, followed by the main pod power a couple of seconds later. In that time, the pod must re-home the steppers and various other functions before the power is cut, which is plenty of time and it works perfectly in the configuration I have currently working.

All I'm trying to do at the moment is build a little test PCB to function test the pod when it's not in the car, so I've stuck in some pots and toggles to replicate various inputs, but I'd like to build a simple circuit to replicate the 12v signals and how they will work in the car.

I see your point about the emitter following the voltage down - that's not going to be ideal as you both say! Would you mind sharing an example of a NPN driving a PNP as you mention to achieve a fast switching circuit?

Just sayin'.

Thanks Doug! These do look good, but I've got a board design that I'm about to get printed so I was hoping to be able to add a couple of simple components on there before I place the order to add the functionality on the same board. If I can do it that way then perfect.

On the actual car, the delay off will be controlled by a solid state power distribution unit where I can add control logic for this pretty easily.

Not sure what to suggest. You could search on your favourite search engine for monostable multivibrator, which is what you are trying to make. All the circuits I found use NPN transistors, but you will need PNP. Just mirror the circuit and swap positive for negative everywhere.

My favourite way of getting timeouts before micro-controllers was to use a CMOS 40106 hex Schmitt trigger with a resistor and capacitor. Also good for making oscillators.

However, I think what @JohnLincoln said is best:

Get the Arduino to switch its self off after it has completed all its required tasks.

To do this requires 2 transistors, ideally MOSFETs. This comes up on here sometimes, with people trying to do it with 1 transistor: It cannot be done with 1 transistor! Do some searching for the question and the solutions.

The Arduino already works great for how the car will work. I'm just trying to simulate how the car will work for my test board.

After some trawling of the interweb, I've come up with this hopefully slightly better circuit based on an NPN and a PNP transistor... Is this looking a little better??

It's better than the other one. I suggest you build it on breadboard and try it out.

I mentioned the CMOS 40106 in reply #7, do you happen to have any? That is still the device I'd use today if I wanted something like this, I just can't imaging wanting something like this now there are better things to use.

This is just a test board so I don't really want to spend any more time than I have to getting it to work and I don't understand how the other circuit you mention would work. This isn't about turning the Arduino off, it's just about being able to keep a 2A 12v supply live for 2 seconds after I turn off a toggle switch. The Arduino is already programmed to do everything it needs to do as soon as it sees one pin go low. It only needs a very short time to shut down, but the process of fading down LEDs, re-homing steppers and showing the exit splash screen on the OLED takes the time.

If the above circuit works then I will just use that as I can solder it pretty easily with some through hole components - it doesn't need to be elegant or perfect, just needs to do the job more or less :slight_smile:

There's a misunderstanding somewhere, I don't know if by you or me. In your OP you said:

So I think that means the Arduino circuit is powered off after about 2 seconds, but you've just said this is not about turning the Arduino off. Please clarify.

In any case:

If the Arduino is to remain powered then it can control the power to stage 2. This requires 2 MOSFETs, one P channel to switch the power and a low power N channel MOSFET to switch the P channel one.

If the Arduino is to be turned off then it can do this itself, this also requires 2 MOSFETs. This has been discussed many times on this forum, do some searching.

What I mean is, the Arduino will have no control over the power source in the car. The PDU will supply the dash pod with a ~2A supply which is used to power the complete pod, including 3 arduino boards, lots of LEDs, an OLED screen, 4 stepper motors, and a few other bits. When the ignition key is turned on, the PDU will enable this 12v supply which will cause the Arduinos to boot and start things up.

When the ignition is turned off, the PDU will first cut power to a signal wire (stage 1) which tells the Arduinos in the pod that main power is about to get cut and to initiate shutdown sequence. This involves not just super fast EEPROM updating but re-homing of the steppers, a LED fade sequence and a shutdown logo to be shown on the OLED.

What I'm building is a test board that can control the pod when not connected to the car to test and demonstrate its features. I have various pots, toggles and even another arduino to simulate various inputs, and it has a toggle to control the shutdown 12v signal. I'd like this same toggle to also control the main power to the pod and mimic the action of the PDU in the car, so both main power and shutdown signal go high when the toggle is turned on, then shutdown signal falls immediately followed by main power 2s later when it's turned off.

I think the circuit I have should do that?

Thanks. Somewhere along the line I misunderstood, thanks for the clarification.

I don't know. Try it. One of my pet things (apart from Simba, my cat) is that I strongly believe electronics is about experimenting and trying things out. There comes a time when it's time to stop asking questions and start plugging components into breadboard and finding out if they work the way you want. You have reached that point!

I would not build that circuit, I'd use whatever Arduino I had kicking around spare and use it to drive a MOSFET or 2 to give me the timed switching. However, I am not trying to put you off trying, go ahead and see if it does what you want, whether it does or it doesn't you will learn something useful.

1 Like

Yes that's very true... I will give it a try and see what happens.. If it all goes horribly wrong then it's only a test board so it doesn't matter too much. I think in this case I'm just rushing because of that fact... Thanks again for your help :slight_smile:

1 Like

Ok so I built it, have just tested it and when I turn the switch off, the stage 2 voltage falls pretty quickly. I tried doubling the resistance of the 100k resistor to 200k which I figured should double the delay, but no change from what I can detect. It's not a huge problem but I'd love to know if there's something I can do to fix it so it works as intended!

In post #8 your circuit has collector and emitter the wrong way round on the TIP2955. Collector goes to load for a switch (common emitter configuration), and as the TIP2955 is PNP it is correct for a high-side switch.

1 Like

The 100(200)k resistor is not what discharges the 22μF capacitor, the current into the base of the 2N2222A discharges it. The current is limited only by a 47R resistor and not much else. Transistors are current operated and it is that current that is discharging the capacitor. I would expect the capacitor to discharge so fast it might appear almost instant. For that circuit to have reasonably slow discharge times you need a MOSFET not a BJT. Hopefully you learnt something by making it.

I was following this example circuit which notes that R2 is the time governing resistor... I guess this is wrong then?

I tried switching the collector and emitter of the TIP2955 but that had no effect...

R2 will not have much effect on the discharge time of the capacitor and thus the timeout. R1 is in the discharge path from C1 and is a very low value. Q1 BE junction is a diode, so you have a 47R resistor in series with a diode discharging C1. Compared to 47R 100k is so high it might as well not be there. The circuit would work a lot better if Q1 was a MOSFET.

Do you understand RC time constant? Multiply R by C and you get a number called the time constant. The time constant is the time in seconds it will take to discharge the capacitor by about 63%. Unfortunately I can't remember where 63% comes from. I remember that when they taught me that at college it seemed 'obvious', but I've long since forgotten. Multiply 0.000022 by 47 and you will get a very small number. Rule of thumb is 5RC is how long it takes to discharge the capacitor completely. Rule of thumb because it's not true, the capacitor never discharges completely, but for most practical purposes 5RC is close enough. Multiply the number you got above by 5, I think you will find it's roughly how long the timeout lasts.

Homework: Search for information on RC time constant and see where the 63% comes from.

Play around with R1, but don't let it go any lower than it is. You can make it as high as you like.

Before micro-controllers, when I wanted a time out I used CMOS 40106 Schmitt triggers with RC circuits, they work very well.

Are you sure you didn't damage it?

1 Like

Thanks very much Perry, I think part of the problem here is that I'm trying as much as possible not to divert mental capacity to this problem as I'm spending most of my time developing the board that this is used to test. I was hoping for a quick off the shelf solution but it's not quite worked out that way!

I am I'd say "lightly" familiar with the RC constant as it's been a long time since I worked with such formulas too! I agree that it seemed odd to me too that R2 should be the time governing resistor but I trusted (hoped) that the referenced example was correct - perhaps the author meant to write R1?!

I'll have a go at switching out R1 and will see how it effects things. I'm pretty sure I didn't damage Q1 as I properly desoldered the old unit and replaced it with a new one but used some pliers to carefully bend the legs around each other and re-soldered. I think my mistake here was that the Eagle symbol didn't show the flow of current and I forgot it was PNP so the other way around!

Fingers crossed increasing R1 will solve it. I really should spend some proper time learning the details of transistor so I can properly diagnose the circuit or design it better from the outset, but I just don't have time unless I stop development on other aspects of the project that are more time critical.

EDIT: It works! It was R1 indeed. I now have R1 and R2 as 100k and it has a nice delay before it cuts the second 12v feed. Thanks very much for your help Perry and Mark!

1 Like