Connect with us

Logic gate input from comparator

Discussion in 'General Electronics Discussion' started by Chando, Nov 23, 2011.

Scroll to continue with content
  1. Chando

    Chando

    17
    0
    Nov 23, 2011
    Hi. I am trying to build a circuit that latches on and after a set time turns off. So far I have got a NOR latch to a transistor turning on a relay. On the output of the relay I have a capacitor resistor for the delay. This goes to a lm339 with the inverting input held at 7v5 with a Zener. The output of the op amp then goes for the reset of the latch. I have built the circuit in a simulator and this is where I have found a problem. When the comparator comes on it blows the transistor on the output of the latch. The gates are held low with 1M resistors.

    How do I stop the transistor blowing as everything I have tried doesn't work?

    Many Thanks

    Matt
     
  2. (*steve*)

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

    25,291
    2,731
    Jan 21, 2010
    It would help if you draw a circuit diagram for us, but I suspect the problem is that you're using the transistor to switch power to the relay in parallel with a capacitor.

    The capacitor represents a very low impedance path and the initial charging current probably destroys the transistor (or causes it to get so hot it is destroyed after a few operations).

    You are better off googling "monostable". You want a circuit that holds its state for some time period after a trigger input, and that is it. You can then use a transistor to switch the relay.

    Another thing you'll need is a reverse biased diode across the relay coil. This will prevent another cause of failure.

    If I was wrong and you don't have a capacitor across the relay contacts then it is almost certainly the inductive spike as the relay turns off that is killing the transistor.

    However without a circuit diagram, everything is conjecture.

    Oh, and welcome to Electronics Point!
     
  3. Chando

    Chando

    17
    0
    Nov 23, 2011
    HI, cheers for the help. It was the diode on the relay coil i had forgot to add.


    Cheers

    Matt
     
  4. Chando

    Chando

    17
    0
    Nov 23, 2011
    I am still having problems with my circuit in there is always about 2v on the output of the op amp and even if i disconnect it from the rest of the circuit it doesnt go high when the voltage at the non inverting inout goes about the voltage at the inverting input. It works in the simualtion so im a little confused. I have included the circuit below so if anyone can help i would be eternally greatful


    Cheers
    Matt
     

    Attached Files:

  5. duke37

    duke37

    5,297
    739
    Jan 9, 2011
    Would this circuit do?
     

    Attached Files:

  6. (*steve*)

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

    25,291
    2,731
    Jan 21, 2010
    The LM339 requires a pull-up resistor on the output. Check the datasheet -- there's one on every circuit diagram they present :)

    edit: I think that you could simplify things a lot (as per duke37's diagram)
     
  7. Chando

    Chando

    17
    0
    Nov 23, 2011
    Cheers for the reply. Duke 37 i dont quite understand your diagram. I have tried to build it in a simulator but i must be going wrong.

    Does an op -amp that doesnt need a pull up resistor and runs of a single supply spring to mind at all??

    Cheers

    Matt
     
  8. duke37

    duke37

    5,297
    739
    Jan 9, 2011
    The 4093 is a dual input quad Schmitt nand gate. If the inputs are tied together, with a low input, the output is high and visa versa. The output changes when the input gets to within a third of the final destination, thus there is a band in the middle where nothing occurs.

    In this circuit, the output needs to be low normally so the input of the second gate is pulled high., When it is driven low by the capacitor, the output goes high untill the capacitor charges through the pull up resistor. The error that I have made is that the drive to the second gate needs to be held low until the capacitor is charged so the input of the first gate needs to be high for this time.

    *Steve* wil be able to show you how to use a 555 monostable (he likes them) to do a similar job. In this case the transistor may not be needed.

    Any normal op-amp will not need a pull up resistor and can be used as a comparator, possibly with a bit of positive feedback to give a Schmitt trigger action.

    Duke
     
  9. (*steve*)

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

    25,291
    2,731
    Jan 21, 2010
    Actually, I am more a Schmitt trigger man.

    Three of these devices could be built using a single hex Schmitt trigger (40106).

    AN-140 gives a lot of information. Duke37 uses a variation of one of these circuits to convert a level change to a pulse, and then to extend the pulse.

    Pretty much exactly the same thing can be done with a 555.

    Note that with a 555, you also have to convert the edge to a pulse.

    The importance of generating the pulse is that the monostable will extend the trigger pulse for some duration. If the trigger is a change in state, the monostable will remain triggered and not go off. So the change in state generates a pulse, and it is this which is extended. When the state changes the other way, either no pulse is generated, or it has the wrong polarity to trigger the monostable (depending on your design)..
     
  10. TedA

    TedA

    156
    16
    Sep 26, 2011
    Matt,

    The other forum members have offered good advice.

    If the delay time you need is on the order of a few seconds, the suggested NE555 would be a good bet. It should be able to provide your delay, while driving the relay directly.

    If you don't like using an NE555, you can easily use either a CD4001B, or an LM339, to do the whole timing job; no need for both. If you go this route, you may well need a transistor to boost the current to drive the relay coil, as their outputs are much weaker than the one on the NE555.

    If your delay is longer, better to go with an oscillator / counter IC, than try to use really big timing capacitors and resistors. See Steve's article over at the top of the General Electronics Chat forum.

    Just for educational purposes, here are some thoughts on your original schematic ( And thanks for posting it!):

    Perhaps we do not understand some of your requirements, but it does look like far too much circuit for the job.

    I'm not sure why three different power supply voltages would be needed.

    It is not entirely clear where you take the output from the circuit.

    In the real world, as opposed to a simulator, it is a good thing to add a resistor between any CMOS gate input and connections to the outside world. That might include the connection to your start switch. Also, the 1M value for R2 will make your switch input sensitive to noise and leakage currents. A small capacitor to ground at the gate pin might be a good idea, as well. You may need to concern yourself with the minimum current requirements of the particular switch.

    What is the purpose of the relay? Could you not use a transistor, or an IC output, to provide the current to charge the timing capacitor?

    If you are using the same contact to both drive the timing circuit and to provide an output signal, you risk the external load upsetting the timing.

    The schematic includes no discharge path for C2, the 4700uF timing cap. The LM339 has PNP inputs, so the input current may actually charge-up the timing cap! Is the circuit supposed to work only once? And only shortly after the power is turned-on? The capacitor leakage current might be larger than the LM339 input current, so you cannot be sure what will happen, while the relay is off.

    Large timing cap and resistor values are not a good way to get a long delay, whether or not an LM555 timer is being used. See Steve's timer article.

    I did not check the datasheet for your zener, but I'll bet the device's voltage is not defined at the current this circuit provides. If you must operate a zener diode at a very low current, you must be careful about choosing the device. This is an area where the same P/N may be very different, as made by different manufacturers.

    Yes, the LM339 is not an op-amp, but a comparator. The output on this particular part pulls down only. As has been pointed-out, the resistor on the output needs to go to +, not common.

    I hope all this is of some slight interest.

    Ted
     
  11. Chando

    Chando

    17
    0
    Nov 23, 2011
    Hi, cheers for the responses. As it will prove helpful i will out line what the circuit is for. I have a heater on my car that i want to come on at a certain time. So i plan to take the buzzer feed from a digital alarm clock to a timer circuit that would 1) turn the realy on for approx 30 mins 2) send a signal back to the alarm clock to reset the alarm.

    I have been messing about with a NE555 timer today and can only get the cap to charge to approx 3v before discharging and the output is only on momentarly and its not even connected to anything.

    Hope this helps clear up some things

    Cheer
    Matt

    *Edit* Forgot to add, the 3 different power supplies is an error, there are only 2. A 13v from the car and a 10v to regualte the supply as an alternator can produce some spikes and you can attenuate the 10v rail but not the 13v one, i think anyway. Cheers
     
    Last edited: Dec 1, 2011
  12. TedA

    TedA

    156
    16
    Sep 26, 2011
    Matt,

    30 minutes is really too long for an NE555 timer; the timing R and C must be too large, and you are at the mercy of capacitor leakage current. See Steve's article.

    I suggest you look at the CD4060 ( MC14060 ). It contains an oscillator, plus a 14 stage ripple counter. The oscillator can run at a reasonable frequency, while the counter provides the long delay time.

    If your alarm clock is going to be dedicated to this system, you can likely tap a 1Hz signal somewhere inside the clock, then count this to provide the delay. Would 2048 seconds be too long?

    If you really insist on going for a half hour with an RC timer, at least use a CMOS 555, or base the circuit on an op amp or comparator with FET inputs.

    You are going to have to post a new schematic if we are to be able to help with whatever is going on with your 555 circuit.

    Are you powering this from the car battery? If so you need to think about how to avoid a dead battery.

    If powered by the mains, some thought about electrical safety might be in order!

    Ted
     
  13. Chando

    Chando

    17
    0
    Nov 23, 2011
    Ok. I have been reading up on the 4060 and it looks promising but i have a few questions. Am i right in thinking that the counter is always counting and starts from zero when the reset is trigged or the power is turned on? And is the ouput i want for my time period, only going to go high when the counter reaches that output if that makes sense?

    Also the timer is to power a diesel pre heater which doesnt draw that much current when one and would only be on for the 30mins before i drive it but switch off after 30m in case i am late to my car etc etc.

    Cheers

    Matt
     
  14. TedA

    TedA

    156
    16
    Sep 26, 2011
    Matt,

    I think the way the 4060 works, is that as long as the reset pin is high, the oscillator is inhibited, and all the outputs are zero. When the reset pin goes low ( and stays low ) the oscillator starts, and the counter starts counting. Look at the logic diagram on the Motorola data sheet. The buffered reset signal goes to the oscillator and to each counter stage. ( Motorola calls this an "MC14060". The short-lived MC4000 series was TTL MSI.)

    The simplest way to use the count for timing is to watch a single bit of the counter, and end the delay when that bit goes high. The Q4 output will provide a short delay, the Q14 output a much longer one. It is also possible to decode more counter output bits in order to gain resolution, or a longer delay than what the Q14 output can provide alone.

    To do what you want, some extra logic is required, besides the 4060. I'm sure there are single chip solutions out there, but these may be less universally available than the standard CMOS parts. The CD4000 series is as old as the hills, but still has multiple sources. If you don't need the oscillator, there are several similar CMOS ripple counters in the CD4000 series.

    I think what you can do, is have the alarm clock alarm signal set a latch. The latch being set can remove the reset signal from the 4060, and switch on your heater. The latch will remain set through the delay time. Finally, have one of the 4060 outputs going high reset the latch to restore the original state.

    You might want a power-up reset circuit, to be sure the thing starts out "off". I think the 4060 can come-up with any count, as power is applied.

    Ted
     
  15. Chando

    Chando

    17
    0
    Nov 23, 2011
    Cheers for the help Ted. I found this circuit on the web (below) which is for an hour but i have done the maths to redo the time delay part.

    I have tried to build it in a simulator but most of the time the nand gates start in the wrong state even though the cap on the reset pin is supposed to short to ground. Is this just a simulation error or is it likely to happen in real life?

    http://www.doctronics.co.uk/4060.htm#monostable

    Cheers

    Matt
     
  16. TedA

    TedA

    156
    16
    Sep 26, 2011
    Matt,

    The doctronics circuit looks as if it should work. Perhaps you have a simulation problem. Many simulators have ways to set-up initial conditions, you might look into that. It's possible the cap is not starting out at zero volts.

    You might try adding a resistor between pin 6 ( the latch not- reset input ) and pin 10. Then move the 100nF cap to pin 6. The simulator may be able to understand this better.

    I think your own latch circuit, using a 4001 quad nor gate, might eliminate the need to invert the 4060 Q13 signal. The start signal would have to be positive-going, in that case.

    Note that the doctronics circuit shows a polarity sign on the timing cap. This should be an non-polarized part. A low voltage polyester film cap might be a good choice.

    The power-on reset cap also serves to stretch the reset signal to the 4060, when the time delay ends. A really fast latch, used with a really slow 4060, might lead to reset timing problems with the 4060.

    You might want to put an RC network on the "go" switch input, with the cap connected to Vdd, in the doctronics version. This could protect the CMOS input, and reduce sensitivity to noise.

    Ted
     
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

-