# Detecting an open circuit by sensing current flow using a shunt and comparator

I need to detect if a load resistor is taken out of circuit. The load resistor is a photoresistor and can vary from 50k$\Omega$ up to 2M$\Omega$ and is driven by +5V to ground.

The approach I thought of was to put a small sense resistor between +5V and the load, and use a comparator to detect the voltage drop across the sense resistor. When current is flowing, there will be a drop across the sense resistor, one comparator input will be higher than the other and so the comparator output will go to (say) +5V.

When the load is disconnected, there is no drop across the resistor, and so the comparator inputs are (very close to) equal. However, I can't be sure if the output will switch to ground, since the output state of the comparator is undefined when the inputs are equal.

Is there a simple way to add a tiny offset so that the comparator switches at (say) $V_+ > V_- + offset$? That would allow me to guarantee the comparator output when the inputs are equal. I don't want hysteresis here but just an offset to the point where the transition happens.

Alternatively, is there some other way to solve this problem? Basically, I want to detect the difference between even a small current flowing and no current flowing.

Edit: Especially to those who suggested the wheatstone bridge, what if the photoresistor varies from 50k$\Omega$ to 50M$\Omega$? At the higher end of that range, the two inputs to the comparator become very close to being equal again... If I use a gigantic (i.e ~50M) resistor (R3 in @markt's diagram) in the static arm of the bridge to compensate for the larger load range, then V- is going to be very, very close to rail; when the load is disconnected, the two comparator inputs are again very close to being equal to each other.

• I think you need to tell us how the photoresistor will be connected to the rest of your circuit. You said you want to detect when the load resistor is "taken out of a circuit"...what sort of circuit? Are you trying to measure the light level or is this just an academic exercise? – Joe Hass Sep 16 '13 at 10:50
• Not academic - real world :-) The photoresistor is acting as a light detector and is not physically on the same board as the circuitry. I'm trying to detect the situation where the light sensor is left disconnected. As far as the rest of the circuit is concerned, the photoresistor is part of a voltage divider which indirectly indicates the ambient light conditions. – Westerley Sep 16 '13 at 16:26

A good cookbook for op-amp designs (Application Note 31 - Op Amp Circuit Collection) can be found here from the former National Semiconductors (now part of Texas Instruments). On the lower part of page 26, you can find a current monitor circuit. It uses a small value sense resistor in series with the load, like your idea, to measure the current flowing through the voltage being dropped across the sense resistor.

• How does this circuit work? I see the drop across R1 caused by the load will get compared against the drop across R2, but what is Q1 for? – Westerley Sep 16 '13 at 0:03
• @Westerley: there is no comparison involved. Q1 is controlled by the OPA to increase the current flowing through R2 in such a way that the voltages across R1 & R2 are the same. This way the current flowing through R3 is the same as the current flowing through R2, which has a fixed ratio to the current flowing through R1. A key to understand the circuit is that the current flowing through R2 is the same as the current flowing into Q1 (neglecting the input current of the OPA), which is the same as the current flowing out of Q1 to resistor R3 (neglecting the monitor output current). – Laszlo Valko Sep 16 '13 at 4:20
• @LaszloValko Ah, ok! But with no feedback, doesn't the op amp swing from rail to rail (i.e. act as a comparator)? In which case Q1 would be driven off or on? – Westerley Sep 16 '13 at 5:26
• @Westerley: there IS feedback! The output of the OPA controls Q1, which changes the resistance of Q1 between its Source & Drain, changing the current flowing through R3 & R2, thereby changing the voltage at the "-" input of the OPA. – Laszlo Valko Sep 16 '13 at 21:03

simulate this circuit – Schematic created using CircuitLab

Try this.

You probably need to use what is called a bridge circuit. This uses two limbs of resistors.

Here's a picture I just found that is similar to what you probably need: -

The comparator inputs connect to the mid points of the 2 limbs. It's called a wheatstone bridge if you want to look it up. Here is a link where I took the picture from.

This needn't run from +/-15V supplies providing you choose the right comparator or op-amp BUT watch out for leakage currents into the op-amp/comparator inputs if you are using large values of resistance.

With a 50 MΩ (presumably) dark resistance it will be very hard to differentiate between sensor present and an open circuit.

One option that might be worth considering is to mount an LED beside the sensor and pulse the LED periodically while simultaneously checking for a drop in resistance. If there is light on the sensor already the resistance will be low so it won't be necessary to blink the LED.

This solution requires at least one extra wire to drive the LED and due to the switching and checking it probably suits a micro-based project rather than a continuous analog-only circuit.

simulate this circuit – Schematic created using CircuitLab

You should probably check for short-circuits too while you're at it.