Variable DC Voltage Detector

Discussion in 'The Projects Forum' started by jimlbeaver, Jan 28, 2008.

  1. jimlbeaver

    Thread Starter New Member

    Jan 28, 2008
    5
    0
    This should be an easy one...I think I am making it too hard.

    I have a DC power pack that is used for model railroading. It outputs a variable voltage from -14 to 14 v DC. I am building some other digital control circuitry and I want to be able to detect whether there is any voltage coming out of the controller.

    I have a LM339 that I was going to use but, that might be overkill. I am running my logic at +5 but, the LM339 has an open collector so, that shouldn't be a problem. And, it seems to have over voltage tolerance on the inputs up to 36V.

    So, here are my concerns:
    1. There is no discernible ground on the power pack output so, what are the consequences of making tying one of those leads to my circuit ground? I don't want to risk driving current into my digital circuits.

    2. Can I have negative voltages on the inputs if I really only have a single supply +5V circuit? (i.e., I have looked at dual supply circuits but, I couldn't figure out how to accomplish it without having a second +/-36V power supply.

    Maybe there is something even more simple that just uses a high-impedence transistor? (If so, I would have to make order and pay more for shipping than the chip).

    Any help would be appreciated.

    :confused:
     
  2. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Hi Jim,
    So, your +/- 14v supply is floating (not grounded) right?

    Do you have any future plans to ground the DC power pack to your logic supply's ground?

    If not, some things could be worked out with a Zener diode, a few resistors and the comparator IC, I think.

    Actually, just a few regular diodes would work as well - instead of a particular voltage Zener.
     
  3. jimlbeaver

    Thread Starter New Member

    Jan 28, 2008
    5
    0
    I believe it is floating. There is only a two-pronged AC cord into it. It's a product specifically for model railroading so, I don't have the schematics.

    The only reason I was thinking of grounding it was to tie it to this circuit. I am using separate DC power supplies to do the logic and control switches, lights etc.

    What did you have in mind for the diodes?

    Thanks,
     
  4. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    See the attached schematic ;)

    In it, I'm using four 1N4001 diodes to create a constant voltage close to 2.5. They don't have to be 1N4001's, just about any silicon diode would work fine, like 1N4148's, etc. R1 feeds them current from the +5V supply, and they keep the voltage constant with a constant current supplied to them. C1 quiets down any noise. This is our "virtual ground" point for reference.

    R8 and R9 form a voltage divider network for the +/-14V source you want to monitor. R9 is tied to the reference point. The junction of R8/R9 provides a 1/11 scaled voltage for input to the comparators.

    R2/R3 provide a constant reference voltage for U1A, as the R4/R5 network provides a constant reference voltage for U1B. As the circuit sits right now, if the voltage swings away from zero more than about 24 mV (0.264mV at the transformer, due to the scaling), the output of one of the comparators goes high. The LM339 has open-collector outputs; that's why there are 1k Ohm resistors on their outputs.

    If you want, you can OR the two outputs using diodes. Or you could use one of the comparator's outputs to light up a green LED, and the other light up a red. Or whatever you wish. Just as long as you don't expect the comparator to sink over 20mA, you'll be fine. ;)
     
  5. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    There's an improved and corrected version attached to this reply.

    I changed the ratio for the input voltage divider so the comparators will see 5V peak to peak, or roughly 17.5% of the voltage at the power pack instead of 9.1%; more accurate. This will cause one of the comparators to trip if the power pack strays from zero volts more than 137mV in either direction. That thresholds can be changed by the R2/R3 and R4/R5 networks. The 22 and 2.2K resistors give a ratio of 22/2222, or 1/101. Decreasing the 22 Ohm resistors to 10 Ohms would make it more than twice as sensitive, but the more sensitive it is, the more chance you'll have of false readings.

    I also swapped around the comparator references. I neglected to see that I had the low reference on the high input, and the high reference on the low input, which threw things way out of kilter - I didn't notice it until I started double-checking things.
     
  6. jimlbeaver

    Thread Starter New Member

    Jan 28, 2008
    5
    0
    I don't think I have seen that diode trick before. Then again, it's been a long time and I am pretty rusty. I understand the voltage divider and the window comparator part. But, I don't quite understand how these diodes create the ground and why you need 4 of them.

    I am trying to conserve current draw since my 5V supply is driving alot of stuff. So I am guessing I could use larger resistors (but same ratios) to help with that.

    This is a really huge help...thanks for taking the time and being so thorough.
     
  7. jimlbeaver

    Thread Starter New Member

    Jan 28, 2008
    5
    0
    PS. I need all of the current I can get to drive the trains, so I can't have too much draining through the diodes.

    Thanks again.

    Jim
     
  8. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    I understand your concern.

    From the +5v supply, the total current consumption is less than 20mA.
    From the train power pack, the maximum current draw is 2.7mA, which flows through the R8-R9 network.

    If you wish, you can increase R8 to 47k, and R9 to 10K, resulting in a 270uA maximum power draw; however the stability of the circuit may be negatively affected. 2.7mA is not enough current to light a standard LED, so I can hardly imagine that causing a discernable impact on normal train operation.

    The four diodes simply act as a voltage reference. You could certainly use a 2.5V Zener diode instead, or obtain a TL431 adjustable precision shunt reference, and connect it's adjustment terminal to the input terminal - but diodes are cheap and available everywhere for a couple of dollars a dozen - and you can use virtually ANY silicon diode; IN4148, 1N914, etc.

    None of your train power pack current will flow through the diodes. As it is, there is only 2.5mA current flowing through those diodes, which is all sourced from R1 and the +5V supply.

    If you're running short on +5V power, I suggest converting a spare ATX-form factor computer power supply into a bench supply. It's very cheap, easy to do, and you get a LOT of power out of the thing. Just Google "ATX bench supply" and you will find a lot of helpful pages.
     
  9. jimlbeaver

    Thread Starter New Member

    Jan 28, 2008
    5
    0
    Okay, I think I got it now. I wasn't getting the fact that not much current was coming from the power pack. Let me noodle on it a little and make sure I understand it.

    Thanks for the input on the power supply as well. I am using a Basic Stamp BOE board that has a convenient 5V regulator on it but, if I outgrow that, I'll look up the ATX.

    Thanks again for all of your help.
     
Loading...