Digital ESR meter - Page 1
Forum section: electronics / projects

author: dannyf
author_rank: Super Contributor
timestamp: December 28, 2013, 12:19:19 am
content: 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.

author: dannyf
author_rank: Super Contributor
timestamp: December 28, 2013, 12:24:16 am
content: 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.

author: dannyf
author_rank: Super Contributor
timestamp: December 28, 2013, 12:27:26 am
content: 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:

author: dannyf
author_rank: Super Contributor
timestamp: December 28, 2013, 12:30:51 am
content: 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.

author: dannyf
author_rank: Super Contributor
timestamp: December 28, 2013, 12:41:55 am
content: 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 thatVdut(charging) = Vc + Im * ESR; during charging; andVdut(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.

author: dannyf
author_rank: Super Contributor
timestamp: December 28, 2013, 12:51:45 am
content: 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.

author: dannyf
author_rank: Super Contributor
timestamp: December 28, 2013, 12:54:58 am
content: 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.

author: dannyf
author_rank: Super Contributor
timestamp: December 28, 2013, 12:57:32 am
content: 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.

author: dannyf
author_rank: Super Contributor
timestamp: December 28, 2013, 01:08:00 am
content: 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.

author: dannyf
author_rank: Super Contributor
timestamp: December 28, 2013, 01:11:10 am
content: How does it work in simulation?Here is the reading for ESR = 0.1ohm -> 50ohm.The reading goes linearly to 230mv.

author: dannyf
author_rank: Super Contributor
timestamp: December 28, 2013, 01:12:04 am
content: The same chart presented in double-log form shows more detail when ESR is very small:Still very linear.

author: dannyf
author_rank: Super Contributor
timestamp: December 28, 2013, 01:21:34 am
content: 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.

author: dannyf
author_rank: Super Contributor
timestamp: December 28, 2013, 01:37:59 am
content: 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.

author: dannyf
author_rank: Super Contributor
timestamp: December 28, 2013, 01:48:39 am
content: 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.

author: BravoV
author_rank: Super Contributor
timestamp: December 28, 2013, 06:24:12 am
content: Sub-ed, and thank you.

author: cwalex
author_rank: Frequent Contributor
timestamp: December 28, 2013, 07:49:06 am
content: Quote from: BravoV on December 28, 2013, 06:24:12 am+1

author: oldway
author_rank: Super Contributor
timestamp: December 28, 2013, 10:30:26 am
content: 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.

author: tszaboo
author_rank: Super Contributor
timestamp: December 28, 2013, 10:49:08 am
content: 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

author: oldway
author_rank: Super Contributor
timestamp: December 28, 2013, 12:19:54 pm
content: 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.

author: dannyf
author_rank: Super Contributor
timestamp: December 28, 2013, 12:30:08 pm
content: 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.

author: dannyf
author_rank: Super Contributor
timestamp: December 28, 2013, 12:34:37 pm
content: 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,

author: dannyf
author_rank: Super Contributor
timestamp: December 28, 2013, 12:45:03 pm
content: TMR2 (with auto reloading) is used to generate the excitation signal.Code://isr for tmr2void interrupt isr(void) {TMR2IF = 0;//clear tmr2 interrupt flagSW_DDR ^= SW1 | SW2;//flip sw1/sw2 direction register - both initialized to clearEXC_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:30 ;main.c: 26: void interrupt isr(void) {31 0008 1283bcf3,532 0009 108Cbcf12,133 ;main.c: 28: TRISA ^= (1<<4) | (1<<5);34 000A 3030movlw4835 000B 1683bsf3,536 000C 0685xorwf5;volatile37 ;main.c: 29: PORTA ^= (1<<2);38 000D 3004movlw439 000E 1283bcf3,540 000F 0685xorwf5;volatileI 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.

author: dannyf
author_rank: Super Contributor
timestamp: December 28, 2013, 12:46:52 pm
content: 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.

author: dannyf
author_rank: Super Contributor
timestamp: December 28, 2013, 02:27:58 pm
content: 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.

author: dannyf
author_rank: Super Contributor
timestamp: December 28, 2013, 02:29:45 pm
content: 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.

author: dannyf
author_rank: Super Contributor
timestamp: December 28, 2013, 04:50:32 pm
content: adc now implemented (5v Vref):Vp: 1010.6mv/207;Vn: 934.3mv / 191;So a differential reading of adc 16 corresponds to a ESR of 20ohm (used in the simulation).The code is now calibrated to that.

author: dannyf
author_rank: Super Contributor
timestamp: December 28, 2013, 04:51:14 pm
content: With the code calibrated to 16 adc readings = 20ohm esr, here it is measuring 10ohm esr:spot on!

author: dannyf
author_rank: Super Contributor
timestamp: December 28, 2013, 04:53:05 pm
content: here it is measuring 1 ohm esr:measured as 1.125 (that's 1/16th).

author: dannyf
author_rank: Super Contributor
timestamp: December 28, 2013, 05:26:36 pm
content: Flash is about 50% utilized at this point.The code at this point is very portable - porting it to other mcus would be fairly easy.To-Dos:1) outboard amplification / better resolution: the resolution is now limited by the onboard adc. One way to get around would be to use outboard amplification. We can use a differential amplifier to calculate Vp - Vn; better yet, we can use another opamp to further amplify the signal, with its gain controlled by the mcu. If we pick 50ohm as our max range, you have a maximum Vp - Vn of about 150mv (depending on the voltage used). So a 20x of gain would be max for that range, yielding a resolution of about 4mv / (150mv * 20) * 50ohm = 67mohm (on a maximum range of 50ohm).That 20x gain can be divided into two gain blocks (so we can use a dual opamp): the first gain block has a fixed gain of 10x, and the 2nd gain block has variable gains of 2x and 20x, controlled by the mcu. At 20x gain, the combined gain would be 200x, yielding a resolution of 7mohm (on a maximum range of (3000mv / 200x) / 150mv * 50 = 5ohm.That should be good enough.Using outboard amplification also frees up one input pin. However, it introduces more complexity and the need to null offset (two point calibration).2) calibration: as is, the calibration (how Vp - Vn maps to ESR) is hard-coded. For a working module, you will need to allow the users to set the calibration.That usually is not a problem when we have additional pins to introduce some "calibration capacitors" - capacitors with known ESRs. Our challenge here is that we have only one input-only pin left.How do we calibrate then? One approach is to use a known (small value) resistor in serial with a capacitor. We will measure the esr of the capacitor alone, and then we will measure the esr of the capacitor + the known resistor. We can use the difference to calibrate the meter.How do we get the meter into calibration? if we boot up the meter without the calibration key (=the input only key) pressed, we go straight to measurement phase; if we boot up the meter with the calibration key pressed, we go into calibration and at the end of it, we save the calibration results in eeprom for future uses.3) two-point calibration - applicable of outboard amplification is used.The calibration in 2) above calibrates only the slope of the meter - it assumes that at esr = 0ohm, the output will be sufficiently close to 0mv.With high-gain blocks used, that may not be the case. As such, we have to calibrate both slope and offset (aka two-point calibration). I haven't given it much thought but will deal with it later.So next step is to figure out how to implement the (one-point) calibration.

author: dannyf
author_rank: Super Contributor
timestamp: December 28, 2013, 07:38:03 pm
content: I may have a simpler solution: oversampling. I implemented 5-bit oversampling (2^5 times oversampling) and here is the measurement of 0.2ohm ESR on a meter calibrated at 20ohm.So a simpler way to calibrate is to measure a small esr capacitor in serial with a known resistor (say 20ohm) and the user can press the calibration button to save the results into eeprom -> meter calibrated!

author: vindoline
author_rank: Unknown
timestamp: December 28, 2013, 11:04:39 pm
content: FYI, there is another "digital" ESR meter project using the Arduino here:http://forum.arduino.cc/index.php?topic=80357.0

author: dannyf
author_rank: Super Contributor
timestamp: December 29, 2013, 05:25:24 pm
content: Here is the near-final version of the meter without outboard amplification.Hardware: The excitation signal comes out on RA2, R5/C5 (or R2/C2) form the dut. Two sync detectors' output is on C1 and C3, respectively. They are being adc's on RA0 and RA1. RA4/RA5 are the switches for the sync detectors.PORTC used to drive the lcd.SW_CAL and related circuit is for calibration.Software: The software uses oversampling on adc, and then oversampling on the calculation of ESR measurements. The mcu runs at the 8Mhz internal rc oscillator. No external crystals required - I have built a version of this on a breadboard and no detectable "warbling" from the internal oscillator - the internal oscillator is also quite accurate, requires just an OSCTUNE at 0x01 to produce a 9.969khz excitation signal (vs. 10Khz theoretical).The software is also adaptive: you can put a cap + 15ohm resistor in, calibrate it (under either 5v or 3.3v), and the meter is ready to go.Calibration: the calibration is simple. Put a cap + 15ohm serial resistor to the meter, and let meter measure its ESR. Once the meter stablizes, press SW_CAL and the meter would have saved the current measurement into eeprom, and use it later on. the eeprom calibration result will be used on the next boot-up.Performance: Once calibrated, the meter is accurate from 2ohm - 25ohm, within 10% (more accurate at the higher end). Below 2ohm, the meter becomes less accurate and below 1ohm, it can be significantly off - 1ohm for example is often read as 0.5 - 0.7ohm and the measurements vary fairly significantly from one measurement to the next - this is where the lack of high resolution adc is missed.

author: dannyf
author_rank: Super Contributor
timestamp: December 29, 2013, 05:38:17 pm
content: The flash is about 85% used. All math is in fixed point.Real vs. simulation: simulation showed higher error rate, particularly when esr is low. But otherwise, the two are quite comparable.Potential for error correction: it is possible that you can build a look-up table in the software that will correct the reading. The lack of stability in this version makes that difficult.Capacitance vs. ESR: the esr measurement is fairly stable once the capacitance is over 11uf. At 47uf or over, it makes practically no difference if it is a 110uf or 220uf capacitor for example.Small ESR measurement: it looks like impractical to apply this approach to measure ESR < 5ohm. Outboard amplification looks to be a must in that case.

author: dannyf
author_rank: Super Contributor
timestamp: December 29, 2013, 06:21:16 pm
content: With one gain stage (~20x): 2.6 ohm ESR reading on a 2 ohm ESR.RA1 is now available, potentially to control gain, or help out in calibration.The readings are very stable - at least 3 stable digits: this opens the possibility of having the errors corrected in software.Given the way the meter calibrates, the gain of the amplifier is not that important. Its upper limit is determined by the linearity of the opamp and the desired upper range of ESR scale. 22ohm ESR generates an output of 1v on the opamp. So potentially you can have a gain of 40x - 50x, with the output headroom of at least 2v under a 5v system.Exact resistor values not required, just R13 matches R15 and R14 matches R16, as closely as possible.BTW, 1ohm ESR reads 1.4ohm, 100mohm ESR reads 0.5ohm, approximately. I haven't explored the source of the errors - I think it is due to the mis-alignment of the excitation signal and the two sync switches.

author: dannyf
author_rank: Super Contributor
timestamp: December 29, 2013, 06:34:07 pm
content: QuoteI re-arranged the isr and took out 1 tick between the two statement. Now 2ohm ESR reads 2.4ohm, vs. 2.6ohm before. So I definitely will need to optimize it more (using shadow registers for example), or to run the mcu faster. I would think an AVR running at 20Mhz would be quite helpful here.

author: jaxbird
author_rank: Frequent Contributor
timestamp: December 29, 2013, 07:10:31 pm
content: Very nice and interesting projectthanksWhile the 16F684 is a nice and cheap little uC, IMO it might be worth adding a few $ to the BOM and use a much faster PIC24 with 12bit ADCs for higher accuracy.

author: kripton2035
author_rank: Super Contributor
timestamp: December 29, 2013, 07:36:36 pm
content: you can also use a pic 16f753 same architecture but with an integrated opamp.http://www.microchip.com/wwwproducts/Devices.aspx?product=PIC16F753

author: dannyf
author_rank: Super Contributor
timestamp: December 29, 2013, 08:05:36 pm
content: Yeah. 16f684 is pushing beyond its limit,Here is a 24F running the same code - pin setup is slightly different.Flash usage is 3.5k, btw.

author: dannyf
author_rank: Super Contributor
timestamp: December 29, 2013, 08:06:55 pm
content: Ideally, you want a mcu with high resolution adc + onboard opamp (or configurable logic, like on some the later PICs).

author: dannyf
author_rank: Super Contributor
timestamp: December 29, 2013, 09:16:16 pm
content: QuoteThanks for the link. However, I don't think that particular approach will yield the right measurement.Here is the relevant code:Code:digitalWrite(PULSE_PIN,LOW);//making a miliVolt pulse of 50mAdelayMicroseconds(1);//on the scope it looks that after enabling the pulse a litle delay is//recomended so the oscillations fade awayacumulator = analogRead(ESR_PIN);//reading value on AIN0digitalWrite(PULSE_PIN,HIGH);//stopping pulsedigitalWrite(DISCHARGE_PIN,HIGH);//discharging the capacitorsdelayMicroseconds(600);//waiting a bit longer to fully discharge before another pulseIt works by injecting a 50ma current pulse into the dut, and measure the voltage across the capacitor while it is being charged. It then discharges the capacitor.Two key issues:1) for smaller capacitors (220uf or less), a 50ma charging current over 10us or so will have significantly altered its voltage during the course of charging, particularly if the adc is slow.2) any residual voltage on the capacitor would have been accumulated. To minimize it, the code allows a (relatively) long period of discharge time but it could have been easily resolved if by double reading the capacitor.Another minor issue is that the voltages are going to be very small. Without amplification, you are playing into the hands of "uncertainty", even with oversampling, as my experience above showed.

author: dannyf
author_rank: Super Contributor
timestamp: December 29, 2013, 09:24:33 pm
content: To show that, here is the simulation:R2/C1 is the dut. Q1 + R1 form a 50ma pulsed current source, controlled by V1. Q2 discharges the dut.Since the esr of the dut is 1ohm, you should be getting a 50mv reading. Instead, the arduino code is reading somewhere in the 63mv range (assuming a 10us ADC time). That's about 20% off.Instead, if the code performs another adc AFTER the pulse has been turned off. He would have gotten a reading like 53mv -> <10% error.So the code should have been something like this:Code:digitalWrite(PULSE_PIN,LOW);//making a miliVolt pulse of 50mAdelayMicroseconds(1);//on the scope it looks that after enabling the pulse a litle delay is//recomended so the oscillations fade awayacumulator = analogRead(ESR_PIN);//reading value on AIN0digitalWrite(PULSE_PIN,HIGH);//stopping pulse//***********revision****************/acumulator -=analogRead(ESR_PIN); //subtrack the base//***********end revision************/digitalWrite(DISCHARGE_PIN,HIGH);//discharging the capacitorsdelayMicroseconds(600);//waiting a bit longer to fully discharge before another pulseThe revision is less of an issue if you are dealing with large capacitors (like 1100uf): 50ma over a few us isn't going to materially change their voltage.

author: dannyf
author_rank: Super Contributor
timestamp: December 29, 2013, 10:23:22 pm
content: Here is another simulation that will confirm the issues above.Here is the arduino code running on an arduino uno / 328p. Only modifications are to run it on the original liquidcrystal library.R1/C1 is the dut, with ESR/R1 = 1ohm. At 50ma, we expect the voltage reading to be 50mv.The actual reading is more like 65mv, which the chart shows to be accurate.

author: dannyf
author_rank: Super Contributor
timestamp: December 29, 2013, 10:28:25 pm
content: With a double-read, you get a much better reading of 51mv, considerably closer to the theoretical 50mv.The resolution of this type of approach is poor. So I continue to think some amplification is needed is you intend to read more accurately at below 1ohm.

author: dannyf
author_rank: Super Contributor
timestamp: December 29, 2013, 10:34:05 pm
content: Here is the original code, running on a 1ohm / 47uf dut. You can see clearly that the voltage over the cap went up 20mv when it was being sampled by the adc. The resulting mv reading is 79mv, vs. 50mv.With a double read, you get a reading of 53mv, vs. 50mv: much closer to reality.

author: vindoline
author_rank: Unknown
timestamp: December 30, 2013, 03:30:19 am
content: Hi dannyf,I didn't mean to imply that the other project was better (or worse) than your approach. It was just a heads up that there was a similar project that people were thinking about. I briefly looked into that project about a year ago, but it seemed to be confusing implementation of the Bob Parker ESR meter approach. Anyhow, your simulations have gone far beyond any analysis I did on this. Best of luck on your project.Quote from: dannyf on December 29, 2013, 09:16:16 pm

author: dannyf
author_rank: Super Contributor
timestamp: December 30, 2013, 12:47:53 pm
content: QuoteThat was not my concern. Actually I didn't think something like this approach was possible (actually it is difficult to implement on a mcu with slow adc, like the low-end PICs). It looks good on an avr. So that was a good discussion, thanks to you pointing it out.I do think there are two possible branches with this pulsed current approach:1) brutal force: obviously, you can increase the current being pulsed into the dut. and you can simplify the discrete driver circuit in the process. You can use a dedicated gate driver for example - some of them go up to multiple amps; You can use a 555 timer as a driver, up to 200ma; Or you can use parallel logic gates: a HC132 can deliver up to 80ma for example. Or you can parallel multiple output pins to do that - the simplest approach.Obviously, current consumption and battery life in a portable environment would suffer.2) low power consumption: instead, you can driver the dut from a mcu's pin, and use an opamp to amplify the pulse. With a single-rail fixed gain opamp, you can save on part counts greatly.Just more possibilities.

author: dannyf
author_rank: Super Contributor
timestamp: December 30, 2013, 12:50:43 pm
content: I am now working on a "digital" esr meter that provides analog output, utilizing some of the elements talked about earlier. All implemented on 1 or 2 8pdip parts.It should be challenging.

author: oldway
author_rank: Super Contributor
timestamp: December 30, 2013, 03:15:39 pm
content: Perhaps time to go back and to try understand how the ESR meter project of Jay_Diddy_B work and why he choosed the technical solutions of his project.With bad hardware, your software development will never succeed to give a good result...That's what you finally found: you are nowhere and you have to turn back.My goal is not to criticize, but draw a useful lesson from what has happened.Learn, study and understand what the others have done is a first step before developping a project.There are other people on earth who are as clever, and soms more clever than whe are...Lets have a look first what are their ideas...Using diodes (with voltage drop depending of temperature and current) with low ac voltage is a wrong choise.Compensation can only be achieved if the diodes are perfect matched.You had to choose higher DUT current to minimize this problem, but you can't protect you ESR meter for this reason.Other problem: DUT will have to reach 0.6V dc voltage before you can make a reading.With a 10000 µF, you will have to wait 2.7s before reading ESR value.Jay_Diddy_B used synchronous rectification: that's far better.With this solution, he could work with very low DUT current and protect his ESR meter very well.Why don't you reuse the hardware project of Jay_Diddy_B but with a mcu and digital display ?

author: BravoV
author_rank: Super Contributor
timestamp: December 30, 2013, 03:23:11 pm
content: Quote from: dannyf on December 30, 2013, 12:50:43 pmCMIIW, so it will be ... DUT -> analog front end -> ADC -> MCU -> DAC -> "An analog meter" ?

author: dannyf
author_rank: Super Contributor
timestamp: December 30, 2013, 03:40:51 pm
content: That's roughly right. All of it done within a 8pdip package (6 active pins. actually 5 output pins and 1 input pins). Plus a slow adc.

author: dannyf
author_rank: Super Contributor
timestamp: December 30, 2013, 03:42:39 pm
content: I was thinking about the voltage rises across the capacitor when it is being charged - an issue with slow adc.There may be a way to counter that and obtain both a ESR reading and a capacitance reading (for small capacitors, like <220uf).

author: dannyf
author_rank: Super Contributor
timestamp: December 30, 2013, 03:53:14 pm
content: QuoteHow to output the data is quite interest. Obviously, you can output an analog value; You can also send the output via a serial pin (uart). Or with two+ pins, via shift registers to light up (7-segment) leds or simple led indicators.The chip I picked is PIC12F675 - 4Mhz internal oscillator, 5 output pins, 1 digital input pin, 1 10-bit adc (very slow). At minimum, I need 1 digital pin to charge / discharge the capacitor, 1 analog pin to perform the adc, and 1 digital pin to output the value of ESR.So I have 2 output pins and 1 input pin left. I can either use one of the output pins to parallel-drive the capacitor, or the other for a complimentary analog output or RS232 output.Most of the functions have been implemented and the flash is about 40% utilized - still more room to grow.

author: G0HZU
author_rank: Super Contributor
timestamp: December 30, 2013, 04:32:20 pm
content: QuoteYes, there were too many bad things about this ESR meter design. There comes a point where dannyf has to realise that he is trying to polish a turd

author: dannyf
author_rank: Super Contributor
timestamp: December 30, 2013, 09:51:10 pm
content: Here is the "digital" esr meter with analog output, based on 12F675: a DDM reading can be taken across C3; or put an analog meter next to C3 and adjust R6 for sensitivity.Output is taking on GP2, and fullscale to 25ohm.Drive pins are GP4 and GP5 (only GP5 connected so far).Q1/Q2/R1/R3 can be replaced with a 555 timer, without any change to the firmware. Actually, the meter will work with just the GPIO pins driving the dut - I will show that later.Some performance figures:2200uf capacitors:Actual ESR / Meter reading:0.5 / 0.61 / 1.12 / 2.15 / 4.910 / 9.2220ufActual ESR / Meter Reading:0.5 / 0.51 / 12 / 25 / 4.910 / 9.222ufActual ESR / Meter Reading:0.5 / 0.71 / 1.22 / 25 / 4.810 / 9.02.2ufActual ESR / Meter Reading:0.5 / 2.61 / 3.12 / 45 / 6.710 / 10.7So it is good until about 22uf. After that, the meter starts to go off - the software tried a few strategies when measuring small capacitors, attempting to minimize the voltage rise on the dut when the adc sampling is done. But it is difficult, as the numbers here show.

author: dannyf
author_rank: Super Contributor
timestamp: December 30, 2013, 10:21:53 pm
content: A simplified version, with just two gpio pins (GP4/GP5) as drivers:Code is 99% identical to the one used above, just changing the drive current setting (50ma vs. 27.5ma), and change the polarity of the drive signal (clear to charge before vs. set to charge now).Some performance figures:220uf and over:Actual ESR / Meter reading:0.5 / 0.51 / 12 / 25 / 510 / 1022uf:Actual ESR / Meter reading:0.5 / 0.51 / 1.12 / 2.15 / 5.110 / 102.2uf:Actual ESR / Meter reading:0.5 / 2.81 / 3.42 / 4.35 / 7.410 / 12.1In case you want to play with it, here is the hex file:Code::020000001828BE:10000800A00003088301B5000B1183123208810791:100018000130B10604308506B209B20A83123508E8:100028008300A00E200E09002130840031302C20DE:100038000030B4004D30B30031308400333031200B:100048008316FF2390008301322904068001840A65:100058000406031D292864000034D4003C208000D5:10006800840A040854060319003432288312B300A2:10007800B41B452834088A003308B30A0319B40AA4:1000880082008313341883173308B30A84000008E6:1000980008000134143484018312B601DC01DD0147:1000A800DE01DF01580859045A045B0403195F286C:1000B800C030B6056A28D401D501D601D701CA28AF:1000C8000310D80DD90DDA0DDB0DB60ADB1F642835:1000D800B60A0310DC0DDD0DDE0DDF0D5B085702DF:1000E800031D80285A085602031D80285908550206:1000F800031D802858085402031C92285C145808D1:10010800D4025908031C590FD5025A08031C5A0F68:10011800D6025B08031C5B0FD7020310DB0CDA0C5A:10012800D90CD80CB60336083F39031D6D28361F85:10013800AA280310FF30D407D409031CD507D50912:10014800031CD607D609031CD707D7095408D800BB:100158005508D9005608DA005708DB005C08D400B7:100168005D08D5005E08D6005F08D700B61FCA280C:100178000310FF30D407D409031CD507D509031C85:10018800D607D609031CD707D709CA288408031934:1001980000345708800084035608800084035508FB:1001A8008000840354088000003464308312A50062:1001B800A601A701A801A901AA0100308312DC2128:1001C800D601D7015408A7025508031C550FA802E9:1001D8005608031C560FA9025708031C570AAA02FF:1001E800303085040030DC21D601D7015408A70738:1001F80055080318550FA80756080318560FA907DE:1002080057080318570AAA07CF3085056430AF008E:10021800B001CF2125080319A603A503250A031950:10022800260A031DE1286430D800D901DA01DB0170:100238002708D4002808D5002908D6002A08D7009E:100248004F205408AB005508AC005608AD005708BD:10025800AE002C08D5002B08D40008008312E82132:10026800B7217A218B17D9205408A3005508A40078:100278008A30D800D901DA01DB012408D500230827:10028800D400D601D7015608D7005508D60054081F:10029800D500D4014F205408A3005508A400230416:1002A800031D5A290130D400D5015F29831224087F:1002B800D5002308D40054088312A3005508A400CD:1002C80001302402003003192302031C7029FF3077:1002D800A300A401851471298510B1080319762992:1002E800230878292308003CB200372983161F13F6:1002F8009F121F1683129F111F119F171F130C1394:1003080083160C1383121F14F3309F0583169F1155:100318001F119F101F1400000000000000000000C3:1003280000000000000000000000000000000000C5:1003380000000000000000000000000000000000B5:1003480000000000000000000000000000000000A5:100358000000000000000000000000000000000095:10036800000083120800303083128504CF308316D2:1003780085058312851083168510811381128111DA:100388000115811401140B118B16831205158316A0:10039800051183120800D129000083122F080319C0:1003A800B003AF032F0A0319300A03190800D02934:1003B80083129F149F18DE291E08D500D4018316C6:1003C8001E08D4048312080007308312990083168C:0603D8009F0183120800E2:02400E00843FED:00000001FFFlash is <50% utilized.Potential enhancement:1) I have one more digital pin unused (GP1). It can be used to enhance drive current;2) You can potentially implement the code so it has variable drive current: from 1 pin drive to 2 pins drive or 3 pins drive. This is handy when esr is very small.edit: the code I posted earlier has no handling for over-range. Now, if the resistor is over-range, the led will turn.I may implement variable drive later so the meter can measure a wider range of ESRs.

author: Jay_Diddy_B
author_rank: Super Contributor
timestamp: December 31, 2013, 12:54:57 am
content: Hi DannyF and the group,If you are going to pursue the pulsed approach to ESR measurement you should have a look at Bob Parker's approach. The manual can be found here:http://shop.anatekcorp.com/clientuploads/directory/products/pdfs/BlueESR%201.pdfThis meter was originally the Dick Smith Electronics ESR. It is now sold as the AnaTek blue ESR meter. It one of the more popular choices.* It has the capability to measure in circuit.* It has some, limited protection against charged capacitors.Kripton, who is a member of the forum has collected together links to most of the common ESR meter designs. These can be found at:http://kripton2035.free.fr/esr-repository.htmlI ran LTspice simulations on a few of these designs before I arrived at my designs.https://www.eevblog.com/forum/projects/5-transistor-esr-meter-design/?topicseenandhttps://www.eevblog.com/forum/projects/esr-meter-adapter-design-and-construction/msg341177/#msg341177A microprocessor could be added to the second design. A timer function could be used to replace the oscillator and a low speed ADC could be used the display the results. It would be easier to do this with a 5V microprocessor connected between -2.5V and +2.5V. A 12 bit ADC will give reasonable resolution.Regards,Jay_Diddy_B

author: G0HZU
author_rank: Super Contributor
timestamp: December 31, 2013, 01:10:00 am
content: dannyf really needs to bin this awful ESR meter and start again.40-50 years ago, people (on a low budget) were probably measuring capacitor ESR at 100kHz with a sig gen + dual beam scope and a sense resistor followed by a few sums using trig/log tables. They would also get reactance/capacitance as well as the 'real' component (ESR) from this simple measurement of complex impedance. (By measuring channel A and B and then measuring relative phase on the scope)Total outlay today if you already have a sig gen and a scope = 1 penny for the sense resistor. (plus some simple trig/vector maths in an excel spreadsheet)i.e. I bet I could measure a 1uF cap for ESR at 100kHz far more accurately than the dannyf design just using the ancient method above with a scope + 100kHz gen + 1 penny resistor and some maths in an excel spreadsheet. How anyone can make such a design disaster for such a trivial task despite having 50 years of tech advances plus the internet (for help) plus access to modern components is beyond me...Sorry to be so harsh but it simply beggars belief how awful some of these homebrew ESR meters are.

author: dannyf
author_rank: Super Contributor
timestamp: December 31, 2013, 02:15:23 am
content: QuoteI was asked how that might be done. So here it is:No change to the software. Obviously, the drive current remains at 50ma, which simplifies the circuit but defeats the purpose of having a 555 as the driver (200ma current output).If you lower the value of R1 to around 22 - 25 (@5v), you would have increased the drive current to ~200ma, which allows you to measure lower ESR capacitors.To do that, you will need to recompile the software.Hope it helps.

author: oldway
author_rank: Super Contributor
timestamp: December 31, 2013, 04:58:02 am
content: Did you ever read a 555 datasheet ?For 5V power supply:Output voltage drop(low): Isink 8mA -Typical 0.25V -Max 0.35V With 100mA sink, output voltage low is 1V(High): Isource 100mA -Min 2.75V -Typ 3.3V555 will generate a square wave from 1V low to 3.3V high and not from 0v to 5VTheses voltage drops are temperature and current dependents, no way to succeed some precision if the current feeding de DUT is not perfectly known.Your new design is a real piece of shit

author: oldway
author_rank: Super Contributor
timestamp: December 31, 2013, 11:19:04 am
content: Why don't you change your mind ?We are participating of this forum to share ours knowledges and experiences for helping each others.You seems to want to make an "one man show" (what became an "one man disaster")...that's not the goal of a forum.Read what we wrote and try to analyse it.I think that you could implement a mcu for offset compensation and for digital reading to the project of Jay_Diddy_B.Nothing wrong to use his project !Himself said to you to do this.

author: dannyf
author_rank: Super Contributor
timestamp: December 31, 2013, 12:43:38 pm
content: QuoteYeah. Something like the ATTINY would be perfect for this, and the avrs offer some big advantages over the PIC I used:- low (and internal) Vref of 1.1v: this allows better resolution for low ESR.- fast adc: the code on the PIC spends a lot of footprint trying to counter the rise of voltage across dut when it is being charged. That would be less of an issue if the adc is fast.- hardware pwm: the output can be done in hardware without the cpu's intervention.I suspect the use of an avr + variable drive will broaden the range of ESR measurement considerably. I may try this myself.Implementing this on an Arduino can be tricky, as the arduino port operations are slow and you have to do it directly on the registers.

author: dannyf
author_rank: Super Contributor
timestamp: December 31, 2013, 05:12:57 pm
content: The AVR has an amplifier in the adc module (gains differ from chip to chip). In the Attiny, you have a choice of 1x or 20x (differential mode only and you lose a pin because of that).So, with 1.1Vref @ 10bit, each bit is 1mv @ 1x or 50uv @ 20x. At 10ma drive current, you can measure ESR from 100mohm - 100ohm @ 1x, or 5mohm -> 5ohm.If you look at the Parker ESR design, the complexity comes from 1) the variable drive circuit: 3 levels, which can be implemented easily with a mcu, or not used at all; and 2) the 10x amplifier - which is already implemented in the avr.When I get some time later, I will hash this out on the AVR, re-using the code for the PIC.

author: dannyf
author_rank: Super Contributor
timestamp: January 01, 2014, 02:25:36 am
content: Ported the code to a usb1286 (teensy++2.0).The hardware is quite simple: three resistors (one of them optional) + a dut.The picture showing it measuring a dut with 50mohm ESR - software calibrated at 10ohm. 50mohm also happens to the bottom end of the meter.Fixed 5ma drive current so it can be entirely power by a battery.My Attiny85s are on the way.Top end of the meter, at 10x gain, is about 20ohm - beyond that, it starts to underestimate ESR. The range can be extended at lower gain (1x) - not yet implemented.

author: dannyf
author_rank: Super Contributor
timestamp: January 01, 2014, 02:36:23 am
content: The software does a few things:1) each esr measurement takes four adc readings - the meter then calculates the esr. This strategy works on small caps, down to about 4.7uf.2) 128x oversampling of the esr;3) at each esr measurement, the meter nulls its offset automatically;4) adc gain set at 10x;5) meter compensate for drive current variations - duts with large esr will have lower drive current. If not compensated, the meter will under-estimate th esr.6) the meter uses internal bandgap reference for better resolution. The attiny has a lower Vref and higher gain opamp. That should extend the lower-end of the meter even further.The output is now on a lcd. On an attiny, you can use analog output, or leds driven by shift registers (either statically or dynamically), or lcd + shift register.

author: dannyf
author_rank: Super Contributor
timestamp: January 01, 2014, 01:36:36 pm
content: Happy new year everyone!While waiting for my attiny to arrive, I decided to shrink the number of pins needed to drive the lcd.Here is the same code running a lcd through a HC595, measuring a 500mohm ESR capacitor.

author: dannyf
author_rank: Super Contributor
timestamp: January 01, 2014, 01:46:15 pm
content: Some inner workings of the ESR measurement routines utilized by this meter:1) It starts by measuring the adc offset;2) The meter then charges up the capacitor, and perform 4 successive reads. Based on that, it estimates the capacitance of the dut and classifies it into three buckets: small capacitor, medium capacitor and large capacitor. That classification is utilized to optimize the strategy utilized later to measure the esr.3) The general theme for the strategies is to take four readings, one before the dut is charged up, two successive readings when the dut is being charged up, and one after the dut is being discharged. Two measurements are returned: the raw ESR reading (unadjusted for drive current variation), and drive current estimation.4) An adjustment is then made to the raw ESR to account for smaller drive current for the rise of voltage across the dut.With oversampling, the meter refreshes the adjusted ESR 5 times per second.At present time, the meter is optimized to low ESR measurements (<10ohm). In the future, we can implement auto-ranging and let the meter selects the right range based on the dut being tested. This approach will allow a more accurate reading over a wider range of ESR.

author: dannyf
author_rank: Super Contributor
timestamp: January 01, 2014, 01:49:00 pm
content: I will add a 7-segment led read-out and analog read-out later.

author: Jay_Diddy_B
author_rank: Super Contributor
timestamp: January 01, 2014, 03:34:13 pm
content: Hi dannyf and the group,I am intrigued by the minimal circuit implementation using the ATtiny85. So I have built a LTspice model so that I can get an idea of the ADC converter 'sees' during the measurement process.The ADC in the ATtiny takes 14 conversion clocks from acquisition to conversion complete. The datasheet warns against using a conversion clock greater than 1MHz, as this will degrade the ADC converter performance.I assumed a 200kHz clock for the model. This gives a conversion time of 70us. I placed the two conversions during the 100us pulse 70us apart.LTspice modelI have implemented 4 sample and hold circuits in the LTspice model to simplify the modelling. I have also implemented 4 conversion units which convert the sample and hold outputs to ADC counts. In the real implementation these functions are performed sequentially on the same hardware.I have attached a zipfile with the LTspice model for people who want to experiment.Here is the model:and here are the results that I obtained from the model:I am still thinking about how to determine the ESR step from the four data points.Regards and Happy New Year !!Jay_Diddy_B

author: dannyf
author_rank: Super Contributor
timestamp: January 01, 2014, 03:34:52 pm
content: Added support for 7-segment leds, driven off shift registers. Via the flip of a switch, you can switch in / out of either of those output media.You can actually combine the two serial clock / data lines together.

author: dannyf
author_rank: Super Contributor
timestamp: January 01, 2014, 03:52:10 pm
content: Now, the meter measuring 10ohm ESR.The lcd is re-routed to run off the same serial bus as the leds.

author: dannyf
author_rank: Super Contributor
timestamp: January 01, 2014, 05:24:45 pm
content: Auto-ranging implemented: the meter will switch to optimize measurements for high-ESR and low-ESR.Here is the meter measuring 5ohm ESR, with 10x gain - noticed the last two digits of the ESR display in the lcd?

author: dannyf
author_rank: Super Contributor
timestamp: January 01, 2014, 05:26:16 pm
content: Now, the same meter switched to measure a 50ohm ESR, with 1x gain.Notice the last "1" (vs. "10") in the ESR display.

author: dannyf
author_rank: Super Contributor
timestamp: January 01, 2014, 05:27:21 pm
content: The top end of the meter is limited by Vref and your algorithm for measuring high esr.Next, analog output.

author: dannyf
author_rank: Super Contributor
timestamp: January 01, 2014, 05:30:26 pm
content: ESR readings are generally more accurate with higher gains. However, high gain starts to under-read the ESR north of 25ohm (in this implementation). So you will need to switch out to use lower gains before that.

author: dannyf
author_rank: Super Contributor
timestamp: January 01, 2014, 05:34:48 pm
content: Wiring for the leds: you want to use individual resistors for each segment to maintain constant brightness. The way I wired it, the segments will get dimmer if more of them are lit. You can reduce the visibility of the dimming by running the leds hotter. But using individual resistors is the way to go in a final build.

author: dannyf
author_rank: Super Contributor
timestamp: January 01, 2014, 07:54:39 pm
content: Capacitance read-out: I was asked how accurate the meter is in estimating the capacitance and if it is possible to display the capacitance as well.The capacitance estimates are only utilized in the meter to steer the esr algorithms. You would expect that the capacitance measurement is less accurate in case of large capacitance and low adc gain settings.Otherwise, the meter does a fairly good job at estimating the capacitance.Here is a case where a 110u/30ohm ESR is being measured. The high ESR forces the meter to switch to low-gain setting, wich degrades the capacitance (and ESR) accuracy: 110uf is measured as 80uf.

author: dannyf
author_rank: Super Contributor
timestamp: January 01, 2014, 07:56:59 pm
content: Here is the meter reading a 220uf/3ohm ESR dut, at 10x setting.220uf capacitance is estimated fairly accurate.I have also added a range indicator (D1/D2) - useful with analog read-out.

author: dannyf
author_rank: Super Contributor
timestamp: January 01, 2014, 09:32:12 pm
content: PWM output is now implemented.I decided to have two full-scale output - 50ohm and 5ohm.Here is the meter measuring 2.5ohm ESR on a 5ohm full-scale. The output should be close to 2.5v - indeed.

author: dannyf
author_rank: Super Contributor
timestamp: January 01, 2014, 09:33:58 pm
content: Now the meter measures a 25ohm ESR dut, on 50ohm full scale. The output, again, should be close to 2.5v.The (analog) meter is configured as a voltage read-out. It is easy to wire it to drive a coil meter. In that case, R12 can be used to adjust sensitivity / calibration.

author: dannyf
author_rank: Super Contributor
timestamp: January 01, 2014, 09:36:18 pm
content: With all the functions discussed so far together, the flash is just shy of 5k. So there is a good chance it will fit into an Attiny45, and maybe even Attiny25.Now, we just need to wait for the chips to come in.In its simplest implementation, you just need a few resistors to cover 50mohm - 50ohm ESR measurement with reasonably good accuracy, not a bad deal in my view.

author: oldway
author_rank: Super Contributor
timestamp: January 02, 2014, 09:20:44 am
content: Where are you going ?Don't you notice you are on the wrong way?it is a white elephant project without any protection...you better stop with this

author: dannyf
author_rank: Super Contributor
timestamp: January 02, 2014, 02:19:23 pm
content: The project consists of 11 .h/.c files, totally roughly 55KB.For winavr: with just analog output compiled in, it takes 3KB flash; 3.7KB flash with just the led display; 4.5KB with the lcd display. About 60% of that at the highest optimization levels.So it is fairly doable with fit all in an attiny45. With some profiling and hand optimization, you may be able to fit it into an attiny25.

author: cellularmitosis
author_rank: Unknown
timestamp: January 02, 2014, 09:26:30 pm
content: Thanks to everyone contributing to this thread. For a newb like me it's very interesting to see the tools and methods used.dannyf, what software package is that which you are using to simulate the hd44780 LCD and the seven segment displays?

author: dannyf
author_rank: Super Contributor
timestamp: January 02, 2014, 11:27:05 pm
content: Flash usage when compiled to an ATTINY:Analog output: 1.8kbLED output: 2.0kbLCD output: 2.4kb(compiler: gcc-avr)So a little bit efforts needed to fit it to an attiny25. Plenty of space left for attiny45.I will try to compile it to IAR and see if it can skinnied down a little bit more.

author: dannyf
author_rank: Super Contributor
timestamp: January 03, 2014, 12:01:36 am
content: No go under IAR either. Looks like attiny25 for analog output / led output, and attiny45 for lcd output.QuoteProteus.

author: dannyf
author_rank: Super Contributor
timestamp: January 03, 2014, 12:18:30 am
content: The design process is a surprise to me as well. I never expected that the pulse current approach could work out this well - granted, the math involved was fairly extensive, particularly doing all of it in integer.Once I get it working, I will go back to my original approach and see how I could get it working a little bit better.Yes, it is very educational to me as well.

author: dannyf
author_rank: Super Contributor
timestamp: January 19, 2014, 03:46:54 pm
content: Some progress to report.I ported the code to a pic24f (!) for its adc speed initially.At this point, it consists of simply a 1k resistor to charge up the dut, a pin to adc the voltage across the dut, and a lcd for display.Other than those I mentioned earlier, I did a few tweaks:1) pre-charge the dut: To obtain reliable reading, I had to pre-charge the dut to about mid scale and then start the measurement process. This approach eliminates the need to compensate for the impact on charge-up current when small value capacitors are measured. However, you can no longer calibrate the meter with resistors.2) shorting out the current limiting resistor on the adc pin: even at 1k, that resistor, combined with Ccharge, presents a problem during fast measurement and will under-estimate the ESR. I simply shorted it out.The following are a series of test photos measuring an unknown capacitor (47uf 50v) against two known resistors (15R and 0R47), in various configuration.First, the capacitor alone: ESR = 0.9R per the meter.

author: dannyf
author_rank: Super Contributor
timestamp: January 19, 2014, 03:48:40 pm
content: BTW, forget about the capacitance reading - I haven't paid attention when porting the code to the pic24f. Will do it later.Now, the same capacitor + 15R:

author: dannyf
author_rank: Super Contributor
timestamp: January 19, 2014, 03:49:41 pm
content: The same capacitor + 15R + 0.47R resistors.

author: dannyf
author_rank: Super Contributor
timestamp: January 19, 2014, 03:50:42 pm
content: The same capacitor + just 0.47R resistor:

author: dannyf
author_rank: Super Contributor
timestamp: January 19, 2014, 04:02:04 pm
content: Each measurement cycle is about 40us - 6 adc samples are done, plus 4 accumulations. I do 1024 measurements for each ESR reading so the display updates very fast - you can see that in some of the pictures.I relaxed the measurement cycle to 80us -> corresponds to about 80ksps. Beyond which measurement errors became more pronounced without utilizing the capacitance into calculation. This means that porting it to a low-end mcu like 16F684 (for its slooooooow adc) can be a challenge (and fun!).That's exactly what I will do next.

author: dannyf
author_rank: Super Contributor
timestamp: January 24, 2014, 03:49:40 pm
content: I am back.Having implemented the pulsed current ESR meter and then the avr-based milliohm meter, I thought I would go back to my original approach, posted on the first page: a gpio-controlled phase detector.Instead of using switches, I am shorting one of two integrators, based on the phase of the driving signal. To prevent the shorting to discharge the integrator (a capacitor), I used a diode to isolate them. The two output signals from the integrators are then differentially measured by the onboard adc.The bulk of the code is stolen from my milliohm meter, as the basic structure of the circuit / code are highly alike.Preliminary results: measuring a capacitor with unknown ESR - the meter says that the esr is 1.682ohm but I don't really know.

author: dannyf
author_rank: Super Contributor
timestamp: January 24, 2014, 03:51:58 pm
content: If I were to increase the capacitor's ESR (via a known resistor for example), I should see a corresponding increase in the meter's reading.Here is the same capacitor + a 0.47ohm resistor measured by the meter: The meter says the combined ESR is 2.056ohm, an increase of 0.4ohm. Fairly close to the anticipated value.

author: dannyf
author_rank: Super Contributor
timestamp: January 24, 2014, 04:21:50 pm
content: Here is the new meter, in its entirety (lcd not shown).The drive signal comes out of PC7, through the current limiting resistor (labeled "a"), to charge up two integrators (capacitors + their bleeders) through two diodes. The signal to the integrators is shorted to ground by two resistors periodically (controlled by PC2 and PC3 on the usb1286). The voltage on the capacitor is measured differentially by AN2 and AN3 (PF2 and PF3), respectively.For a total of 9 parts.It comes with relative measurements, calibration, but does not compensate for drive current - so the meter cannot be calibrated by a resistor.

author: dannyf
author_rank: Super Contributor
timestamp: January 31, 2014, 04:31:09 pm
content: I further simplified the schematic: took out the two diodes and replaced them with two resistors. This lowers the gain of the whole instrument but saves two diodes (2 cents?).

author: dannyf
author_rank: Super Contributor
timestamp: January 31, 2014, 04:42:51 pm
content: Here is a shot of the meter on breadboard. 5 resistors + 2 capacitors.Cannot be any simpler than that,

author: dannyf
author_rank: Super Contributor
timestamp: January 31, 2014, 04:45:00 pm
content: A big advantage of eliminating the diodes is that you can calibrate the meter now with a resistor.Here is the meter measuring a 0R47 resistor in relative mode (to null the wire resistance).

author: jaxbird
author_rank: Frequent Contributor
timestamp: January 31, 2014, 05:05:47 pm
content: Quote from: dannyf on January 31, 2014, 04:45:00 pmNice results with so few components

author: dannyf
author_rank: Super Contributor
timestamp: January 31, 2014, 07:18:38 pm
content: That is the power of mcu: the mci serves as the oscillator to excite the dut.. The resistors plus two mcu pibs form a sync detector. The detector's output goes through a 200x difference amplifier before being digitized by the mcu.while simple it had all the elements of a proper meter.

author: dannyf
author_rank: Super Contributor
timestamp: February 03, 2014, 12:01:42 pm
content: It's possible to reduce the number of resistors down to 3: by integrating the positive cycles first and then the negative cycles.

author: dannyf
author_rank: Super Contributor
timestamp: February 08, 2014, 09:19:21 pm
content: Didn't forget about my earlier intention of building a digital esr meter with analog output.Here is what I have done so far.The mcu is a ATtiny85 (8pdip). It creates an excitation signal across the dut (ESR + C3 in the attached schematic). A synchronous detector is built around R2/R4/C3/DRV_P and R1/R5/C1/DRV_N, with DRV_P/DRV_N are two GPIO pins out of the ATtiny85. DRV_P/DRV_N pins alternatively short the signal coming from the dut. As a result, the voltage during the positive cycle is integrated on C3 and the voltage during the negative cycle is integrated on C1.A differential amplifier in the mcu picks up the differences, from pins ADC_P and ADC_N, respectively. The software picks up the right gain to maximize the resolution automagically.Once the difference is ADC'd, the mcu calculates the ESR, and then drives a pwm generator to create an analog voltage on C4.So the operating principle is almost identical to the ones shown earlier here.The picture below shows the meter measuring a 5ohm ESR capacitor, with the meter full scale being 50ohm / 5V so we should expect to see 0.5v on C4 -> which the meter does.Interesting features of the meter:1) it will auto-null the opamp offset;2) it utilizes three strategies to calculate the ESR. Each ESR measurement is done via 6 adc sampling.3) The meter picks the strategies based on the estimated capacitance.Rough performance figures: Fairly good from 0.5ohm to 50ohm. Below 100mohm, the meter tends to underestimate ESR for large capacitors (1100u or over), and overestimate ESR for small capacitors (22uf and under).Calibration: given the lack of pins, the calibration is done via adjusting R6 (for a coil meter), or adding another resistor across C4 if a voltage meter is used.Total part count: 10 (+ 1 decoupling cap for the avr).

author: dannyf
author_rank: Super Contributor
timestamp: February 08, 2014, 09:24:43 pm
content: 5ohm 22uf on the same software vs. 5ohm 220uf previously.