Using TTL Gates from computer software to control a light, current limiting? Pull up resistors?

Discussion in 'The Projects Forum' started by MichiganWolverine5974, May 13, 2015.

  1. MichiganWolverine5974

    Thread Starter Member

    May 13, 2015
    63
    4
    I am doing a project that is using a 5vdc signal from a watchdog timer and sending the signal to a bunch of NAND, AND, and OR gates to create a signal.

    upload_2015-5-13_9-25-59.png

    Here is my drawing. I'm trying to have one light on a 0vdc signal and another on for 5vdc signal. Both lights cannot be on at the same time. When Watchdog is 5v one light is on, when Watchdog is 0v the other is on. Where would I need pull up or pull down resistors?

    There is one signal coming from each software in each station (A-F) and its going to one light tower.

    Part numbers are: NAND: SN7401N, AND: SN7409N, OR: 74HC32, Photocoupler: DEK-OV-5DC/24dc/3

    Would I have to limit current anywhere? Will this design even work?
     
  2. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    No comment on the logic.

    A TTL output can sink enough current to drive the input side of photo-coupler, but cannot source enough current to do so. You will have to invert the logic so that the TTL signal is low when you want the opto-coupler on.
     
  3. Reloadron

    Active Member

    Jan 15, 2015
    963
    232
    Why not just use the 5 volts from the watchdog timer to light one LED and also run that watchdog signal into a hex buffer chip like the 74HC04 so the 5 volt signal is always inverted? A single 74HC04 will give you six channels. The watchdog signal of 5 volts is either On or Off correct?

    Ron
     
  4. MichiganWolverine5974

    Thread Starter Member

    May 13, 2015
    63
    4
    The watch dog timer is either on or off. But each signal is independent of each other. So if all of them are out putting the 5 volts, I don't want to input all the signals into photocoupler or the LED. If one turns on or if 4 turn on, I still want it to output 5 volts
     
  5. MichiganWolverine5974

    Thread Starter Member

    May 13, 2015
    63
    4
    I've never used a photocoupler before. Wouldn't I have to input 5 volts into the photocoupler to get the 24 volt output I need?
     
  6. Reloadron

    Active Member

    Jan 15, 2015
    963
    232
    OK, I got it. Multiple inputs but a single light. So for example if 1 of 4 is high (5 Volts) the light is lit. If all are low (0 Volts) then no light is lit.

    Ron
     
  7. MichiganWolverine5974

    Thread Starter Member

    May 13, 2015
    63
    4
    Sorry for the confusion.... if any, some, or all of them are high one light is lit. If and only if all are low, the other light is lit.
     
  8. JohnInTX

    Moderator

    Jun 26, 2012
    2,346
    1,029
    The 7401 and 7409 have open-collector outputs so you would need a pullup resistor on each of those outputs in the logic. Consider 7400, 7404, 7408 for any intermediate logic.

    Based on the description 'If any station outputs 5V, turn on a light else turn it off with the other working the opposite' couldn't you just OR the stations getting a logic 1 to drive one light and invert that output to drive the other i.e BAD = GOOD/?

    It sounds like the stations are located apart and drive some monitor light? If so, I'd be tempted to use the 5V from each station to drive the LED in an optocoupler on the monitor board, one opto for each channel. Logic level inputs on the end of a long wire in a noisy environment can be troublesome. Wire the collectors of the opto outputs together to OR them for one light and use an inverter off of that for the other light.

    Good luck.
     
  9. MichiganWolverine5974

    Thread Starter Member

    May 13, 2015
    63
    4
    The stations are located apart from each other. The issue is that the photo coupler I need to use is 5v to 24v and they are pretty pricy.

    The signal wires will probably be about 30-40 feet from the signal source to the logic board. Then from the logic board directed to the photocoupler. Then it will be another 10-20 feet to the light. If noise is an issue, could I use a few capacitors to eliminate the noise?
     
  10. MichiganWolverine5974

    Thread Starter Member

    May 13, 2015
    63
    4
    upload_2015-5-13_12-43-10.png

    Does this look a little more simpler? With the Or gates (74HC32), I wouldn't need pull up resistors, is this correct? One light is always going to be on, just when one any signal is +5vdc one light will be on, and when all the signals are 0vdc, the other will be on
     
    korchoi likes this.
  11. JohnInTX

    Moderator

    Jun 26, 2012
    2,346
    1,029
    OK, I see that the 'opto' you refer to is expensive. So do the logic and protection with cheap stuff. You could use something like a PS2501-4 quad opto for input conditioning and use the combined outputs to drive the PhotoCoupler switches. Connect a 7404 to buffer the output and another to invert that.

    You also could replace all of the gates with a 74HC4708 8-Input OR/NOR gate or similar which would do your logic in fewer packages. At any rate, the logic you show is much simpler and would work OK.

    As others have said, you need to change the wiring of the photo switch inputs so that + is hooked to +5V and the (-) is hooked to the output of the gate. TTL sinks decent current but won't source much and probably not enough to turn on the switches. All that changes is the logic sense - 0 = ON. Wire it up normally and swap the labels on the relays and you are done.

    Have fun.
     
  12. AnalogKid

    Distinguished Member

    Aug 1, 2013
    4,539
    1,251
    Your logic is correct, but there still is the issue that a 7400 series gate output can not source enough current to effectively energize the optocoupler, but it can sink enough. This means that the cathode of each opto's input LED should be connected to the gate output, and the anode connected to +5V through a 220 to 270 ohm resistor. Connected this way, each opto will come on when its input signal is a logic zero. Referring to your first schematic, the outputs of the new schematic would be reversed.

    If these are not fast signals you are working with, then small capacitors on each of the 6 signal inputs will prevent nuisance flickering of your lights. For example, if they are status signals that change once every few seconds rather than narrow pulses, you can use 0.01 uF or 0.1 uF capacitors as noise filters. It would be good to put a small resistor in series with each capacitor, but old TTL inputs are picky about input current. Working from old memory here, a TTL input needs to see an equivalent resistance of around 500 ohms or less to ground to interpret the input as a logic zero. So with the long wire runs, connectors, etc. in the circuit, start with 47 ohms.

    external wire input > 47 ohm resistor in series > 0.1 uF capacitor to GND > input to TTL gate

    ak

    Yes, that is an O-H-I-O license plate.
     
  13. MichiganWolverine5974

    Thread Starter Member

    May 13, 2015
    63
    4
    Thank you so much for all you help. It is great.

    So in other sense, I should wire it like I have it with the OR gates and the one side to the inverter gate. But connect it to the negative (or ground) side of the octocoupler and have the 5v source on the other side of the switch? Thus this would just complete the circuit and turn on the octo.

    Just have it so what ever side I want "on" make sure the logic is "on" to complete the ground?

    Also the P2501-4, would this support a 5v in and a 24v output? I looked at the datasheet, but it was very confusing.

    Thanks again for your help. Its greatly appreciated! GO BLUE
     
  14. JohnInTX

    Moderator

    Jun 26, 2012
    2,346
    1,029
    Yup! The isolated LED input doesn't know the difference. Its probably more common to have outputs pull down the (-) input with the (+) tied to the supply than the other way around.

    Sure. Since the outputs are complementary (opposites) pick the logical sense that works. You probably should be able to flow it out on paper as well but that sounds like work :)

    It would (Collector to Emitter voltage Vceo= 80Vmax) but I was thinking of using them for input conditioning. The 5V signal from the stations turns on the LED and that turns on the output transistor, pulling the collector (pin4) to ground (pin3 connected to GND - pin numbers for the single opto package). If you connected all of the collectors together and pulled that node up with a resistor (33K or so) , any LED on would pull that node LOW. Connect a buffer (74LS04 would do) to that node. Any LED on then would be a logical HIGH output. Connect another 74LS04 to the output of the first one and now you have complementary, buffered outputs that can be used to pull down the (-) inputs of your big opto-relays as before.

    We are talking about things on 2 different levels - the logic and the actual circuitry needed to implement the logic. Personally, I'd use the opto inputs just because I don't like exposing delicate TTL inputs to the bad old outside world. Even if they don't get hammered, you still have to ensure that there is a good ground between all of the stations so that a logic low (<.8v referred to station ground) shows up as a logic low referred to this circuit's ground. 800mv ground offsets (and more) are not unheard of in industrial settings.

    Either way, you are on track with the logic and ultimate driving of the big relays. Proceed.

    You're welcome and as a proud papa of a USNA grad, maybe we could add a bit of GOLD to that, eh?

    EDIT: BTW, all of that fancy input opto talk assumes that your 5V signals from the stations can drive a few mA of current for the LED...
     
    Last edited: May 13, 2015
  15. MichiganWolverine5974

    Thread Starter Member

    May 13, 2015
    63
    4

    I'm pretty sure I understand what I should do now.
    1) use an opto on both ends of the logic to "protect them" from higher voltages

    2)Tie all the outputs from the OR gates together into one node. Then use a pull up resistor from that node to a 5V supply (or Vcc)

    3)I don't understand the need to connect a buffer 74LS04, let alone 2 of them. When they need to go before or after the pull-up resistor

    4) Should all grounds from each 5v signal coming from each station be tied together with all the other grounds in the circuit? I didn't know that a high/low signal needed a ground connected to the rest of the circuit. I thought it was just a "signal"

    5)What do you mean "ground offsets" of 800mv?

    Thank you!! Go Midshipmen!!!
     
  16. JohnInTX

    Moderator

    Jun 26, 2012
    2,346
    1,029
    Getting there!

    1) They provide a low impedance, isolated input that's hard to break. A bonus is that the various stations don't have to run from the same supply or even output the same voltages.
    2) Yes. See the sketch.
    3) The buffer makes it so that the optos just do the logic without having to drive the relays. With a CTR of 80%, you don't get a lot of current out of the phototransistor unless you really bang the LED. Plus, we need complementary logic outputs which would be harder to do with an opto only scheme.
    4) Without optos, yes. With them, all you have to do is light the LED. The input source does not have to be referred to the logic at all - a big plus. As for 'just a signal' every signal has to be referred to something - in this case some common point we are referring to as 'ground' - probably not the best naming convention since we have several points of reference. The stations switch from 0-5V referred to their grounds, the TTL inputs decide on 1 or 0 depending on the input referred to their ground. Note that since stations and non-opto-equipped logic are referred to their local ground, to make everything work, the ground potential must be the same across all units. Making it so can be challenging in a distributed environment leading to..
    5) Ground offsets in the signal lines can arise when things are driven by multiple sources (the stations) that may be far apart and/or sourced from different supplies. Impedances in the conductors can cause voltages to appear in the signal ground lines due to currents, noise etc. These voltages can easily rise to values that would cause trouble in a TTL input. There are many more ways to get burned in this area. That's why optos are frequently used in things like this.

    The sketch should clear up any other questions. I've included sample calculations to show how to choose component values etc. No fair commenting on the penmanship. Still on the first cup of coffee..

    Have fun.
     
    MichiganWolverine5974 likes this.
  17. MichiganWolverine5974

    Thread Starter Member

    May 13, 2015
    63
    4
    upload_2015-5-14_9-48-28.png

    The only issue I have with this is....will the 0v signal from the software complete the circuit for the "ground" for the LED in the opto diode. Since the 5vdc power supply is connected to the positive side of the Diode.

    Also, when one of the stations turns on (outputs 5v), then 5v would be entered into both ended of the diode in the opto. And I don't believe that is very good for the diode. What are your thoughts?
     
  18. MichiganWolverine5974

    Thread Starter Member

    May 13, 2015
    63
    4
    Thank you for the schematic, its very informative and helpful!!! =) Still my concern is the photocoupler will only be "on" when the station is 0 (to complete the ground). When its 5v, the photocoupler will be off (will 5v from each side of the diode be damaging?) Or is the signal connected to the + and - is always connected to ground. I was confused from the conversation yesterday.

    Wouldn't that node be 1 when a station is over 5v since the diode will be on when a station is outputting 5v?

    Also after the inverters, would I be able to add another opto to make a 24vdc output. The LEDs run off of 24vdc (3A max).
     
    Last edited: May 14, 2015
  19. JohnInTX

    Moderator

    Jun 26, 2012
    2,346
    1,029
    5V on both sides of the opto LED won't hurt anything.
    I am working on the assumption from the original post that in normal operation, the stations issue no signal i.e. both lines are 0V or 5V (no net voltage). When one or more stations issue a 5V signal (a difference of 5v i.e. one leg 5V, the other GND) the logic changes state and raises the alarm.
    Correct? If so, the circuit I posted will work. If not, we can change it.
     
  20. MichiganWolverine5974

    Thread Starter Member

    May 13, 2015
    63
    4
    That is correct. 0v input is normal operation. 5v signal is an "alarm or LED". So if the signal is 0v, then the photocouplers are off. Then the node you pointed to on schematic would be 1. Then this logic signal will travel into the inverter and so on.

    If the photocoupler is on (5v), then the +5v logic will go to logic ground and not the inverter?

    Also, would I be able to add another octo at the end of the inverters to output the final 24vdc I need? Just wire the logic signal to the ground and have the positive signal as +24vdc from a power supply?
     
Loading...