Show Posts
Pages: [1] 2
1  Topics / Science and Measurement / Re: ESR meter with Arduino on: October 23, 2012, 02:05:36 pm
Hi there,
1. You can use 2 wires no problem, no need for the 4 wire setup to understand why initially proposed that setup read back as I explained in a previous post.
2. The schematic that uses BS170 is a newer one, version 4.0, the esr meter presented here is based on an older schematic version 3.0 from lee hung. I see the new version has a bunch of modifications compared to ver 3.0. I guess the adition of see it BS170 would be to discharge the cap.
If you build the esr meter with Arduino read the post on this thread as you will find answers and some important modifications to the code.

Restecp smiley-wink
2  Topics / Science and Measurement / Re: ESR meter with Arduino on: July 20, 2012, 04:20:29 am

I'm glad you found the "bug" in your circuit and managed to get better readings, I will answer to your questions now:

- your assumption are right, with the 100 ohm branch max reading is around 6 ohm (R = U/I) = 0.300/0.05 = 6 ohm (0.300 is max voltage allowed by schottky diode 1N5822), if you need more range there is R4 branch with the 1k ohm 1% resistor (on D8), (you can implement this in the code and can have upper range that will give you the range of the 100 ohm resistor X 10, I think the same way a lower range could be implemented with a proper transistor that can source 500mA of current through resistor of 10 ohm 1%).
- you mentioned in your first post that did not use the diodes, I just want to explain now the role of the two groups of diodes, the first group of antiparalel 1N5822 diodes is to allow in circuit measurements, this diodes assure that we will get max 0.3 V on the probes and will not damage components on the board, the second group of diodes 1N4004 are there to protect the input of the Atmega from charged capacitors, good practice is to discharge caps before measurements.
- 65536 comes from 2^16(using oversampling in code we can have a mapped value between 0 and 65535), if we would take a simple measurement on a AIN pin we would get a 10 bit result which is 1024, but as we are enhancing our reading we get a 16 bit result that needs the proper scaling, thus dividing it by 65535, see

I wonder where I am wrong with the voltage divider formula, I currently don't have the hardware assembled and no possibility to test it, if you have spare time and in mood please try the following (would be nice to get better results from this simple hardware):
I think the problem comes from mixing Volts with mVolts in the formula I gave you, probably the reason for negative numbers too, display on your LCD the value of
and see the representation for a known resistor, say 1 ohm, this should be around 0.05 V or 50 mV:

if milivolt (not good)
esrVal = (miliVolt*100)/(4.9-miliVolt) = (50 * 100) / (4.9 - 50) = 5000 / -45.1 = -110

if volt
esrVal = (miliVolt*100)/(4.9-miliVolt) = (0.05 * 100) / (4.9 - 0.05) = 5 / 4.85 = 1.03 ohm

I have to say it's great to have someone to help testing and give feedback, otherwise it gets boring and can lose interest.

Thanks and glad if I could help smiley
3  Topics / Science and Measurement / Re: ESR meter with Arduino on: July 17, 2012, 03:30:53 pm
I think I made some mistakes in my sketch and assumed wrong how the original circuit worked when reverse engineered Lee Hung's schematic. I assumed it was a constant current circuit, which as I see it now it is not. The formula used in the sketch thus will not give correct results, funny thing is when I tried it by measuring different value resistors, readings were pretty sound. I currently don't have the possibility to test the following but if you have time please replace the formula and post back if this works better.

As I see it now in the circuit we have a voltage divider (see Wikipedia article on this (from there we get the formula for calculating Z2 = (Vout*Z1)/(Vin-Vout))

replace this line
esrVal = (miliVolt)/current - esrCal;//calculate ESR in miliOhm
with this
esrVal = (miliVolt*100)/(4.9-miliVolt);//calibration should be done by changing the value of 100 (This is the 1% reference resistor) and/or changing the 4.9 value which is the Vin and it is given by the the voltage regulator on the arduino board

When I have a litle spare time I'll test it.


4  Topics / Science and Measurement / Re: ESR meter with Arduino on: May 11, 2012, 08:52:11 am

To be honest I did use only two wires to the DUT and worked well (one wire from gnd and only one wire from AIN0 and pulse, this means that on CN1 you tie together pin1 and pin2 thus resulting the point of connection for the probe), for more accuracy a four terminal sensing should give better results, you can read more here

5  Topics / Science and Measurement / Re: ESR meter with Arduino on: May 01, 2012, 02:26:28 pm
You are right, for the sketch to work with the schematic you should edit the define lines (I updated the sketch also):

//define the input and output pin we will use
#define ESR_PIN A0
#define PULSE_SMALL 8 //this is not used in the sketch, implement it as needed (for 5mA current needed for smaller cap value measurement)
#define PULSE_PIN 9
#define BUTTON_PIN 0
and for the lcd use pin 5, 6, 10, 11, 12, 13 as in schematic.

Yes, this should work in circuit, voltage P-P should be 300mV (max permited by antiparalel Schottky diodes.)
6  Topics / Science and Measurement / Re: ESR meter with Arduino on: February 21, 2012, 04:27:22 pm

If you have time and will follow the link at the start of the topic to dr. Le Hung's page from where I got the original schematic you can find some good information on how this ESR meter works.

Until then I will try to explain in a few words some basic things that will help you understand why some components are used.
To calculate the ESR we use ohm's law for which the formula is V = I * R, for us the ESR is represented by the R from this equation, thus R = V / I, now we have to get these two values from somewhere so we can compute a result.

For this we setup a circuit which will connect the DUT to a known current that in turn will produce a voltage drop on the DUT which we can measure through the analog pin of the arduino, depending on the resistance (esr) we need to measure we might need different current values, the sketch implements just the 50 mA branch, a 5mA branch is available on the schematic and can be easily used switching to the proper pin for higher ESR measurement (in case of lower value capacitors, let's say 10uF and smaller) thus it can be implemented as an auto-range function.

How we obtain the constant current:
For a 50 mA current we have: (I = V / R) = 5 / 100 = 0.05 A. Values are from: for Vcc = 5, this is supplied by the arduino's on board voltage regulator and R = 100 (obtained from R8 + the resistance of the transistor at saturation which should be very close to 0 ohm, thus 100 ohm).
So the reason to use low tolerance resistor in the current circuit is to ensure the value of the current is exactly as expected and calculated.

The 1 k ohm 1% resistor (R4) branch can give us a current of 5 mA (I = V / R) = 5 / 1000 = 0.005 A. I have to mention that the 5 mA current is not implemented in the sketch, so you can leave it out for now, this is necessary if you want to measure higher ESR or higher value resistors.

Some more things about the way we measure: we need to pulse the DUT with a very short pulse so that the capacitor we are measuring (especially if is a lower value) will not have time to charge and mess up the reading, plus charging and discharging fast is needed so that we measure the capacitor with a frequency as high as possible so capacitive reactance will be negligible (this is the reason I tried to speed up the analog read by changing the prescaller).

Conclusion: you can use 5% resistor (you can try to calibrate the device from the variables in the sketch), I guess the A1015 should be good too for a 50mA current, give it a try and see what are the results smiley

7  Topics / Science and Measurement / Re: ESR meter with Arduino on: February 17, 2012, 05:00:56 pm
I currently use a 47uF, 35V non-polarized electrolytic capacitor, a polarized electrolytic would not be really good (there is the AC component), but a non-polarized ceramic capacitor with the proper C*V values might work, definitely you should give it a try, an interesting experiment would be obtaining a pseudo "non-polarized" cap from two electrolytic wired in series, experiment and see what results you can get. The ESR readings should not be taken as an exact measurement, as ERS really varies with frequency, temperature, capacitance, one will rather use this device to compare two capacitors with same characteristics to see which has a lower ESR, or test if the selected capacitor has a low ESR value, don't get me wrong, the device produces some good readings but I had no possibility to compare it to a reference, the sub ohm (miliohm) measurement precision for pure resistive load is pretty good once calibrated smiley

I'm glad you can see some results there, keep trying and the device will work, it's not a very complicated schematic but is very rewarding once you get it going. (at least it was for me as I learned a lot building it). If there are questions and I have the answers I'll gladly help.
Keep us posted with the progress.
8  Topics / Science and Measurement / Re: ESR meter with Arduino on: February 16, 2012, 11:23:06 am

The transistors are not critical, you need a pair of complementary transistors that have similar characteristic to the BC, something like general purpose low-power amplifying or switching applications transistor, a good candidate would be 2N2222 and 2N2907, I think the 2N3904 and 2N3906 pair can be used also.
9  Topics / Science and Measurement / Re: ESR meter with Arduino on: February 15, 2012, 02:47:15 pm
Hi, I looked at the protesus schematic drawn by you, as I see some things are not right, here are my observations:
- Q2 should be a PNP transistor (BC327) (In your schematic I see Q2 as NPN BC337) not to mention that is not wired up properly, the correct transistors used in the schematic are complementary one is BC327 the other BC337, see original schematic.
- the part that leads signal to the AIN0 pin is not correctly wired either, look at the the original schematic carefully, the diodes and the 10k resistor's (R7 your schematic) one side should be tied to the ground not in parallel with the 470R resistor (R6 your schematic).
- please check carefully with the original schematic to make the proper corrections.

As for the code part you can comment out this part (after you corrected the hardware part):
eeprom_read_block((void*)&esrCal, (void*)0, sizeof(esrCal));
    esrCal = (miliVolt)/current;
    lcd.print(" done!");
    //writing calibration value into EEPROM so we don't have to calibrate on restart
    eeprom_write_block((const void*)&esrCal, (void*)0, sizeof(esrCal));
    lcd.print("saved to EEPROM");

After commenting see if you can produce some readings (should be resistance value of wires + resistance of DUT, zeroing is needed only to eliminate the resistance of the cables used, you will uncomment the part of code when you have some meaningful readings and need a proper zeroing.) For when the hardware is corrected you can test if it is working like this: when a DUT is not conected you should read on the AIN0 pin the max voltage permited by the anti-parallel diodes (around 700 mV, depends on diodes) and when the leads to the DUT are tied together this value should drop to a very small value.

10  Topics / Science and Measurement / Re: ESR meter with Arduino on: January 17, 2012, 04:08:18 pm

The button for the zeroing has nothing to do with the LCD, it is just a button tied to a digital pin (in this case D0) which has the pull up resistor enabled, when you push the button that digital pin is put to the ground and this condition is tested in this section of code:

    esrCal = (miliVolt)/current;
    lcd.print(" done!");
    //writing calibration value into EEPROM so we don't have to calibrate on restart
    eeprom_write_block((const void*)&esrCal, (void*)0, sizeof(esrCal));
    lcd.print("saved to EEPROM");

I suppose you have some kind of serial interface LCD so you must set up your LCD to use a proper library, the schematic here shows  HD44780 type LCD wiring using 4bit mode, more on LCD you can find here:
11  Topics / Science and Measurement / Re: ESR meter with Arduino on: January 15, 2012, 03:17:45 pm

2N4401 as I see from datasheet should do the job.  smiley
12  Topics / Science and Measurement / Re: ESR meter with Arduino on: January 13, 2012, 03:50:05 pm

Hi, using your display setup is ok, looking at the code I saw that I made a mistake when specifying the columns and rows of my display (16x2) so this code: lcd.begin(20,2) should really be lcd.begin(16,2), as I saw from your lcd object initialization yours to is 16x2 display, for this reason the code should be:


The two lines that I suppose to which you refer to and commented out are:
they have no important role in the code, they just control the back light on my display and another LED.
If the code compiled, everything should be all right, you can test your setup using an 1 ohm resistor (or other small values resistors). If the cables are zero-ed your reading should be accurate (you can further calibrate the meter modifying the value for the double
current = 0.046200;
For any questions I can answer I will help gladly.

13  Topics / Science and Measurement / Re: ESR meter with Arduino on: December 30, 2011, 11:47:31 am
Good point, probably one way would be to test the capacitors at two different freq. high an low plus measuring the capacitance (computing the ideal values from capacitance and freq to get the ideal reactance and inductance) and than analyze the outcome comparing all the values and decide upon this result for a proper verdict of what the cap is good for and where it can be used, would be nice to have some capacitors with the same value and different ESR and ESL to test for this variable, the sketch could be modified to use different freq. This gives me an idea of a sketch where we could analyze the capacitor's response on a frequency range and plot the value and compare this to the ideal capacitor.
14  Topics / Science and Measurement / Re: ESR meter with Arduino on: December 21, 2011, 04:26:47 pm
Good question, the smallest capacitor I played with was 4,7uF value, this was not a problem to measure, the code presented here uses only the 50mA branch of the schematic (through R8 and the transistor), using the 5mA branch (through R4, the code must be adapted a bit) lower value capacitors can be measured (the smallest cap value that can be measured accurately I don't know). I don't have an reference instrument to compare with, but I guess if one needs to compare two capacitors and sort out the one with the smallest ESR this can be done easily with the current schematic, eventually the schematic can be modified for a lower current (increasing R4's value) so that when the current is applied to the DUT will not charge the small capacitor to quickly and distort the reading (increasing frequency should be necessary to), maybe another schematic with a true sine 100khz constant current generator or even at higher frequency as this is important for the small value capacitors can give better results. Sorry I don't have now this on my breadboard and can't test it. Probably the best way to know if this schematic is good for such small capacitance (pF, nF range) is necessary to study a bit the theory behind ESR measurement and make some calculation to know at least the theoretical limits of this device.

I just took a peak on the net and got to this page where is a calculator for reactance (, as it turns out we must use a frequency where reactance will be negligible versus ESR, as this schematic uses aprox. something around 60khz (more or less) reactance becomes an issue beginning with the nF range, for pF we need something with several Mhz oscillations.

Sadly the answer is no measuring the ESR for (pF) range with this schematic, only the upper range of nF (even here reactance should be taken in account).
15  Topics / Science and Measurement / Re: ESR meter with Arduino on: December 19, 2011, 11:28:02 am
Thank you all for your appreciation, for the schematic I used the Eagle Cad with freeware licence and the adafruit library (you can find it here
Pages: [1] 2