check if input signal stays high for a given time interval

Discussion in 'The Projects Forum' started by fenicento, Jan 11, 2015.

  1. fenicento

    Thread Starter New Member

    Jan 11, 2015
    4
    0
    Hi all,
    I'm an Arduino user and not to skilled in electronics (not at all actually). I'm trying to build a lamp that switches on and off if a digital proximity sensor detects and object for more than one second. I'm actually using an Adafruit Trinket, but I'd really like to use integrated circuits thant don't need to be programmed, since the application is really easy.

    In order to toggle the on/off I guess I can use a T-type flip flop, but I really don't know how to check if the signal of the sensor stays high for one second. In short, I need an integrated chip or a circuit that reproduces this behaviour:





    Any ideas?
     
  2. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    You need to verify that a signal lasts more than one second before taking action on that signal. A one-shot multivibrator can be used to "time" a signal. For example, the rising edge of the signal triggers the one-shot. If the input signal is still present after the 1 sec period of the one-shot, then you do something, else not.

    The thing you want to do after the signal is validated is to "toggle" an output. One (>1s) Push to turn something on; a second (>1s) Push to turn it back off. A flip-flop will do that.

    Sounds like your minimum system is a momentary switch, a one-shot, followed by a flip-flop, plus some logic, and a driver for the final output.
     
  3. fenicento

    Thread Starter New Member

    Jan 11, 2015
    4
    0
    I googled around, but I only found examples in which one-shot multivibrators produce a high output of arbitrary time length whenever a rising edge is recorded on the input (useful for debouncing inputs). Do you have any link, tutorial or schematics that fit my application?
    Regarding the flip-flop, I see that the CD4013 integrated is widely used, hence I think I'll go for it.
     
  4. crutschow

    Expert

    Mar 14, 2008
    13,000
    3,229
    Below is the LTspice simulation of a circuit consisting of a comparator delay and FF that should do what you want.
    The output has to be low for at least 1.1s (as determined by the R4C1 time-constant) before the CD4013 FF is triggered. (The spec says the proximity sensor output is low when it senses an object)
    The power and ground pins for the CD4013 aren't shown but must be wired.
    Also all unused inputs for the other FF in the CD4013 package must be grounded.
    You will likely have to add a buffer circuit on the CD4013 output, depending upon what you want to drive.

    Delayed Sw.gif
     
    ErnieM likes this.
  5. fenicento

    Thread Starter New Member

    Jan 11, 2015
    4
    0
    Wow, that's exactly what I was looking for, thank you! Actually i want to drive a 12V 3A DC halogen lamp, so the idea was to connect the output of the flip flop to the base of an NPN transistor (preceeded by a resistor in series), and to drive the lamp through its collector. So the general scheme of the project is:


    12V, 5A power source --> voltage regulator to 5V --> comparator delay of sensor signal and FF --> transistor driving the lamp (whose positive pole is connected to the original, unregulated power source).

    Is it right? Do you see any issues?
     
  6. crutschow

    Expert

    Mar 14, 2008
    13,000
    3,229
    One problem. A standard NPN BJT requires about 300mA base current to fully turn on with a 3A collector load and the CMOS FF can't deliver that.
    Easier is to use a logic-level type N-MOSFET (fully turns on with 5V Vgs), which requires no gate current to drive.

    Edit: You can operate everything off the 12Vdc since both the comparator and FF are 12V tolerant. The resistor values just have to be adjusted for the new voltage.
    That also means you can use a standard N-MOSFET.
     
    Last edited: Jan 12, 2015
  7. fenicento

    Thread Starter New Member

    Jan 11, 2015
    4
    0
    unfortunately I need 5V for the proximity sensor. I looked for a similar one working at 12V, but they are much more expensive. I really don't like the idea to use a voltage regulator, since I guess I'll have to include a heat sink, but I see no other options...
     
  8. crutschow

    Expert

    Mar 14, 2008
    13,000
    3,229
    You'll need a heat sink only if the regulator power dissipation is above a watt or so (for a TO-220 type case).
    What's the total 5V current?
    The power dissipated is that current times the voltage drop across the regulator (7V).
     
  9. ebeowulf17

    Active Member

    Aug 12, 2014
    678
    79
    Out of curiosity, pros/cons of the N-MOSFET vs a Darlington transistor in a simple switching situation like this? I've used Darlingtons for several projects with good results and haven't played with MOSFETs yet.
     
  10. crutschow

    Expert

    Mar 14, 2008
    13,000
    3,229
    Darlingtons still require base current, but it's much less than a single BJT.
    MOSFETs draw no steady gate current, but the gate looks like a small capacitor that must be charged and discharged to switch the FET.

    MOSFETs have a much lower ON voltage than a comparable Darlington.
    The minimum Darlington ON voltage is about one diode drop or 0.7V.
    A MOSFET can have an ON resistance in the milliohm to tens of milliohm region.

    MOSFETs are a much faster switch, that's why they are used in high frequency power switching applications such as switching regulators and converters.
     
    Last edited: Jan 13, 2015
  11. ebeowulf17

    Active Member

    Aug 12, 2014
    678
    79
    Fascinating! Thanks for the great descriptions. A lot of isolated things I've read, but not pieced together make a lot more sense now. Thanks!
     
Loading...