Header Ads

Header ADS

How To Make A Capacitor Measurement Meter Using Arduino

 How To Make A Capacitor Measurement Meter   Using Arduino?


📌JLCPCB $2 for 5 pcs 2layer pcb prototype/ 4 layer pcb prototype : https://jlcpcb.com
The PCB board will be needed to make the trainer board like the picture above. According to the above circuit, you can build a trainer on the Vero board. I made my PCB board from http://www.jlcpcb.com. Gerber file is required to order on this website. If you want to get the Gerber file of this PCB, enter this link https://youtu.be/tpIZDV5NqpI. And if you want to design a PCB yourself, then go. at http://easyeda.com.


In this blog, I teach you how to make a capacitance meter for measurement of any kinds of capacitor value like - what's the value of capacitor microfarad or picofarad or nano farad? So guys this is really an interesting project. In this tutorial, I am using Arduino programming. So you can easily make it yourself. You just this video till the end.


Complete this required components:
1. Arduino Uno Board
2. Atmega328P IC
3. 28 Pin IC Base
4. 16Mhz Crystal
5. L7805 IC
6. USB B Connector
7. Power Socket
8. 103 variable Resistor
9. Female to Male IC Rail Header
10. 22 pf Ceramic Capacitor
11. 4.7 K Resistor x2
12. 10K Resistor x2
13. 1K Resistor
14. 100K Resistor
15. 220R Resistor


This project shows how to build a capacitance meter based on an Arduino board where the value of capacitor capacitance is displayed on a 16×2 LCD screen and on the laptop through serial monitor software (for example Arduino IDE serial monitor).

Working Principle:
When a capacitor is connected in series with a simple resistor (series RC circuit) and by applying a certain voltage VS, the capacitor voltage VC increases exponentially towards VS according to the following equation:

Capacitor charging equation (RC circuit)

RC Called time constant (Tau) which is the time when VC = 0.632VS where R is in Ω and C in Farads.
So, from the previous function, if we know VSVCR, and t we can calculate the value of C.

The Arduino microcontroller ATmega328P (Uno, Nano, Mini …) has a built-in analog comparator which will be used in this project to detect the voltage of the capacitor when it goes above VS/2 (approximately 2.5V).
When VC = 0.5VS the capacitance value C = t/[R x ln(0.5)]
Timer1 module is used to count time t between VC = 0 and VC = VS/2.
To get a voltage of VS/2 we may use a voltage divider using 2 similar resistors.




#include <LiquidCrystal.h>   // include Arduino LCD library
// LCD module connections (RS, E, D4, D5, D6, D7)
LiquidCrystal lcd(2, 3, 4, 5, 8, 9);
 
#define discharge_pin  A1
#define channel0_pin   A2
#define channel1_pin   A3
#define channel2_pin   A4
 
// variables
bool ok;
byte ch_number;
const uint32_t res_table[3] = {1000, 10000, 100000};
uint32_t res, t_mul;
char _buffer[9];
 
void setup(void) {
  Serial.begin(9600);
  lcd.begin(16, 2);     // set up LCD's number of columns and rows
  lcd.setCursor(0, 0);  // move cursor to column 0, row 0 [position (0, 0)]
  lcd.print("Capacitance =");
 
  pinMode(discharge_pin,   OUTPUT);
  digitalWrite(discharge_pin, LOW);
 
  // Timer1 module configuration
  TCCR1A = 0;
  TCCR1B = 0;
  TIMSK1 = 1;   // enable Timer1 overflow interrupt
 
  ADCSRA = 0x04;    // disable ADC module
  ADMUX  = 0x45;    // select channel 5
  ADCSRB = (1 << ACME);  // comparator negative input comes from ADC multiplexer
  ACSR   = 0x12;         // configure analog comparator & its interrupt (interrupt on falling edge)
 
  ch_number = 2;
 
}
 
// analog comparator ISR
ISR (ANALOG_COMP_vect) {
  TCCR1B = 0;  // disable Timer1
  // disconnect all charging pins
  pinMode(channel0_pin, INPUT);
  pinMode(channel1_pin, INPUT);
  pinMode(channel2_pin, INPUT);
  // start discharging the capacitor
  pinMode(discharge_pin, OUTPUT);
  digitalWrite(discharge_pin, LOW);
  ok = 1;          // process completed
  ACSR &= ~0x08;   // disable analog comparator interrupt
}
 
// Timer1 overflow ISR
ISR(TIMER1_OVF_vect) {
  t_mul++;
  if(ch_number != 0) {
    ch_number = 0;
    ch_select(ch_number);
  }
}
 
// main loop
void loop() {
 
  // reset everything
  TCNT1 = 0;
  t_mul = 0;
  ok    = 0;
 
  // wait for capacitor discharge
  ADCSRA |= 0x80;  // enable ADC
  uint16_t volt;
  do {
  ADCSRA |= 1 << ADSC;    // start conversion
  while(ADCSRA & 0x40) delay(1);  // wait for conversion complete
  volt = ADCL | ADCH << 8;        // read analog data
  } while (volt > 0);
 
  ADCSRA &= ~0x80;  // disable ADC
  delay(100);
 
  // disconnect discharging pin
  pinMode(discharge_pin, INPUT);
 
  ACSR |= 0x08;  // enable analog comparator interrupt
  TCCR1B = 1;    // start Timer1 with prescaler = 1 (1 tick every 62.5 ns)
  ch_select(ch_number);
 
  while(ok == 0) delay(1);  // wait for process complete (charging the capacitor)
 
  int32_t _time = 65536 * t_mul + TCNT1;
  uint32_t cap;
  if(ch_number == 0)
    cap = -62.5 * _time/(res * log(0.5));  // cap is in nF
  else {
    _time -=  385;   // apply some correction
    if(_time < 0) _time = 0;
    cap = -62500.0 * _time/(res * log(0.5));  // cap is in pF
  }
 
  if( (ch_number == 1 && cap < 10000) || (ch_number == 0 && cap < 10) )
    ch_number = 2;
  if( (ch_number == 2 && cap > 12000) || (ch_number == 0 && cap < 500) )
    ch_number = 1;
 
  if(ch_number != 0) {
    if(cap < 1000)     // if cap < 1000 pF = 1 nF
      sprintf(_buffer, "%03u pF  ", (uint16_t)cap);
    else
      sprintf(_buffer, "%03u nF  ", (uint16_t)(cap/1000) % 1000);
  }
  else {
    if(cap < 1000000)  // if cap < 1000000 nF = 1000 uF
      sprintf(_buffer, "%03u.%1u uF", (uint16_t)(cap/1000), (uint16_t)(cap/100)%10);
    else
      sprintf(_buffer, "%u uF ", (uint16_t)(cap/1000));
  }
 
  lcd.setCursor(0, 1);  // move cursor to position (0, 1)
  lcd.print(_buffer);
  Serial.print("Capacitance =  ");
  Serial.println(_buffer); Serial.println();
 
  delay(1000);    // wait a second
 
  
}
 
void ch_select(byte n) {
  switch(n) {
    case 0:
      pinMode(channel1_pin, INPUT);
      pinMode(channel2_pin, INPUT);
      pinMode(channel0_pin, OUTPUT);
      digitalWrite(channel0_pin, HIGH);
      break;
    case 1:
      pinMode(channel0_pin, INPUT);
      pinMode(channel2_pin, INPUT);
      pinMode(channel1_pin, OUTPUT);
      digitalWrite(channel1_pin, HIGH);
      break;
    case 2:
      pinMode(channel0_pin, INPUT);
      pinMode(channel1_pin, INPUT);
      pinMode(channel2_pin, OUTPUT);
      digitalWrite(channel2_pin, HIGH);
  }
  res = res_table[n];
}
 
// end of code.





🇧🇩 🔥🔥Visit My Programming Tutorial Channel: https://youtube.com/channel/UCeVGeehSnnf-X_FpAsIF3OQ Please subscribe to my channel. Subscription link here: https://goo.gl/JDjNeq 🔥 All Documents Download Link: https://drive.google.com/drive/folders/1znhORU69oAL1jmnRtnVFKBXxo9uijdo8?usp=sharing All social link Facebook: https://bit.ly/2SAbptO Instagram: https://bit.ly/2MWRobw Estiak Khan Jhuman Facebook Link: https://bit.ly/2MVL1oM Youtube Link: https://bit.ly/2US5spz


2 comments:

Theme images by Bim. Powered by Blogger.