Author Topic: Digital ESR meter  (Read 42138 times)

0 Members and 1 Guest are viewing this topic.

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Digital ESR meter
« on: December 28, 2013, 12:19:19 am »
In an earlier thread, an analog ESR meter was proposed that has a linear reading with regards to ESR.

That particular design utilizes an oscillator to generate a 50% square wave to excite a resistor in serial with the dut. A sync detector + opamp were used to obtain the ESR reading on a meter. No analysis was done on how the meter works.

I wanted to shed some light on how that meter works. More importantly, I want to simplify the design around a mcu - let the mcu perform as much as possible. In fact, I want to achieve the following:

1) use the mcu to generate the excitation signal;
2) use the mcu to perform sync detection;
3) use the mcu to perform adc on the detector's output (for reasonable accuracy, this will require a 12-bit or higher adc. Otherwise, some external amplification is required);
4) use the mcu to generate a digital read-out (on a lcd for or led for example).

With the right mcu, this design has the potential of using minimum external parts (some resistors + capacitors + diodes). Otherwise, you may need an extra opamp.
================================
https://dannyelectronics.wordpress.com/
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Digital ESR meter
« Reply #1 on: December 28, 2013, 12:24:16 am »
First, the excitation part of the circuit.

V1 generates a 5vp 10khz square wave that excits the dut (ESR + C1) through a serial resistor Rm. As expected, the voltage on dut (Vdut - not yet in the circuit) stablizes to 5v/2 = 2.5v.

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

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Digital ESR meter
« Reply #2 on: December 28, 2013, 12:27:26 am »
Naturally, you would expect the capacitor is being charged / discharged at around 2.5ma (2.5v / (Rm + ESR) ~= 2.5v / Rm, assuming ESR << Rm).

And it is indeed:

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

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Digital ESR meter
« Reply #3 on: December 28, 2013, 12:30:51 am »
Now, comes the interesting part that will help you understand how the meter works.

Here is the voltage over dut. You will notice that when the dut transitions from charging to discharging (or vice versa), there is a sharp drop of voltage (or rise, in the case of discharging -> charging). In this case, it is 1mv - remember that number.

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

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Digital ESR meter
« Reply #4 on: December 28, 2013, 12:41:55 am »
You may ask why 1mv?

Assuming that the voltage on the capacitor portion of the dut is Vc (not observable in real life), and the current going through the circuit (either charging or discharging) is Im (=2.5ma).

It must be true that

Vdut(charging) = Vc + Im * ESR; during charging; and
Vdut(discharging) = Vc - Im * ESR; during discharging

[note: I cheated a little bit here as I assumed Vc is symmetrical during charging and discharging. That assumption (mostly) holds if Rm >> ESR, and the impedance of C1 is sufficiently small vs. Rm - this allows the Tylor expansion of e^x to be carried out to its 2nd term without sufficient error).

So you will see that Vdut(charging) - Vdut(discharging) = 2 * Im * ESR.

That is, if we could take a reading of the voltage over the dut at time t and T - t (where T is the period of the excitation signal), the difference between the two readings will be linear to ESR.

That is really the gist of this whole design.
================================
https://dannyelectronics.wordpress.com/
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Digital ESR meter
« Reply #5 on: December 28, 2013, 12:51:45 am »
How do you read the differential signals that are at two different points in time?

One approach would be to use a very high speed adc and take two snap shots - tough to synchronize them in time though. Maybe the adc can be triggered by a signal that is 90 degrees apart from the excitation signal.

Another approach would be to use a sample-and-hold circuit before a slow adc, again triggered by a signal that is 90 degree apart from the excitation signal.

Both are complicated, however.

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

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Digital ESR meter
« Reply #6 on: December 28, 2013, 12:54:58 am »
A simpler approach is to integrate Vdut during the charging and discharging cycles and measure the difference:

If I integrate Vdut during the charging cycle, I will obtain the area marked red in the chart below; and if I integrate Vdut during the discharging cycle, I will obtain the area marked green.

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

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Digital ESR meter
« Reply #7 on: December 28, 2013, 12:57:32 am »
The difference between the two areas, however, will be linear to ESR:

The green shade in the chart below = delta Vdut * t = 2 * Im * t * ESR.

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

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Digital ESR meter
« Reply #8 on: December 28, 2013, 01:08:00 am »
So, all we need is to obtain two readings: integration of Vdut during the charging and discharging cycles of the excitation signal. That's easy to do with a sync detector.

What if we don't use a (real) sync detector? Here is how we did it:

R1/D1/C2 forms one integrator, R4/D2/C3 forms another integrator.

SW1 and SW2 are controlled by the excitation signal, connected 180 degree apart: when SW1 is closed, SW2 is open; when SW1 is open, SW2 is closed.

When SW1 is closed (when the dut is charged up), it shorts Vdut and C2 only integrates Vdut during the discharging cycle;

When SW2 is closed (when the dut is discharged), it shorts Vdut and C3 only integrates Vdut during the charging cycle.

Thus, we have our sync detector.
================================
https://dannyelectronics.wordpress.com/
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Digital ESR meter
« Reply #9 on: December 28, 2013, 01:11:10 am »
How does it work in simulation?

Here is the reading for ESR = 0.1ohm -> 50ohm.

The reading goes linearly to 230mv.
================================
https://dannyelectronics.wordpress.com/
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Digital ESR meter
« Reply #10 on: December 28, 2013, 01:12:04 am »
The same chart presented in double-log form shows more detail when ESR is very small:

Still very linear.
================================
https://dannyelectronics.wordpress.com/
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Digital ESR meter
« Reply #11 on: December 28, 2013, 01:21:34 am »
How to implement the meter?

1) excitation signal: it can be generated via a timer. In the isr, we just need to flip an output pin;

2) SW1 and SW2: we will use two pins to simulate SW1 and SW2 - pulling them to ground is equivalent to closing those two switches; turning them into input is equivalent to opening those switches. They have to be done in the same isr and them have to be done "concurrently".

So we will initialize SW1/SW2 to output low, but ***as input***. In the isr, we will use a shadow register to remember the port direction register. Flip the two bits in the shadow register corresponding to the SW1/SW2 pins and then assign the shadow register's value to the port direction register - this will alternately turn one of the pins as input (thus allows Vdut to be integrated) and the other as output (thus shorts Vdut to ground so it will not be integrated). This assures the switches / pins will be concurrently turned on / off.

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

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Digital ESR meter
« Reply #12 on: December 28, 2013, 01:37:59 am »
The values are selected with some consideration:

Rm:

1) the maximum value of Rm is determined by the desired maximum range for ESR. In general, smaller values of Rm allows faster charging / discharging of the dut and that allows a reading of lower ESR. However, the smaller the Rm, the poorer the linearity of the reading: ignoring the 3rd and higher orders of e^x Tylor expansion generates higher errors. I would say that you pick Rm that is at least 10x of the top range of ESR.
2) the minimum value of Rm is determined by the required current drive. I wanted to utilize no more than 20ma - typical of an 8-bit mcu.

In the end, I settled on 1k but I am sure you can pick one that suits your needs.

Excitation signal:
1) you want to reduce the impedance of C1 to a minimum (again, to maintain the linearity). So a higher frequency allows the measurement on smaller capacitors.
2) a higher frequency, however, provides less time for the isr.

I picked 10Khz so that the smallest capacitor I can measure is 1/((Rm / 10) * 2 * f) = 0.1u and I think 4.7u minimum allows adequate room.

R1/R4:
1) they should be matched as much as you can. Or they will produce uneven readings on the integrators;
2) they should not be too much smaller than Rm: R1/R4 are essentially attenuating the drive voltage with Rm.

I made R1/R4 = Rm for simplicity.

D1/D2:
1) we are not using any (linear) property of those diodes, other than their small signal resistance (rD): those diodes are being turned on digitally: drive voltage vs. the capacitor's voltage.
2) I will need to experiment a little bit more to see to what extent using vastly different diodes here impact the reading.
================================
https://dannyelectronics.wordpress.com/
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Digital ESR meter
« Reply #13 on: December 28, 2013, 01:48:39 am »
Consideration for ADC / outboard amplification:

The output signal from the sync detector is fairly small, < 250mv in a 5v @50ohm environment, < 75mv in a 3.3v@20ohm environment. For a 10-bit ADC, that yields a maximum of 50 / 25 distinct readings (Vref = 5v/3.3v), and a resolution of 1ohm.

That's probably not as desirable. Using a 10x amplifier yields 0.1ohm resolution (5v); Using 20x amplification yields 0.05ohm resolution (3.3v).

If you don't want to use outboard amplification, you can use a 12-bit adc (TI's TM4C series for example, or 8051C35x from Silabs for 24bit adc), for better resolution.

Alternatively, you can use outboard adc to take the two readings differentially: it doesn't need to be a high speed adc. Just 10-bit+ adc will do.

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

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 7547
  • Country: 00
  • +++ ATH1
Re: Digital ESR meter
« Reply #14 on: December 28, 2013, 06:24:12 am »
Sub-ed, and thank you.  :-+

Offline cwalex

  • Frequent Contributor
  • **
  • Posts: 299
  • Country: au
Re: Digital ESR meter
« Reply #15 on: December 28, 2013, 07:49:06 am »
 

Offline oldway

  • Super Contributor
  • ***
  • !
  • Posts: 2172
Re: Digital ESR meter
« Reply #16 on: December 28, 2013, 10:30:26 am »
When a project is modified, it is done to reach benefits, both in terms of cost and performance.
The first condition is to fully understand the project you want to modify and to know the reasons of the choosen technical solutions.

1) the DUT was fed with a  square wave voltage of + / - 2.5V without DC component, not a square wave of 0 - 5V.
A square wave of 0 - 5V consists of a 2.5V DC component plus a square wave of + / - 2.5V.
This is a bad choice for two reasons:
- 1) an additional problem is introduced because the DUT has to be charged to 2.5V
-2) The inicial project provided two protection capacitors  (C9 and C10) and diodes that protect the ESR meter when measuring a charged capacitor with voltages as high as 400V.
With only a 1K resistor without these capacitors, this resistor should dissipate 160 W and should blow immediately if making a measurement on a 400V charged capacitor.

The original project was operating at a frequency of 100Khz , which seems indispensable.
I had also added the option to test at 10Khz .
Here it seems to be only 10Khz .

Another key issue, that is low consumption .
The idea was to make an ESR meter powered by a 9V battery , which implies that consumption has to be as low as possible.
In the initial project , we used components with very low consumption . ( OP amp micropower , Cmos ...).
The modified project will he low power consumption ?

In terms of cost , would it be an improvement ?
Multimeters cost a few bucks , a Fluke 87 is not necessary for this application.
In the last diagram I posted , I planned an offset compensation.
Simply mount the offset potentiometer on the box and use it to set to 0 with two short circuits test leads so it is not necessary to have relative function on the multimeter.
You can also use a cheap LCD panel voltmeter if you do not want to use external multimeter.
 

Online tszaboo

  • Super Contributor
  • ***
  • Posts: 7392
  • Country: nl
  • Current job: ATEX product design
Re: Digital ESR meter
« Reply #17 on: December 28, 2013, 10:49:08 am »
We have a Hameg 200Khz LRC bridge at work, and I find that useless. It is unable to distinguish between an NP0 and an X5R capacitor. Not to mention the frequency is way to low for any useful application. Simple digital circuits run at 20 Mhz speed, why would I be interested in the 10Khz range?
Your circuit would lack even DC biasing. So what is your application for this?

mod: electrolytic. OK
« Last Edit: December 28, 2013, 01:01:36 pm by NANDBlog »
 

Offline oldway

  • Super Contributor
  • ***
  • !
  • Posts: 2172
Re: Digital ESR meter
« Reply #18 on: December 28, 2013, 12:19:54 pm »
For sure, nobody should use an electrolytic condensator for filtering 20 Mhz nor would test them at 20 Mhz.
100Khz is an industrial standart for testing electrolytics condensators.

Always provide a 0.1µf in parallel with the electrolytics condensators because they have a serial inductance and do'nt work with high frequencies.

The Tantalum condensators have a better high frequencies behaviour.

ESR is a greater concern with SMPS, where we have high frequencies and high ripple currents.
(25Khz to 250Khz)

DC biasing is not necessary, we only apply several hundreds AC mV's, this is not enough to reach the reverse electrolyse voltage level.

Low ESR is very important in SMPS.
 
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Digital ESR meter
« Reply #19 on: December 28, 2013, 12:30:08 pm »
What kind of mcus would one need for something like this?

1) mips: since I am using the isr to generate the excitation signal + sync-detect the output, I would have to take the isr overhead (20 ticks conservatively), plus maybe 20 - 30 ticks to flip the excitation pin + switch pins (very conservative). So I am talking about about 50 ticks at least in every 50us -> 1MIPS  minimum. Plus other functions I think you will need a 2MIPS minimum to start with (again, being conservative here).

That means we need a PIC running on 8Mhz oscillator or a AVR running on a 2Mhz oscillator.

Using an avr allows a lot of headroom but I like challenges so I will pick a PIC instead.

2) pins: we need 1 pin for excitation, 2 pins to switch in the sync detector -> 3 digital pins minimum. We will also need at least 1 adc pin (if we are to use an outboard differrential amplifier, or two adc pins if onboard adc is used). We will likely need 1 pin for calibration (I will explain how it works later), and 1 pin for input?

that means 3 - 5 digital pins and 1 - 2 analog pins.

In addition, if we are to drive a lcd, we need 6 pins (4-pin mode), or 3 pins with a shift register, or 2 pins with a few rc network.

So we are looking for a PIC with 5 - 11 digital pins and 1-2 analog pins.

I will use a 16F684 - it has 12 pins (1 input only). PORTC has 6 pins that can be used to drive the lcd (4-pin mode), or to drive the lcd in 3-pin mode (with a shift register) + 3 pins for excitation + switches.

3) oscillators: I would like to use a crystal oscillator, for better stability. However, it consumes two pins on PORTA. To save those two pins and to reduce component counts, I may have to try the internal rc oscillator (limited to a max of 8Mhz): I have to take my chances at stability.

So, for now, 16F684 + internal oscillators.
================================
https://dannyelectronics.wordpress.com/
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Digital ESR meter
« Reply #20 on: December 28, 2013, 12:34:37 pm »
A little hack produced this:

The excitation signal on RA2, switches on RA4/5. R2/C2 is the dut (R2 being the esr). 16f684 running on internal oscillators (8Mhz).

Output signal on C1 (Vp) and C3 (Vn).

at 5vp excitation, 20ohm ESR, the differential is about 90mv. at 10ohm ESR, it is about 45mv - as expected, :)
================================
https://dannyelectronics.wordpress.com/
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Digital ESR meter
« Reply #21 on: December 28, 2013, 12:45:03 pm »
TMR2 (with auto reloading) is used to generate the excitation signal.

Code: [Select]
//isr for tmr2
void interrupt isr(void) {
TMR2IF = 0; //clear tmr2 interrupt flag
SW_DDR ^= SW1 | SW2; //flip sw1/sw2 direction register - both initialized to clear
EXC_PORT ^= EXC_PIN; //flip the excitation signal
}

The isr is considerably shorter / simpler than I had expected: only 3 statements (two in an avr). SW1 / SW2 are the switch pins. They are initialized to be cleared and one as input and another as output. In the isr, we only need to flip the TRISx bits. EXC_PIN is the excitation signal output pin - initialized as output.

Here is the delisting from the compiler (picc9.60):

Code: [Select]
   30                           ;main.c: 26: void interrupt isr(void) {
    31  0008  1283                bcf 3,5
    32  0009  108C                bcf 12,1
    33                           ;main.c: 28: TRISA ^= (1<<4) | (1<<5);
    34  000A  3030                movlw 48
    35  000B  1683                bsf 3,5
    36  000C  0685                xorwf 5 ;volatile
    37                           ;main.c: 29: PORTA ^= (1<<2);
    38  000D  3004                movlw 4
    39  000E  1283                bcf 3,5
    40  000F  0685                xorwf 5 ;volatile
 

I am sure you have spotted the issue here right away: the excitation signal and the switches are not exactly synchronized - one is 3 ticks (1.5us on a 2MIPS mcu) ahead of the other. One way to solve that is to use an external switch controlled by EXC_PIN (the delay there would be in <1us territory).

Without the use of an external switch, we have to either run the mcu at higher speed, or lengthen the period of the excitation signal. Right now, I am running the signal at 50us per switch cycles so missing 1.5us every 50us may not be that big of a deal.



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

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Digital ESR meter
« Reply #22 on: December 28, 2013, 12:46:52 pm »
I estimated that at 2MIPS, about 20% of the processing power is consumed in the isr + overhead. So processing power doesn't seem to be that big of an issue.

Next, I will implement the lcd + adc.
================================
https://dannyelectronics.wordpress.com/
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Digital ESR meter
« Reply #23 on: December 28, 2013, 02:27:58 pm »
With the lcd display function added. 4-bit mode at this point.

No adc implemented yet - a generic adc routine is in. Flash about 44% utilized at this point.

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

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Digital ESR meter
« Reply #24 on: December 28, 2013, 02:29:45 pm »
Two adc pins (RA0/RA1) left, for Vp/Vn. ESR reading simulated at this point.

One input pin left (RA3). No output pin left. I will need to figure out an innovative way to implement calibration.
================================
https://dannyelectronics.wordpress.com/
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf