1
\$\begingroup\$

I have a small and very basic circuit that PWMs an RGB LED. It has a potentiometer to allow me to set brightness level for night time and a LDR that allows me to detect night time.

I took some measurements of the LDR under various lighting conditions so that I could select a reasonable resistor to put in series with the LDR as a voltage divider.

In practice, however, the readings were not what I expected. If I measure the resistance of the LDR with my multimeter, it's about 1/5th what I had measured when it was not in the circuit.

I selected a 51K Ohm resistor for the LDR divider circuit. My multimeter is also measuring that as 10K Ohm. The potentiometer I'm using for setting the brightness is 10K Ohm, but in circuit it measures as about 3K Ohm.

I'm assuming that these resistances are reduced because they're in parallel with each other, but I can't figure out how to isolate them so that I can get reliable readings for the micro-controller.

I'll do my best to mock up the circuit . . .

schematic

simulate this circuit – Schematic created using CircuitLab

Based on some of the comments, I decided I should isolate parts of the circuit to see if I could reproduce the measurements in the full circuit. I built this circuit in a breadboard and the measurements are the same as I mentioned above. That is to say, my expected resistances are reduced by about 66%.

schematic

simulate this circuit

\$\endgroup\$
  • 1
    \$\begingroup\$ That's an effect of measuring the diodes internal to the µC which are protecting the input pins from over/undervoltage. Remove the µC and measure again. (It does not matter, though.) \$\endgroup\$ – Janka Nov 12 '18 at 0:58
  • 2
    \$\begingroup\$ In general, you should not expect to be able to measure the resistance of an individual component with a multimeter when it is connected in-circuit. \$\endgroup\$ – The Photon Nov 12 '18 at 1:00
  • 1
    \$\begingroup\$ @Janka most resistance meters don't output a voltage high enough to switch on diodes, so I don't think this is the issue. Even if this was the case though, I would think the resistance he'd measure would be much lower than what he's seeing \$\endgroup\$ – DerStrom8 Nov 12 '18 at 1:00
  • 1
    \$\begingroup\$ Just curious, but have you considered the idea of doing the analog stuff externally, including the hysteresis, and simply having a digital I/O signal for light/dark? See my answer for Choosing Voltage Divider Resistor For LDR. \$\endgroup\$ – jonk Nov 12 '18 at 1:46
  • 1
    \$\begingroup\$ Are you trying to measure resistances with power applied to the circuit? If so, any readings you get will have little or no relation to the "real" resistance. An ohmmeter applies a voltage between its probes, and measures the resulting current (or applies a current, and measures the resulting voltage). If something else is also causing currents or voltages in the circuit, the ohmmeter reading is meaningless. In any case, the meter measures the apparent resistance between its probes - which will include anything connected in parallel with the component you wish to measure. \$\endgroup\$ – Peter Bennett Nov 12 '18 at 2:19
3
\$\begingroup\$

This is a bit of an X-Y problem. You cannot accurately measure the resistances involved in the voltage dividers when the circuit is not powered, because the constituent resistors wind up in parallel. For instance, when you attempt to measure the resistance across the LDR, you wind up measuring the resistance of this circuit:

schematic

simulate this circuit – Schematic created using CircuitLab

Which, if you do the math gives you:

\$R_{measured} = \frac{1}{ \frac{1}{R_{LDR}} +\frac{1}{ R_{1} + R_{2}} }\$

\$R_{measured} = \frac{1}{ \frac{1}{82k} +\frac{1}{ 51k + 10k} } = 34.97k\Omega\$

That said, this does not mean that the two dividers will interfere with each other in circuit. In that case, as long as the power supply is stable and has low impedance, the voltage across the whole divider can be considered fixed. The typical way that surrounding circuitry interferes with the output of a voltage divider is when enough current is drawn out of the voltage divider to create a meaningful error in the divider.

schematic

simulate this circuit

Ideally, the load current on the output of the voltage divider would be zero, and if the voltage divider were connected to the input of an op amp, that would be close enough to true. If, however, we draw a substantial amount of current \$I\$ out of the divider, then we get an error:

If \$I\$ is zero: \$V_{out} = \frac{V}{R_{1}+R_{2}}\times R_{2}\$

If \$I\$ is non-zero: \$V_{out} = (\frac{V}{R_{1}+R_{2}}-I)\times R_{2}\$

(note that the sign of \$I\$ depends on the direction of current flow, so the error could increase or decrease our actual reading)

This shows that the amount of current that flows out of the voltage divider \$(I)\$ needs to be substantially smaller than the current that flows through the divider \$ (\frac{V}{R_{1}+R_{2}})\$ to minimize this error.

Now, you haven't mentioned whether your ADC readings are coming out as you expect, but let's discuss the main potential source of error there anyway. To start with, lets look at what a typical ADC channel looks like, electrically. In this case, it's going to have a sampling capacitor that is temporarily connected to the input for some period of time before the ADC performs the conversion. Something like this:

schematic

simulate this circuit

What this means is that during the sampling time, the input mux will have connected the appropriate input channel to the sampling capacitor, and the capacitor will charge (or discharge) towards the input voltage at a rate determined by the capacitance and the impedance of whatever's connected to the selected ADC input (in this case, one of your voltage dividers). In order to get an accurate reading, your sampling time must be some multiple of the time constant of the sampling capacitor and your total input impedance (check the datasheet for details). If your sampling time is inadequate, your ADC readings will be off, because the sampling capacitor does not have adequate time to charge or discharge to the correct voltage.

For this reason, the sampling time on MCU ADCs is typically configurable, as the required sampling time will depend on the nature of the circuitry you're attempting to measure. If you have some really high impedance circuitry, you would probably want to use an op-amp buffer as another answer suggests. However, in your case, this is entirely unnecessary as long as your sampling time is set correctly.

\$\endgroup\$
  • 1
    \$\begingroup\$ This is a solid answer. \$\endgroup\$ – DerStrom8 Nov 12 '18 at 11:31
1
\$\begingroup\$

The easiest way to do this is using an op-amp buffer circuit:

enter image description here

V_in is connected to the output of your voltage divider, and V_out connects to the rest of the circuit.

No current flows into the inputs of an op-amp (practically speaking, anyway), so this will not affect the behavior of the voltage divider. The output voltage of the op-amp will follow the input voltage exactly, since it is a x 1 amplifier. This is usually the easiest way to isolate your voltage divider from the rest of the circuit so that additional impedance doesn't affect the voltage divider output.

EDIT: You may need to use one of these as the supply to the voltage dividers for your particular setup. In that case connect V_in to your Vcc, and V_out to the "top" of the resistor divider.

\$\endgroup\$
  • 1
    \$\begingroup\$ An excellent question by the way. \$\endgroup\$ – DerStrom8 Nov 12 '18 at 0:59
  • 1
    \$\begingroup\$ This is definitely information worth knowing, but is not clearly related to the OP's present problems, which relate to using a multimeter to measure in circuit, nor to the actual function of the OP's circut, where the impedances are low enough that this technique is not necessary. \$\endgroup\$ – ajb Nov 12 '18 at 2:44
  • 1
    \$\begingroup\$ @ajb The title of the question itself asks how to isolate the dividers so that they aren't interfered with by other parts of the circuit, which is the question that I answered. But either way I would expect this solution to help, though as was already mentioned in comments, the best way would be to pull the parts out of the circuit. \$\endgroup\$ – DerStrom8 Nov 12 '18 at 2:58
  • 1
    \$\begingroup\$ @DerStrom8 An opamp buffer will essentially add nothing over OP's current circuit. Some of the interference comes through R2 and the rails, some of it through the ESD protection devices, which an opamp is as likely to have as a microcontroller. The circuit is effectively identical to the current one, since you still have the same things connected effectively in parallel to the DUT. \$\endgroup\$ – nitro2k01 Nov 12 '18 at 6:21
  • 1
    \$\begingroup\$ @nitro2k01 I don't think you understand my answer. First of all, I doubt ESD protection devices are interfering in this case because, as I already said before, most resistance meters don't apply a voltage high enough to cause silicon to switch on. Therefore it can be treated as an open circuit, or at the very least a very high impedance. As for the op-amp buffers, you can use them to isolate each divider/resistance from the rails, which is what the OP was asking for. \$\endgroup\$ – DerStrom8 Nov 12 '18 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.