Connect with us

Timing Circuit? Counter?

Discussion in 'General Electronics Discussion' started by Ernest George, Aug 26, 2014.

Scroll to continue with content
  1. Ernest George

    Ernest George

    71
    13
    Jul 18, 2014
    Hi guys;

    I'm very new to electronics and have little to no experience and so, I decided to create a mainboard for my electronics project :eek:

    Believe it or not, it's going pretty well and I'm probably 90% done before having the prototype boards made up.

    The last thing on my wish list is a timing circuit. I don't know if there are any easy 'canned' solutions out there but this is the general functionality;

    An input is monitored for a 'normal' voltage of 3.6 => 4.4 volts - if it sees this the circuit does nothing
    If the input shows .7 => 1.3 volts then the circuit begins counting to 3 seconds. If the voltage does not return to 3.6 => 4.4 volts then it grounds an output until re-set (powered off).

    I don't know how to build this but I have run into a number of recent IC's that are called 'timers' and this has me wondering....perhaps it's not as hard to implement as I feared?
     
  2. Gryd3

    Gryd3

    4,098
    875
    Jun 25, 2014
    How accurate do you want it?
    There are simple methods you could employ with RC circuits. (Resistor Capacitor)
    You could use a 555 Timer, or other ICs.
     
  3. Ernest George

    Ernest George

    71
    13
    Jul 18, 2014
    Hi Gryd3 - thanks for the response!!

    It's funny that you mention the 555 because that's the exact 'timer' I kept running into even though I know nothing about it, and when I researched it, I understood even less :rolleyes:o_O
    Accuracy is not that important. As long as it did not activate prior to 3 seconds - that's important. Even if it was off by a second on the other side it would not be a big deal. Simple is important as I'm pretty much lost when it comes to creating/designing a circuit. I am working with resistors and capacitors at the moment so they don't scare me (yet!).
     
  4. Gryd3

    Gryd3

    4,098
    875
    Jun 25, 2014
    haha... well a 555 is a timer, and a very famous one at that!
    I will have to think something up. Have you played with transistors yet?
     
  5. Ernest George

    Ernest George

    71
    13
    Jul 18, 2014
    Not really :) I've used two so far and both were common mods whose implementation I could interpret and implement without too much thought - basically copy/massage what others did in similar projects.

    I'm using ExpressPCB to design a mainboard for a custom application and I set really low goals for myself as this is my first electronics project. To that end, I created a wish list of increasing complexity and said to myself, "if you can only achieve the first option off the list, that would be fine." That was 4 options ago and the timer circuit is the last on the list!

    I'm reasonably confident in my design although it has gotten a lot more complex since the early days. Real estate is becoming an issue as the board is getting packed :D I'm very much still a newby without any understanding on how things actually work - but - this is typically how I work. Once I've implemented something (usually following someone else) then later my brain usually comes around to actually desiring to understand how it works and, at that point, it's where I become much more proficient in something. Starting to think from the perspective of electricity :)

    On the timer side of the project, no-one I know has done this before in my application. As mentioned, I did see the NE555 timer and read it's history page at the WikiPedia but I could not even see how you set/program the time interval and at that point I realized I could not do it.

    For me, using CAD/ExpressPCB has been tough in some respects. Getting all the dimensions correct for proper fitment has been very tough, I had to design several custom connectors that are not standard pitch and then the whole board needs to sit in a pre-existing box that has offset connectors - ugh! Some real headaches there - just to name a few! And then there's always the issue of getting my head around a 4-layer circuit board etc. For someone with zip for electronics experience I'm actually doing quite well as I'm reasonably certain my design will work when it comes time to pull the trigger on getting the boards made up :D

    But, to bring this back on topic, no, I don't really have any understanding of transistors at all. I'm still at a very entry level stage. I didn't even draw up a schematic of my project. I just kept moving pieces around as they got added in and re-designing such that lines don't cross etc. Very interesting stuff!
     
  6. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    Hi Ernest and welcome to Electronics Point :)

    You've listed four different voltages there, but there only seems to be one decision threshold - somewhere between 1.3V and 3.6V. If it's greater than that threshold, the voltage is OK, and if it's less, the voltage is out of specification, and after a three second delay you want an output to go low and latch. Is that right? A voltage of around 2.5V would be about half way between those voltages, so would that be an appropriate threshold?

    What power source is available for the circuit? Do you need it to be powered from the input source? (From a battery, I assume, based on the voltages you specified.) Or do you have another power source that is guaranteed to be at least 2~3V? Because circuitry that operates from less than 2V needs some special design considerations. What would the minimum available supply voltage be?
     
  7. Ernest George

    Ernest George

    71
    13
    Jul 18, 2014
    Hi Kris - thanks for the warm welcome and also for pointing out some things that I missed :)

    It may be best to put it this way,

    • if the monitored voltage is above 1.4 volts then do nothing and keep monitoring
    • if below 1.4 volts, begin 3 second count-down.
    • If the voltage returns to above 1.4 volts before the 3 seconds expires then cancel countdown and return to monitoring.
    • if the voltage remains below 1.4 volts past the 3 second monitoring period then ground an output
    • remain grounded unless power cycled
    That should be the logic of it. I wonder if it can be done?

    With respect to power for the circuit there is both 5v and 12v available.

    Does that help? Like I said, I'm a total newby to electronics etc so if I've missed something or said something stupid - that's why! :eek:;):)
     
  8. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    Yes, it can definitely be done. I'm just considering the most appropriate way to do it.

    Thanks for the clear definition of behaviour. I had realised that you want the three second timer to reset if the voltage goes back over the threshold, but it's good to see it spelled out like that.

    How accurate does the threshold voltage need to be? For example, would "somewhere between 1.4V and 1.8V" be accurate enough?

    Is the input current drain important? If it's being connected permanently to a battery-powered supply, you might want to specify the maximum allowable load current, so it doesn't discharge the battery unnecessarily. I guess if it draws less than around 100 µA this will be low enough that you don't need to worry about it.

    What does the output need to switch? Is it just driving an LED, or is there something else?

    You want the circuit to unlatch when it's power-cycled? I guess you mean when the power supply to the circuit is disconnected, not when the monitored voltage is disconnected?

    What is your priority: minimum component cost? Minimum component count? Minimum PCB space? If PCB space is critical, can you deal with SMT (surface mount technology) components?
     
  9. Ernest George

    Ernest George

    71
    13
    Jul 18, 2014
    "How accurate does the threshold voltage need to be? For example, would "somewhere between 1.4V and 1.8V" be accurate enough?"

    The native voltage threshold for the circuit that I am replacing has an activation range of between .7v to 1.3v - which is something I would like to duplicate. Accuracy there is important and those numbers should be the set point. So if it reads anything between those voltages, start counting! :cool:

    "Is the input current drain important? If it's being connected permanently to a battery-powered supply, you might want to specify the maximum allowable load current, so it doesn't discharge the battery unnecessarily. I guess if it draws less than around 100 µA this will be low enough that you don't need to worry about it."

    I can't see 100 µA being anything to worry about at all. The power feed to the circuit is cut when the application is shut off so there is no need for concern about parasitic draw or battery drain. It may be ideal for it run from 12v as I can get this anywhere on the board by punching down into the power plane (as opposed to running a separate trace for 5V). This would make it easier to install.

    "You want the circuit to unlatch when it's power-cycled? I guess you mean when the power supply to the circuit is disconnected, not when the monitored voltage is disconnected?"

    Exactly! When the power supply to the circuit is interrupted (ie. shut off) then the circuit should unlatch or 'reset'. If the monitored voltage was disconnected (this should not happen and would indicate a failure in that circuit) then the circuit should fail in an un-latched manner (ie. if it reads nothing, do nothing).

    "What is your priority: minimum component cost? Minimum component count? Minimum PCB space? If PCB space is critical, can you deal with SMT (surface mount technology) components?"

    A very interesting question, I would suggest through-hole if possible. I can deal with SMT but the tiny sizes are hard on my eyes:rolleyes: My thinking went along these lines, get the prototype functionality perfect, and then, if a re-design was desired, re-do it for fun using all SMD's. Of the 3 priorities you listed, I would say, minimum space, minimum count, and then cost, in that order.

    "What does the output need to switch? Is it just driving an LED, or is there something else?"

    This one I have to think more about. What I was hoping for was to make a line go to ground. I'm using this timer circuit to kill another device so if I interrupt one of it's inputs with ground then I could probably kill the device. But, more thought is required....

    I'm really curious to see how this transpires. Normally, I would look to software to accomplish this task. I'm really curious to see how this would be implemented in the electronics world!
     
  10. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    So there is actually another threshold somewhere between 0.7V and 0V. The timer should be enabled only when the voltage is between 0.7V and 1.3V. Less than 0.7V or more than 1.3V should disable it. Right? And you want both of those voltages to be fairly accurate? Would 0.55~0.75V and 1.2~1.5V be accurate enough?
     
  11. Ernest George

    Ernest George

    71
    13
    Jul 18, 2014
    That sounds perfect!
     
  12. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    OK I'm working on a design but it won't be ready until tomorrow. In the meantime maybe Gryd3 would like to suggest something.
     
  13. Ernest George

    Ernest George

    71
    13
    Jul 18, 2014
    Go for it! (I'll brace myself....) :) and BTW....

    Thank you for the help!!!
     
    Last edited: Aug 27, 2014
  14. Gryd3

    Gryd3

    4,098
    875
    Jun 25, 2014
    These are the two building blocks I'm thinking of using for a suggestion, but I am unsure how I would 'cancel' the timer once started. I'm thinking my method would simply 'pause' the timer and I don't like that ;)

    The window comparator would saturate a transistor that will provide current to the capacitor connected to the 555. The RC delay would be set to at least 3 seconds, but if the reference voltage goes back to normal, the capacitor will still maintain a partial charge... so the next time the timer should start, there may only be 1-2 seconds until the event is triggered. I have not drawn it from scratch because I have not thought of a way to drain the capacitor in a nice timely fashion to reset the 3 second delay.
     

    Attached Files:

  15. Ernest George

    Ernest George

    71
    13
    Jul 18, 2014
    Hi guys! I'll be back a little later on (probably this evening) as I've been hanging off a roap on the side of a cliff with a power saw in my hand :eek::confused::mad:
     
  16. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    OK, here's what I've come up with.

    269993.001.GIF

    This circuit must be powered from a clean, regulated 12V supply. It has an open collector output that goes low and latches low when the input voltage has remained between the two thresholds (1.3V and 0.7V) continuously for about 3.5 seconds.

    It is based around an LM339 quad comparator, U1, which is an old device but still widely used. The LM339 contains four identical voltage comparators, named U1A~U1D, which are represented as triangles on the schematic diagram, each with two inputs and one output.

    Each comparator drives its output low if the voltage on its inverting ("-") input is higher than the voltage on its non-inverting ("+") input. If the "+" input voltage is higher than the "-" input voltage, the output floats and can be pulled up to a positive voltage.

    This type of output is called "open collector". In the low state, it is able to pull down to 0V quite strongly, but in the high state, it does not pull up. External components must be used to pull the output up towards a positive voltage.

    The input voltage is monitored by U1D and U1C, using two different voltage thresholds set up by the four-resistor voltage divider RA~RD. The voltages created by this voltage divider are marked on the diagram; these voltages are only accurate to within a few percent.

    If the input voltage is higher than 1.3V, U1D will pull its output down to 0V. If the input voltage is lower than 0.7V, U1C will pull its output down to 0V. In either case, their commoned ouputs will pull to 0V and this will hold CT discharged, because QL is (initially at least) conducting like a short circuit.

    Only if the input voltage is between those two voltage thresholds will both outputs go into the floating state, and allow CT to charge up through RT.

    This configuration is called a "window comparator" because it compares the input voltage to a "window" between 0.7V and 1.3V. If the input voltage is outside that window, the commoned outputs pull low; if the input voltage is within the window, the combined output signal becomes "open" and no longer pulls down to 0V.

    While the input voltage remains within the window, CT charges up through RT. If this condition remains true continuously, after about 3.5 seconds the voltage on CT will reach the 9.6V threshold voltage on pin 5. When this happens, U1A will pull its output to 0V.

    When U1A's output goes low, QL turns OFF, and becomes an open circuit, and the commoned outputs of U1D and U1C can no longer discharge CT, even if the input voltage goes outside the input window.

    Also when U1A's output goes low, U1B's "+" input goes lower than the fixed 9.6V threshold on its "-" input, so its output goes low as well. This output is designed to sink about 5 mA maximum.

    Once the output goes low, it latches into that state. This is done by QL, a small-signal N-channel MOSFET, which is controlled by its gate, driven by the output of U1A. While the gate is high, i.e. +12V, QL will conduct when the window comparator's output goes low, and this will discharge CT. Once U1A's output has gone low, however, QL has no gate bias and does not conduct at all, so the window comparator cannot discharge CT. CT charges up to +12V and the circuit's output stays low until power is cycled.

    I'm not too happy with this arrangement. If anyone can suggest a more reliable way, that doesn't require too many components, please do.

    When power is removed and the +12V rail goes to 0V, DD conducts and discharges CT ready for the next run.

    U1 is powered through pins 3 and 12 which are shown attached to U1A. CD is a 100 nF (also called 0.1 µF) ceramic capacitor called a "decoupling capacitor" and it is needed to ensure reliable operation of U1. It must be connected as closely and directly as possible between pins 3 and 12 of the IC - tacked on underneath the board is good.

    DIN and RIN provide some protection against excessive voltage at the input.

    CT needs to be a good quality low-leakage capacitor. Electrolytics might be suitable but I recommend a film capacitor such as http://www.digikey.com/product-detail/en/R60DI4470AA30J/399-5908-ND/2571343

    The delay time is determined by RT and CT. The formula is roughly
    t = 1.6 × RT × CT
    where t is the delay in seconds,
    RT is in ohms,
    and CT is in farads.

    With the values given:
    t = 1.6 × 470,000 × 4.7×10-6
    = 3.5 seconds.
     
  17. Ernest George

    Ernest George

    71
    13
    Jul 18, 2014
    Hi Kris;

    Nice work!! For me, this is a complex circuit and I'll have to really sit down and go through it and spend some time trying to properly understand it. I have a breadboard here as well as a variable output power supply so I'm quite certain I can test it out prior to using it and this will help me to understand it as well. That, along with your excellent circuit description, makes me think my understanding is going to grow a lot over the next bit :D

    Now the dumb questions start....:eek:;

    "This circuit must be powered from a clean, regulated 12V supply."

    Can the voltage fluctuate? ie. 14.5 down to 12V or is this going to be a deal breaker?

    I'm trying to get a DigiKey order together for these parts;

    LM339N = 296-1393-5-ND
    Film Capacitor = 399-5908-ND
    BS107 = BS107ARL1GOSCT-ND
    2N7000 = 2N7000TACT-ND
    1N5234B = 1N5234BFSCT-ND
    1N914 = 1N914BCT-ND

    With respect to the resistors, can they be regular 1/4 watt carbon film or is there anything special about them?

    Again, my apologies for the dumb questions. Like I said, for me, this is a complex circuit but I am interested in trying it out as I have all the gear here to do it (less the parts). This is really nice work Kris, thank you very much for undertaking it!
     
  18. Gryd3

    Gryd3

    4,098
    875
    Jun 25, 2014
    Ra, Rb, Rc, Rd create a voltage divider.. if you change the 12V to 14.5V then the device will trigger at a different reference point. So instead of triggering between 0.7 and 1.3V it could end up shifting to 0.9 and 1.7V. That is the first thing I notice, perhaps Kris has another reason.
     
  19. Ernest George

    Ernest George

    71
    13
    Jul 18, 2014
    Good catch - Probably the smartest thing for me to do is read the exact voltage being provided and then tailor resistors as required/if required. Being out by the spec you mentioned is not necessarily a big deal but some more thought is required on my part.
     
  20. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    Sorry about the slow reply. Real life rudely intruded into my little online bubble :)
    As Gryd3 said, the input voltage thresholds are set based on a 12V power supply voltage using RA~RD. Also the 9V6 threshold voltage affects the timing; it should be 80% of the supply voltage, whatever that is. I could change the circuit to use a regulator to set the thresholds; this might make it easier to deal with the latching logic as well. I'll look into this option. If you're buying components from Digi-Key, add a TL431C (http://www.digikey.com/product-detail/en/TL431CLPM/296-26717-1-ND/2256072 for the through-hole version or http://www.digikey.com/product-detail/en/TL431AIDBVR/296-15237-1-ND/566512 for the SMT version) to your list. But there will also be some new resistor values.
    Those all look good. You only need either a BS107 or a 2N7000, not both. There's no preference so you might as well get the 2N7000; it's about 20 cents cheaper!
    Regular 1/4 watt metal film 1%. These are better quality than carbon and the price increment is negligible.
    My pleasure :)

    I will see if I can improve the design to be less fussy about the power supply voltage, and to latch more reliably.
     
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

-