Need to build a 2-channel AND gate…but I don’t know wtf I’m doing - Page 1
Forum section: electronics / beginners

author: bri
author_rank: Contributor
timestamp: August 24, 2017, 09:49:04 pm
content: Hey,I’m doing a personal project that I don’t want to go into excessive detail on just yet, but the major thing that I’m doing (which I need some help with) is replacing a multiple-output power supply that was custom-designed for a circuit board with a PicoPSU-120, and then substituting the 5V rail on the PicoPSU with a larger one from a separate, 15A 12V to 5V DC-DC converter.I specifically chose 15A because I do not know the exact current draw of my application, but its stock power supply’s 5V rail is rated for 13.2A, and its 12V rail is rated fore a measly 1.2A. In comparison the PicoPSU-120’s 5V rail is rated for 6A sustained and requires forced air cooling with that current draw, but its 12V rail is rated for 7-10A and draws directly from the 12V input (except switched).Now here’s where the AND gate comes in: an ATX power supply needs to assert that its power rails have stabilized by outputting 5V across a line known variously as “PS_GOOD” or “PS_OK” or “PWR_GOOD” or “PWR_OK” and so on. This line is only a sense line to tell the computer attached to boot; it is not used for current draw. I have looked around and found a lot of 12v to 5v DC-DC converters on Amazon and the like, and many of them mention “automotive” and “subwoofer” leading me to believe that for cheap ($20 max) crap they can’t bethatbad — if my subwoofer growled based on the throttle position of my car I would be unhappy, and I know I’m not alone, so I at least am planning on returning anything that’s noisy or otherwise gives me problems. But of course, none of them have internal test mechanisms that assert themselves when they’ve stabilized.I’ve read that the cheapest “ATX” power supplies just break the spec by tying their 5V output directly to the PS_OK line, causing the computer to potentially begin booting before the power supply’s lines are stable, but it “works.” I imagine I could do that, or (and this probably wouldn’t be much better) I could leave the PicoPSU’s OK line alone so the Pico itself asserts that it’s OK, but that will completely bypass the additional 5V converter I’m adding. What I think would be thebestway to stay close to spec would be to attach PS_GOOD from the Pico to one input on an AND gate, and the output from my auxiliary 5V rail to the other input, and then splice the output of the gate to the PS_GOOD input on the circuit this all attaches to.I don’t know my ass from my elbows when it comes to digital transistor logic. I pulled two transistors out of my parts bin by knowing the package shape (and so I have two IRF520 power MOSFETs) but I have no idea if these would even work for what I want to do. Basically, I have no idea how an AND gate works aside from requiring two transistors, and what I’m finding on Google leaves me scratching my head.A few things unrelated to the AND gate that I imagine I’ll be asked: the PicoPSU doesNOTrequire a load across any of its outputs for it to function properly. I checked with their engineering department on that one. And also, I know I’d want to completely isolate this 5V converter from the one built-into the PicoPSU. In other words, I intend to splice every 5V lead on my PicoPSU and swap it over to this other supply’s output. (Come to think of it, I should get a terminal block while I’m at it to make this part a little simpler and cleaner, but I digress…) and simply not use the primary 5V rail from the PicoPSU at all. Again, I have confirmed with the engineers that designed it that the PicoPSU-120 will function properly without a load across any of the rails, so I’m not concerned about that.And most importantly,yes,I know I’m messing with power supplies. I know the implications, and while I might not be an electrical engineer (just yet…) I am well aware of electrical safety. That’s actually part of why I’m using low voltage DC-DC supplies here. (The other reasons being size and heat generation).So… am I missing anything? To simplify this all down to a single question, how would I make an AND gate that’ll switch a 5V output based on two 5V inputs?According to theATX power supply specification, the asserted signal should be <0.4V when low (and it mentions “while sinking 4 mA” but I’m not certain what that means — does it mean that it should be able to function as ground without burning for a load ? 4mA?) and 2.4-5V when high (“while sourcing 200µA,” which I figure simply means “don’t draw more than 200µA from this line”). It also states that the high state output impedance should be "1k? from output to common” which I am not certain about, either. Finally, it states the signal should be +5V TTL compatible, which I’m not worried about since I already know that. (All this information is on page 26 of the PDF, in Table 21)tl;dr: 5V TTL AND gate. All inputs and outputs are 5V. IF 5vA= 5v AND 5vB= 5v THEN OUT = 5v. IF 5vA? 0.4v OR 5vB? 0.4v THEN OUT = ? 0.4vEDIT: replaced Unicode logic symbols with text.

author: KL27x
author_rank: Super Contributor
timestamp: August 24, 2017, 10:08:17 pm
content: Pullups and open drain ouptuts are the simplest way to look at this, IMO.Whenever you have say 2 open drain outputs connected together with, say, a pullup to 5v, you get:5V output is the result when both open drain outputs are off. And only when this is the case. This is the AND result. The logic low output will happen when either or both are switched on, which equates to an ior result. Reverse the logic of inputs and/or outputs as you need.You can have open drain P transistor outputs with pulldown to ground. You can reverse the logic after the fact. You can do it however you want.An open collector output is what you'd call it, if it's BJT. Open drain for FET. Same thing. The source/emitter goes on the rail. The drain/collector IS the output, which is simply floating when it's off. So you put a pullup/down on it, and this gives you the logic level output.In N-style, the collector/drain output will need pullup to the positive rail, and the source/emitter will be tied to the ground rail.You can pretty much forget you ever read the current/voltage specs. Don't worry about it. This just gives you data you need to know the maximum impedance or value of pullup resistor you can put on the input to make sure it registers as a logic high. And how much current will be sunk if you tie it directly to ground rail. But it's an input. Which means you can tie it directly to +5 or ground rail without any damage. You can choose pullup/down value to provide enough current with margin to spare. Unless you are designing super low power draw circuit you do not need to flirt with minimum. Just use 10K resistor for pullup/down and forget you read this stuff.

author: Ian.M
author_rank: Super Contributor
timestamp: August 25, 2017, 10:55:58 am
content: @O.P,*NOT* a good idea - as described you may run into power sequencing problems and possibly damage your board.What you need to do is make the presence of power from the ATX PSU switch on the substitute 5V supply output - this would be easy to do with a 20A logic level MOSFET, gate to +12V via a 100R resistor, drain to substitute +5V, source to the 5V load - and intercept the active low ATX PS_ON# signal and OR it with the output of a PSU supervisor IC*monitoring the substitute 5V supply output before the MOSFET. If the new 5V rail is out of spec its disconnected from the load and the ATX PSU is held in shutdown. The OR gate should be TTL and powered from the ATX 5V standby supply.You can get ATX PSU cable extenders - better to hack one of those rather than the original PSU wiring harness.* Or a reset controller. However whatever you use needs an active low output when the rail its monitoring is in spec. If all you can find is active high, use a 74LS00 and De Morgan's laws to implement the OR function with the input from the PSU supervisor inverted.

author: IanMacdonald
author_rank: Frequent Contributor
timestamp: August 25, 2017, 12:56:05 pm
content: Something like one side of a dual 4-input schmitt cmos nand gate would do. Followed by the other nand wired as an invertor.You then need to work out what potential divider is needed on each input to take the gate past its threshold if the supply is adequate. The schmitt input is needed to give a clean output change. Basically if any i/p is below its threshold the first gate o/p is high, so the second gate o/p is low and the computer doesn't start.Remember to tie all unused cmos inputs to +Vdd, or to another input.One chip, and two resistors per supply rail. You could make something more precise and repeatable using a TL084 quad opamp and a reference zener, but the arrangement I've outlined should do for a one-off.

author: bri
author_rank: Contributor
timestamp: August 25, 2017, 05:19:39 pm
content: Quote from: Ian.M on August 25, 2017, 10:55:58 amSo, in order to rephrase this so I know if I understand, I want the substitute 5v supply to have a constant input upon applying power to the main DC input, and wire up a circuit to switch its output — rather than switching its12V inputby connecting that to the output from the ATX PicoPSU? This would solve something else I was slightly concerned about — the PicoPSU’s manual suggests not drawing more than 7A max, 10A peak from the 12V output, although it states that forced air cooling is not required for a sustained max load onthatrail (presumably because it’s only regulated by switching the input) so I was figuring I could cheat a little there. The spec for 5V on the stock power supply I’m replacing is 13.2A, which is why I chose 15A (15A 12V to 5V DC-DC converters are readily available, and on the off-chance that 10A isn’t actually enough 15A would be).Is the power sequencing problem you mention something like the Pico turning on PS_OK, which then would connect to my AND gate, and then as soon as the 5V substitute supply is high enough to trigger the other input of the AND gate (regardless of what the actual voltage is) its output would be HIGH thus signaling the motherboard to boot (whether or not 5V actually is stable)?I don’t think I mentioned clearly enough how much of a newbie I am to this. I’ve never taken an electronics course, and I’ve learned everything I know between reading and experimenting. (Please don’t try to discourage me from this project, the entire reason I’m wanting to pursue this myself is to learn more about proper power supply logic; knowing what I know about the type of motherboard I’m powering with this it’s very likely I could get away with cheating aloton the spec, but I want to remain (at least mostly) ATX compliant for the sake of learning how this works).Quote from: Ian.M on August 25, 2017, 10:55:58 amI’m hoping to do this without a dedicated PSU supervisor IC. If I can make something myself out of discrete parts that functions as one that’d be better. However, I’m also open to either buying one new (if they’re not that expensive) or stealing one from an old PSU.That said, again to reiterate what you’re saying to ensure I understand: the idea is that the MOSFET becomes the switched output of the 5V supply (and as mentioned above it’s powered by the direct, “always on” 12V input instead of being switched on via 12V output from the PicoPSU) and then… I’m a little lost at the OR gate — is that simply because PS_ON# is active-low, as opposed to the PWR_OK signal from the ATX PicoPSU that is held high when the PicoPSU is ready?So really, I wouldn’t be influencing the PWR_OK line at all; I’d just be leaving that to the ATX supply. Rather I’d be switching the output of my substitute 5V rail (which is otherwise “always on” before the MOSFET, like the 5Vsb line) and if the PSU monitoring chip says it’s NG then the OR gate would raise PS_ON# high, turning the PicoPSU off.Why would I be better off raising PS_ON# high in the event of bad 5V than de-asserting PWR_OK?Quote from: Ian.M on August 25, 2017, 10:55:58 amI actually have no choice but to hack an ATX extender because the PicoPSU is just two double-sided PCBs soldered directly to the Molex Mini-Fit Jr. plug, anyway. Not to mention I have pin extraction tools to leave cutting to a minimum. I actually have an ATX extender on my desk right now that I’m intending on using for this. It’s 24-pin, and the PicoPSU is only 20-pin (and in fact this extender is a 24-to-20-pin adapter), but thanks to the genius keying design I just have to be aware of the extra 4 pins (and which four they are!)Quote from: Ian.M on August 25, 2017, 10:55:58 amWhat is a reset controller?What are De Morgan’s laws?I ended up bumping into this while still writing this: De Morgan’s laws are logical laws that (to oversimplify for this) allow one to implement the OR function via AND gates and inverters, and vice versaI’m going to look this up online as soon as I hit post, but I figure I’ll ask here, too.Quote from: IanMacdonald on August 25, 2017, 12:56:05 pmSo this would be essentially making my own rudimentary PSU monitor by biasing (I’m not sure if this is the right word for this) the transistor inputs such that an under voltage would not turn on PWR_OK? Is there a way to use another gate/inverter/something to also account for an overvoltage? Say, biasing a gate such that it requires 5.25V to go HIGH, inverting that, and then using itto pull PWR_OK back low?as input to a gate with the undervoltage gate as the other input?EDIT: something didn’t feel right, I want to use transistor logic and not have resistors pulling things up or down here if I understand it correctly, or at least that’s the way I intend to implement it. I think. One gate goes high if the voltage is above 5.25V (overvoltage, and low if not), another gate goes low if the voltage is below 4.75V (the undervoltage limit, and high if not), both are inputs to an XOR gate (or whatever, De Morgan’s laws are such that I can invert an input and use an AND gate instead of an XOR, and similar, right?) and that’s the final PWR_GOOD output?I don’t know what Schmitt means. I know I’ve heard the term used in this sort of context before, but I’m not quite sure.Schmitt is referring to a Schmitt trigger? If I’m understanding Wikipedia’s article on it correctly, I’d have the Schmitt set to “trigger” high at 5 volts with a .25v hysteresis (how do I do this?), and it would be the input to my XOR that goes low if the voltage falls to low?…am I making sense here? I apologize sincerely for how much hand-holding I might need here… This is really my first attempt at understanding semiconductors.

author: Ian.M
author_rank: Super Contributor
timestamp: August 26, 2017, 10:08:28 am
content: To attempt to clarify: the MOSFET gate must be driven by the SWITCHED 12V output of the ATX PSU. Due to the circuit I suggested, the ATX PSU cant switch on unless your replacement 5V supply is up and running, but the MOSFET only switches 5V to your board when all the other ATX outputs turn on. If the replacement 5V rail before the MOSFET is out of spec or missing the ATX PSU is disabled. That way there's no way (short of MOSFET failure) for the 5V to be applied without the other power rails or for the other rails to be applied without the 5V.Why intercept PS_ON# instead of PWR_GOOD?PWR_GOOD is used to hold the board in reset. If the replacement 5V supply was missing, holding the boar in reset may not be enough to prevent damage. Forcing the ATX PSU off by overriding PS_ON# totally cuts power to the board, minimising the risk of damage if the replacement 5V supply trips or fails.N.B. if your board remembers its power on state and reasserts PS_ON# if power is lost and reapplied, you'll need extra logic to wait for a new low going transition on its PS_ON# output after the replacement 5V rail becomes good, otherwise if it trips the 5V supply due to over-current, the MOSFET will cut off, removing the overload and the board will attempt to restart the ATX PSU, tirning the 5V rail back on and tripping it again repeatedly. The desired behaviour is for any overload to tripp the PSUs and stay off.

author: bri
author_rank: Contributor
timestamp: August 28, 2017, 11:43:48 pm
content: So I think I’m starting to understand better. But one thing that eludes me is how to monitor voltage without a special monitoring IC. I’d rather build my own, as half the idea of the project is to learn more about how all this works, but I’m not finding much of anything for a voltage monitoring/protection circuit on Google. Is it really that complex to monitor for > ±0.25V difference

author: Ian.M
author_rank: Super Contributor
timestamp: August 29, 2017, 01:53:55 am
content: You'd want awindow comparator, probably using aLM393Dual Comparator or equivalent. You could also use the very similar LM339 Quad comparator if you wanted to monitor two different voltage rails.However by the time you've added low pass filtering so it doesn't trip on EMI, and added its own reference because you don't trust the accuracy or stability of the 5v standby supply, and hysterisis so it doesn't jitter if the rail is right on the edge of the spec, even a single window comparator gets rather complex.Therefore IMHO you should get a precision PSU supervisor IC that has all the gubbins built in and just needs a few resistors to set the upper and lower threshold.LTspicesim, complete with LM393 model attached.

author: Zero999
author_rank: Super Contributor
timestamp: August 29, 2017, 12:58:06 pm
content: Quote from: Ian.M on August 29, 2017, 01:53:55 amAre D2 & D3 really required in real life or are they there for simulation purposes. The LM393/339 have open collector outputs, so unless you want to keep the low output level above a few hundred mV, then the diodes aren't necessary.

author: Ian.M
author_rank: Super Contributor
timestamp: August 29, 2017, 01:29:57 pm
content: The diodes*vastly reduce positive feedback to one comparator becoming negative feedback to the other when coupled through R8 or R3. Without them its much harder to tweak the hysterisis (try R9=390K,R10=1.2Meg) and the lower limit transitions become rather sloppy. Try it and see (don't forget to also delete net labels 'uo' & 'lo'), plotting V(out) against V(in) on x axis.* Schottky so it can meet a real TTL logic '0' threshold.

author: bri
author_rank: Contributor
timestamp: August 29, 2017, 03:29:49 pm
content: Okay, this makes sense, I guess I’m going to look up 5v supervisor/voltage monitor ICs. Any suggestions for something inexpensive and simple to work with?Quote from: Ian.M on August 29, 2017, 01:53:55 amThis actually gets me thinking — I wasn’t intending on substituting the 5Vsb rail because the one in the PicoPSU is good enough for me, but is there any reason why I should — or shouldn’t — substitute it as well? If my supply is going to have its input on at all times then I could certainly add another FET that allows it to pass its 5v output as long as the supervisor IC approves (i.e., regardless of PS_ON#, as long as voltage is within tolerances), but I have no idea if Ishouldor not.EDIT: the PicoPSU has ±1.25% tolerances on the 5Vsb rail (http://resources.mini-box.com/online/PWR-PICOPSU-120/PWR-PICOPSU-120-manual-engl.pdf), and although I didn’t specifically check the ATX supply spec on this Ithinkthat 5V and 5Vsb aren’t allowed to touch, and thus I shouldn’t have to worry about fighting 5v regulators.

author: Zero999
author_rank: Super Contributor
timestamp: August 29, 2017, 03:53:54 pm
content: How about the LTC4365?http://cds.linear.com/docs/en/datasheet/4365fa.pdfPreviously discussed here:https://www.eevblog.com/forum/projects/ltc4365-resistor-values/msg1194789/#msg1194789I did some calculator spreadsheets, see the following links:OpenOffice.orgExcel

author: Ian.M
author_rank: Super Contributor
timestamp: August 29, 2017, 04:08:33 pm
content: The reason not to trust the 5V standby supply AS A VOLTAGE REFERENCE for the other supplies is its tolerance makes it difficult to set the upper and lower limits for other rails. I would however trust it to supply near enough 5V at its rated current.Linear Technology'sLTC2912Single UV/OV Voltage Monitor looks like a likely candidate - three resistor divider chain to set the thresholds and its /OV and /UV outputs can be wire-ORed together. You will however need a SOT23-8 breakout board for it if you want to prototype it on matrixboard or in a breadboard.The LTC4365 is more for input protection, and if you are running this off an automotive 12V supply woud be a sensible addition upstream of your PSUs

author: bri
author_rank: Contributor
timestamp: August 29, 2017, 06:08:33 pm
content: What about theTPS3702? (Specifically a TPS3702CX50.)Also, these are all ridiculously small… I see why I need a breakout board — I was really hoping to not need a board at all… ¯\_(?)_/¯

author: Ian.M
author_rank: Super Contributor
timestamp: August 29, 2017, 06:59:49 pm
content: Yes, the TPS3702CX50 could work - even fewer external components but you have to settle for their standard thresholds.

author: bri
author_rank: Contributor
timestamp: September 04, 2017, 02:59:19 am
content: I’m starting to get really frustrated here… I definitely don’t know enough about electronic signaling to do this the way I hoped. I’m thinking I’m probably going to end up implementing my logic by interfacing a monitoring chip, the logic signals to/from the ATX PSU, the gate to my MOSFET, and logic to/from the motherboard all to an ATtiny and just implementing the logic in software. I’m confident that I could write an appropriate state machine in Arduino-dialect C++ and AVRs already use TTL signals.But then there’s still the issue of how to wire up the MOSFET, and I’m just not even sure what sort of MOSFET I want — since I’m switching a positive voltage do I want a P-MOSFET? And how would I interface it to the micro? I assume if I use a logic level FET I just hook gate to a pin that I set as an output, and then either drain or source goes to the substitute 5v and the other side to my load, but then would I drive it low or high to switch it? And which way’s on? …and which one (drain or source) goes to the load and then ground?I’m feeling really dumb hereI need to take some online electronics courses or something, because I really don’t know as much as I thought I did.Sent from my iPhone using Tapatalk

author: Ian.M
author_rank: Super Contributor
timestamp: September 04, 2017, 04:07:44 am
content: Whatever you do, the MOSFET's body diode needs to be reverse biassed, or you cant switch it off! For a N-MOSFET that means the drain must be positive with respect to the source, and the reverse for a P-MOSFET.A N channel MOSFET used as a high side switch needs a gate voltage supply above the rail its switching. This is often awkward to arrange, so at low to medium power levels its usually preferable to use a P channel MOSFET, even though the lower charge carrier mobility results in higher resistive losses for the same silicon area. However, in your application you have +12V available from the PicoPSU so *could* use a N-MOSFET to switch the 5V rail, as long as it had a gate threshold voltage <3.5V. (rough rule of thumb: you need double the gate threshold voltage to switch a MOSFET on hard enough to be worthwhile), due to the 7V difference between the +5V and +12V rails. The problem would be driving it from a ground referenced logic level signal - it needs a full 12V swing for its gate (otherwise it wont turn fully off as it will act as a source follower if you just dropped the gate to 5V). There are various ways of doing this including purpose designed gate driver chips, or discrete level shifters. A P-MOSFET would be easier to drive - just pull its gate down to 0V to turn it on or up to 5V to turn it off, but you'd have to do the math with the ATtiny output current rating, the total gate charge of the MOSFET, and the MOSFET's load current (including inital charging surge for the caps on the board's 5V rail) to check you can switch it fast enough not to burn up due to excessive dissipation while in its linear region, while also not exceeding the ATtiny's ratings.

author: bri
author_rank: Contributor
timestamp: September 04, 2017, 04:48:22 am
content: Quote from: Ian.M on September 04, 2017, 04:07:44 amI really hate to be that guy that asks for something that probably can be found on Google, but I don’t know what to search for: what math? What sort of formulas are involved? Doing such math, how would I pick a suitable MOSFET?Are these the sort of graphs I would see in the data sheets for MOSFETs?Also, what’s harder on the MC? Switching the FET on or off? In other words, would I want a pull-up resistor and have the micro pull low to turn it on and go high impedance to turn it off? Or would I want to have a pull-down resistor and have the micro go high impedance to turn it on and pull high to turn it off?Would it be safer to drive another transistor we’ll call Q2 via the micro, and use Q2 to drive the MOSFET? If so, what kind of transistor would I want there? Or you mentioned something about gate drivers?Are there ICs that integrate this all in (and can handle this amount of current)?I mean, I’m sure that for a one-off thing I’m making for myself I wouldn’t need to go this far, but what’s inside an ordinary ATX PSU to control its logic and rail outputs?EDIT: If it matters, the device will definitely not be power cycled frequently or fast, and it will be off more than it is on.Which also reminds me, am I going to want to mount a heat sink to this MOSFET? I mean, it shouldn’t consume much power itself in the circuit, so I’m guessing I wouldn’t?

author: bri
author_rank: Contributor
timestamp: September 19, 2017, 10:47:01 pm
content: So I've decided to go against my idea of doing things with discrete transistors and use an Infineon high current load switch, a TI power monitor IC, and a TI dual NOR gate. Part of this is because it looks like I'm going to need to make a PCB for this, so I might as well do something nice.That all said, is anyone willing to evaluate this schematic and tell me if they think it should work?EDIT: I screwed something up, nevermind

author: bri
author_rank: Contributor
timestamp: September 25, 2017, 08:45:56 pm
content: Well, here’s my completed design. I hope I didn’t do something terribly wrong here.…Wish me luck! Especially when it comes to soldering that TPS3702. Until having it in front of me it looked alotbigger…If it works I’ll put it up on OSH Park as a shared project. I already ordered the boards.(Countdown until I blow myself up begins now)