How do you measure capacitance?
You will say there is no need to measure capacitance because its value is directly printed on it like 1 uF, 4.7 uF, etc, or may be its code like 102, 103, 33 is printed from which we can calculate the capacitance value.
But what if the capacitor is very old (taken out from electronic waste, non working-non used PCB) with printed value rubbed out? Or what if the printed value is unreadable?
In such cases you need capacitance meter that gives digital read out of capacitance value.
In some of the latest, advance digital multimeters, capacitance measurement facility is available. The cost of such multimeters is 5000/- Rs to 10,000/- Rs. In laboratories there is one instrument called LCR-Q meter that can also measure capacitance. But and cost of LCR-Q meter is 20,000/- to 25000/- Rs. Certainly any hobbyists would not like to bear such huge cost.
So what is the solution? The solution is here. A simple micro controller based capacitance meter with LCD made up of normal, easily available components like NE555 IC, micro controller AT89C52, 16×2 LCD and few other components. Let us first understand the block diagram of this meter
System block diagram
Fig. 1: Block Diagram of 8051 Microcontroller and 555 IC based Digital Capacitance Meter
As shown in above figure there are only 3 building blocks IC NE555, micro controller AT89C51 and LCD panel
IC NE555 – the capacitor whose value is to be measured is connected as RC time constant component with this IC. The IC will generate pulse depending upon the value of connected capacitor. This pulse output is given to micro controller
Micro controller AT89C52 – it gets pulse input from IC555 block and measures its time period. From the time period it calculates the value of capacitance using equation. Then it converts it into suitable form to display it on LCD
LCD panel – it shows different messages for proper working and operation and also it shows capacitance value in micro farad (uF) or in mili farad (mF)
System circuit diagram:
(Check the circuit diagram tab for Micro controller based Capacitance Meter with LCD)
As shown in figure the capacitor is connected to IC NE555. NE555 chip is connected in monostable mode. The resistance R1 (1K) along with connected capacitor determines the time period of output pulse. The output of NE555 is connected to port P2 pin P2.0 (21) of AT89C51 microcontroller. Also AT89C51 gives trigger input (pin no. 2) to NE555 through pin P2.1 (22). One push button is connected to EXT Interrupt pin 0 (12) of AT89C51 to generate interrupt for start calculating capacitance value. Data pins of LCD D0-D7 are connected to port P0 and two control pins Rs and En are connected with P2.7 and P2.6 respectively. One more control pin RW is connected to ground. One pot (1K) is connected to VEE pin to vary brightness of LCD. One crystal of 12 MHz with two 33 pF capacitors forms crystal circuit that is connected to crystal input pins 18 and 19. Whole circuit is given power supply from 5 V supply.
Working and operation:
· When 5 V supply is given to circuit the micro controller displays text “capacitance meter using 8051” on LCD
· After few seconds new text message is displayed as “connect capacitor and press button”
· The capacitor has to be connected into NE555 block
· When push button is pressed it generates interrupt for micro controller
· On getting interrupt micro controller gives very short duration (around 2 us) negative trigger pulse to NE555
· Because NE555 is connected in monostable mode, as negative pulse is applied to its trigger input pin, it generates high output pulse
· The pulse time period is based on the RC components connected with NE555 as per the equation
T = 1.1×R×C
· The pulse time period is calculated by micro controller. The value of resistance R is fixed 1 KΩ. so from the calculated time period and the fixed value of R, micro controller calculates value of capacitance as
C = T / 1.1×R
· If calculated value is less than 1 uF (micro Farad) then it is converted in to nF (nano Farad) and finally the value is displayed as uF or nF on LCD
· Again after few seconds the text message is displayed as “connect capacitor and press button” so as to connect next capacitor and measure its value
This entire working and operation is due to the program embedded into the internal ROM (FLASH) of micro controller. The micro controller performs all the tasks due to this program
Software program and logic explanation:
The program is the soul of entire system. It performs all following tasks
1. Gives trigger pulse to IC555 to initiate operation
2. Calculates pulse time period as well as capacitance value from the equation
3. Converts value into suitable form so that can be displayed on LCD
4. Controls (handles) LCD and displays various messages and capacitance value on it
· The program first displays initial messages on LCD and then it waits for high pulse input on port P2 pin
· When push button is pressed, it generates interrupt. This interrupt will give short negative pulse input as a trigger to IC555
· As trigger is applied, immediately the IC555 output goes high
· So the program starts internal timer and calculates time period of pulse in microseconds
· After some time the IC555 output automatically goes low. The program stops timer
· The calculated time is in HEX. So first it is converted in decimal
· Then the capacitance is calculated using equation C = T / 1.1×R (where R is fixed value 1000)
· If the capacitance value is less than 1 uF then it is multiplied by 1000 to convert it into nF
· To display the value on LCD the decimal value is converted into ASCII
Here is the complete program written in C language. It is compiled in KEIL (IDE) software for 8051 micro controller
Fig. 2: Prototype of 8051 Microcontroller and 555 IC based Digital Capacitance Meter
Project Source Code
###
#include <reg51.h>
#include "lcd.h"
# define high 1
# define low 0
# define set 1
# define reset 0
sbit ip_pin = P2^0;
sbit pulse_op = P2^1;
unsigned int time_period, nF_flag=0;
unsigned const Resistance = 1000;
float capacitance;
void calculate_pulse_time()
{
unsigned int t1,t2,t3,t4;
t1 = (TL1 & 0x0F);
TL1 = TL1 >> 4;
t2 = (TL1 & 0x0F);
t3 = TH1 & 0x0F;
TH1 = TH1>>4;
t4 = TH1 & 0x0F;;
t2 = t2*16;
t3 = t3*256;
t4 = t4*4096;
time_period = t1+t2+t3+t4;
}
void calculate_capacitance()
{
capacitance = time_period/(1.1*Resistance);
if(capacitance<1)
{
capacitance*=1000.0;
nF_flag = set;
}
else nF_flag = reset;
}
void display_value(float t)
{
unsigned int tmp,tmp1,tmp2,tmp3,x;
unsigned char ASCII[3];
if(t<10.0)
{
tmp = t*10;
tmp1 = tmp % 10;
ASCII[2] = tmp1 + 48;
tmp2 = tmp/10;
ASCII[0] = tmp2 + 48;
ASCII[1] = '.';
}
else if((t>=10.0) && (t<100.0))
{
tmp = t*1;
tmp1 = tmp % 10;
ASCII[2] = tmp1 + 48;
tmp2 = tmp/10;
ASCII[1] = tmp2 + 48;
ASCII[0] = ' ';
}
else if(t>=100.0)
{
tmp = t*1;
tmp1 = tmp % 10;
ASCII[2] = tmp1 + 48;
tmp = tmp/10;
tmp2 = tmp % 10;
ASCII[1] = tmp2 + 48;
tmp3 = tmp/10;
ASCII[0] = tmp3+48;
}
writecmd(0x01);
writestr("capacitance=");
writecmd(0xC0);
for(x=0;x<3;x++) writedat(ASCII[x]);
if(nF_flag==1) writestr("nF");
else writestr("uF");
}
void delay(int r)
{
unsigned int p,q;
for(p=0;p<r*50;p++)
for(q=0;q<10000;q++);
}
void key_press_delay()
{
unsigned int p,q;
for(p=0;p<250;p++)
for(q=0;q<1000;q++);
}
void pusb_button_interrupt() interrupt 2
{
writecmd(0x01);
writestr("calculating.......");
key_press_delay();
pulse_op = low;
pulse_op = high;
}
void initialize()
{
P0 = 0x00;
P2 = 0x01;
P3 = 0x04;
pulse_op = high;
TMOD = 0x10;
TH1 = 0x00;
TL1 = 0x30;
IE = 0x81;
}
void main()
{
initialize();
init_lcd();
writecmd(0x82) ;
writestr("Capacitance");
writecmd(0xC0);
writestr("meter using 8051");
delay(1);
while(1)
{
writecmd(0x01) ;
writestr("connect capcitor");
writecmd(0xC0);
writestr("and press button");
TH1 = 0x00;
TL1 = 0x30;
while(ip_pin==low);
TR1 = 1;
while(ip_pin==high);
TR1=0;
calculate_pulse_time();
calculate_capacitance();
display_value(capacitance);
delay(2);
}
}
###
Project Video
Filed Under: Electronic Projects
Filed Under: Electronic Projects
Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.