### Author Topic: A mcu-based milliohm meter  (Read 28040 times)

0 Members and 1 Guest are viewing this topic.

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### A mcu-based milliohm meter
« on: January 20, 2014, 07:25:55 pm »
In the thread where I was trying to build a minimalist esr meter based on a mcu, I thought that some AVR's adc modules are quite useful in their offering a gain module + differential inputs.

That got me to think about a way to build a minimalist milliohm meter using such modules.

Since I have a few teensy (usb1286, adc modules with differential inputs and 1x/10x/200x gain) so I thought I would start with them.

Goal:

1) milliohm meter, capable of measuring from 1m - 50ohm;
2) minimal external parts;
3) lcd or coil meter output.

================================
https://dannyelectronics.wordpress.com/

The following users thanked this post: sipo75

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #1 on: January 20, 2014, 07:30:31 pm »
Operating principles:

It is quite simple: two external resistors (R1 and R2 in the following schematics. They don't have to be equal), + dut (R3).

V1 and V2 are two out of phase excitation sources. R1/R2 limit the current going the dut. Vp/Vn are the voltage pin-up points.

In the chart Vp is shifted up by 0.2v to make the illustration a little easier on the eye.

Essentially, if we measure Vp - Vn, we would know the resistance, together with the current.

================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #2 on: January 20, 2014, 07:33:23 pm »
Schematic for my particular fixture.

ADC2/ADC3 are the differential adc inputs. The rest drives a lcd via HC164 - unique to my particular fixture and you can rearrange it.

The adc module runs at 10x gain for now (adc mode 0x0d).

================================
https://dannyelectronics.wordpress.com/

#### hlavac

• Frequent Contributor
• Posts: 536
• Country:
##### Re: A mcu-based milliohm meter
« Reply #3 on: January 20, 2014, 07:38:41 pm »
Any particular reason for using square waves instead of simple dc?
Good enough is the enemy of the best.

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #4 on: January 20, 2014, 07:41:43 pm »

1. Just the wire: 110mohm;
2. a 0.47R resistor + wire: 588mohm;
3. 0.47R + 15R resistors + wire: 15,560mohm;
4. 15R resistor + wire: 15,103mohm.

So the reading for the resistor(s) alone would be

2. 0.47R resistor: 478mohm;
3. 0.47R + 15R resistors: 15,450mohm
4. 15R resistor: 14,993

if 2) and 4) readings above are correct, I should have a theoretical reading of 14993+478=15471mohm for 0.47R + 15R resistors, vs. 14,450mohm of actual measurements.

Not bad, for a 3-part instrument (2 resistors + the mcu).

================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #5 on: January 20, 2014, 07:42:14 pm »
Here is a shot of the set-up: just two resistors + the 15R dummy dut.

================================
https://dannyelectronics.wordpress.com/

#### Jon86

• Frequent Contributor
• Posts: 526
• Country:
##### Re: A mcu-based milliohm meter
« Reply #6 on: January 20, 2014, 07:45:14 pm »
Any particular reason for using square waves instead of simple dc?

Yeah that's confusing me a bit, come on OP, what gives?
Death, taxes and diode losses.

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #7 on: January 20, 2014, 07:47:20 pm »
Test range:

Two things control the range of the instrument:

1) adc module's gain: higher gain allows measurement of lower resistance.
2) measurement current: higher current allows measurement of lower resistance.

On the usb1286, we used Vref = 2560mv. The measurement current is about 6ma. So the lowest voltage drop that can be detected by the adc module is 2560/1024 * 1 / 10 = 0.1mv. Corresponding resistance is 0.1mv / 6ma=20mohm. The maximum would be 20ohm - at that point, you will need to compensate the drop in the measurement current - not yet implemented.

To expand the range of the meter, you could switch to 1x or 200x gain setting; Or use higher value current limiting resistors to read high-value resistance.

More possibilities.
================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #8 on: January 20, 2014, 07:51:43 pm »
Quote
Any particular reason for using square waves instead of simple dc?

Two reasons primarily:

1) The output resistance of those two excitation pins is unknown / unknowable. By alternate them and subtracting the readings, they are nulled.
2) With just the dc source, you would have to null the adc amplifier - not possible on some AVRs - it happens to be possible on this particular avr.

Also, the same approach could be used to measure inductance / capacitance / esr - difficult with a dc source.
================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #9 on: January 20, 2014, 07:57:21 pm »
Here is measuring the same R47 resistor at 200x gain.

I didn't rewrite the ohm conversion so it is still at 10x -> the reading should be divided by 20 (200x / 10x) for the true reading.

The value fluctuates from 11495 - 11502 mostly (indicating a value of ~575mohm), but mostly +/-3.
================================
https://dannyelectronics.wordpress.com/

#### hlavac

• Frequent Contributor
• Posts: 536
• Country:
##### Re: A mcu-based milliohm meter
« Reply #10 on: January 20, 2014, 08:00:51 pm »
Oh I thought you may want to use some sort of transformer to isolate the probe, lower the voltage and increase the sensing current...

If I were making a milliohmmeter, I would make a little voltage limited 0.5V 10mA constant current source, put the current thru the DUT and measure voltage developed across it...
It would have to be battery powered to isolate it though.
Good enough is the enemy of the best.

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #11 on: January 20, 2014, 08:02:08 pm »
At 200x, you can get down to about 1mohm resolution.

To make the meter really useful, you have to null the wire resistance: either a kelvin clip or implement relative measurements (and save the readings into the eeprom).

================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #12 on: January 20, 2014, 08:04:56 pm »
If you implement this on an attiny (10x differential adc module), you can drive a coil meter with two ranges (10 ohm and 1ohm max).

================================
https://dannyelectronics.wordpress.com/

#### Jon86

• Frequent Contributor
• Posts: 526
• Country:
##### Re: A mcu-based milliohm meter
« Reply #13 on: January 20, 2014, 08:08:19 pm »
Oh I thought you may want to use some sort of transformer to isolate the probe, lower the voltage and increase the sensing current...

If I were making a milliohmmeter, I would make a little voltage limited 0.5V 10mA constant current source, put the current thru the DUT and measure voltage developed across it...
It would have to be battery powered to isolate it though.

That's what came to mind when I saw this topic, I think better accuracy could've been had with a constant current source.
Death, taxes and diode losses.

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #14 on: January 20, 2014, 08:09:53 pm »
The particular chip I used (usb1286) is difficult to find. A good alternative is the mega32u4 chip used in many arduino. You can simply implement the same math in either arduino or C - potentially build a simple ship that contains both the lcd + R1/R2.

However, you need to watch out for the arduino pin-out: you have to have adc0/adc1 routed out or it is no good. The official Micro and Leonardo do that, I think.
================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #15 on: January 20, 2014, 08:24:48 pm »
Porting this approach to other mcus:

The basic concept is quite portable. However, you have to have either a high resolution adc (12-bit adc would be equivalent to 10-bit adc + 4x amplification; 16-bit adc would be equivalent to 10-bit adc + 64x amplification), or outboard amplification (a differential or instrumentation amplifier, like ina127/128, or fancier ones where the gain can be controlled by the mcu).

================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #16 on: January 20, 2014, 08:32:20 pm »
If you are to use outboard amplification + inboard adc, you have to drive the output from the outboard amplifier (through a resistor) into a divider network so the output is in the 0-Vcc range. You do lose the gain a little bit in the process.
================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #17 on: January 20, 2014, 11:54:33 pm »
Changed the code a little bit and incresed the oversampling to 4000x. The readings are stable to the last +/- 1-2 lsb.

Measuring a 0.47ohm resistor at 10x gain:

================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #18 on: January 20, 2014, 11:55:07 pm »
Same resistor at 200x gain.
================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #19 on: January 21, 2014, 12:09:47 am »
How would I know if it is accurate?

I have a .47ohm resistor, a 15ohm resistor.

The .47ohm resistor (+ unknown wire resistance) measured  out to be about 570mohm - the reading varies based on the touch points on the leads.

================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #20 on: January 21, 2014, 12:14:18 am »
If I were to parallel the 15ohm resistor to it, I should expect a total resistance of 0.456ohm, or a decrease of readings of 470-456 = 14mohm.

Here is the meter's reading of 15R + R47 = 556mohm, a decrease of 14mohm, vs. 14mohm as expected - the reduction actually varies from 14mohm to 15mohm.

However, the reading only declined 5mohm under 10x gain - as expected.
================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #21 on: January 21, 2014, 12:17:44 am »
Quote
Here is the meter's reading of 15R + R47 = 556mohm,

Quote
Here is the meter's reading of 15R // R47 = 556mohm,
================================
https://dannyelectronics.wordpress.com/

#### Rufus

• Super Contributor
• Posts: 2095
##### Re: A mcu-based milliohm meter
« Reply #22 on: January 21, 2014, 01:05:27 am »
1) The output resistance of those two excitation pins is unknown / unknowable. By alternate them and subtracting the readings, they are nulled.

It doesn't null them.

You should use VCC for the ADC reference to make the measurements ratiometric and so independent of supply voltage.

You could measure the voltage on the drive pins to compensate. Doing that along with the ratiometric measurement would make accuracy and stability dependant on only the 2 series resistors and ADC.

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #23 on: January 21, 2014, 01:17:11 am »
I have a mega32U4 coming in, in the form of an Arduino Leonardo - I can put an lcd + button on that so it becomes a "millieohm" shield, with lcd read-out, uart read-out and analog read-out.

Another option is to use a regular mcu + instrumentation amplifier to really drive the gain up to be able to measure sub-millieohm resistance. It would be interesting to see how that pans out.
================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #24 on: January 21, 2014, 11:02:31 am »
Quote
constant current source, put the current thru the DUT and measure voltage developed across it...

That is very difficult to implement. The HP 34401a for example utilizes that approach and you can see the complexity around it.

Most milliohm meter implementations utilize instead a precision / known resistor in serial with the dut, in a singled-ended fashion. As such, the instrument takes two readings, one across the entire chain of the measurement resistor (known value) and dut, and another over just the dut. You have to deal with drift and offsets in that case.

The beauty of a differential amp + adc is that both drift and offset are taken care of inherently in the algorithm.

Quote
There's such a project in paper published in the "Review of Scientific Instruments" Journal :

The basic approaches are identical. Some minor implementation differences. He went down to uohm range - that's impressive, vs. about 2mohm for mine. He could have biased the -V pin of the ina to make the output in the right range, vs. the use of a divider network.

I don't fully understand why he thinks this is a lock-in amplifier (digitally implemented).

A killer mcu for this application would be C8051F350, with its 24-bit adc + onboard pga.
================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #25 on: January 21, 2014, 11:47:40 am »
Having re-read his paper, I think his analysis of the pins' output resistance is flawed - he basically assumed away the problem he was trying to analyze.

The current flows in two direction in this approach, from pin 1 to pin2 and then from pin2 to pin 1. A central but unspoken assumption is that the two current is identical (or at least close enough). For that to be true, the output resistance has to satisfy certain conditions - none of them requires the two pins to have the same output resistance.

We usually think of the pin's output resistance to be one, from 20 - 50ohm depending on the mcus used, and in serial with the output drive, just as the paper's author assumed. As his analysis shows and you would think intuitively as well, you don't require the two pins to have the same output resistance for the current to be the same in both directions - Page 3 of his paper deals with that, fairly concisely.

However, there are actually two output resistance: one when the pin is high ("high output resistance") and another when the pin is low ("low output resistance"). A little bit of math will show that the current is the same in both directions if pin 1's high output resistance + pin 2's low output resistance = pin 1's low output resistance + pin 2's high output resistance.

I had done some analysis way back that showed me the high output resistance on some Luminary chips (8ma drive I think) to be mostly within 1ohm difference (mostly < 0.5ohm). No analysis on low output resistance. and nothing done on the avr or pic (which the author used).

So I thought it was safe to assume that there are some differences from pin to pin, but the difference is probably within 1 ohm.

Because of that, you want to use substantial current limiting resistors - I used 380ohm resistors -> 6ma drive. That would mean that my accuracy would be around 6mohm, vs. accuracy of 15mohm in the author's case.

You could have further reduced the current to minimize the impact from output resistance mismatches but that limits your low range as well. So it is a balancing act.
================================
https://dannyelectronics.wordpress.com/

#### G0HZU

• Super Contributor
• Posts: 3156
• Country:
##### Re: A mcu-based milliohm meter
« Reply #26 on: January 21, 2014, 08:57:32 pm »
How would I know if it is accurate?

I have a .47ohm resistor, a 15ohm resistor.

The .47ohm resistor (+ unknown wire resistance) measured  out to be about 570mohm - the reading varies based on the touch points on the leads.
If you don't have any accurate shunts then you could measure the resistance of a length of solid copper wire. It's easy to measure the resistance of the wire beforehand using ohms law. eg you might have a wire with 40 milliohms resistance.

Then measure it with your meter. Then halve the length of the wire and measure again. Keep halving the length of the wire to see if you get an accurate straight line down to a few milliohms.

This all assumes you do the testing at a very low test frequency to avoid errors due to the inductance of the wire.
« Last Edit: January 21, 2014, 09:00:47 pm by G0HZU »

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #27 on: January 21, 2014, 10:22:50 pm »
DC vs. AC exciatation signal:

we discussed the pros / cons of each earlier - fundamentally they are the same: by flowing a known signal through an unknown resistor and measuring the voltage drop gives you the resistance reading.

In my last re-read of the article that EmmanuelFaure linked to, it stated that the individual adc readings vary wildly - as you would expect, yet the difference between the successive readings is very stable.

I can confirm that it is indeed the case, particularly in cases where high gain is used - the readings are actually visibly changing if you just put your finger on the mcu or lift it.

That speaks to the beauty of this ac excitation approach: it is inherently immune to drift / offset from the adc amplifier (or external amplifier if it is used).

BTW, the code provided in the link by EmmanuelFaure has two unnecessary steps of subtracting 512 from each reading - it is totally not needed.
================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #28 on: January 22, 2014, 12:22:04 pm »
Quote
Also, the same approach could be used to measure inductance / capacitance / esr - difficult with a dc source.

Here is an example of how the same approach could be used to measure esr.

ESR + C1 is the dut. R1/R2 are the current limiting resistors and V1/V2 are the out-of-phase excitation sources.

The green trace is the differential voltage across the dut. The vertical drops corresponds to 2 * ESR * Current. Current in this case is about 5v/(2*380) = 7ma plus so you should expect about 14mv voltage drop - about right.

The slope at the top corresponds to Current / Capacitance * Measurement time. For fixed current + measurement time, the slope is inversely proportional to the capacitance.

The advantage here with the ac excitation + differential amplifier is that you don't have to deal with drift + offset.
================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #29 on: January 22, 2014, 08:11:27 pm »
To do list:

1) calibration: the code now assumes that the excitation current is the same - there ought to be some variations in that. So we have to provide a means for the user to specify that. I think a +/-10% range will do. This will also compensate for variations in the bandgap reference.

2) two-wire vs. four-wire connection: two-wire connections will work, but its calibration will be a little bit tedious. One approach may be to use four-wire connection to calibrate the module and then use relative measurement to null out the wire resistance.

3) compensation for dut's impact on the excitation current: as we are not using a constant current source and the dut is in the path of current flow, the resistance of the dut will impact the current thus the measurement. However, this impact is bounded at its upper end (<5% for the 10x gain setting and < 0.1% for the 20x gain setting). If we implement autoranging (to 10x gain), we will compensate for the dut resistance.

4) autoranging: a potentially useful feature is to autorange the meter, from 10x to 200x, based on the dut's measurement. at 10x, we can measure from 40mohm to about 40ohm; at 200x, we can measure from 2mohm to about 2ohm.

5) esr capabilities: the hardware set-up is identical and the measurement workflow is almost identical. That would be a nice addition.

6) variable drive: the drive current is about 6ma (@ 380Ohm x 2), or 7ma (@ 330ohm x 2). Good for low resistance measurement. If we further lower the drive current to 2.5ma (@ 1Kohm x 2), we can extend the upper-end of the metter to 110 - 120ohm range.

7) relative / zeroing: For the two-wire mode to be useful, we will have to zero out the wire resistance. That's fairly easy to implement.

Once my Leonardo gets here, I will start working on the list.

================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #30 on: January 22, 2014, 11:09:32 pm »
Quote
4) autoranging:

Implemented.
================================
https://dannyelectronics.wordpress.com/

#### Rufus

• Super Contributor
• Posts: 2095
##### Re: A mcu-based milliohm meter
« Reply #31 on: January 22, 2014, 11:12:45 pm »
To do list:

1) calibration: the code now assumes that the excitation current is the same - there ought to be some variations in that. So we have to provide a means for the user to specify that. I think a +/-10% range will do. This will also compensate for variations in the bandgap reference.

I wonder why I bother posting sometimes.

The following users thanked this post: sipo75

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #32 on: January 22, 2014, 11:13:32 pm »
Quote
3) compensation for dut's impact on the excitation current:

Implemented.
================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #33 on: January 23, 2014, 01:16:58 am »
Quote
]1) calibration:

In progress.

Why do you need calibration?

The meter works by sending a "known" current through an unknown resistor and measures the voltage drop over the resistor to obtain its resistance.

The "known" current is (largely) determined by those two current limiting resistors (380ohm * 2 vs. milliohms for the dut - which we have corrected in software).

For the meter I am building now, I know precisely what the current is - I measured it to be around 6000ua for the current limiting resistors I used. So when I specified that in the code and compiled the code to that value, no calibration is needed.

Unfortunately, you don't have that luxury. For the "software", it always assumes the current to be what's specified in the code. Obviously, when you use different current limiting resistors, or run the code under different Vcc, or due to chip to chip variance, the actual current going through the dut will likely differ from those specified in the code.

Thus you need calibration.

================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #34 on: January 23, 2014, 01:22:09 am »
How to implement the calibration?

The simplest would be to use buttons but I am an anti-button kind of guy so I would use pot instead. A smaller trimmer would be used to dial in the adjustments to the current setting. I plan to allow +/- 32ua adjustments, for ease hand tweaking.

Once the adjustments are dialed in, the base current is modified and saved into eeprom for future uses: the current will be read back for measurements and / or calibration in the future.

This approach allows for the opportunity to dial in unlimited adjustments, through as many calibration sessions as needed. That means you can use any value current limiting resistors as you want and they don't need to be precision resistors at all.
================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #35 on: January 23, 2014, 01:39:25 am »
There are three possible ways to calibrate the meter:

1) a resistor of known value (needs to be less than the maximum range of the meter): in 4-wire mode, turn the meter into calibration mode, and measure the known resistor. Adjust the trimmer - the lcd will display the "measured" resistor value and modified current reading, in ua. Repeat until the lcd displays the correct resistor value.

2) a ua meter: put the ua meter on the milliohm meter to measure its "resistance" - the ua meter is now a dut to the milliohm meter. The ua meter will show the current flowing through itself (=dut). Adjust the trimmer until the displayed current matches that of the reading from the ua meter. You would need to have a ua meter with as low of burden voltage as possible.

3) two resistors: pick two resistors of known value - they don't need to be precision resistors and their values don't need to be precise. Pick the first resistor (R1) to be small (<1ohm), 0.47ohm or 0.22ohm for example. Pick the 2nd resistor (R2) to be 10 - 20ohm range (again, no need to be very precise). Use your multimeter to measure the resistance of the 2nd resistor - most meters will give fairly good measurement on this resistor.

Put the meter in calibration mode - it will display measured resistance + modified current reading.

Put the first resistor on the meter - it should show one reading; Then parallel it with the 2nd resistor - the reading should decline by a little bit: R1 - R1 * R2 / (R1 + R2) = R1 * R1 / (R1 + R2) = R1 / (1 + R2 / R1). Since R2 >> R1, the changes will be dominated by R2, which you have fairly good measurement of.

You just need to adjust the trimmer now to reproduce the expected changes.

This approach is more tedious but works in cases where your equipment is limited, and in 2-wire mode as well - I actually showed that approach a while back.

Now, I just need to code all that into the chip,
================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #36 on: January 23, 2014, 08:45:16 pm »
Quote
1) calibration:

Done!

Now, working on relative / zeroing.
================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #37 on: January 23, 2014, 09:42:18 pm »
Quote
working on relative / zeroing.

Done!

The first picture is the measurement of absolute resistance - 579mohm, between wires + a 470mohm resistor. 278 is the adc reading.

I then zero'd the wire resistance by shorting the leads. and then put on the 470mohm resistor. The same reading of 278 now translates into a 474mohm "relative" reading, just for the resistor - see the 2nd picture.

Next step:

My Leonardo is in so now I just need to implement this on the Leonardo / atmega32U4. After that, I will work on the ESR measurements.

================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #38 on: January 23, 2014, 09:59:00 pm »

Th highest I have seen is actually 1022. Never 1023.
================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #39 on: January 23, 2014, 10:17:02 pm »
The meter defaults to 200x gain.

When the resistance is greater than 1.5ohm (user specified), it switches over to 10x gain automatically.

Range is 2mohm - 40ohm, with 2mohm resolution (<2ohm) and 40mohm resolution for 2ohm or higher.

Accuracy: don't know yet. Likely better than 5% + 10mohm - my experience with avr adc accuracy.
================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #40 on: January 23, 2014, 10:22:43 pm »
Meter behavior:

1) on boot up, the meter tests if the avr is a virgin avr - aka it has no value for charge current calibration in the eeprom. If so, it writes the default value (about 6000ua, representing an avr driving a 800ohm load at 5v Vcc). The meter will display that value briefly.
2) If the calibration key is pressed, the meter goes into calibration.
3) If not, or calibration is done, it starts to measure the resistance. Update speed is about 5x per second.
4) during the measurement phase, user can zero current reading to obtain relative reading any time, by pressing the relative / zero key (the same key as the calibration key actually). When that key is pressed, two measurements are shown on the lcd, v1 and v2 (adc readings accumulators for the two charge cycle).

Calibration:
1) if you pressed the calibration key while powering on the meter, it goes into calibration where you can adjust the charge current while a known resistor is being measured.
2) Press the calibration key in this phase saves the calibration results into eeprom.
3) If no key is pressed, the meter times out and goes into measurement mode with the old calibration result.

================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #41 on: January 23, 2014, 10:26:31 pm »
Parts used:

mcu: Teensy ++ 2.0 (usb1286) now and Leonardo (atmega32u4) in the future.
lcd: hd44780. I used 16x2, driven by a shift register (to be removed in the final version).
resistors: 380ohm x 2 (can be user calibrated. no precision resistors required).
pot: a trimmer (10k. value not critical).
switch / button: 1.
posts: 4.

maybe some capacitors for decoupling.
================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #42 on: November 13, 2014, 01:39:42 am »
I spent sometime rethinking about this project, and decided that I want to shrink it down to a more minimalist approach.

Here is an implementation on an ATTINY85 running the adc at 20x gain.

The principle is the same: apply a current through the dut and measure the voltage drop through the differential adc at 20x. The current through the dut is limited by two resistors (150ohm, picked to limit the current through the pins to less than 20ma).

The output is read through a pwm generator by a voltage meter (or alternatively an amp meter, with a slightly different and simpler circuitry - not shown here).

For a total of 3 resistors + 1 capacitor + 2 optional resistors, you have yourself a milliohm meter.

The current through the dut is about 15ma, using internal 1.1v reference, the adc's resolution is about 50uv (1100mv / 1024 / 20). So the milliohm meter has a resolution of 50uv / 15ma = 3mohm, and a maximum range of 3ohm.

However, as we have only 8-bit pwm available on this particular chip, I am limited to 3ohm / 256 = 10mohm.

Here is the meter measuring a 0.1ohm resistor. As the meter is caliberated to 1ohm/1v, we should expect a reading of 100mv.

================================
https://dannyelectronics.wordpress.com/

The following users thanked this post: sipo75

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #43 on: November 13, 2014, 01:47:15 am »
How about a test on real resistors?

How about two real resistors? 100mohm x 2 power resistors.

Each measures to 85.8mohm, slightly different from the expected value.

One reason is that the resistors are indeed off. Another is that my software assumes 5v Vcc and my actual Vcc is 4.9v. So I should expect 2% off on the adc side and another 2% off on the pwm side.
================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #44 on: November 13, 2014, 01:50:39 am »
Another test - what about paralleling the two resistors?

I should get 85.8mohm / 2 = 43mohm, right?

I got instead, 48.0mohm - the numbers actually fluctuated between 47.9mohm and 48.0mohm.

Vs. my expected value, the overall error rate is 10%.
================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #45 on: November 13, 2014, 02:01:12 am »
Room for improvement:

1) Better caliberation - this can be done a pot on across the capacitor + a precision resistor; or a serial pot for a coil meter. The 150ohm resistors don't need to be precision resistors at all.

2) Better software - I didn't attempt to null the adc in the software. I would expect that more work can be done there;

3) Better adc - the attiny's adc has a maximum gain of 20x. There are plenty of avrs with 40x, 100x or 200x adc.

4) Better pwm - this particular avr has only 8-bit pwm. 10-bit pwm would offer more display resolution. However, I don't expect that to be more than marginal.

5) External amplifier: Using an instrumentation amplifier (either a real one or a 2-opamp one) would easily increase the gain and provides better resolution on the low end. That can be done with a dual opamp (ne5532 for example) + three resistors.

6) Better topology - a real high precision milliohm meter can be done with an external adc - differential input, differential external reference input, 16 bit or more. Put the dut in serial with the precision resistor. The differential adc across the dut and the differential external reference across the precision resistor. The output is ratiometric to the precision resistor.

Alternatively, you can simply use a low drift resistor in place of the precision resistor and use the precision resistor instead to caliberate the meter.

I thought for a couple dollars, this provides an interesting way to measure low resistance.

BTW, the same approach can be used to measure low voltage too.
================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #46 on: November 13, 2014, 02:03:24 am »
I didn't do this in the test but you should use kelvin clips to minimize wire resistance.
================================
https://dannyelectronics.wordpress.com/

#### nuno

• Frequent Contributor
• Posts: 606
• Country:
##### Re: A mcu-based milliohm meter
« Reply #47 on: November 13, 2014, 02:29:39 am »
The gain on the diferential ADC mode is a nominal value, which means you will have a gain error. Best way to calibrate is to do a 2 point measurement (use points near the extremes of your range for best accuracy) and then linearly interpolate on readings (because this system is linear). This will calibrate for "the entire system" parts, from resistor tolerances to gain tolerances Vref tol etc. I usually go directly from the ADC count reading into my desired final value, no need to have other units in between.

I would also use the internal Vref to generate the test current (buffered through an ampop), for its better stability (vs a power rail voltage).
« Last Edit: November 13, 2014, 02:35:02 am by nuno »

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #48 on: November 13, 2014, 02:44:11 am »
I implemented nulling and put a ghetto kelvin clip in place. Single resistors measure out to be 104.8 - 104.9mohm, very stable.

Paralleling those two resistors yields 51.8 - 53.5mohm mostly.

Pictures are attached:
« Last Edit: November 13, 2014, 02:47:42 am by dannyf »
================================
https://dannyelectronics.wordpress.com/

#### Vgkid

• Super Contributor
• Posts: 2727
• Country:
##### Re: A mcu-based milliohm meter
« Reply #49 on: November 13, 2014, 03:06:07 am »
If you own any North Hills Electronics gear, message me. L&N Fan

#### janengelbrecht

• Regular Contributor
• Posts: 181
• Country:
##### Re: A mcu-based milliohm meter
« Reply #50 on: November 13, 2014, 08:36:08 am »
Really a interesting project. Not until now i had realised the presence of differential ADC in these Atmel chips I will follow this subject with great joy in the future

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #51 on: November 13, 2014, 12:15:15 pm »
AVR's ADC modules are quite unique among 8-bit mcus (and even among 32-bit mcus) in that it not only offers differential capabilities but has a variable gain module there, allowing it to achieve better resolution than spec'd.

The Attiny's ADC module, unfortunately, is a little bit crippled in that its positive input must be at a higher potential than its negative input. Other AVRs, like usb128x or 32u4, don't have that limitation.

Unfortunately, usb128x is quite expensive. 32u4 is used in many of those cheap Pro mini boards. Unfortunately, those designers did not route out the ADC0/ADC1 pins.

The best pick for this would be a Leonardo board - its ADC0/1 pins are full accessible. But it seems an overkill for this purpose.

If you want to build, however, a milliohm / millivolt meter with digital display, a Leonardo + lcd shield would be a perfect choice.
================================
https://dannyelectronics.wordpress.com/

#### nuno

• Frequent Contributor
• Posts: 606
• Country:
##### Re: A mcu-based milliohm meter
« Reply #52 on: November 13, 2014, 12:27:03 pm »
Some (for example ATtiny24, ATtiny261) support the "Bipolar Differential Conversion" mode, in which any of the inputs can be higher than the other and the result will be a signed integer.

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #53 on: November 13, 2014, 01:26:53 pm »
Not sure about 261 but Attiny24/44/84 have the same adc module as the 25/45/85: the positive input needs to be at a higher potential than the negative input.

I will get a pro micro and hand solder out the ADC0/ADC1 pins to experiment.
================================
https://dannyelectronics.wordpress.com/

#### nuno

• Frequent Contributor
• Posts: 606
• Country:
##### Re: A mcu-based milliohm meter
« Reply #54 on: November 13, 2014, 03:57:31 pm »
"As default the ADC converter operates in the unipolar input mode, but the bipolar input mode
can be selected by writting the BIN bit in the ADCSRB to one. In the bipolar input mode two sided
voltage differences are allowed and thus the voltage on the negative input pin can also be
larger than the voltage on the positive input pin
."

Datasheet is your friend . In each generation ATMEL introduces some minor improvements.
« Last Edit: November 13, 2014, 03:59:32 pm by nuno »

The following users thanked this post: I wanted a rude username

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #55 on: November 13, 2014, 04:19:16 pm »
That's indeed the case.

Thanks.
================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #56 on: November 14, 2014, 12:46:45 am »
Current consumption: 16.6ma total. The driver circuit consumes about 14.7ma so the chip itself consumes 2ma.

================================
https://dannyelectronics.wordpress.com/

#### nctnico

• Super Contributor
• Posts: 27690
• Country:
##### Re: A mcu-based milliohm meter
« Reply #57 on: November 14, 2014, 09:11:56 am »
I have a feeling you can increase the resolution a lot if you change the software to do synchronous integration.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #58 on: November 14, 2014, 09:30:33 pm »
Quote
6) Better topology - a real high precision milliohm meter can be done with an external adc - differential input, differential external reference input, 16 bit or more. Put the dut in serial with the precision resistor. The differential adc across the dut and the differential external reference across the precision resistor. The output is ratiometric to the precision resistor.

An example of it would be here - notice how DUT (R3) is connected with the reference resistor (R2). R2 doesn't need to be a precision resistor. If it is not, you need to calibrate the meter.

You can easily go sub-milliohm with this approach.
================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #59 on: November 14, 2014, 09:31:30 pm »
You can reconfigure a typical digital meter, like DT830, in a similar approach to get a very inexpensive milliohm meter out of it, with digital readout too.
================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #60 on: November 15, 2014, 10:51:40 pm »
Changed the gain to 1v/100mohm.

The readout is a digital volt meter (1v/100mohm), and a digital current meter (10ua/100mohm)
================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #61 on: November 19, 2014, 01:05:15 am »
I took the attiny85 code and ported it to attiny84 - minor changes.

Here it is, measuring a 0.1ohm resistor on a 1v/0.1ohm scale.

Because of the bipolar output, nulling is very easy here.

================================
https://dannyelectronics.wordpress.com/

#### dannyf

• Super Contributor
• Posts: 8221
• Country:
##### Re: A mcu-based milliohm meter
« Reply #62 on: November 19, 2014, 01:20:49 am »
Minor changes -> running on timer1, 10-bit pwm.

================================
https://dannyelectronics.wordpress.com/

#### nuno

• Frequent Contributor
• Posts: 606
• Country:
##### Re: A mcu-based milliohm meter
« Reply #63 on: November 19, 2014, 09:49:09 am »
Very nice

Smf