Measuring of Capacitance

advertisement
Electronic Instrumentation
Capacitance Measurements
* In this presentation definitions and examples
from Wikipedia, HowStaffWorks and some other sources
were used
Lecturer: Dr. Samuel Kosolapov
Items to be
defined/refreshed/discussed
• Measuring capacitance by using
sinus wave
Wheatstone bridge
Wheatstone bridge with Instrumental amplifier
Square wave
• Arduino-based capacitance measurements
2
Capacitance measurement with sinus wave
http://meettechniek.info/passive/capacitance.html
Equations are trivial
As voltages as phase can be
used…
(… prepare them for exam…)
The resistor Rs must have
approximately the same value as
the impedance of the capacitor
3
Capacitance measurement with Wheatstone Bridge
http://www.play-hookey.com/ac_theory/randr/wheatstone_ac_apps.html
Earphones can be used
as “null” indicator !!!!
Instrumental Amplifier must be used for
“professional measurements”
4
Instrumental Amplifier
https://en.wikipedia.org/wiki/Instrumentation_amplifier
CMRR can arrive to 120 dB !!!!
 Vout = A1*V1 –A2*V2
A1 == A2
5
Instrumental Amplifier with Wheatstone Bridge
http://forum.allaboutcircuits.com/threads/wheatstone-bridge-amplifier-circuit.34804/
Why Instrumentation Amplifier is better in this case ?
6
Capacitance Measurements with Square Wave
http://forum.arduino.cc/index.php?topic=173708.0
1 kHz signal and 1 Vpp
find the point where the voltage reaches
63.2% (that is, 632 mV).
Switching to the "time" cursor we measure how
long it takes to charge to this point (47 mkS )
C is equal to T / R
C = 0.000047 / 1000
In other words, 47 nF,
which is in fact the
capacitor that was used.
 the theory agrees
with practice
7
Capacitance Measurements by using T = R*C
https://www.arduino.cc/en/Tutorial/CapacitanceMeter
A resistor will charge a capacitor in TC seconds, where
TC = R * C
TC = time constant in seconds
R = resistance in ohms
C = capacitance in farads (1 microfarad [ufd] = 10E-6 farads )
The voltage at 1 Time Constant equals
63.2% of the charging voltage.
8
Capacitance Measurements Arduino
https://www.arduino.cc/en/Tutorial/CapacitanceMeter
Arduino pins can be in one of two states:
Input State (set with pinMode(pin, INPUT);)
High Impedance (resistance)
- Makes very little demand on the circuit that it is sampling
Good for reading sensors but not lighting LED's
Output State (set with pinMode(pin, OUTPUT);)
Low Impedance - Can provide 40 mA source (positive voltage)
Good for lighting LED's, driving other circuits
Additionally the pins can be
HIGH (+5 volts), to charge the capacitor;
or
LOW (ground) to discharge the capacitor
9
Capacitance Measurements Arduino
https://www.arduino.cc/en/Tutorial/CapacitanceMeter
Alogrithm for capacitance meter sketch
1. Set discharge pin to INPUT (so it can't discharge the capacitor)
2. Record the start time with millis()
3. Set charge pin to OUTPUT and make it HIGH
4. Check the voltage repeatedly in a loop
until it gets to 63.2% of total voltage.
5. After the cap is charged, subtract the current time from the start
time to find out how long the capacitor took to charge.
6. Divide the Time in seconds by the charging Resistance in ohms to
find the Capacitance.
7. Report the value with serial.print
8. Discharge the capacitor. To do this:
8.1 Set the charge pin to Input
8.2 Set the discharge pin to OUTPUT and make it LOW
8.3Read the voltage to make sure the capacitor is fully discharged
9. Loop and do it again
10
Capacitance Measurements Arduino
https://www.arduino.cc/en/Tutorial/CapacitanceMeter
/* RCTiming_capacitance_meter
* Paul Badger 2008
* Demonstrates use of RC time constants to measure the value of a capacitor
*
* Theory A capcitor will charge, through a resistor, in one time constant, defined as T seconds where
* TC = R * C
*
* TC = time constant period in seconds
* R = resistance in ohms
* C = capacitance in farads (1 microfarad (ufd) = .0000001 farad = 10^-6 farads )
*
* The capacitor's voltage at one time constant is defined as 63.2% of the charging voltage.
*
* Hardware setup:
* Test Capacitor between common point and ground (positive side of an electrolytic capacitor to common)
* Test Resistor between chargePin and common point
* 220 ohm resistor between dischargePin and common point
* Wire between common point and analogPin (A/D input)
*/
11
Capacitance Measurements Arduino
https://www.arduino.cc/en/Tutorial/CapacitanceMeter
#define analogPin 0
// analog pin for measuring capacitor voltage
#define chargePin 13
// pin to charge the capacitor - connected to one end of the charging resistor
#define dischargePin 11
// pin to discharge the capacitor
#define resistorValue 10000.0F // change this to whatever resistor value you are using
// F formatter tells compliler it's a floating point value
unsigned long startTime;
unsigned long elapsedTime;
float microFarads;
// floating point variable to preserve precision, make calculations
float nanoFarads;
void setup(){
pinMode(chargePin, OUTPUT);
digitalWrite(chargePin, LOW);
Serial.begin(9600);
// set chargePin to output
// initialize serial transmission for debugging
}
12
Capacitance Measurements Arduino
https://www.arduino.cc/en/Tutorial/CapacitanceMeter
void loop(){
digitalWrite(chargePin, HIGH); // set chargePin HIGH and capacitor charging
startTime = millis();
while(analogRead(analogPin) < 648){
}
// 647 is 63.2% of 1023, which corresponds to full-scale voltage
elapsedTime= millis() - startTime;
// convert milliseconds to seconds ( 10^-3 ) and Farads to microFarads ( 10^6 ), net 10^3 (1000)
microFarads = ((float)elapsedTime / resistorValue) * 1000;
Serial.print(elapsedTime);
// print the value to serial port
Serial.print(" mS ");
// print units and carriage return
……………………………..
13
Capacitance Measurements Arduino
https://www.arduino.cc/en/Tutorial/CapacitanceMeter
void loop(){
……………………………..
if (microFarads > 1){
Serial.print((long)microFarads);
// print the value to serial port
Serial.println(" microFarads");
// print units and carriage return
}
else
{
// if value is smaller than one microFarad, convert to nanoFarads (10^-9 Farad).
// This is a workaround because Serial.print will not print floats
nanoFarads = microFarads * 1000.0; // multiply by 1000 to convert to nanoFarads (10^-9 Farads)
Serial.print((long)nanoFarads);
// print the value to serial port
Serial.println(" nanoFarads");
// print units and carriage return
}
………………………..
14
Capacitance Measurements Arduino
https://www.arduino.cc/en/Tutorial/CapacitanceMeter
void loop(){
……………………………..
/* dicharge the capacitor */
digitalWrite(chargePin, LOW);
pinMode(dischargePin, OUTPUT);
digitalWrite(dischargePin, LOW);
while(analogRead(analogPin) > 0){
}
pinMode(dischargePin, INPUT);
// set charge pin to LOW
// set discharge pin to output
// set discharge pin LOW
// wait until capacitor is completely discharged
// set discharge pin back to input
}
15
Capacitance Measurements Arduino
https://www.arduino.cc/en/Tutorial/CapacitanceMeter
Some tips (to think before exam):
1. Use larger resistor R if the charging time is too short,
smaller resistor R if the charging time is too long.
2. Use Averaging a group of readings for more accuracy
3. Swap out several charging resistors on different pins to make an "auto-ranging" capacitance meter
4. Modify the sketch to have the charging resistor also discharge the capacitor.
Think about “equations”.
5. Think about error of measurements
16
Control Questions
• What have I learned ?
17
Literature to read
1. TBD
18
Download