Tutorial.CapacitanceMeter History

Hide minor edits - Show changes to markup

June 04, 2010, at 02:47 PM by Equipo Traduccion -
Changed line 107 from:
                                            //de fondo de escala 
to:
                                            // de fondo de escala 
Changed line 119 from:
    Serial.println(" microFarads");         //  imprime las unidades y añade enter
to:
    Serial.println(" microFarads");        // imprime las unidades y añade enter
Changed line 127 from:
    Serial.print((long)nanoFarads);         //imprime el valor por el puerto serie
to:
    Serial.print((long)nanoFarads);         // imprime el valor por el puerto serie
June 04, 2010, at 02:46 PM by Equipo Traduccion -
Changed line 107 from:
                                       //de fondo de escala 
to:
                                            //de fondo de escala 
June 04, 2010, at 02:45 PM by Equipo Traduccion -
Changed line 107 from:

de fondo de escala

to:
                                       //de fondo de escala 
June 04, 2010, at 02:44 PM by Equipo Traduccion -
Changed lines 106-107 from:
  while(analogRead(analogPin) < 648){       // 647 es el 63.2% de 1023, el cual se corresponde con el voltaje \\de fondo de escala 
to:
  while(analogRead(analogPin) < 648){       // 647 es el 63.2% de 1023, el cual se corresponde con el voltaje

de fondo de escala

June 04, 2010, at 02:43 PM by Equipo Traduccion -
Changed lines 66-67 from:
 * Teoría Un condensador se cargará, a través de un resistor, en una constante de tiempo, definida como T en segundos donde
to:
 * Teoría Un condensador se cargará, a través de un resistor, en una constante de tiempo, definida como T 
 * en segundos donde
Changed lines 77-78 from:
 *  El condensador a medir entre el punto común y tierra (La parte positiva del condensador electrólítico al común)
to:
 *  El condensador a medir entre el punto común y tierra (La parte positiva del condensador electrólítico al 
 * común)
Changed line 106 from:
  while(analogRead(analogPin) < 648){       // 647 es el 63.2% de 1023, el cual se corresponde con el voltaje de fondo de escala 
to:
  while(analogRead(analogPin) < 648){       // 647 es el 63.2% de 1023, el cual se corresponde con el voltaje \\de fondo de escala 
June 04, 2010, at 02:41 PM by Equipo Traduccion -
Changed line 108 from:
 // convert milliseconds to seconds ( 10^-3 ) and Farads to microFarads ( 10^6 ),  net 10^3 (1000)  
to:
 // convierte milisegundos a segundos ( 10^-3 ) y Faradios a microFaradios ( 10^6 ),  net 10^3 (1000)  
Changed lines 110-113 from:
  Serial.print(elapsedTime);       // print the value to serial port
  Serial.print(" mS    ");         // print units and carriage return

to:
  Serial.print(elapsedTime);       // imprime el valor por el puerto serie
  Serial.print(" mS    ");         // imprime las unidades y añade enter

Changed lines 115-116 from:
    Serial.print((long)microFarads);       // print the value to serial port
    Serial.println(" microFarads");         // print units and carriage return
to:
    Serial.print((long)microFarads);       // imprime el valor por el puerto serie
    Serial.println(" microFarads");         //  imprime las unidades y añade enter
Changed lines 120-121 from:
    // if value is smaller than one microFarad, convert to nanoFarads (10^-9 Farad). 
    // This is  a workaround because Serial.print will not print floats
to:
    // si el valor es más pequeño que un microfaradio, convertimos a nanoFaradios  (10^-9 Faradios). 
    // Esto es un parche porque  because Serial.print no imprime floats
Changed lines 123-125 from:
    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
to:
    nanoFarads = microFarads * 1000.0;      // multiplica por 1000 para convertir a nanoFaradios (10^-9 Farads)
    Serial.print((long)nanoFarads);         //imprime el valor por el puerto serie
    Serial.println(" nanoFarads");          // imprime las unidades y añade enter
Changed lines 128-132 from:
  /* dicharge the capacitor  */
  digitalWrite(chargePin, LOW);             // set charge pin to  LOW 
  pinMode(dischargePin, OUTPUT);            // set discharge pin to output 
  digitalWrite(dischargePin, LOW);          // set discharge pin LOW 
  while(analogRead(analogPin) > 0){         // wait until capacitor is completely discharged
to:
  /* Descarga del condensador  */
  digitalWrite(chargePin, LOW);             // configura el pin de carga a BAJO 
  pinMode(dischargePin, OUTPUT);            // configura el pin de descarga como SALIDA 
  digitalWrite(dischargePin, LOW);          // configura el pin de descarga como BAJO
  while(analogRead(analogPin) > 0){         // espera hasta que esté totalmente descargado
Changed line 135 from:
  pinMode(dischargePin, INPUT);            // set discharge pin back to input
to:
  pinMode(dischargePin, INPUT);            // configura el pin de descarga de nuevo como ENTRADA
June 04, 2010, at 02:33 PM by Equipo Traduccion -
Changed lines 11-13 from:
  • R = Resistencia en Ohmios
  • C = Capacidad en Faradios (1 microfariadio [ufd] = .0000001 faradios = 10^-6 faradios )
to:
  • R = Resistencia en ohmios
  • C = Capacidad en faradios (1 microfariadio [ufd] = .0000001 faradios = 10^-6 faradios )
Changed line 64 from:
 *  Demonstrates use of RC time constants to measure the value of a capacitor 
to:
 *  Demostración del uso de Constantes de tiempo RC para la medida de valores de capacidades 
Changed line 66 from:
 * Theory   A capcitor will charge, through a resistor, in one time constant, defined as T seconds where
to:
 * Teoría Un condensador se cargará, a través de un resistor, en una constante de tiempo, definida como T en segundos donde
Changed lines 69-71 from:
 *    TC = time constant period in seconds
 *    R = resistance in ohms
 *    C = capacitance in farads (1 microfarad (ufd) = .0000001 farad = 10^-6 farads ) 
to:
 *    TC = Periodo de la constante de tiempo en segundos
 *    R = resistencia en ohmios
 *    C = capacidad en faradios (1 microfariadio [ufd] = .0000001 faradios = 10^-6 faradios) 
Changed line 73 from:
 *    The capacitor's voltage at one time constant is defined as 63.2% of the charging voltage.
to:
 *    En una Constante de tiempo se carga al 63.2% del voltaje.
Changed lines 75-79 from:
 *  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)
to:
 *  Configuración Hardware:
 *  El condensador a medir entre el punto común y tierra (La parte positiva del condensador electrólítico al común)
 *  Resistencia a medir entre el pin de carga y el punto común. 
 *  220 ohms de resistencia entre el pin de descarga y el punto común
 *  Cable entre punto común y el pin analógico (A/D input)
Changed lines 82-87 from:
  1. define analogPin 0 // analog pin for measuring capacitor voltage
  2. define chargePin 13 // pin to charge the capacitor - connected to one end of the charging resistor
  3. define dischargePin 11 // pin to discharge the capacitor
  4. define resistorValue 10000.0F // change this to whatever resistor value you are using
                                  // F formatter tells compliler it's a floating point value
to:
  1. define analogPin 0 // pin analogico para realizar la medida del voltaje en la capacidad
  2. define chargePin 13 // pin de carga del condensador - conectado al final de la resistencia cargada
  3. define dischargePin 11 // pin para descargar el condensador
  4. define resistorValue 10000.0F // modifica este valor al valor de resistencia que estés utilizando
                                  // F Formatea para comunicar al compilador el valor de una coma flotante
Changed line 90 from:

float microFarads; // floating point variable to preserve precision, make calculations

to:

float microFarads; // Variable de coma flotante para asegurar la precisión, realiza cálculos

Changed line 94 from:
  pinMode(chargePin, OUTPUT);     // set chargePin to output
to:
  pinMode(chargePin, OUTPUT);     // configura chargePin a salida
Changed line 97 from:
  Serial.begin(9600);             // initialize serial transmission for debugging
to:
  Serial.begin(9600);             // inicializa la transmisión serie para debugging
Changed line 101 from:
  digitalWrite(chargePin, HIGH);  // set chargePin HIGH and capacitor charging
to:
  digitalWrite(chargePin, HIGH);  // configura chargePin a ALTO y carga el condensador
Changed line 104 from:
  while(analogRead(analogPin) < 648){       // 647 is 63.2% of 1023, which corresponds to full-scale voltage 
to:
  while(analogRead(analogPin) < 648){       // 647 es el 63.2% de 1023, el cual se corresponde con el voltaje de fondo de escala 
June 04, 2010, at 02:05 PM by Equipo Traduccion -
Changed line 53 from:
  • Configurar el pin a ''INPUT
to:
  • Configurar el pin a INPUT
Changed lines 56-59 from:
  • Realizar el bucle y vuelta a empezar.

to:
  • Finalizar el bucle y vuelta a empezar.

Changed lines 138-151 from:

Further things to try

  • Substitute in larger resistors if the charging time is too short, smaller resistors if the charging time is too long.

  • Measure capacitors in parallel and in series, check to see if your observations agree with electronic theory
  • Average together a group of readings for more accuracy
  • Swap out several charging resistors on different pins to make an "auto-ranging" capacitance meter
  • Modify the sketch to have the charging resistor also discharge the capacitor. Note that the reported value is not twice the value reported when it only charges this capacitor. Explain this. Hint - study the changing curve on the graph.

to:

Más cosas para intentar

  • Sustituir por una resistencia más grande si el tiempo de cargar es demasiado corto o por resistencias más pequeñas si el tiempo es muy largo.
  • Medidas de capacidades serie y paralelo, chequear teoría de circuitos si es así, en base a los test realizados.
  • Realizar la media de varias medidas para más exactitud.
  • Intercambiar varias cargas resistivas en diferentes pines para realizar un medidor de capacidad con auto-rango
  • Modificar el ''sketch para tener además de la carga resistiva, tener la descarga del condensador. Tener en cuenta que el valor reportado no es dos veces el valor reportado cuando sólo carga el condensador. Explicación.Indirecta -Estudiar la curva de la carga en la gráfica.

June 04, 2010, at 01:51 PM by Equipo Traduccion -
Changed lines 43-57 from:

Alogrithm for capacitance meter sketch

  • Set discharge pin to INPUT (so it can't discharge the capacitor)
  • Record the start time with millis()
  • Set charge pin to OUTPUT and make it HIGH
  • Check the voltage repeatedly in a loop until it gets to 63.2% of total voltage.
  • After the cap is charged, subtract the current time from the start time to find out how long the capacitor took to charge.
  • Divide the Time in seconds by the charging Resistance in ohms to find the Capacitance.
  • Report the value with serial.print
  • Discharge the capacitor. To do this:
    • Set the charge pin to Input
    • Set the discharge pin to OUTPUT and make it LOW
    • Read the voltage to make sure the capacitor is fully discharged
  • Loop and do it again
to:

Algoritmo para medir capacidad con un sketch

  • Configurar el pin de descarga como INPUT (así no podrá descargarse el condensador)
  • Guardar el tiempo de inicio con millis()
  • Configurar el pin A como OUTPUT y ponlo como HIGH
  • Chequear el voltaje repetidamente en un bucle hasta alcanzar el 63.2% total del voltaje.
  • Cuando el condensador esté cargado, restar el tiempo actual del tiempo de inicio para encontrar cuanto tiempo ha tardado en cargarse.
  • Dividir el tiempo en segundos por la Resistencia de carga en ohmios para encontrar la capacidad.
  • Reportar este valor con serial.print
  • Descargar el condensador. Para hacer esto:
    • Configurar el pin a ''INPUT
    • Configurar el pin de descarga a OUTPUT y configurarlo en LOW
    • Leer el voltaje hasta asegurarse que el condensador esté totalmente descargado.
  • Realizar el bucle y vuelta a empezar.

June 04, 2010, at 01:42 PM by Equipo Traduccion -
Changed line 35 from:
  • Baja Impedancia - Puede proporcionar 40mA (voltaje positivo), o en modo ''sink (voltaje negativo)
to:
  • Baja Impedancia - Puede proporcionar 40mA (voltaje positivo), o en modo sink (voltaje negativo)
June 04, 2010, at 01:41 PM by Equipo Traduccion -
June 04, 2010, at 01:41 PM by Equipo Traduccion -
Changed lines 26-29 from:

Este 'sketch' muestra porque los pines del Arduino pueden trabajar en dos estados, los cuales son eléctricamente muy diferentes.

This sketch works because the Arduino pins can be in one of two states, which are electrically very different.

to:

Este sketch muestra porque los pines del Arduino pueden trabajar en dos estados, los cuales son eléctricamente muy diferentes.

June 04, 2010, at 01:39 PM by Equipo Traduccion -
Changed lines 36-47 from:
  • 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), or sink (negative voltage)
    • Good for lighting LED's, driving other circuits - useless for reading sensors.

Additionally the pins can be HIGH (+5 volts), to charge the capacitor; or LOW (ground) to discharge the capacitor

to:
  • Buena para iluminar LED's, alimentar otros circuitos - inútil para leer sensores.

Además los pines pueden estar a nivel ALTO (+5 volts), para cargar condensadores; o a nivel BAJO (tierra) para descargar condensadores.

June 04, 2010, at 01:26 PM by Equipo Traduccion -
Changed lines 24-25 from:

Experimental Setup

to:

Configuración del experimento

Este 'sketch' muestra porque los pines del Arduino pueden trabajar en dos estados, los cuales son eléctricamente muy diferentes.

Added lines 30-36:
  • Estado de entrada (configurar con pinMode(pin, INPUT);)
    • Alta impedancia (resistencia) - Utiliza muy poca demanda de corriente en los circuitos de muestreo.
    • Buena para leer sensores pero no para iluminar LED's

  • Estado de salida (configurar con pinMode(pin, OUTPUT);)
    • Baja Impedancia - Puede proporcionar 40mA (voltaje positivo), o en modo ''sink (voltaje negativo)
June 04, 2010, at 12:56 PM by Equipo Traduccion -
June 04, 2010, at 12:50 PM by Equipo Traduccion -
Changed lines 1-3 from:

Capacitance Meter and RC Time Constants

to:

Medidas de Capacidad y constantes de tiempo RC

Changed lines 6-7 from:

Overview: A resistor will charge a capacitor in TC seconds, where

to:

Recordatorio: Una resistencia cargará a un condensador en una Constante de tiempo ('TC') en segundos donde:

Changed lines 10-19 from:
  • TC = time constant in seconds
  • R = resistance in ohms
  • C = capacitance in farads (1 microfarad [ufd] = .0000001 farad = 10^-6 farads )

The voltage at 1 Time Constant equals 63.2% of the charging voltage.

Example: 1 megohm * 1 microfarad = 1 second
Example: 10k ohms * 100 microfarad = 1 second

to:
  • TC = Constante de Tiempo en segundos
  • R = Resistencia en Ohmios
  • C = Capacidad en Faradios (1 microfariadio [ufd] = .0000001 faradios = 10^-6 faradios )

En una Constante de tiempo se carga al 63.2% del voltaje.

Ejemplo; 1 Megaohmio * 1 microfaradio = 1 segundo
Ejemplo; 10k ohmios * 100 microfaradios = 1 segundo

June 06, 2009, at 06:00 AM by Paul Badger -
Changed line 43 from:
  • Set charge pin HIGH
to:
  • Set charge pin to OUTPUT and make it HIGH
Deleted line 51:
  • Set discharge pin back to INPUT
June 06, 2009, at 05:58 AM by Paul Badger -
Added line 47:
  • Report the value with serial.print
Changed lines 51-52 from:
  • Read the voltage to make sure the capacitor is fully discharged
to:
  • Read the voltage to make sure the capacitor is fully discharged
  • Set discharge pin back to INPUT
June 06, 2009, at 05:55 AM by Paul Badger -
Changed lines 138-144 from:
  • Modify the sketch to have the charging resistor also discharge the capacitor. Note that the value is not twice the value reported when it only charges this capacitor. Explain this. Hint - study the changing curve on the graph.

to:
  • Modify the sketch to have the charging resistor also discharge the capacitor. Note that the reported value is not twice the value reported when it only charges this capacitor. Explain this. Hint - study the changing curve on the graph.

June 06, 2009, at 05:54 AM by Paul Badger -
Added lines 133-134:
  • Substitute in larger resistors if the charging time is too short, smaller resistors if the charging time is too long.
Deleted line 136:
  • Fight with "Serial.print" to print out decimal point and fraction (see Stopwatch sketch)
Changed lines 138-143 from:
  • Substitute in larger resistors if the charging time is too short, smaller resistors if the charging time is too long.

to:
  • Modify the sketch to have the charging resistor also discharge the capacitor. Note that the value is not twice the value reported when it only charges this capacitor. Explain this. Hint - study the changing curve on the graph.

October 20, 2008, at 05:44 AM by Paul Badger -
October 20, 2008, at 05:41 AM by Paul Badger -
Changed lines 36-41 from:

Millis function - good for timing events

  • Record the start time
  • Cause the event to occur
  • Check the time and subtract the start time to find the elapsed time of the event
  • For short events put the event in a loop and do it many times
to:
October 11, 2008, at 02:04 AM by David A. Mellis -
Changed line 141 from:
  • Swap out several charging resistors on different BBB (Arduino) pins to make an "auto-ranging" capacitance meter
to:
  • Swap out several charging resistors on different pins to make an "auto-ranging" capacitance meter
October 09, 2008, at 04:51 PM by Paul Badger -
Changed lines 141-148 from:
  • Swap out several charging resistors on different pins to make an "auto-ranging" capacitance meter
    • Substitute in larger resistors if the charging time is too short, smaller resistors if the charging time is too long. By using some extra Arduino pins, you could make the capacitance meter auto-ranging.

to:
  • Swap out several charging resistors on different BBB (Arduino) pins to make an "auto-ranging" capacitance meter
    • Substitute in larger resistors if the charging time is too short, smaller resistors if the charging time is too long.

October 09, 2008, at 04:49 PM by Paul Badger -
Changed lines 50-51 from:
  • After the cap is charged, subtract the current time from the start time
  • to find out how long the capacitor took to charge.
to:
  • After the cap is charged, subtract the current time from the start time to find out how long the capacitor took to charge.
October 01, 2008, at 05:42 AM by Paul Badger -
Changed lines 12-13 from:
  • C = capacitance in farads (1 microfarad (ufd) = .0000001 farad = 10^-6 farads )
to:
  • C = capacitance in farads (1 microfarad [ufd] = .0000001 farad = 10^-6 farads )
September 27, 2008, at 04:19 PM by David A. Mellis -
Changed lines 24-25 from:

This sketch works because the BBB (Arduino) pins can be in one of two states, which are electrically very different.

to:

This sketch works because the Arduino pins can be in one of two states, which are electrically very different.

September 27, 2008, at 03:16 AM by Paul Badger -
Changed lines 6-7 from:

Overview: A resistor will charge a capacitor in T seconds, where

to:

Overview: A resistor will charge a capacitor in TC seconds, where

September 27, 2008, at 03:13 AM by Paul Badger -
September 27, 2008, at 03:11 AM by Paul Badger -
Changed line 66 from:
 *    T = R * C
to:
 *    TC = R * C
Changed line 68 from:
 *    T = time in seconds
to:
 *    TC = time constant period in seconds
September 27, 2008, at 03:09 AM by Paul Badger -
Changed lines 8-10 from:
  • T = R * C

  • T = time in seconds
to:
  • TC = R * C

  • TC = time constant in seconds
Changed line 17 from:

Example: 1 megaohm * 1 microfarad = 1 second\\

to:

Example: 1 megohm * 1 microfarad = 1 second\\

Changed lines 24-25 from:

The BBB (Arduino) pins can be in one of two states, which are electrically very different.

to:

This sketch works because the BBB (Arduino) pins can be in one of two states, which are electrically very different.

Changed lines 32-33 from:
  • Good for lighting LED's, driving other circuits - useless for reading sensors
to:
  • Good for lighting LED's, driving other circuits - useless for reading sensors.

Additionally the pins can be HIGH (+5 volts), to charge the capacitor; or LOW (ground) to discharge the capacitor

Deleted lines 137-139:

September 27, 2008, at 03:05 AM by Paul Badger -
Changed lines 142-143 from:
  • Fight with "Serial.print" to print out decimal point and fractions
    (see Stopwatch sketch)
to:
  • Fight with "Serial.print" to print out decimal point and fraction (see Stopwatch sketch)
September 27, 2008, at 03:04 AM by Paul Badger -
Changed lines 140-141 from:
  • Average together a group of readings for more accuracy
  • Use several charging resistors on different pins to make an "auto-ranging" capacitance meter
to:
  • Measure capacitors in parallel and in series, check to see if your observations agree with electronic theory
  • Average together a group of readings for more accuracy
  • Fight with "Serial.print" to print out decimal point and fractions
    (see Stopwatch sketch)
  • Swap out several charging resistors on different pins to make an "auto-ranging" capacitance meter
September 27, 2008, at 03:01 AM by Paul Badger -
Changed line 87 from:

float microFarads; // floating point variable to preserve precision, make calculations, printing easier

to:

float microFarads; // floating point variable to preserve precision, make calculations

September 27, 2008, at 03:00 AM by Paul Badger -
Changed lines 107-110 from:
    Serial.print(elapsedTime);       // print the value to serial port
    Serial.print(" mS    ");         // print units and carriage return

to:
  Serial.print(elapsedTime);       // print the value to serial port
  Serial.print(" mS    ");         // print units and carriage return

September 27, 2008, at 02:58 AM by Paul Badger -
Changed lines 105-106 from:
  microFarads = ((float)elapsedTime / resistorValue) * 1000;   // convert milliseconds to seconds ( 10^-3 ) and Farads to microFarads ( 10^6 ),  net 10^3 (1000)
to:
 // convert milliseconds to seconds ( 10^-3 ) and Farads to microFarads ( 10^6 ),  net 10^3 (1000)  
  microFarads = ((float)elapsedTime / resistorValue) * 1000;   
September 27, 2008, at 02:56 AM by Paul Badger -
Changed line 101 from:
  while(analogRead(analogPin) < 648){       // 647 is 63.2% of 1023. 1023 is the A/D reading that corresponds to the charging voltage 
to:
  while(analogRead(analogPin) < 648){       // 647 is 63.2% of 1023, which corresponds to full-scale voltage 
September 27, 2008, at 02:54 AM by Paul Badger -
Changed line 87 from:

float microFarads; // floating point variable to preserve precision and make calculations and printing easier

to:

float microFarads; // floating point variable to preserve precision, make calculations, printing easier

September 27, 2008, at 02:53 AM by Paul Badger -
Changed lines 48-49 from:
  • Subtract the time from the start time to find out how long the capacitor took to charge.
to:
  • After the cap is charged, subtract the current time from the start time
  • to find out how long the capacitor took to charge.
September 27, 2008, at 02:51 AM by Paul Badger -
Deleted lines 56-57:
Changed line 71 from:
 * Hardware setup:
to:
 *  Hardware setup:
September 27, 2008, at 02:50 AM by Paul Badger -
Changed lines 74-85 from:
 * Charging resistor (10k as set below) is connected at one end to chargepin, 
 * at other end to common point (blank breadboard column)
 * OK to change charging resistor value for testing small capacitors 
 * Don't forget to change the value in the #define too though!
 * Discharge resistor (220 ohm or 1k - value doesn't matter) connected at one end to discharge pin,
 * Other end to common point
 * Capacitor under test: One end(negative if polarized cap) to ground,
 *  other end to common point
 * Try lots of different values - also series and parallel arrangements. 
 * Wire from common point to analog pin
  • /
to:
 *  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)
 */
Changed line 81 from:
  1. define chargePin 13 // pin to charge the capacitor - this is connected to one end of the charging resistor
to:
  1. define chargePin 13 // pin to charge the capacitor - connected to one end of the charging resistor
Deleted lines 85-94:

/* 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)
 */

September 27, 2008, at 02:47 AM by Paul Badger -
Changed line 78 from:
 * Dischage resistor (220 ohm or 1k - value doesn't matter) connnected at one end to discharge pin,
to:
 * Discharge resistor (220 ohm or 1k - value doesn't matter) connected at one end to discharge pin,
Changed lines 101-103 from:

Arduino Sketch

to:
September 27, 2008, at 02:45 AM by Paul Badger -
Changed line 106 from:

float microFarads; // floating point variable to preserve precison and make calculations and printing easier

to:

float microFarads; // floating point variable to preserve precision and make calculations and printing easier

Changed line 110 from:
  pinMode(chargePin, OUTPUT);               // set chargePin to output
to:
  pinMode(chargePin, OUTPUT);     // set chargePin to output
Changed line 113 from:
  Serial.begin(9600);                       // initialize serial transmission for debugging
to:
  Serial.begin(9600);             // initialize serial transmission for debugging
Changed line 117 from:
  digitalWrite(chargePin, HIGH);            // set chargePin HIGH and capacitor charging
to:
  digitalWrite(chargePin, HIGH);  // set chargePin HIGH and capacitor charging
September 27, 2008, at 02:41 AM by Paul Badger -
Changed lines 89-92 from:
  1. define resistorValue 10000.0F // change this to whatever resistor value you are using - F formatter tells compliler it's a floating point value

to:
  1. define resistorValue 10000.0F // change this to whatever resistor value you are using
                                  // F formatter tells compliler it's a floating point value

September 27, 2008, at 02:39 AM by Paul Badger -
Changed lines 80-81 from:
 * Capacitor under test - try different values - also series and parallel arrangements. One (negative if polarized) end to ground
 *     other end to common point
to:
 * Capacitor under test: One end(negative if polarized cap) to ground,
 *  other end to common point
 * Try lots of different values - also series and parallel arrangements. 
September 27, 2008, at 02:37 AM by Paul Badger -
Changed lines 74-76 from:
 * Charging resistor (10k as set below) is connected at one end to chargepin at other to common point (blank breadboard column)
 * OK to change charging resistor value for testing small capacitors - change the value in the #define too though!
 * Dischage resistor (220 ohm or 1k - value doesn't matter) connnected at one end to discharge pin, other end to common point
to:
 * Charging resistor (10k as set below) is connected at one end to chargepin, 
 * at other end to common point (blank breadboard column)
 * OK to change charging resistor value for testing small capacitors 
 * Don't forget to change the value in the #define too though!
 * Dischage resistor (220 ohm or 1k - value doesn't matter) connnected at one end to discharge pin,
 * Other end to common point
September 27, 2008, at 02:34 AM by Paul Badger -
Changed lines 4-5 from:
to:
Changed lines 40-41 from:
to:
September 27, 2008, at 02:33 AM by Paul Badger -
Changed lines 4-5 from:
to:
Changed lines 20-21 from:
to:
Changed lines 40-41 from:
to:
September 27, 2008, at 02:33 AM by Paul Badger -
Changed lines 4-5 from:
to:
Changed lines 20-21 from:
 
to:
Changed lines 40-41 from:
to:
September 26, 2008, at 11:34 PM by Paul Badger -
Changed lines 130-131 from:
    // if value is smaller than one microFarad, convert to nanoFarads (10^-9 Farad). This is because Serial.print will not print floats
to:
    // if value is smaller than one microFarad, convert to nanoFarads (10^-9 Farad). 
    // This is  a workaround because Serial.print will not print floats
September 26, 2008, at 11:32 PM by Paul Badger -
Added lines 1-160:

Capacitance Meter and RC Time Constants

Overview: A resistor will charge a capacitor in T seconds, where

  • T = R * C

  • T = time in seconds
  • R = resistance in ohms
  • C = capacitance in farads (1 microfarad (ufd) = .0000001 farad = 10^-6 farads )

The voltage at 1 Time Constant equals 63.2% of the charging voltage.

Example: 1 megaohm * 1 microfarad = 1 second
Example: 10k ohms * 100 microfarad = 1 second

 

Experimental Setup

The BBB (Arduino) pins can be in one of two states, which are electrically very different.

  • 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), or sink (negative voltage)
    • Good for lighting LED's, driving other circuits - useless for reading sensors

Millis function - good for timing events

  • Record the start time
  • Cause the event to occur
  • Check the time and subtract the start time to find the elapsed time of the event
  • For short events put the event in a loop and do it many times

Alogrithm for capacitance meter sketch

  • Set discharge pin to INPUT (so it can't discharge the capacitor)
  • Record the start time with millis()
  • Set charge pin HIGH
  • Check the voltage repeatedly in a loop until it gets to 63.2% of total voltage.
  • Subtract the time from the start time to find out how long the capacitor took to charge.
  • Divide the Time in seconds by the charging Resistance in ohms to find the Capacitance.
  • Discharge the capacitor. To do this:
    • Set the charge pin to Input
    • Set the discharge pin to OUTPUT and make it LOW
  • Read the voltage to make sure the capacitor is fully discharged
  • Loop and do it again

Arduino Sketch

/*  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
 *    T = R * C
 * 
 *    T = time 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:
 * Charging resistor (10k as set below) is connected at one end to chargepin at other to common point (blank breadboard column)
 * OK to change charging resistor value for testing small capacitors - change the value in the #define too though!
 * Dischage resistor (220 ohm or 1k - value doesn't matter) connnected at one end to discharge pin, other end to common point
 * Capacitor under test - try different values - also series and parallel arrangements. One (negative if polarized) end to ground
 *     other end to common point
 * Wire from common point to analog pin
*/

#define analogPin      0          // analog pin for measuring capacitor voltage
#define chargePin      13         // pin to charge the capacitor - this is 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



/* 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)
 */

!!!! Arduino Sketch


unsigned long startTime;
unsigned long elapsedTime;
float microFarads;                          // floating point variable to preserve precison and make calculations and printing easier
float nanoFarads;

void setup(){
  pinMode(chargePin, OUTPUT);               // set chargePin to output
  digitalWrite(chargePin, LOW);  

  Serial.begin(9600);                       // initialize serial transmission for debugging
}

void loop(){
  digitalWrite(chargePin, HIGH);            // set chargePin HIGH and capacitor charging
  startTime = millis();

  while(analogRead(analogPin) < 648){       // 647 is 63.2% of 1023. 1023 is the A/D reading that corresponds to the charging voltage 
  }

  elapsedTime= millis() - startTime;
  microFarads = ((float)elapsedTime / resistorValue) * 1000;   // convert milliseconds to seconds ( 10^-3 ) and Farads to microFarads ( 10^6 ),  net 10^3 (1000)
    Serial.print(elapsedTime);       // print the value to serial port
    Serial.print(" mS    ");         // print units and carriage return


  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 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
  }

  /* dicharge the capacitor  */
  digitalWrite(chargePin, LOW);             // set charge pin to  LOW 
  pinMode(dischargePin, OUTPUT);            // set discharge pin to output 
  digitalWrite(dischargePin, LOW);          // set discharge pin LOW 
  while(analogRead(analogPin) > 0){         // wait until capacitor is completely discharged
  }

  pinMode(dischargePin, INPUT);            // set discharge pin back to input
} 

Further things to try

  • Average together a group of readings for more accuracy
  • Use several charging resistors on different pins to make an "auto-ranging" capacitance meter
    • Substitute in larger resistors if the charging time is too short, smaller resistors if the charging time is too long. By using some extra Arduino pins, you could make the capacitance meter auto-ranging.

Share