Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering

Micro Controller Based Capacitance Meter with LCD

By Ashutosh Bhatt

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

Block Diagram of 8051 Microcontroller and 555 IC based Digital Capacitance Meter

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

Prototype of 8051 Microcontroller and 555 IC based Digital Capacitance Meter

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

 

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


Featured Tutorials

  • PS2 Keyboard To Store Text In SD Card Using Arduino Circuit Setup On Breadboard
    How To Use PS2 Keyboard To Store Text In SD Card Using Arduino- (Part 42/49)
  • Wireless Path Tracking System Using Mouse, XBee And Arduino Circuit Setup On Breadboard
    How To Make A Wireless Path Tracking System Using Mouse, XBee And Arduino- (Part 43/49)
  • How to Make a Wireless Keyboard Using Xbee with Arduino- (Part 44/49)
  • Making Phone Call From GSM Module Using Arduino Circuit Setup On Breadboard
    How to Make Phonecall From GSM Module Using Arduino- (Part 45/49)
  • How to Make a Call using Keyboard, GSM Module and Arduino
    How To Make A Call Using Keyboard, GSM Module And Arduino- (Part 46/49)
  • Receiving SMS Using GSM Module With Arduino Prototype
    How to Receive SMS Using GSM Module with Arduino- (Part 47/49)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • How to interface a DS18B20 temperature sensor with MicroPython’s Onewire driver
  • What is a low power design?
  • Renesas partners with Tata to accelerate progress in advanced electronics
  • STMicroelectronics’ new touchscreen controller for smartphones enables longer runtime
  • Samsung unveils ISOCELL image sensor with industry’s smallest 0.56μm pixel

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr bluetooth dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics renesaselectronicscorporation Research samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • How do you find the angle made by two isosceles triangles in a kite?
  • MWO - EM Structure missing
  • Effect of variable gain amplifier and LNA on the input RF signal's phase
  • HF preamplifier with threshold?
  • Does Monostable pulse stay HIGH whilst input pulse is HIGH?

RSS Electro-Tech-Online.com Discussions

  • Help wanted to power an AC120v induction motor ( edited from Brushless motor - thank you @SHORTBUS= )
  • NOR gate oscillator in LTspice not working
  • HELP NEEDED
  • intro to PI
  • Lighting a .010 green fiber optic with led
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering