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.

timed delay circuit ON/OFF

Status
Not open for further replies.

MrDEB

Well-Known Member
Am working on a game for my new grandson (15 months old) and instead of a simple ON/OFF switch am looking for a method to press a button and game stays ON until there is no activity of playing.
Circuit has a microcontroller and 9 tactile switches.
Eight of the tactile switches have an LED so power consumption is very low.
Game will play selected melodies displayed on LCD display.
So far found attached circuit.
I was thinking maybe an SCR would require less power consumption?
 

Attachments

  • delay2Btimer2Bimproved2Bcircuit.png
    delay2Btimer2Bimproved2Bcircuit.png
    26.4 KB · Views: 228
You've got a micro-controller, use that - you can set the timing to anything you want, and manually switch it if need be. The AVR component tester is a good example, T1, T2 and T3 are the relevant parts of the circuit for the on/off (you don't need LED1 if you don't want it - replace it with a 3.3K resistor). A few minor software changes are all you need. I've used on numerous commercial projects, and implemented auto-power off under various circumstances.
cheap-and-cheerful-transistor-tester-circuit-diagram-wiring.png
 
I am looking to have the entire project turn off after child has stopped playing with it,
Doing research, thinking maybe pressing a button activates an SCR gate. When the child stops playing the load will drop below the holding current of the scr thus turning off the entire game. Pressing a button will activate the scr and play proceeds.
Doable??
 
If you use a voltage regulator with an ON/OFF control you can usually arrange that to work with
a momentary pushbutton, 2 resistors, and an IO pin.

The pushbutton turns on the regulator, the uC runs and sets IO pin to keep it on until you want to turn it off.

What regulator are you using now?
 
I downloaded a copy of your schematic. Will study it further
thanks

If you study it, it's very simple - and remarkably clever - which is why I stole the idea :D

When you press 'test' (or on/off in my case) it switches T3 ON (via R7), this powers up the micro which immediately sets R8 high turning on T1 - this locks T3 ON as well. After the required 'in-activity time' R8 is simply switched low by the micro, and that shuts all power down - there's no resistor across the supply, so zero consumption when switched OFF. T2 is there so you can detect the button has been pressed again, so you can manually turn it OFF, and simply pulls an I/O pin low.
 
I was thinking that having portb monitored for activity with say porta.1 connected to scr gate. If portb has no activity scr is turned off.
no activity, the gate (with an RC network ) would turn off.
Turning the unit on w/ button press activates the rc network on the gate of scr.
basically same idea as your schematic but fewer parts?
weather it would work is a different story.
 
So I'm not the only one that stole that idea from the Banggood component tester. I think it was worth the money just for the power on / off idea.

Les.
 
I was thinking that having portb monitored for activity with say porta.1 connected to scr gate. If portb has no activity scr is turned off.
no activity, the gate (with an RC network ) would turn off.
Turning the unit on w/ button press activates the rc network on the gate of scr.
basically same idea as your schematic but fewer parts?
weather it would work is a different story.

I suggest you study SCR's and how to turn them off.
 
So I'm not the only one that stole that idea from the Banggood component tester. I think it was worth the money just for the power on / off idea.

Les.

Nice simple idea, and works wonderfully. One of the devices we manufacture uses an external plug-in transducer (basically a 24V solenoid), and is switched ON and OFF via the circuit above, as it uses internal Li-Ion batteries I also have voltage and current sensing (using an I2C chip) in order to monitor charging, discharging, and to give a battery indication (via a flashing LED).

I was lying in bed one night when I had a 'brain wave' (as you do :D) As battery current is already monitored you could easily tell if the transducer has been unplugged, simply by the current falling below a certain level - this would also prevent it getting accidentally turned ON, and flattening the batteries.

Next day at work, a few minutes with XC8, and it now switches OFF if the transducer is unplugged after 30 seconds - it took almost no effort to add, as all the required routines were already in place, and just needed linking together.
 
That circuit in post#12 looks fairly easy and less complicated. Now to search if components are available in SMD.
Going to run a simulation in TINA just to get an idea of what is going on.
Thanks Jon.
this project is battery powered only
 
I am thinking that maybe a timed delay using an rc network should be included with the switch so micro has time to turn on completely?
 
I was thinking about something more like this (depending on the input voltage)

Clipboard01.jpg


The R1/R2 voltage divider should have R1 adjusted so the EN voltage is about 2V.
The 10K pulldown will keep the reg off if EN isn't driven.
The diode will keep the input voltage from backfeeding thru the IO pin protection diodes.

I am thinking that maybe a timed delay using an rc network should be included with the switch so micro has time to turn on completely?
Don't bother... the micro should startup pretty quick. Try it and see.
 
Here's a variation on Nigel's ircuit that might be a little simpler and has a good explanation of how it operates and use.

That's essentially just replacing the PNP with an FET, and removing the input to the micro - which I've always found very useful, and could of course easily be added to the FET circuit.

But for the simplest approach, if you're using a voltage regulator, I think Tumbleweed wins!

Probably OK for this application, but that approach wastes too much power when turned OFF for long term battery life (it's no where near as low as you might think) - the discrete one is essentially zero when off, either bipolar or this FET version.

Don't bother... the micro should startup pretty quick. Try it and see.

Mr Deb is confusing mechanical speed (the button) and electronic speed (the micro), there's no issue whatsoever over speed - just do the latching near the start of the setup procedure, don't set every thing else (and display screens of data) before latching it.

Here's a snippet of code from one of my applications:

C:
void main(void)                    // program entry
{
    
    ANSELA=0;                   // Analogue inputs off
    ANSELB=0;
    ANSELC=0;
    TRISA = 0b00000000;            // PortA as all outputs - used for some LCD and PulseOut
      TRISB = 0b00111110;         // set RB0 as output for ON/OFF + RB4(Mode), RB1(Power) & RB5(Range) as inputs for keys,
                                // RB2 & RB3 as inputs for signal, rest as outputs
    TRISC = 0b00000000;            // PortC as all outputs - used for some LCD and PWM for contrast
    LATB = 0;                    // all PortB outputs initially LOW
    
    PowerLatch = 1;                // latch ON/OFF switch ON
 
If you look around, some parts have a lower current when disabled than others. The one shown here is in the 10uA typ/300uA max but there are others spec'd at 1uA. But as Nigel points out it's definitely something to look at.

Since MrDeb uses Swordfish Basic, it takes a little more "work" to get the initialization sequence since module initializers run before the start of the main program.

Note: in Nigel's example the C library runtime startup code will run before main() is called, so you'd have to do a custom startup module there too if you want it to happen fast.

For SF, here's how to do it:

First, create a file that contains the code you want to run. Call it "startup.bas"
Code:
module startup

// define a default enable pin (can be overridden)
#option STARTUP_ONOFF_PIN = PORTA.0

dim onoff_pin as STARTUP_ONOFF_PIN.STARTUP_ONOFF_PIN@

// set IO pin as output high
high(onoff_pin)

end module

Then, in your main program be sure to include startup.bas before all other include files.
This is important, as the initializers are run in the order they're included...
Code:
device = 18F43K22
clock = 32

// change the IO pin option if needed
#option STARTUP_ONOFF_PIN = PORTA.1
include "startup.bas"

// other includes go here...

If you do that then the IO pin will be set high within the first dozen instructions or so.
Set the config settings to disable the Power On Timer and it should startup within 1ms or so of pressing the button.
I'd keep the Brown Out config setting enabled
 
Last edited:
If you look around, some parts have a lower current when disabled than others. The one shown here is in the 10uA typ/300uA max but there are others spec'd at 1uA. But as Nigel points out it's definitely something to look at.

Since MrDeb uses Swordfish Basic, it takes a little more "work" to get the initialization sequence since module initializers run before the start of the main program.

Note: in Nigel's example the C library runtime startup code will run before main() is called, so you'd have to do a custom startup module there too if you want it to happen fast.

As I said, it's not an issue - and while I'm aware of the setup that C programs do it's still a fast electronic event, compared to a VERY slow mechanical event. While Swordfish may take a little longer, it's still a fast electronic event.
 
While Swordfish may take a little longer, it's still a fast electronic event
Actually, if done correctly Swordfish will be faster than the C version.

The C runtime will have to clear the bss and set any module level static variables that have initializers.
Assuming you're running with the internal osc, all of that will be done at the default osc freq, which could be a lot slower than the runtime clock.
 
Last edited:
Actually, if done correctly Swordfish will be faster than the C version.

The C runtime will have to clear the bss and set any module level static variables that have initializers.
Assuming you're running with the internal osc, all of that will be done at the default osc freq, which could be a lot slower than the runtime clock.

Regardless, it's still completely irrelevant - as it all happens VASTLY faster than the slow mechanical operation of the switch.

We all seem obsessed with faster clock speeds etc. but then the programs spend almost all their time sat in loops waiting for slow mechanical operations to occur, I suspect many programs would be quite happy running at only 32KHz clock :D

Incidentally, the C snippet above runs at 4MHz clock, but while I've been playing recently I've moved it to 32MHz instead - basically "just because I could".
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top