Delay switch that really switches off

cpedw

Senior Member
My challenge here is with limited electronics understanding; the picaxe aspect is quite straightforward.

The objective is a 12V DC switch that stays on for a short time (order of 3 minutes) then switches off, completely disconnecting the timer circuit as well as the load. It's a light switch on a sailing boat; the light is in an obscure locker and leaving the light on could go unnoticed for a long time, dangerous for the battery. The timer circuit must also be disconnected completely when not in use to protect the battery.

I have attached an outline circuit that I thought would work.
View attachment Delay Switch concept.pdf
Pressing the momentary switch powers the 5V regulator for the Picaxe which has a very simple program:
Code:
high 2
pause 3 minutes
low 2
This latches power to the picaxe and the load for the required time, then switches the load and the picaxe off at the MOSFET.

The trouble is, the off switching doesn't work. Using a 2N7000 or STP36NF06L, the gate voltage doesn't fall low enough to switch off. Is this a fundamental flaw of the design or is the concept sound but with a problem in the detail?

I have found a module on ebay that can achieve my initial objective but I'd like to understand what is wrong with this idea.

Derek
 

AllyCat

Senior Member
Hi Derek,

No, that configuration is unlikely to work because you're using the FET as a "Low-side switch". When it attempts to turn off, its output rises towards the 12 volt supply and switches the gate back on again (there is an internal "protection" diode from ground to each of the output pins). The output (and hence the regulator and PICaxe earths) must rise close to 12 volts for no current to flow! With a 12 volt supply you also need to be careful that you don't destroy the (maximum 6 volt rated) PICaxe.

The solution is not easy because the regulator alone would draw too much continuous current from the supply, in most cases more than a PICaxe! Basically you need a "High Side Switch" (directly in series with the 12 volt supply), typically a relay or a PNP transistor. But the PNP cannot be driven directly by a PICaxe pin, so you need an NPN or N-channel FET (as you have now) to isolate the PNP gate (at 12 volts) from the maximum 5 volts on the PICaxe.

This has been discussed several times on the forum, so we can probably find one of those threads if you need more help.

Cheers, Alan.
 
Last edited:

The bear

Senior Member
Hi,
pause 3 mins? Try pause 30000

pause 30000mS = 30 secs, you can increase that when you have it working.

Good luck..
 

erco

Senior Member
Mosfet, schmosfet. Slap in a 5V reed relay, 20 mA or less driven directly by a picaxe pin and be done with it. That coil current is chump change compared to what your light is drawing. Zero leakage, low on power, no voltage drop, 100% full off, good for hundreds of thousands of cycles.

I've used these many times lately in circuits powered by 4.5V, 3xAAA batteries. 10 mA coil!

https://www.ebay.com/itm/10pcs-New-original-SIP-1A05-reed-relay-5V-Voltage/191674316313

https://datasheet.lcsc.com/szlcsc/SIP-1A05_C10496.pdf

Disconnects everything, including the Picaxe. My momentary "on" switch just shorts the relay contacts to turn everything on, and as soon as the Picaxe boots up it turns the relay on to keep power applied. For power off, just turn the relay off. Perfect.

Seems like a waste of a Picaxe, BTW. With 5 minutes of experimenting you could whip up a 4-cent 555 timer one shot circuit to turn the relay on for 3 minutes. Nice big RC.
 
I have to agree that the above solution with a reed relay, providing it can handle the current required for the light, is the way to go for low cost, especially with a 555 timer (the CMOS version can give even longer delays I think than the standard version).

The advantage of an 8M2 is its programmability: you can easily change the time delay, flash the light a few times before switching off, or other features that might be useful?

Having wanted to do much the same thing myself recently I came up with this:
Latching relay circuit 01.JPG

Sorry if it looks a bit daunting, but the idea is to check the battery voltage is safe before allowing the light to be switched on, or to switch it off if it falls below a critical value.

It can be greatly simplified to this though:
Latching relay circuit simple.JPG
The essence of this circuit is the latching relay, this particular version is a two-coil type (e.g. 12V Coil Bistable Latching Relay DPDT 2A 30VDC ) which only requires a short pulse on either coil to set or reset it. The actual pulse length will depend on the particular relay. Although I've recently bought some like this I haven't tried them yet, but another latching relay responded to 10ms pulses, but I will use 50ms in the final program to be safe. I'd suggest doing a few tests to see how short a pulse can be used and then use 5x times that?

The programming is very simple: when it powers up, put out a suitable length pulse on the SET coil circuit to latch the power to the 8M2 and the light or whatever, and then when it's timed out, another pulse to the reset coil. If you did want to flash the light, maybe add a biggish capacitor to the +5V supply to keep the 8M2 alive for a second or two so that it can switch the power back on again after switching off for say, half a second. Once switched off for several seconds and the 5V power has decayed, the only way of getting it back on again will be the push button.

These relays have the added benefit that they don't take any current at all once switched, and this particular one can switch up to 2A. Higher current ones are available. They also come in single coil variants where a short pulse on the coil switches it either on or off. This type would save on a couple of other components but the relay itself might cost more.

The n-FETs can be tiny TO-92 type devices (e.g. 2N7000) which should easily handle the coil currents, or cheap NPN transistors (e.g. 2N3704 with a 4k7 or so resistor to the base from the 8M2 o/p) would be equally suitable. Food for thought anyway.
 
Last edited:

rq3

Senior Member
It's a light switch on a sailing boat; the light is in an obscure locker and leaving the light on could go unnoticed for a long time, dangerous for the battery.

Derek
Does the door of the locker get closed religously, or could it be spring loaded to do so? If yes, a microswitch on the door jam would fix the whole issue. Of course, there's no picaxe involved, so not as much fun!
 

erco

Senior Member
This is what I did (hacking sghioto's sketch). Relay could use a backfire diode across the coil, and replace R1 with 10k/22k download circuit resistors.
 

Attachments

Just checking, is the light really only 180mA? That's only about 2W which is probably about right if it's a fairly low power LED, but it sounds a bit low to me?
 

cpedw

Senior Member
Thanks for all the interesting contributions. It seems my original concept is fundamentally flawed so I will go with an ebay timer relay for simplicity https://www.ebay.co.uk/itm/252978657790 and cheapness. I still have 3 08Ms (not 08M2) in my bits box; I can't seem to get rid of them usefully! I was also hoping to avoid relays because of the moving parts/corrosion considerations. Time will show how the ebay cheapie copes with the environment...

I considered a switch in the hatch frame to do the job automatically but getting a waterproof one is difficult. Mounting the switch inside it only needs to be splashproof.

The light is a strip of LEDs; 200mm uses 180mA and gives enough illumination.

I know bit more about electronics. Thanks again.

Derek
 
A search on eBay for "waterproof project box" reveals a massive choice of cheap enclosures (from China mostly) at very reasonable prices. The best ones have a gasket in a groove in the lid. You'll need to seal any cable exits but there are good cable glands for that.
 

AllyCat

Senior Member
Hi,

I still have 3 08Ms (not 08M2) in my bits box; I can't seem to get rid of them usefully! I was also hoping to avoid relays because of the moving parts/corrosion considerations.
Most relays are sealed or encapsulated now, and of course reed relay contacts are totally moulded within a glass sleeve, so contact corrosion shouldn't be a problem. Also it's hard to compete with ebay/China prices (if you're patient).

BUT if the PICaxe is "free" (surplus to requirements) then you only need to "rearrange" your original design and add a (low power) PNP transistor and one or two resistors. Basically the design shown in #6 without the relay (note the comment to use either a relay or the PNP). Or, as said above, if the relay option is chosen, then a "flywheel" diode across the coil would be wise.

Cheers, Alan.
 

StefanST

New Member
BUT if the PICaxe is "free" (surplus to requirements) then you only need to "rearrange" your original design and add a (low power) PNP transistor and one or two resistors. Basically the design shown in #6 without the relay ...
You can replace the switch with a waterproof version: You can switch the reed switch (Ø2x10mm) in a heat shrink sleeve with a small piece of permanent magnet.

Note: Your timer from China is a 555 based timer with an electrolytic capacitor in the timing circuit. It is not the best solution for long times, wide temperature range and long-term stability.
 

Billo

Senior Member
I think an MCU is a bit of overkill for this. You could easily do this with just a switch, cap, resistor, mosfet and a small relay. Pot the whole thing in silicone.

timer.jpg
 
Last edited:

Billo

Senior Member
Note: Your timer from China is a 555 based timer with an electrolytic capacitor in the timing circuit. It is not the best solution for long times, wide temperature range and long-term stability.
He's putting the timer on a compartment light so it does not stay on too long or get forgotten. How much stability and precision does he need? I think even a 555 is overkill.
 

newplumber

Senior Member
Hi
I like all the cool answers/shematics here ...so for fun and just to make sure I'm "following some track" ... I seen the word "compartment" and the word "timer"
so I added/drawn my thought ... :)
but for reals I like the reed relays ...seem pretty cool
 

Attachments

Dartmoor

Member
I might be missing the point but the talk of reed relays & waterproof door switches makes me wonder why not just use a reed switch & magnet (eg SEN055 from Picaxe store) on the door?
Switch sealed in glass and nothing else needed except for battery & LED light.
 

cpedw

Senior Member
I think an MCU is a bit of overkill for this. You could easily do this with just a switch, cap, resistor, mosfet and a small relay. Pot the whole thing in silicone.

View attachment 21773
Your circuit does what I originally sought; even simpler, it works substituting the load in place of the relay.

I'm also now considering Dartmoor's recommendation. I don't know why I didn't think of a reed switch although a Normally Closed (switch is On with no magnet) is a bit difficult to find.
 

AllyCat

Senior Member
Hi,

a Normally Closed (switch is On with no magnet) is a bit difficult to find.
"Change Over" reed switches do exist, with the "Normally Closed" contact made of a non-magnetic material.

However, an alternative method is to "bias" the reed switch with a fairly weak fixed magnet beside it, and then the moving magnet would be oriented to cancel out the bias field. Many years ago this was done for "Normally Closed" reed relays, but might be quite difficult to engineer reliably.

Cheers, Alan.
 

techElder

Well-known member
+1 Alan.

I remember a piece of equipment that had a reed switch and a bias magnet enclosed axially in a plastic tube sized for a friction fit of the magnet. Then the moving magnet moved nearer to the bias magnet thus drawing the bias field away from the reed switch.

I would try laying the bias magnet with the reed switch in half of a split length of tubing. Adjust for N.C. then glue and shrink tubing around to hold it in place.

Anyway, like Alan says, there's some engineering involved depending on your layout, but I've seen something similar work.

Code:
{[B]N[/B].moving magnet.[B]S[/B]} <-----> {[B]N[/B].bias magnet.[B]S[/B]}<-adjust for N.C.->{reed switch}
 

mikeyBoo

Senior Member
No Need to Re-invent the Wheel

Take a look at this link. It’s a motion detector that draws ~50uA until triggered. You can directly power it from +5 to +20v & hook up to 20W of LED lighting to it. If you’re concerned it may be triggered in daylight, it has a night-only option.
You can spray the board with clear acrylic if corrosion from moisture is a problem.
Handy for boat-related stuff (e.g. you want light to come on when someone gets on boat or enters storage shed)

Cheap & Easy Motion Detectors/Night Light Controllers (Picaxe or Stand-alone)
http://www.picaxeforum.co.uk/showthread.php?28233-Cheap-amp-Easy-Motion-Detectors-Night-Light-Controllers-(Picaxe-or-Stand-alone)
 

mikeyBoo

Senior Member
Hmm&#8230; Just thought of another cool boat project I&#8217;d like to see: A beeper that sounds when the ignition keyswitch is off & the battery is sourcing excess current. (i.e. Solution for leaving stuff left turned on by accident). After a dusk to dawn fishing trip, this ain&#8217;t hard to do. Would need to be a current-sensing switch with a logic input from the keyswitch (a Picaxe project).
Sorry, got off on a tangent (it&#8217;s winter now & I miss being on the water).
 
Top