3
\$\begingroup\$

I have an application where I need to measure the voltage drop over a resistor that varies between 10 ohm - 50 kohm. As I have this set up as a voltage divider, with the result being read by an AtoD, I thought the best way to be accurate is to switch in different resistors, depending on the resistance of the variable one:

schematic

simulate this circuit – Schematic created using CircuitLab

Something like the above. This needs to be controlled by a microcontroller, and my initial thought was to use a multiplexer to switch in the different resistors. This seemed like a good idea at first, however, when looking through the datasheets of these components, the ON resistance was a problem. For the higher ranges, it was negligible, but if the 100R resistor was in, the on resistance of the MUX was significant enough to affect the result.

This is a budget controlled design so all of the very low on resistance MUX/decoders etc. are out of the budget (I am not in control of this). My next thought was to perhaps use MOSFETS to switch in the resistors as these can be extremely low with on resistance, however, this takes us more port pins on my microcontroller. 4 rather than 2. This would leave me with only 2 I/O pins left, which doesn't leave much room for adding anything else that may be requested in the future. This method also means more components, which slightly adds to the placement cost.

Is there a better way to do this that I am missing? Or are the MOSFETS perhaps the best way to do this?

\$\endgroup\$
13
  • 1
    \$\begingroup\$ Decoder and mosfets \$\endgroup\$ – Kartman May 19 at 7:30
  • 1
    \$\begingroup\$ @Kartman I did mention budget a few times in the question. It needs to be a cheap solution. Yes, the components don't cost much, but when hundreds or thousands are being made, I'm being asked to stick to a tight budget. Adding more components to the solution won't work \$\endgroup\$ – MCG May 19 at 7:34
  • \$\begingroup\$ If you explain the application a bit better than "measure voltage drop across a resistor" I am sure people can recommend solutions that are far simpler than the depicted one. \$\endgroup\$ – tobalt May 19 at 7:37
  • 1
    \$\begingroup\$ @tobalt I don't think it needs more. That is essentially what it is doing. Measuring the voltage drop over something that has a varying resistance depending what it is measuring. Doesn't matter whether this is a thermistor, FSR, whatever, it is still measuring the drop over a change in resistance \$\endgroup\$ – MCG May 19 at 7:41
  • \$\begingroup\$ @MCG so you are essentially trying to measure the unknown resistance ? Because everything else is put in by your circuit (VCC, series resistors, switching) \$\endgroup\$ – tobalt May 19 at 7:42
4
\$\begingroup\$

More cost efficiency (this feels like code golf):

  • only 1 control line
  • only 1 transistor (N JFET or P MOSFET), 1 R and 1 C
  • infinite number of possible measurement ranges
  • can get rid of the ADC, if it isn't needed otherwise (see below)
  • needs calibration and could be temperature dependent, but the same goes for the switched R method at a lesser extent (so it depends on your desired level of accuracy)
  • 1kS/s is ambituous with an MCU (needs fast control clock)

enter image description here

How does it work:

By controlling the duty cycle of control, you vary the DC gate voltage and therefore tune the resistance of the FET in a continuous fashion. You can also use feedback to bring AtoD to some defined voltage (e.g. VCC/2) and then your Duty cycle gives you the value of R1 (via a conversion which you have to establish once).

Down the road, you could even scrub the ADC (save costs) and realize the feedback with a comparator, so your MCU can read the duty cycle directly.

\$\endgroup\$
12
  • \$\begingroup\$ The ADC does have a buffer on the input, it just wasn't important to the question to put it in here as that isn't the part of the circuit I am focusing on. Adding in another component like a MUX as well as the MOSFETs isn't a good solution as it adds extra cost to the design as mentioned in the comments \$\endgroup\$ – MCG May 19 at 7:39
  • \$\begingroup\$ Ok, that gives me an idea of the level of cost-sensitivity you are talking ;) \$\endgroup\$ – tobalt May 19 at 7:40
  • \$\begingroup\$ With the edit, where does the infinite measurement ranges come from? You are still just switching a FET which was one of my earlier thoughts? As to calibration, this will be done, as well as having temperature compensation for ambient temperatures between -10°C to +50°C \$\endgroup\$ – MCG May 19 at 7:55
  • 2
    \$\begingroup\$ Code golf should be used more often in other fields of engineering. Not as a goal in itself but as a method to question complexity and cost. \$\endgroup\$ – winny May 19 at 8:00
  • 1
    \$\begingroup\$ Ahh I see. Still very early in the morning! +1 for this, I'll stick this circuit into the next prototype and see how it works. If no other solutions come up, I'll accept this in a couple of days. Cheers for the response! \$\endgroup\$ – MCG May 19 at 8:09
3
\$\begingroup\$

If your microcontroller has tri-state I/O pins, you may not need transistors to switch the resistors. Just use three IO pins and switch them between high (output) and high-impedance (input) mode:

schematic

simulate this circuit – Schematic created using CircuitLab

You can use variants of this circuit with the resistors in parallel or on the low side, etc.

Also look into whether your microcontroller has configurable series resistors built into the pins that you could rely on to dispense with the lowest value resistor.

[EDIT] You may need to adjust the resistor values to stay within the current capabilities of your microcontroller. Maybe you can get sufficient accuracy with just 2 pins and 3 resistors down to 470 Ohms.

\$\endgroup\$
1
  • \$\begingroup\$ This microcontroller doesn't have tri-state pins unfortunately, however, it's a good idea, so still +1 \$\endgroup\$ – MCG May 19 at 23:01
2
\$\begingroup\$

Your requirements (2% accuracy @ 1 kHz sample rate) are relatively high; because of this I think I would avoid 'tricks' that require oversampling, and stick to using MOSFETS to switch in the resistors.

But if you want to lower costs you may be able to get away with fewer than 4 resistors, depending on the effective noise-free resolution of your ADC at this sample rate:

enter image description here

Note that this is just looking at a 2% resolution, not necessarily 2% accuracy. But with a 16-bit ADC you may be able to get away with a single 680 Ohm resistor (no need for any switching). With a 12-bit ADC two resistors may be enough. With a 10-bit ADC, you probably need three.

Note that you don't need to switch out the highest calibre resistor — you can just switch in a lower resistor in parallel. So if you use 2 resistors, you only need one MOSFET, etc.

\$\endgroup\$
2
  • \$\begingroup\$ Another good idea. +1 again! I'll be designing all of these into the next prototype so I can test each of them. Which program did you use to make that graph? Or was it a graph you found somewhere? \$\endgroup\$ – MCG May 20 at 11:53
  • 1
    \$\begingroup\$ @MCG I used python: gist.github.com/damiendr/ed47eafa26b4ef938d66d16c6e2031e1 \$\endgroup\$ – DamienD May 20 at 12:08
1
\$\begingroup\$

Another very low cost way. While the original one can get rid of the ADC and save a lot of cost, it may not be able to achieve 1kHz of bandwidth if the Control Clock of the MCU is too low.

Here is another solution that requires the ADC, but uses zero control lines and realizes a logarithmic resistance measurement. Part costs should be well below 50c. The output voltage will be proportional to the log of R over some decades. As the accuracy requirement is modest, the logarithmic single range solution should be fine.

enter image description here

If the current through D1 and R1 is too large for small R values, then a two transistor current sink can be wrapped around R1. This will also make the circuit more temp stable and use less current for minimum added cost.

The gain settings resistors R2 + R3 have to be chosen according to the diode and VCC range.

The diode can also be "under" R1, with the gain working vs GND instead of VCC. This has the advantage that the output signal will be GND referenced ( in case the ADC is not using VCC as reference)

\$\endgroup\$

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.