Connect with us

Help designing circuit for box alert light

Discussion in 'LEDs and Optoelectronics' started by mbailey218, Jan 1, 2014.

Scroll to continue with content
  1. mbailey218

    mbailey218

    4
    0
    Jan 1, 2014
    Hi,

    Can anyone help me design a circuit that does the following:

    I want to put a switch in a box so that when you open the lid, a LED light starts flashing and will continue flashing even when the lid is closed. Subsequently opening and closing the lid will not affect the light. To turn the light off, you would need to open the lid and press a "reset" button. Then the next time the lid is opened, the light will flash again, etc.

    I'd like this to run on a 9v battery.

    Thanks for you help!
    Mike
     
  2. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,305
    2,738
    Jan 21, 2010
    How's this?

    [​IMG]

    The IC is a 40106, a hex Schmitt trigger inverter.

    I have assumed that you want the device to power up un-triggered.

    R1/C1 ensure that the input to the first gate is low when power is applied. S1 acts as a reset switch to pull it low again.

    R5 is a CDS cell, I have assumed you want the device to turn on when it sees light. If you want to use a switch, replace this with a switch that is closed to trigger the flashing. Also place a low value resistor in series (say 1K) so that pressing the reset switch with this activated doesn't short out your battery.

    The first 2 gates with resistor R2 form a latch. When the input to the first gate is pulled high, the output goes high and stays high until the input is pulled quite strongly low. The CDS (R5), reset switch (S1), and the capacitor (C1) are all capable of doing that (In the case of C1, it can only do it for a brief instant after power is applied. Resistor R1 is NOT capable of pulling it low.

    The third gate is simply a buffer so the next stage doesn't disrupt the latch.

    Diode D1 allows C2 to charge from the output of the third gate, but not the discharge. When the output of the third gate is high, the 4th gate cannot oscillate. When the output of the third gate goes low, the 4th gate will start to oscillate. The frequency is determined by R3 and C2, and the frequency is about 1/(0.6*R*C) from memory.

    The fifth and sixth gates buffer the output of the oscillator and provide extra current drive to the LED.

    When it is first turned on, C1 looks like a short term short circuit, so the input of the first gate is low. Thus the ouptut is high, and the output of the second gate is low. The output of the second gate feeds back to the first gate via resistor R2 which maintains this state.

    Because the output of the second gate is low, the output of the third gate is high and that charges the capacitor C2. Resistor R3 (which should be in the order of 10K to 1M) prevents the output of he 4th gate from overpowering the third gate, so its output remains low.

    the inputs of the 5th and 6th gates are low, so their output is high, and thus the LED remains off.

    When the CDS (R5) is exposed to strong light, it provides enough current to overpower R2, pulling the input of the first gate high. The output of the first gate is low, the output of the second gate is high, and this feeds back to the input of the first gate holding it high against R1.

    The input of the 3rd gate is high, so the output goes low. The diode D1 effectively disconnects it from C2.

    Now resistor R3 begins to discharge C2. At dome point the change is low enough that the schmitt trigger changes state and the capacitor begins to charge via R3. This goes on until the schmitt trigger changes state again... The gate is oscillating.

    These oscillations are fed to the inputs of gates 5 and 6. Their outputs then flash the LED.

    When S1 is closed,the input of the first gate is pulled low, and everything progresses as per the beginning causing the LED to stop flashing.
     

    Attached Files:

  3. mbailey218

    mbailey218

    4
    0
    Jan 1, 2014
    Thanks Steve. This looks great - thanks for taking the time to include so much detail. Now I just have to figure out how to physically build it.. ;)

    Mike
     
  4. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,267
    Nov 28, 2011
    Steve, how will you be able to reset the latch if the box is open and the LDR is illuminated? The reset button is inside the box, remember!
     
  5. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,305
    2,738
    Jan 21, 2010
    Hmmm.... Either have a pulse extender for the reset switch, or make the LDR (practically you'd have to use another switch) edge trigger rather than level trigger.
     
  6. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,267
    Nov 28, 2011
    Yeah, I'd go for the latter. Feed the LDR through a Schmitt to a C-R pulse generator (differentiator) then a diode, to set the latch.
     
  7. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,267
    Nov 28, 2011
    Here's my suggestion. It's very similar to yours, Steve.

    [​IMG]

    Here's a circuit description for the OP.

    U1 is a CD40106B hex Schmitt trigger inverter IC. It is shown as six gates named U1A~U1F. Power is connected to pins 14 and 7, which are shown on the first gate. CD is a "decoupling" capacitor and should be connected directly between the power pins of the IC with leads as short as possible.

    Each gate has an input on the left and an output on the right. The gate drives its output to the logical opposite of its input, but it also has a feature called hysteresis ("hiss-tur-EE-siss") that causes its input threshold voltage to change depending on its output state; this feature makes it switch very cleanly in response to gradual and poorly-defined input voltage changes. Google hysteresis for more information.

    RP and the LDR form a voltage divider whose voltage depends on the amount of light hitting the LDR. More light makes the LDR's resistance drop, so the voltage drops, which causes the output (pin 2) to go high. On this rising edge, the C-R "differentiator" circuit consisting of CT and RT produces a short positive pulse at the anode (left side) of DT. Google capacitor-resistor differentiator or pulse generator for more information on how that part of the circuit works.

    U1B and U1C form a latch that consists of two cascaded inverters with "positive feedback" through RB. This feedback tends to hold the latch in its current state - the input is inverted, and inverted again, and fed back to reinforce itself. But the latch state can be changed by forcing the input. The output of the latch enables or disables the LED flasher.

    The positive pulse on DT (caused by light falling on the LDR) is coupled through DT (which conducts only in the direction of the arrow) and forces the latch input high, setting the output high as well. Pressing SW1, the "RESET" button, forces the latch low. At power-up the latch will assume a random state and may have to be reset with SW1. I can modify the circuit so the latch always starts up in the low state, but that requires three more components. Let me know if you want that feature.

    The output of the latch, on pin 6, is high when we want the LED to flash, and low when we don't. RD and DD allow this signal to enable and disable the flashing oscillator, which is formed by U1D. The oscillator uses negative feedback through RF into the timing capacitor CF. This combined with the input hysteresis forms an oscillator, that oscillates with a total period (ON time plus OFF time) that's very roughly equal to 1.6 RF CF, where RF is in ohms and CF is in farads.

    With the values shown (CF = 4.7 µF), 1.6 RF CF is about 0.75 seconds, so the LED will flash ON and OFF about four times every three seconds.

    The output of the oscillator is buffered by two gates with their inputs and outputs tied together, to provide more output current, and fed through current limiting resistor RL to the LED. When the oscillator is disabled (latch output low), its output (pin 8) will be high and pins 10 and 12 will be low, so the LED will turn OFF.

    I have shown an ON/OFF switch and a battery which should be 9V or 12V. When the switch is ON, the circuit's current consumption is around 0.1 mA at 9V so a PP3 battery (the snap-on connector type) will run the circuit in the idle state for at least a week. Current consumption is much higher when the LED is flashing; this current can be reduced by increasing RL (which will make the LED dimmer).

    Edit: CF is shown as a non-polarised capacitor, but it should be an electrolytic (polarised). The positive side connects to the IC; negative side to the 0V rail.
     

    Attached Files:

    Last edited: Jan 2, 2014
  8. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,305
    2,738
    Jan 21, 2010
    But much prettier!

    One thing that mbaily218 might note is that some things appear reversed as compared to my circuit.

    Because this circuit is using inverters, each stage of the circuit which employs a single element (a Schmitt trigger inverter) will invert the signal.

    We're working with a fixed number of gates (there are six in a package and we want to use them all, but not end up needing a second package) so we kinda trace the on and off logic levels as we move through the circuit.

    One minor difference is that there is a chance that Kris' circuit will power up in the triggered state. This probably isn't a major concern.
     
  9. mbailey218

    mbailey218

    4
    0
    Jan 1, 2014
    Thanks again Kris and Steve. One thing that both of you included was the LDR - which I think from your narratives is a light detecting device. I don't need this to detect light to determine if the box is opened, I just need a "pressure switch" which is depressed when the lid is closed, and "pops up" when the lid is opened. This is what will trigger the light (LED) to flash - but closing the lid will not turn it back off. Actually, this box could be opened in the dark - or in almost no light.

    Thanks again - this is awesome!!

    Mike
     
  10. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,305
    2,738
    Jan 21, 2010
    Simply replace the LDR with a switch that is closed when the box opens.

    If you have a switch which closes when the box closes, swap the position of it and the resistor (RP in Kris' circuit).
     
  11. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,267
    Nov 28, 2011
    [​IMG]

    I've updated the diagram to use a normally closed pushbutton. That is, a pushbutton that has continuity when there is no force pushing it down. When the box lid is down, it pushes the pushbutton down, and breaks the circuit. When the box lid is lifted, the pushbutton springs up and closes the circuit.

    The extra components (RZ, CP) are there to debounce the pushbutton. If you don't debounce the button, the circuit will trigger when you close the box lid, because the switch contacts do not open and close cleanly. Google contact bounce for more information.

    As Steve says, you can use a standard normally open pushbutton if you swap the positions of the pushbutton and RP, but (a) this will cause a higher load on the battery while the box is closed, and (b) normally open pushbuttons usually have to be pushed to their limit before they make contact, which would make the positioning of the pushbutton quite critical; normally closed pushbuttons normally disconnect as soon as the plunger is pushed down, even slightly, so the distance between the pushbutton's body and the lid is not critical.

    I've added a note on the schematic about the latch state being undefined on power-up. I mentioned this in the circuit description but it is worth noting on the schematic as well.
     

    Attached Files:

Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-