Contacts

Algorithm for measuring the capacitance of capacitors on the avr. Digital capacitance meter. Models based on double-junction expanders: assembly and adjustment

Having found the article Digital Capacitance Meter on the Internet, I wanted to assemble this meter. However, the AT90S2313 microcontroller and LED indicators with a common anode were not at hand. But there were ATMEGA16 in a DIP package and a four-digit seven-segment liquid crystal display. The outputs of the microcontroller were just enough to connect it to the LCD directly. Thus, the meter was simplified to just one microcircuit (in fact, there is also a second one - a voltage regulator), one transistor, a diode, a handful of capacitor resistors, three connectors and a button. The device turned out to be compact and easy to use. Now I have no questions about how to measure the capacitance of a capacitor. This is especially important for SMD capacitors with capacities of several picofarads (and even in fractions of a picofarad), which I always check before soldering into any board. Many desktop and portable meters are now being produced, the manufacturers of which claim a lower limit for capacitance measurements of 0.1 pF and sufficient measurement accuracy for such small capacitances. However, in many of them measurements are carried out at a rather low frequency (units of kilohertz). The question is, is it possible to obtain an acceptable measurement accuracy under such conditions (even if a larger capacitor is connected in parallel with the measured one)? In addition, on the Internet you can find quite a few clones of the RLC meter circuit on a microcontroller and operational amplifier(the same one with electromagnetic relay and with one- or two-line LCD). However, it is impossible to measure small capacities with such devices “humanly”. Unlike many others, this meter is specially designed for measuring small capacitance values.

As for measuring small inductances (nanogenry units), I successfully use the RigExpert AA-230 analyzer manufactured by our company.

Photo of the capacitance meter:

Capacitance meter parameters

Measurement range: 1 pF to approximately 470 μF.
Measurement limits: automatic switching of limits - 0… 56 nF (lower limit) and 56 nF… 470 μF (upper limit).
Indication: three significant digits (two digits for capacities less than 10 pF).
Control: the only button for setting "zero" and calibration.
Calibration: once, using two reference capacitors, 100 pF and 100 nF.

Most of the microcontroller pins are connected to the LCD. Some of them also have a connector for in-circuit programming of the microcontroller (ByteBlaster). Four pins are used in the capacitance measurement circuit, including the comparator inputs AIN0 and AIN1, the output for controlling the measuring range (using a transistor) and the output for selecting the threshold voltage. A button is connected to the only remaining pin of the microcontroller.

The +5 V voltage regulator is assembled according to the traditional scheme.

Indicator - seven-segment, 4 characters, with direct connection of segments (i.e. non-multiplexed). Unfortunately, there was no marking on the LCD. The same pinout and dimensions (51 × 23 mm) have indicators of many companies, for example, AND and Varitronix.

The diagram is shown below (the diagram does not show a diode for protection against "polarity reversal", it is recommended to connect the power connector through it):

Microcontroller program

Since ATMEGA16 is from the "MEGA" series, and not from the "tiny" series, it makes little sense to write an assembly program. In the C language, it is possible to make it much faster and easier, and a decent amount of flash memory of the microcontroller allows you to use the built-in library of floating point functions when calculating the capacity.

The microcontroller measures the capacitance in two steps. First of all, the time for charging the capacitor through the 3.3 MΩ resistor (lower limit) is determined. If the required voltage is not reached within 0.15 seconds (which corresponds to a capacitance of about 56 pF), the capacitor is charged again through the 3.3 kΩ resistor (upper measurement limit).

In this case, the microcontroller first discharges the capacitor through a 100 Ohm resistor, and then charges it to a voltage of 0.17 V. Only after that, the charging time to a voltage of 2.5 V (half of the supply voltage) is measured. After that, the measurement cycle is repeated.

When the result is displayed, a voltage of alternating polarity (relative to its common wire) with a frequency of about 78 Hz is applied to the LCD terminals. A sufficiently high frequency completely eliminates the flicker of the indicator.

This capacitance meter can measure the capacitance of capacitors with 1pF resolution at the lower end of the range. The maximum measurable capacitance is 10,000 μF. The actual accuracy is not known, but the linear error is within a maximum of 0.5%, and usually less than 0.1% (obtained by measuring several capacitors connected in parallel). The greatest difficulties arise when measuring large electrolytic capacitors.

The capacitance meter operates in the mode of automatic selection of measurement limits, or forcibly in the lower or upper range of capacities. The instrument has two different measuring ranges, making two measurements for the same capacitor. This makes it possible to check the veracity of the measurement and find out whether the measured part is actually a capacitor. With this method, electrolytes exhibit their characteristic non-linearity, giving different values ​​at different measuring ranges.

The capacitance meter has a menu system, which, among other things, allows you to calibrate the zero value and the capacitance of 1 μF. The calibration is saved in the EEPROM.

One of the smallest chips, Atmega8, was chosen for the project. The circuit is powered by a 9 volt battery through a 7805 linear regulator.

The device can operate in three modes: measurement in the lower range, in the upper range, and in the discharge mode. These modes are determined by the state of the pins PD5 and PD6 of the controller. During discharging PD6 has a log. 0 and the capacitor is discharged through the R7 resistor (220 Ohm). In the upper measuring range PD5 has a log. 1, charging the capacitor through R8 (1.8K) and PD6 is in the Z-state to allow the analog comparator to compare the voltage. In the lower measuring range, PD5 is also in the Z-state, and the capacitor is charged only through R6 (1.8MΩ).

Any 16x2 character display on the HD44780 controller can be used as an indicator. The display connector pinouts are shown in this figure:

The device is assembled on a breadboard and housed in a simple rectangular plastic case. Holes for the indicator, button and LED are cut in the case cover, which are fixed with hot melt glue:

Capacity meter program

The device can use atmega8 and atmega48 / 88/168 controller families. When replacing a controller in the program, you need to change the line responsible for the configuration of the timer for a particular controller.

On the microcontroller, but after some discussions with fellow radio amateurs and a series of experiments, thoughts about its further improvement came to mind. The new device is characterized by increased accuracy and more wide range... It is based on the PIC16F90 controller.

Capacitance and inductance meter circuit

LCR meter characteristics

Capacitors:

  • 1pF to 1nF - Resolution: 0.1 PF, Accuracy: 1%
  • 1nF to 100nF - Resolution: 1pF, Accuracy: 1%
  • 100nF to 1uF - 1nF resolution, error: 2.5%

Electrolytes:

  • 100 nF to 100,000uF - 1nF resolution, accuracy: 5%

Inductance:

  • 10nH to 20H - 10nH resolution, accuracy: 5%

Resistance:

  • 1 mOhm to 0.5 Ohm - 1 mOhm resolution, accuracy: 5%

Here you need to get better - the device works more like a milliohmmeter. Resistors more than one Ohm, it almost does not measure. Printed circuit board for the instrument is designed in such a way that it is possible to connect an LCD display on the top. The R10 trimming resistor is used to adjust the display contrast.

All resistors are metal-film, 1%. Two 1nF capacitors also with 1% deviation. Capacity CX1 - 33nF, is also critical - it must be polypropylene with a high operating voltage of the capacitor (several hundred volts). The choke should be low Rdc. There is a connector in the meter for a separate network adapter that bypasses the shutdown button.

If the device works with an external power adapter, you can increase the brightness of the screen backlight by decreasing the resistance value of the resistor R11. Consult the documentation for the display to select the correct resistor value.

Note that electrolytic capacitors must be discharged prior to measurement, otherwise there is a danger of burning the controller. All files for assembling the circuit (several firmware options, printed circuit boards) are in the archive. ...

This is a simple capacitance meter. There are several methods for measuring capacitance, for example by using a resistance bridge or by measuring the deflection of a magnetic needle. V Lately typical capacitance meters measure capacitance and some additional characteristics measuring the current vector, applying an alternating voltage to the measured capacitance. Some simple capacitance meters use an integration method to measure the transient response of an RC circuit. There are ready-made kits for assembling capacitance meters that implement this method.

This project uses an integration method. The advantage of this method is that the result can be easily obtained immediately in digital form, because the method is based on measuring time intervals, an accurate analog circuit is not required, the meter can be easily calibrated using a microcontroller. Thus, the integration method is most suitable for a hand-assembled capacitance meter.

Transient process

The phenomenon that manifests until the state of the circuit stabilizes after a change in state is called a transient. The transient process is one of the fundamental phenomena in impulse circuits... When the switch in Figure 1a opens, capacitor C will charge through R and Vc will change as shown in Figure 1b. To change the state of the circuit in Figure 1a, it is also possible to change the EMF E, instead of using a switch, the two methods will be equivalent. The dependence of the voltage Vc on time t is expressed by the formula.

(1)

Dimensions of quantities: t - seconds, R - Ohms, C - Farads, number - e, approximately 2.72. when the voltage Vc reaches a certain value Vc1, the time t1 can be expressed by the formula:

(2)

This means that the time t1 is proportional to C. Thus, the capacity can be calculated from the charging time and other fixed parameters.

Hardware part

To measure the charge time, all you need is a voltage comparator, a counter, and some connecting logic. However, the microcontroller (AT90S2313) used in this project makes it easier to implement. At first I thought that the analog comparator in AVR controllers is useless, but I found that the signal from the output of the comparator can be fed to the input of the TC1 flip-flop. This is a great opportunity for our occasion.

The integrating circuit can be simplified as shown in the device diagram. The reference voltage is generated by a resistive divider. It seems that the use of a divider makes the result unstable to changes in the supply voltage, however, the charging time does not depend on the supply voltage. Using formula (2), you can find that the voltage can generally be replaced by the parameter Vc1 / E, which depends only on the ratio of the resistance of the divider. This advantage is used in the NE555 timer chip. of course, the supply voltage must be stable during the measurement.

In accordance with fundamental principles, only one reference voltage can be used when measuring capacitance. However, using an input voltage close to zero is problematic for the following reasons.

  • The voltage will never drop to zero volts. The voltage across the capacitor cannot drop to 0 volts. It takes time for the capacitor to discharge to a low enough voltage level to allow measurements. This will increase the measurement interval. A drop in voltage across the discharge key will also increase this effect.
  • There is a time between the start of the charge and the start of the timer. This can cause measurement errors. This can be neglected on the AVR because they only need one cycle clock frequency, for this. Other controllers may need to fix this problem.
  • Leakage current in an analog circuit. According to the AVR specification, the leakage current on analog inputs increases when the voltage on them is close to zero. This can cause measurement errors.

To avoid using near-zero voltages, two reference voltages Vc1 (0.17 Vcc) and Vc2 (0.5 Vcc) are used and the time difference t2-t1 (0.5RC) is measured. This avoids the above problems and the comparator delay is also compensated for. The circuit board of the device must be kept clean to minimize surface current leakage.

The supply voltage is generated by a converter powered by a 1.5 volt battery. The key power supply is inapplicable for the measurement circuit, although it looks like the circuit is not subject to voltage fluctuations, since two filters are applied in the power circuit ... I recommend using a 9 volt battery with a 5 volt stabilizer 78L05 instead of him, and do not exclude the BOD function or you will suffer from data corruption in the non-volatile memory of the controller.

Graduation

To calibrate the lower range: First of all set 0 with SW1 button. Then connect a 1nF precision capacitor, short pins # 1 and # 3 of P1 and press SW1.

To calibrate the high range: Connect a 100nF precision capacitor, short-circuit pins # 4 and # 6 of connector P1 and press SW1.

"E4" when powered on means that the calibration value in the non-volatile memory is corrupted. This message will never be displayed if a calibration has already been performed. As for the zero setting, this value is not written to the non-volatile memory and must be reset at each power-up and before each measurement.

Usage

Automatic switching range

The measurement process starts with an interval of 500 milliseconds, from the moment the measured capacitance is connected. Measurement starts at the lower range (3.3 mΩ). If the voltage across the capacitor does not reach 0.5 Vcc within 130 milliseconds (> 57 nF), the capacitor is discharged and the measurement restarts at the high range (3.3 kΩ). If the voltage across the capacitor does not reach 0.5 Vcc within 1 second (> 440 μF), the measurement is canceled and the message "E2" is displayed. In the case where the valid time value is measured, the capacitance is calculated and displayed. The capacity value is shown in such a way that only the first three digits from the left are shown on the display. This automatically selects two measuring ranges and three display ranges.

I am sure that this project is not new, but it is my own development and I want this project to be known and useful as well.

Scheme LC meter on ATmega8 simple enough. The oscillator is classic and is made on the LM311 operational amplifier. The main goal that I pursued when creating this LC meter was to make it inexpensive and available for assembly by every radio amateur.

Schematic diagram of a capacitance and induction meter

LC meter specifications:

  • Measuring capacitance of capacitors: 1pF - 0.3mkF.
  • Measurement of inductance of coils: 1mkH-0.5mH.
  • Information output on the LCD indicator 1 × 6 or 2 × 16 characters, depending on the selected software

For this device, I have developed software, allowing you to use the indicator that the radio amateur has at the disposal of either a 1x16 character LCD display, or 2x16 characters.

Tests with both displays gave excellent results. When using a 2x16 character display top line the measurement mode (Cap - capacitance, Ind -) and the generator frequency are displayed, in the lower line the measurement result. The 1x16 character display shows the measurement result on the left, and the generator frequency on the right.

However, in order to fit the measured value and frequency on one character line, I reduced the display resolution. This does not in any way affect the measurement accuracy, only purely visually.

As with other well-known variants, which are based on the same universal scheme, I added a calibration button to the LC meter. Calibration is carried out using a 1000pF reference capacitor with a deviation of 1%.

Pressing the calibration button displays the following:

The measurements made with this instrument are surprisingly accurate, and accuracy largely depends on the accuracy of the standard capacitor that is inserted into the circuit when you press the calibration button. The method of calibrating the device consists only in measuring the capacity of the reference capacitor and automatically recording its value into the microcontroller's memory.

If you do not know the exact value, you can calibrate the instrument by changing the measurement values ​​step by step until you get the most accurate capacitor value. There are two buttons for such a calibration, note that they are labeled "UP" and "DOWN" in the diagram. By pressing them, you can adjust the capacitance of the calibration capacitor. This value is then automatically written to memory.

Before each measurement of the capacity, it is necessary to reset the previous readings. Resetting to zero occurs by pressing "CAL".

To reset in inductance mode, you must first short-circuit the input pins, and then press "CAL".

The entire installation is designed taking into account the free availability of radio components and in order to achieve a compact device. The size of the board does not exceed the size of the LCD. I have used both discrete and surface mount components. Relay with an operating voltage of 5V. Quartz resonator - 8MHz.



Did you like the article? Share it