Measure resistance with a microcontroller
Create a voltage across an unknown resistance and digitize it.
By Adolfo Mondragon, Electrolux Products, Juarez, Mexico -- Test & Measurement World, 2/1/2011 12:01:00 AM
|
Figure 1 shows the basic concept of a circuit I designed to check the resistance of the wire coil winding of a stepper motor. An op amp configured as a differential amplifier produces a voltage proportional to the unknown resistance. You can use this circuit to measure resistances—just start by identifying the range of resistances to measure. The stepper motor has a coil with a resistance of 50 Ω ±15%, which ranges from 42.5 Ω to 57.5 Ω.
|
If you use a microcontroller that contains a 10-bit ADC, it will produce a digital span from 0 to 1023 counts. Set the range of the ADC so that 0 Ω produces a count of 0 and 102.3 Ω produces a count of 1023. This range simplifies the math and maximizes measurement precision. Half of this scale, 512 counts, represents 51.2 Ω. That's close to the nominal 50-Ω measurement of the DUT. Table 1 shows the correlation among the input voltage to the ADC, the number of counts, and the coil's resistance.
The differential configuration of the op amp works as a four-wire measuring circuit similar to those used in many DMMs. Using separate wires for excitation current and voltage measurement eliminates much of the common-mode noise and errors introduced from the DUT wiring and connections.

You must define the op amp's gain and, from that, the resistor values. In this circuit, the op amp provides adequate voltage for the microcontroller. It also provides isolation between the DUT and the microcontroller's ADC input. To minimize errors, select resistors RA through RD so that the op amp operates at unity gain. To verify that you can run the op amp at unity gain, you must calculate the current that passes through the coil. Using the values from Table 1, calculate the current (IIN) needed to achieve a half scale of 51.2 Ω:
The constant-current source is based on an LM317 regulator, which can easily provide 48.8 mA. Thus, you can run the op amp at unity gain, which simplifies selection of the resistance values of RA, RB, RC, and RD. For unity gain, all resistors should be equal. Their values should be considerably higher than the DUT's resistance. Keep the resistor values between 10 kΩ and 100 kΩ.
The circuit works best if you use resistors with 1% or better tolerance. If you need to reduce cost, then measure 5% resistors from a batch with a DMM. Select the four resistors that best match each other's values. You may be able to achieve better than 1% matching this way.
The op amp also provides some isolation that can prevent dangerous voltages from reaching the microcontroller's ADC input. An op amp such as the LM6132 connected to a 5-V power supply will limit the power supply's output voltage to 5 V, even under extreme conditions.
To operate an LM317 regulator as a constant-current source, you need to calculate a resistor value:
![]()
Figure 2. The complete circuit shows the LM317 constant-current supply, the stepper motor under test, two LEDs, and an LCD screen. |
![]() |
Talkback
No related content found.
- 0 rated items found.
Datasheets.com Electronic Parts & Inventory Search
185 million searchable parts
- Part Number
- Description
- Inventory
- Products
- Manufacturers
Sponsored Links


























