Discover millions of ebooks, audiobooks, and so much more with a free trial

From $11.99/month after trial. Cancel anytime.

Arduino Measurements in Science: Advanced Techniques and Data Projects
Arduino Measurements in Science: Advanced Techniques and Data Projects
Arduino Measurements in Science: Advanced Techniques and Data Projects
Ebook1,117 pages9 hours

Arduino Measurements in Science: Advanced Techniques and Data Projects

Rating: 0 out of 5 stars

()

Read preview

About this ebook

Explore the full capabilities of your Arduino. Whether you need to measure light, heat, mass, force, or conductivity, this book can be used as a complete reference guide for making virtually any scientific measurement with your PC or Linux based system and the Arduino microcontroller.
You'll apply the Arduino and sensors to take measurements at the macro-, milli-, micro-, nano- and pico-sensitivity ranges. By working through the projects in this book, you’ll learn how to apply these techniques in the lab or field in areas such as weighing samples at the gram or milligram levels, measuring water temperature to a tenth of a degree, or its conductivity in milli or micro Siemens. With these projects, you can reliably measure, store, and experiment with a wide range of scientific data.
Arduino Measurements in Science features a novel approach and several little known techniques to measure data that requires only basic and accessible hardware – perfect for the home or school workshop! 

What You’ll Learn
  • Make basic scientific measurements with PCs, and Linux based computing systems
  • Review techniques for weighing measurements down into the double and even single digit milligram
  • Use inexpensive sensors and displays to quantify and validate sensor data
  • Incorporate weighing scales, electrometers, magnetic and static field detectors, motion and vibration detectors, and more
  • Understand the possible noise and accuracy problems that can occur and best practices to refine your projects 
  • See the benefits of data validation for graphical data display
Who Is This Book For

Readers looking to acquire the basic science and engineering skills required to assemble fundamental measurement systems to implement with the simple hand tools found in most home or school workshops.
LanguageEnglish
PublisherApress
Release dateSep 25, 2021
ISBN9781484267813
Arduino Measurements in Science: Advanced Techniques and Data Projects

Related to Arduino Measurements in Science

Related ebooks

Hardware For You

View More

Related articles

Reviews for Arduino Measurements in Science

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Arduino Measurements in Science - Richard J. Smythe

    © The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022

    R. J. SmytheArduino Measurements in Sciencehttps://doi.org/10.1007/978-1-4842-6781-3_1

    1. Capacitance and Charge

    Richard J. Smythe¹  

    (1)

    Wainfleet, ON, Canada

    Separating two electrically conductive plates with an insulator forms a device called a capacitor. Among the many traditional uses of capacitors in experimental science are the storage or collection of charges, the blocking of DC currents, filtering electronic signals, and the generation of voltage ramps and timing. Devices with very large capacitance values are often used to store electrical power as memory backup or provide rapidly delivered high-voltage power pulses for photo flash bright-light production during photographic recordings.

    Capacitance, measured in units called farads and represented by the symbol C, can be written in terms of charge Q and voltage V, written as

    C = Q/V -- (1)

    The insulator is called a dielectric . The capacitance of the device is determined by several parameters: the chemical nature of the insulator dielectric ɛr, the permittivity of free space ɛ0, the area of the capacitor plates, and the thickness of the dielectric or the distance between the plates.

    C = ɛ0 × ɛr × A / d farads -- (2)

    The permittivity of free space is 8.84 × 10–12 farads per meter. Capacitor value calculations made with air or a vacuum as a dielectric are usually quoted in microfarads (μF).

    Dielectric constants tables are available in references such as the CRC Handbook of Chemistry and Physics, 84th edition by David Lide (CRC Press, 2003). Materials such as paper have dielectric constants that vary from 2.5 to 3.5. Glass has dielectric constants ranging from 3 to 10. Minerals such as mica range from 5 to 7. Wood ranges from 3 to 8. Metal oxide powders range from 6 to 20. Various types of dielectrics can create different types of capacitor devices. Chemical solutions are used in some capacitors to create large surface areas of high capacitance in relatively compact devices.

    No dielectric is a perfect insulator. Hence, all capacitors have a leakage current across the plates and a limitation on the voltage that the dielectric can withstand before breaking down under the voltage of the stored charge. Exceeding the safe working voltage of a capacitor may destroy the device through arcing between the plates.

    If you consider Q the charge stored by the capacitor and recall that current is the rate of charge flow, you can write the following.

    C = i × t / V – where i is the current and t is time -- (3)

    If the charging current is constant, as time progresses, the product of the current and time generates a linearly increasing Q on the capacitor. To keep C constant, the value of V, the voltage, must increase linearly. By charging or discharging the capacitor with a constant current, a linear voltage ramp is seen across the capacitor plates.

    Capacitors charged from constant voltage sources display exponential voltage changes across the capacitor plates. Figure 1-1 shows that closing the switch allows the voltage source to force current through the resistance and into the capacitor. The DC current does not cross the insulating medium of the capacitor. Hence, the charge on the top plate becomes electron deficient or positively charged while the bottom becomes negative.

    For circuits containing resistance and a capacitor in series, an important numerical value is the RC product, often specifically denoted by Ƭ (tau). The RC product of the circuit is known as the time constant and is the time required for the voltage on the capacitor to rise to approximately two-thirds of its final value or to decay to one-third of its initial value. These points are familiar to you as the charge and discharge voltage values in 555 timer, astable oscillation applications.

    A capacitor is fully charged or discharged after the passage of five time constants.

    Because electrons cannot move freely across the dielectric, the accumulating static charges on each plate require increasing energy to change values as the size of the charge grows. It can be shown that the rate of change displays an exponential form as the voltage on the capacitor approaches its final value, as seen in Figure 1-1.

    Because of the inversion of the type of charge accumulating on one plate being mirrored in magnitude on the other, a varying electrical signal is inverted but passes through the capacitance.

    ../images/503604_1_En_1_Chapter/503604_1_En_1_Fig1_HTML.jpg

    Figure 1-1

    Capacitor voltage vs. time with ../images/503604_1_En_1_Chapter/503604_1_En_1_Figb_HTML.gif

    A circuit time constant ../images/503604_1_En_1_Chapter/503604_1_En_1_Figc_HTML.gif is the product of the resistance in ohms and the capacitance in farads expressed as seconds.

    ../images/503604_1_En_1_Chapter/503604_1_En_1_Figd_HTML.gif -- (4)

    Tau represents a measurable point in the charging and discharging of capacitors. In a fully discharged capacitor, the voltage rises to 0.632Vin in ../images/503604_1_En_1_Chapter/503604_1_En_1_Fige_HTML.gif seconds. Conversely, a fully charged capacitor discharges to 0.368Vout in ../images/503604_1_En_1_Chapter/503604_1_En_1_Figf_HTML.gif seconds. In mathematical terms, establishing the relationship between the three measurable quantities enables the measurement of any one in terms of the remaining two.

    A capacitor is an energy storage device in DC systems and constitutes frequency sensitive resistance in AC circuits. The basic unit of capacitance is the farad, which is the storage capacity able to hold a coulomb of charge at one volt. A coulomb of charge is equal to one ampere of current flowing for one second. A farad was at one time considered a large unit.

    Capacitor storage capability depends on the plates’ area, the nature of the dielectric material, and the distance between the plates. The construction materials used to make the capacitor determine its capabilities and deficiencies. If capacitors are used for timing in circuits, the dielectric should be selected for minimum charge leakage. Plastic film capacitors are best for low-leakage applications.

    Electrolytic capacitors have relatively large storage capacities, are best for filtering or damping voltage oscillations in power supplies, and usually have leakage rates proportional to device capacitance. Information on the structure, properties, and best usage of various capacitors is found in several literature sources, including Building Scientific Apparatus, 4th Ed., (Cambridge University Press), The Art of Electronics, 2nd Ed. (Cambridge University Press), and Practical Electronics for Inventors, 3rd Ed., (McGraw Hill).

    Although a farad was traditionally considered a large unit, capacitors are manufactured from granulated activated carbon and metallic gels with storage capacities measured in farads. Farad-sized units, called ultra and super capacitors , quickly store and release energy as a backup power source for memory circuits or high-discharge rate applications, such as camera flash illumination. High-speed charge and discharge rates, together with huge numbers of repetitive charging cycle capabilities, plus lightweight materials of construction for devices, offer numerous advantages for super capacitors over rechargeable batteries.

    Capacitors are available in a wide range of charge storage abilities that roughly correspond to a device’s physical size, as depicted in Figure 1-2.

    ../images/503604_1_En_1_Chapter/503604_1_En_1_Fig2_HTML.jpg

    Figure 1-2

    Various capacitor types

    In summary, the three brown, rectangular devices in the upper left-hand field of view are metalized plastic film, low-leakage types of capacitors with capacitance values of 1.2 μF, 2.7 μF, and 5.6 μF, respectively. The large blue rectangular device in the upper right field of view is a low leakage 15 μF plastic film capacitor. The devices in the top row generally increase in dollar values from single to double digits in proportion to the increasing physical and capacitance value size.

    The plastic film devices all have component leads of the same size and are non-polarized. The green drop-shaped and black cylindrical capacitors have electrical connection leads of different lengths and are polarized. The polarized devices have large capacitance values compared to the non-polarized ones because the green drop is a tantalum-based device of 22 μF while the large blue film capacitor is 15 μF. Polarized capacitors must be placed in service with the long lead at a more positive potential than the short lead. Polarized capacitors generally have much higher inter-plate leakage currents than non-polarized devices. The small black cylinder is a 1 μF 400 V unit, while the large cylinder is a 2200 μF 50 V device.

    Ceramic disk capacitors are relatively inexpensive, stable units with metal oxide dielectrics generally rated in microfarad and picofarad ranges. An oxide dielectric can be produced in a small package, withstands higher voltages, and remains at a constant capacitance value with changing temperatures, voltages, and signal frequency.

    A span of several orders of magnitude in capacitance range is not easily evaluated with a single measuring technique. Hence, several methods are examined for the determination of device capacitance values.

    A substantial number of electronic circuits use capacitors in series with a resistance to form a circuit characteristic called the time constant . A time constant, often symbolized by ../images/503604_1_En_1_Chapter/503604_1_En_1_Figg_HTML.gif , is the product of the capacitance and resistance expressed in seconds that are often used to adjust an electronic circuit’s performance characteristics.

    Figure 1-3 is an expanded nomograph depicting the theoretical relationship between the resistance-capacitance time constant value and the output oscillating frequency of an astable configured 555 timer IC chip.

    In the astable configuration, the timer IC outputs a square wave with a frequency defined by the RC time constant in its timing component network. If a well-defined resistance value is used in the time constant network with a capacitance device as the second time-constant component, the value of the output signal’s frequency is proportional to the capacitance.

    When an IC device such as a 555 timer is to be used as a transducer to convert capacitor values into square waves of variable frequency for measurement, you should attempt to keep the range of frequencies measured within a readout device’s capabilities. For a graphical screen display of the actual charging or discharging process generated by the code of Listing 1-1, a relatively low rate of data collection and display is required because of the large software overhead required for plotter displays.

    If a numerical value output display is used, the frequency data can be collected by faster hardware counters, such as those available with the LabJack and Arduino devices that can stream the real-time data to a numerical counter display.

    The higher frequencies generally encountered in radio frequency work and are best visualized with oscilloscope type displays.

    This capacitor measurement/monitoring exercise is divided into four sections. Three sections use the graphical user interface in DAQFactory to display capacitance as a rotating analog gauge–type meter, a digital VOM type numerical readout, or a continuous display strip chart recording.

    Splitting the measurement and display of capacitance values into these arbitrary divisions is created by the limitations of the recording and display systems to accommodate the large dynamic range available in capacitance devices.

    The fourth capacitance measurement technique uses an Arduino microcontroller and its serial port readout as an autoranging capacitance meter in the microfarad to picofarad range. Two programs are available to use the microcontroller as a higher-resolution continuous-capacitance measuring meter.

    The primary continuous display program in Listing 1-2 requires virtually no wiring. It uses stray input capacitance calibration and Arduino microcontroller board’s internal pull-up input resistance to generate a stream of reasonably accurate capacitance values of a device under test (DUT).

    The secondary continuous readout program, requiring some external components and wiring for accurate and continuous measurement of a capacitance DUT, is presented in Chapter 10.

    The secondary program uses accurately measured time periods and known resistance values to determine capacitance values for the DUT. Significant timing accuracy is achieved using internal, microcontroller chip comparators, crystal-based timers, and operating system interrupt sequences to achieve accurate and reproducible time values.

    Using a microcontroller such as the Arduino to measure a DUT’s capacitance has the advantage of permitting the experimenter to build into the measurement system some digital signal processing such as a moving average to improve the system’s signal to noise ratio.

    There are numerous exercises in online forums that demonstrate common uses for a capacitive phenomenon in the assembly of a touchpad for activating an LED with an Arduino microcontroller.

    Charges in a capacitor are determined using basic formulas describing the capacitance and voltage relationship. Non-capacitive static charges are discussed in Chapter 8.

    Capacitor Characteristics

    Capacitors are available in various charge storage sizes and dielectric properties. Capacitor properties are largely determined by the dielectric materials that fill the space between a device’s conducting plates. Typically, high charge storage capacity devices have larger leakage currents that render these devices unsuitable for timing applications.

    Leakage Currents

    In theory, a capacitor is an electric charge storage device. With a highly polarizable insulating dielectric between its conducting plates, the device can store more energy or be made smaller for a given storage capacity. However, when charged, the voltage across the plates causes a current to flow through the dielectric, causing the capacitor to eventually discharge. The leakage current in the capacitor is largely determined by the chemical composition of the dielectric.

    Electrolytic capacitors use an insulating layer of metal oxide as the device’s dielectric. Aluminum and tantalum oxides form thin films with high dielectric constants, but the electrolytic devices also exhibit higher leakage currents.

    Leakage currents are measured with the transimpedance amplifier (TIA) based current electrometer described in Figure 2-2 in Chapter 2. The TIA configuration is also applied to leakage current measurement described in Figure 7-4 in Chapter 7. Only low or line voltage–compatible capacitors are examined because high-voltage and high-current systems are beyond the introductory nature of this book.

    The op-amp TIA electrometers’ high input impedance can measure very low levels of current flow. The capacitor leakage current can be measured directly from the stable battery excitation voltage of the measurement circuit.

    Care must be taken when measuring very small leakage currents in a discharged capacitor. The measurement can only be taken when the device has reached a steady-state equilibrium at the full battery-supplied test voltage.

    Measurements of very small currents require special techniques and instrumentation, as explained in Chapter 2.

    Typical leakage currents measured on various capacitors are shown in Table 2-4 in Chapter 2.

    Leakage currents are sometimes considered detrimental to capacitor timing applications. In a timing circuit, leakage should be minimal to ensure reproducibility in timing operations. Capacitors using plastic films as dielectrics such as polyethylene, Mylar (polyethylene terephthalate film), and polystyrene have minimal leakage currents because of the high resistance or low conductivity of the plastic film dielectric. Most plastic films cannot store a significant charge, however. This non-polarizable nature of their molecular structure limits the capacitance values fabricated in reasonably sized devices. The large blue block seen in the upper-right corner of Figure 1-2 is a 15 μF polystyrene capacitor.

    Leakage currents in capacitors used in filtering out the ripple in rectified AC power are orders of magnitude less than the current smoothed by the capacitor and have virtually no effect on the smoothing operation.

    Ceramic capacitors are relatively lower leakage devices and are usually available in fractional μF and nF values.

    Experiment A: Continuous Display of Lower Capacitance Values (< 10 μF)

    Circuit: A Simple 555 Timer-Based Capacitance Meter

    In most applications, a 555 timer generates a rectangular wave output of a fixed or varying duty cycle. A varying duty cycle can be obtained by substituting a variable resistance or potentiometer for one of the two fixed value resistors used in the astable mode of operation. If the two charging resistor values are fixed in a ten to one ratio then the output signal is an approximately 50% duty cycle square wave whose frequency f is determined solely by the value of the capacitor.

    f = 1.44 / (Ra + 2Rb) * C -- (5)

    C = 1.44 / (Ra + 2Rb) * f -- (6)

    A capacitance value can be determined by measuring the frequency or counting the square wave pulses produced in a second.

    An astable oscillator assembled from a traditional bipolar transistor 555 timer integrated circuit is limited to oscillation frequencies in the low hundreds or thousands of kilocycles. Timer ICs fabricated from CMOS technologies can oscillate in the megacycle range. The maximum frequency output of three common devices is listed in Table 1-1.

    Table 1-1

    555 Timer High-Frequency Limits

    Figure 1-3 is similar to Figure 1-4 in the IMC 7555 datasheets from Intersil, depicting the timer output frequency for various timing network RC component combinations. The plots for the various combinations of the two timing resistors indicate that if (Ra + 2Rb) is 1 kΩ, by measuring the oscillator output frequency between 1/10 Hz and 3 MHz, the capacitance values between 1 pf and 10 mF (10,000 μF or 1/1000 F) should be measurable. The measurements should be made from the linear portions of the capacitance frequency data that follow the preceding formulas, which are reproducible and predictable. Low capacitance values below 100 pf may require a separate calibration with a 1 MΩ resistor network to ensure reasonable accuracy.

    Resistor sums of 1 kΩ, 10 kΩ, 100 kΩ, and 1 MΩ should cover the range of capacitors encountered in regular circuitry. (Note: Some of the 555 variations will not oscillate with less than 1 kΩ in the RC network.)

    Since a 10:1 resistance ratio is desired to keep the output reasonably symmetrical, you may write (Ra + 2Rb) = 1K = (Rb/10 + 2Rb) and solve for Rb as 500 Ω, making Ra 50 Ω. For practical implementation standard sizes of, 47 Ω and 470 Ω or 56 Ω and 560 Ω could be used but since less than a kilohm in total resistance must be tested with the type of 555 timer selected for use.

    ../images/503604_1_En_1_Chapter/503604_1_En_1_Fig3_HTML.jpg

    Figure 1-3

    Graphic 14 from the Intersil datasheets

    The plots in Figure 1-3 form a somewhat intuitive concept in which small capacitors that charge very quickly are associated with high oscillator frequencies. Large current-restricting resistors with large capacitances that charge slowly are associated with lower oscillation frequencies.

    A review of the counter documentation for the LabJack indicates the counter registers a single event when it detects a falling edge followed by a rising edge. Each cycle of the rectangular output wave has one falling edge/rising edge pair. If the resistors’ values are accurately known, the capacitor values can be calculated from the frequency measured.

    Circuit Schematic

    The timer circuit shown in Figure 1-4 can be powered from 5 V drawn from the LabJack supply. Resistance values are not shown in the schematic, as different sizes are used for different measurement ranges, as tabulated in Table 1-2. (Recall that the symbol for capacitance units is F for farads; μF or 10–6 F for microfarads; nF or 10–9 F for nanofarads; and pF or 10–12 F for picofarads).

    Table 1-2

    RC Constant Ranges for 555 Timer Oscillator Frequencies

    ../images/503604_1_En_1_Chapter/503604_1_En_1_Fig4_HTML.jpg

    Figure 1-4

    555 IC capacitance measurement circuit

    Table 1-2 is a guideline for design. Any components can be used with the ranges listed. Recall that care must be given to the low-frequency counting capability of the counter and the increasing power dissipation required for low timing resistance values.

    Software

    Initially, a two-dimensional graph and two-variable value components from DAQFactory developed the capacitance measurement screen. In conjunction with the 555 timer circuit in Figure 1-4, the LabJack counter determined the output frequency monitored in DAQFactory with the counter channel labeled FreqCnt.

    The formula in the Y-Expression box in Figure 1-5 was used in both the graphical and variable value displays to convert from frequency to the capacitor’s measured value. The numerical display of Counts/sec: or the frequency and capacitor values were used during development for debugging.

    ../images/503604_1_En_1_Chapter/503604_1_En_1_Fig5_HTML.jpg

    Figure 1-5

    DAQFactory 2D graph component display configuration window

    Capacitance measurements made with a traditional bipolar 555 timer’s RC timing network are restricted by the chip’s preference for RC network resistors no smaller than 1 kΩ and no larger than 1 MΩ. The measurement range could be extended marginally by using resistors slightly outside the preferred range (47 Ω and 470 Ω for a 100 μF range). Different timing chips such as the CMOS devices can provide wider testing range measurements.

    The full-screen strip chart recording output was used to develop the measurement process. An analog dial with digital readouts and a miniature continuous recorder readout was later assembled to provide a visual image of the reading’s tendency to drift.

    The dial type meter and drift recorder are depicted in Figure 1-6.

    ../images/503604_1_En_1_Chapter/503604_1_En_1_Fig6_HTML.jpg

    Figure 1-6

    DAQFactory meter and mini-SCR display

    If you need a capacitance measurement instrument, the circuit could be assembled on a perf board mounted in a utility box equipped with a range switch and test leads, and used with a laptop, tablet, or desktop.

    Small capacitors must be charged through large resistances to keep the 555 oscillation frequency within the hardware’s and software’s capabilities. Testing large capacitors with a 555 timer requires small resistances and much larger current draws that eventually exceed the LabJack or USB supplied capabilities. To test the larger capacitor values that result from using liquid electrolytic systems as the dielectric medium, external power supplies in the form of batteries or regulated supplies are usually required. As the current supply increases, you must watch the power rating on much smaller resistors in the 555 timing network.

    Experiment B: Measurement of Higher Capacitance Values (> 1000 μF or mF)

    Generally, capacitors with values less than 10 μF are solid-state devices, whereas those greater than 10 μF are electrochemical. The significant differences between the lower valued solid-state devices and the electrochemical capacitors are leakage current or device resistance.

    The larger capacitance values of the electrochemical devices create time constants measurable in minutes, hours, and higher. The devices are also subject to much higher leakage currents across the plates. In some cases, the same device may exhibit differing capacitance values, depending on its recent in service charging/discharging history.

    Charge accumulation in large valued electrochemical capacitance devices for a given constant current is much slower than in solid-state systems and can easily be followed with a graphical display. The cyclic ability of the 555 timer generates a voltage waveform that is followed by DAQFactory’s graphical recording display from which capacitance values for both charging and discharging phases of the DUT can be measured.

    Electrolytic capacitors can have measured capacitance values that their history may influence. Minimizing the history’s effect can be affected by cycling the device being tested through a normalizing or uniform charging and discharging cycle. If an astable 555 timer circuit is assembled with a constant current mirror for charging the device, followed by a discharge through a known fixed resistor, the device’s performance in both phases of its functions can be monitored.

    Circuit

    In Figure 1-7, the oscillator circuit is essentially a 555 timer IC in an astable oscillator configuration but with different charging and discharging voltage waveforms.

    A current mirror circuit supplies a constant current to the capacitance DUT. Once the capacitor charges to two-third of Vcc, the 555 changes state, and the charged capacitor discharges through a 1% metal film resistor. The constant current generates a linear voltage ramp on the capacitor while the discharge forms the exponential decay curve, both of which create the cyclic but asymmetric waveform output.

    Since electrochemical charge storage devices can be influenced by their history, cycling through a device’s charging and discharging functions should re-establish the electrolytic layers. This creates a reproducible device whose capacitance can be measured. Reproducible charge and discharge recorder tracing can establish and validate a device’s electrolytic film restoration.

    To generate an asymmetric oscillator waveform with a reasonable signal periodicity, high charging currents but at low voltage are necessary. Batteries or a regulated power supply can generate the current required to create a graphical display with a reasonable rate of change of voltage (slope) across the DUT plates. You must also ensure that 2/3 Vcc, the 555 IC peak voltage during oscillation, is less than the DUT’s dielectric breakdown maximum voltage limit. For example, tantalum capacitors have low working voltage ranges.

    ../images/503604_1_En_1_Chapter/503604_1_En_1_Fig7_HTML.jpg

    Figure 1-7

    Constant current charging circuit for large capacitors

    Software

    A change in the methodology to determine large capacitance values is necessitated by the current flow required to compensate for the large size of the RC time constant generated when the capacitor value rises into the ranges above 10 μF. Capacitor charging times can become very large, as illustrated by the black traces in Figures 1-8 and 1-9. The red discharge voltage traces require up to a minute to complete, as seen in the trace recorded at 9:20 in Figure 1-9.

    ../images/503604_1_En_1_Chapter/503604_1_En_1_Fig8_HTML.jpg

    Figure 1-8

    Capacitor charge and discharge voltage waveforms (1 min tics)

    ../images/503604_1_En_1_Chapter/503604_1_En_1_Fig9_HTML.jpg

    Figure 1-9

    Capacitor charge and discharge voltage waveforms (5 min tics)

    The waveforms (in black) in Figure 1-8 and 1-9 are obtained with the circuitry shown in Figure 1-7. A flow chart outlining the logic to be developed into DAQFactory scripting code to follow the voltage waveform and calculate the charging and discharging capacitance average is depicted in Figure 1-10.

    ../images/503604_1_En_1_Chapter/503604_1_En_1_Fig10_HTML.jpg

    Figure 1-10

    Software flow sheet

    The code for large capacitor device measurements is provided in Listing 1-1 at the end of this chapter.

    A DAQFactory control screen can be configured with a graphical display, a Start button, and variable value readouts, as illustrated in Figure 1-11.

    ../images/503604_1_En_1_Chapter/503604_1_En_1_Fig11_HTML.jpg

    Figure 1-11

    DAQFactory large capacitor measurement

    Observations

    Figure 1-12 depicts the response of the 555 timer chip capacitance measurement screen to the nominal capacitor values tested.

    ../images/503604_1_En_1_Chapter/503604_1_En_1_Fig12_HTML.jpg

    Figure 1-12

    Nominal vs. measured capacitor values

    Experiment C: Autoranging Measurements for Capacitance

    Introduction

    There are several techniques for using the Arduino microcontroller as a capacitance meter. The earlier techniques charged the device through an accurately known external charging resistor, then determined the time required for the capacitor charge to reach 66 ../images/503604_1_En_1_Chapter/503604_1_En_1_Figh_HTML.gif % of the 5 V charging voltage to calculate the value of C. Later versions of the measurement technique used known capacitor values to calibrate both the internal pull-up resistors and the internal stray capacitance of an Arduino board. When using the internal stray resistance/capacitance values, reasonably accurate capacitance measurements on smaller capacitor devices can be made without using any external components. Newer versions of the original code modified for this book are at https://wordpress.codewrite.co.uk/pic/2014/01/21/cap-meter-with-arduino-uno/ and https://wordpress.codewrite.co.uk/pic/2014/01/25/capacitance-meter-mk-ii/.

    Software Code for Arduino Uno

    Listing 1-2 was modified from the original programs published on the mk-ii version to run in my Windows 7 system.

    Device calibration is required to achieve reasonable accuracy because each Arduino Uno board is different, with both the internal stray capacitance and actual pull-up resistance varying slightly. System calibration requires capacitors with accurately known values to evaluate the stray capacitance and the internal pull-up resistor values. Figure 1-13 shows the capacitor charging circuit’s representative circuit schematic. The mathematics describing the voltage on the DUT, and reasonable assumptions for stray electrical effects can be found on the webpages referenced earlier.

    ../images/503604_1_En_1_Chapter/503604_1_En_1_Fig13_HTML.jpg

    Figure 1-13

    Arduino internal components capacitance measuring circuit

    Known capacitance value, low-leakage dielectric devices like Mylar, polyester, or polystyrene units should calibrate the system. The calibration experiments can begin when the program code for the continuous, autoranging capacitance measurement runs satisfactorily on the Arduino and capacitance values appear on the serial monitor with the low-leakage test capacitor inserted into A0 and A2.

    Listing 1-2 allows for the variation of stray capacitance and stray resistance. I had success using the stray resistance adjustment and found values between 35.9 and 37.0 brought most experimental setups into a reasonable degree of accuracy. You can begin the calibration process with the default values in Listing 1-2 and add or decrease the value a small amount and see what effect the change has on the value measured for the known standard. I only made three or four adjustments to bring the system to a reasonable degree of accuracy.

    The system should be calibrated in a range as close to the desired point of actual operation as possible.

    Take care if electrolytic capacitors are the only units available to calibrate in your desired operation range.

    Observations

    Measurement of a collection of capacitors of various nominal values produced the results tabulated in Table 1-3.

    Table 1-3

    Capacitor Measurement Error

    The data for the 22 μF and 470 μF devices were slow to display on the serial monitor, probably due to the long charge times required for the voltage to reach the two-thirds point of the measurement.

    Discussion

    Measurement of capacitance from pF to F is a dynamic range of twelve orders of magnitude. Measurements spanning 12 orders of magnitude in the range are probably best measured, in experimental work, with several different techniques aptly suited to narrower ranges of interest.

    The pF to nF range is well suited to the Arduino autoranging program in which the capacitor charge times can be realized in the under a second time frame. Capacitance values above 1 μF exhibit longer charging times during measurement and may be more accurately determined by larger charging currents and calculations made from graphical recordings of the data.

    Capacitance devices such as those used in circuit boards are roughly divisible into the two categories of solid state and liquid electrolytic dielectric devices. Tantalum, aluminum, and carbon are the predominant liquid-electrochemical, charge storage devices. The current available from the USB bus or the LabJack type devices is insufficient to charge large capacitance devices in a reasonable time. However, as the capacitance value increases, the voltage that can be impressed across the dielectric decreases. Together with the limited voltage that can be impressed across their ionic layer and the large storage capacities available with electrolytic dielectric systems, you must be cautious with the voltage level of the source of power used, the power dissipation of the resistors to control the charging current, and the leakage current or resistance of the device.

    Calibration of Capacitance Measurements

    If precision resistors are used in the timing network of the 555 timer then the capacitance values measured can be expected to be proportionally or reasonably close to the values predicted by the mathematical model of the oscillator system. If precision components are not available, the system may have to be calibrated with known capacitance values to establish a level of accuracy.

    Measured capacitance values can be displayed in various forms. A numerical visual display and the appropriate measurement units can be read directly from the Arduino serial output monitor to determine the capacitance of a device or component. However, for any form of digital signal processing or graphical display recording requiring transmission over a serial bus, the measurement software’s output must be in a format amenable to the serial protocol.

    Capacitance Measurement with the Raspberry Pi

    Accurate timing with the RPi GPIO array is only possible using the PIGPIO library and its C language interface daemon. An alternate method to achieve a more accurate capacitance measurement is to transfer the timekeeping responsibility to the crystal-controlled clock of a microprocessor acting as a smart sensor for the RPi. The autoranging capacitance measuring program running on the Arduino is a robust and well-developed facility that can stream data out to the Python implementation on the RPi for display.

    Arduino formatted capacitance data arriving at the Python serial port needs to be converted into a numerical format for either a Python console numerical value or a monitor screen graphical display.

    Listing 1-3 in the code listings for this exercise contains the Python code to read the value of a capacitor connected between the A0 and A2 inputs of the Arduino ADC.

    Experiment

    To continuously measure capacitance with the Arduino board, the program for capacitance measurement (see Listing 1-2) is loaded onto the IDE’s microcontroller and the Python program (see Listing 1-3) to receive the data from the serial port is loaded into the RPi.

    The capacitor to be tested is then mounted in the A0 and A2 input header ports of the Arduino ADC. The values being streamed to the serial port are validated on the Arduino serial port monitor. The port monitor is closed before launching the Python program on the RPi.

    Observations

    In Figures 1-14 and 1-15, the character string, string length, and capacitor numerical value output from the serial port reading program were streamed out on the Python interactive terminal or console for recording before termination (Ctrl+C), which causes the system output in red.

    ../images/503604_1_En_1_Chapter/503604_1_En_1_Fig14_HTML.jpg

    Figure 1-14

    Console output for a 330 pF unit

    ../images/503604_1_En_1_Chapter/503604_1_En_1_Fig15_HTML.jpg

    Figure 1-15

    Console output for a 1μF standard

    Discussion

    The calibration of any measurement system with several orders of magnitude of variation in the value being determined should be done carefully and the values measured examined critically. The data streamed out for the 1 μF capacitor is the polystyrene standard on which the stray leakage estimates were made. The nominal 330 pF unit data in Figure 1-14 is measured at 323 pF.

    A Siglent Technologies 5.5 digit bench meter measured the 330 pF unit as having a capacitance value of 0.364 nF.

    The Arduino–RPi combination delivers very good data for such an inexpensive and readily available system.

    Absolute accuracy in any measurement is difficult when very small or very large quantities are involved. Absolute accuracy depends on standards that are often unavailable. If possible, the absolute measurement requirement should be reformulated into a differential measurement problem that can often eliminate the need for an absolute standard.

    The Arduino’s continuous smaller capacitance monitor provides useful and sensitive differential capacitance measurement capabilities.

    Measurement of Large Capacitance Values with Python and Raspberry Pi

    The continuous capacitance measurement program running on the Arduino can measure capacitance values over a microfarad but begins to slow down as the capacitor’s size increases. Timekeeping concerns involving the RPi, GPIO array, and the corresponding Python library become minor when the time spans involve minutes or longer time frames and the constant current, linear voltage ramp monitoring technique is used to measure capacitance values.

    Larger charging currents and higher voltage power supplies can offset some of the problems caused by increased RC time constants. Higher power charging sources for large capacitors must be isolated from the low voltage, low current circuitry of the RPi GPIO array and the MCP3008 ADC.

    A visual recording of the liquid dielectric medium’s controlled preconditioning in large electrolytic devices before measuring the capacitor value can help get more consistent reproducible data. Listing 1-4 provides a method for establishing the visual validation of large electrolytic capacitor charging reproducibility.

    Experiment

    A traditional method for creating a linear voltage ramp is to charge a capacitor with a constant current supply. Current mirrors can provide a constant current power supply that, combined with a 555 timing IC can create an alternating charging/discharging cyclic reconditioning of the dielectric layer in a large capacitance DUT.

    Two 2N3906 transistors wired into a current mirror configuration and an LM555 timer IC and 6 V battery pack (4 - 12,000 mA alkaline D cells) can be used with the RPi and the gpiozero library reading an MCP3008 ADC to record and display the charging history and capacitance values of large electrolytic capacitors (see Figure 1-7). The code for a cyclic reconditioning program is in Listing 1-4.

    To use the Python RPi, premeasurement conditioning and data display or recording programs, the MCP3008 serial peripheral interface (SPI) protocol must be invoked on the RPi from the main menu selections, as seen in Figures 1-16 and 1-17.

    ../images/503604_1_En_1_Chapter/503604_1_En_1_Fig16_HTML.jpg

    Figure 1-16

    Performance menu submenu selections

    ../images/503604_1_En_1_Chapter/503604_1_En_1_Fig17_HTML.jpg

    Figure 1-17

    SPI selection from Interfaces tab

    Figure 1-18 is a connection diagram that provides the transfer of power, control, and data between the RPi GPIO array and the MCP3008 ADC. Vin is the voltage ramp measurement being made at the point indicated by the arrow in Figure 1-7.

    ../images/503604_1_En_1_Chapter/503604_1_En_1_Fig18_HTML.jpg

    Figure 1-18

    Connection diagram for MCP3008 10-bit ADC and RPi GPIO

    For simplicity and ease of implementation, two programs can be used for the large capacitor measurement: the first to precondition the electrolytic layer on the DUT and the second to measure the device’s capacitance. With the current mirror, 555 timer IC, and RPi configured and programmed with the Python code in Listing 1-5, a repeating series of linear increasing voltage ramps from a constant current charging, followed by exponential voltage decay discharging curves should be produced (see Figure 1-19).

    After conditioning the electrolytic dielectric with the hardware-based cyclic charging and discharging to obtain a reproducible and predictable voltage behavior pattern, the software can be launched to follow the timer-controlled cycling.

    Observations

    Figure 1-19 depicts a typical large electrolytic capacitor six-cycle dielectric conditioning program. The relatively uniform peak heights indicate a reasonable degree of reproducibility suitable for quantitative measurement of the device’s capacitance.

    ../images/503604_1_En_1_Chapter/503604_1_En_1_Fig19_HTML.jpg

    Figure 1-19

    Trace recording of voltage cycling for electrolytic capacitor dielectric conditioning

    Figure 1-19 shows a typical cycling pattern that conditioned the liquid dielectric on a nominal 470 μF electrolytic capacitor. Figure 1-20 illustrates the data output from a typical four-cycle measurement.

    ../images/503604_1_En_1_Chapter/503604_1_En_1_Fig20_HTML.jpg

    Figure 1-20

    Console output from large electrolytic capacitor constant current charging technique

    Discussion

    With the 6 V D-cell battery pack as a power supply, the LM555 timer should cycle at one-third or two-thirds of the Vcc or between 2 V and 4 V—well within the electrical limits of the RPi and the MCP3008. The gpiozero implementation of the MCP3008 is a normalized output of 0 to 1.0. The ADC output is multiplied by six to generate the actual voltage on the capacitor during the charge/discharge cycling.

    Large capacitor measurement is greatly simplified by using a visual graphic recording of the pre-measurement conditioning of the liquid dielectric in the DUT. When a series of uniform linear ramps and exponential decay curves are recorded, the graphics program can be closed and the capacitance evaluation program launched to numerically measure the device charge storage capability.

    Careful examination of the right-hand downward slope of the sawtooth wave resulting from the conditioning of the electrolytic capacitor, especially near the lower portions of the trace, reveal the beginnings of the expected curvature or deviation from linearity.

    My original program used a dual entry point algorithm to start on the up or downward sloping trace. However, numerical errors such as negative values, loss of synchronization between the hardware and software programs, and larger spreads in the observed individual data points led to the adoption of a code that only starts a capacitance measurement on the linear upward constant current charging (CCC) portion of the trace.

    The best overall performance of the measurement system was obtained by launching the program at a point as close to the start of the CCC as possible. The starting point was determined by watching the red and green diodes in the timer output circuitry with the red diode illuminated during the exponential decay portion of the cycle and the green diode being illuminated during the CCC portion.

    With the known RPi GPIO timing irregularities, better precision and accuracy is to be expected with longer timing sequences. A nominal 470 μF device typically required a 56 second time period to generate a result, as depicted in Figure 1-20, while a 1000 μF required 1.75 minutes.

    Five electrolytic capacitors from a box of assorted capacitors were found to have measured values from 423 to 430 for a nominal label value of 470 μF (Siglent Technologies 5.5 digit bench meter). Six repetitive RPi measurements were made on a nominal 470 μF unit. The data produced is tabulated in Table 1-4.

    An additional series of meter measurements made on five nominal 1000 μF units varied from 955 to 961. A series of five repetitive RPi measurements on the 1000 μF unit produced the large values in the tabulation.

    Table 1-4

    Measured Capacitor Values for 470 and 1000 μF Devices

    Table 1-5 is a tabular comparison.

    Table 1-5

    Data Comparison Siglent Bench Meter and Raspberry Pi

    Comparing the individual numerical values generated by the RPi and those generated with the bench meter shows a remarkable correlation in accuracy and precision when the close to two orders of magnitude difference in costs between the two measurement systems are considered.

    For experimental work with larger capacitors, the current regulating resistor of the current mirror can be reduced to produce a larger charging current. The 2N3906 can handle 200 mA as a continuous collector emitter current. If a smaller current programming resistor is used to increase the constant current charging value, the computing code current definition and the discharge resistor on the 555 timer must be changed. The conditioning program graphical display can adjust the timer discharge resistor to preserve the computing program’s symmetry to track the changing capacitor voltage. You should also adequately adjust the power ratings on both current mirror, and discharge circuitry for any increases in current flow to measure larger capacitance devices.

    Code Listings for Capacitance Measurement

    // Determination of Large Capacitor Values  Wed. 10-17,11-14 and 12 1 to 15/2012

    // An astable 555 timer circuit uses a constant current derived from a

    // current mirror to charge the cap dut(Capacitance device under test.) and

    // a metal film 1% resistor connected between the Cap dut and pin 7 of the

    // IC to discharge the charged device. The 555 cycles the output through a

    // linear voltage ramp followed by an exponential decay.

    //

    // Started with a descriptive text component or a screen button if else

    // code determines where the waveform is in its cycle by looking at the

    // immediate slope of the capacitor voltage trace. The rising or falling

    // trace is followed to an inflection point. At the inflection point code

    // then calculates the capacitance first from the appropriate linear or

    // exponential formula followed by the complementary exponential or linear

    // formula after the next inflection point.

    // The two calculated linear and exponential values are averaged and displayed.

    //

    // The nominal value of the exponential decay resistor is used as an

    // initial approximation for the decay based calculation but when in the

    // discharge cycle the resistor is in parallel with the resistance to

    // ground through the current mirror. The value used for calculation of the

    // decay based capacitance will have to be adjusted downward until the

    // average of the charging/discharging values agree with known capacitance

    // standards within experimental error.

    //

    // The value of the screen trace slope is declared global and calculated

    // from the values of the capacitor voltage in the channel event monitoring

    // the capacitor voltage.

    // The current variable required to determine the accumulated capacitor

    // charge is Icc for constant current charging. The slope and Icc values

    // are calculated in the event tab of the channels monitoring the voltage

    // drop across the programming resistor in the current mirror circuit and

    // the capacitor under test.

    //

    global Flag = 0

    //

    //

    global linStrtTm       // linear ramp start time

    global linStrtVltg     // linear ramp start voltage

    global linEndTm        // linear ramp end time

    global linEndVltg      // linear ramp end voltage

    global Ccc             // capacitance from constant current charging

    //

    global expVltgStrt     // initial cap vltg at start of exp dischrg

    global expVltgStrtTm   // time of initial vltg msrmnt

    global expVltgEnd      // final valu cap vltg at end of exp dischrg

    global expVltgEndTm    // time of finl vltg vlu msrmnt

    global Cexp            // capacitance from exp dischrg msrmnt

    global Cavrg           // the lin charg expl dischrg capacitance average

    //

    // When start button is keyed Flag is set to 1 to indicate the program is

    // measuring a large capacitance value

    Flag = 1

    //

    //

    if (slope < 0)     // the astable circuit is in the exponential discharging portion of the cycle

    // ------------------------------------------------------------------------

    // ------------------------------------------------------------------------

    // dual capacitance calculation starts here with exponential decay

    // following the down slope to the inflection point then starts dual

    // calculations on the constant current linear up slope.

    //

    // ------------- FINISH  DOWN-SLOPE ---------------------------------------

       while (slope < 0)

          delay(.25)    // wait for inflection point

          endwhile

         // ------- CALCULATE LINEAR UP-SLOPE CAPACITANCE --------------------

         // change of slope from decay to start of linear constant current ramp

         //

          linStrtTm = cnstntCurntCap.Time[0]   // record ramp start time

          linStrtVltg = cnstntCurntCap[0]      // record ramp start voltage

          while (slope > 0)                    // follow linear charging ramp up

             delay(.25) // wait for inflection point

             endwhile

             // change of slope from linear ramp to exponential decaying discharge

             //

             //

             linEndTm = cnstntCurntCap.Time[0] // record ramp end time

             linEndVltg = cnstntCurntCap[0]    // record ramp end voltage

             Ccc = Icc * ((linEndTm - linStrtTm)/(linEndVltg - linStrtVltg))

             //

             //------SLOPE CHANGE TO EXPONENTIAL DECAY DISCHARGE --------------

             //

             //

            expVltgStrt = cnstntCurntCap[0]

            expVltgStrtTm = cnstntCurntCap.Time[0]

            while (slope < 0)          // follow exponential decay down

              delay(.25)

              endwhile

             // change of slope from exponential decay to linear constant current charging for a linear voltage ramp

            expVltgEnd = cnstntCurntCap[0]

            expVltgEndTm = cnstntCurntCap.Time[0]

          //

             Cexp = (-(expVltgEndTm - expVltgStrtTm)/ 3400 * (ln(expVltgEnd/expVltgStrt))) * 1000000

             //

          // --- CALCULATE AVERAGE CAPACITANCE from constnt currnt charge and exp discharge traces ----

          //

             Cavrg = (Ccc + Cexp)/2

          //

    // an averaged capacitor value from a single charge - discharge cycle is complete and Flag is reset to 0

    //

    Flag = 0

    //

    else

    // the astable circuit is in the linear portion of the wave form

    // ------------------------------------------------------------------------

    // ------------------------------------------------------------------------

    // dual capacitance calculation starts with the linear up slope being

    // followed to the inflection point then first calculating the capacitance

    // value from the exp discharge trace then using the linear trace to

    // complete the dual measurement..

    //

    // -------------FINISH UP-SLOPE -------------------------------------------

    while (slope > 0)

       delay (.25)  // wait for inflection point

       endwhile

       // ----------CALCULATE EXPONENTIAL DECAY CAPACITANCE -------------------

       // change of slope from linear increase to exponential decay

       //

       expVltgStrt = cnstntCurntCap[0]

            expVltgStrtTm = cnstntCurntCap.Time[0]

            while (slope < 0)          // follow exponential decay down

              delay(.25)

              endwhile

             // change of slope from exponential decay to linear constant

             // current charging for a linear voltage ramp

             //

            expVltgEnd = cnstntCurntCap[0]

            expVltgEndTm = cnstntCurntCap.Time[0]

          //

             Cexp = (-(expVltgEndTm - expVltgStrtTm)/ 3400 * (ln(expVltgEnd/expVltgStrt))) * 1000000

             //

             //

             //-------- SLOPE CHANGE TO LINEAR UP RAMP CALCULATION ------------

           // change of slope from decay to start of linear constant current ramp

           //

          linStrtTm = cnstntCurntCap.Time[0]   // record ramp start time

          linStrtVltg = cnstntCurntCap[0]      // record ramp start voltage

          while (slope > 0)                    // follow linear charging ramp up

             delay(.25) // wait for inflection point

             endwhile

             // change of slope from linear ramp to exponential decaying discharge

             //

             linEndTm = cnstntCurntCap.Time[0] // record ramp end time

             linEndVltg = cnstntCurntCap[0]    // record ramp end voltage

             Ccc = Icc * ((linEndTm - linStrtTm)/(linEndVltg - linStrtVltg))

             //--------------------CALCULATE UP and DOWN SLOPE Average --------

             //

             // a single charge - discharge cycle complete and Flag is reset to 0

             //

             Cavrg = (Ccc + Cexp)/2

             //

             Flag = 0

             //

             //

    Endif

    Listing 1-1

    DAQFactory Sequence Code

    //CAPACITANCE METER PROGRAM

    //Program requires calibration with known capacitors to evaluate internal resistance

    const int OUT_PIN = A2;

    const int IN_PIN = A0;

    //Capacitance DUT between IN_PIN and Ground

    //Stray capacitance value will vary from board to board.

    //Calibrate this value using known capacitor.

    const float IN_STRAY_CAP_TO_GND = 24.48;

    const float IN_CAP_TO_GND = IN_STRAY_CAP_TO_GND;

    //Pull up resistance will vary depending on board

    //Calibrate this with known capacitor.

    const float R_PULLUP = 37.0;  //has been found to vary from 35.9 to 37.0 in K ohms

    const int MAX_ADC_VALUE = 1023;

    void setup()

    {

      pinMode(OUT_PIN, OUTPUT);

      //digitalWrite(OUT_PIN, LOW; //This is the default state for outputs

      pinMode(IN_PIN, OUTPUT);

      //digitalWrite(IN_PIN, LOW);

      Serial.begin(9600);

    }

    void loop()

    {

      //Capacitor under test between OUT_PIN and IN_PIN

      // Rising edge on OUT_PIN

      pinMode(IN_PIN, INPUT);

      digitalWrite(OUT_PIN, HIGH);

      int val = analogRead(IN_PIN);

      digitalWrite(OUT_PIN, LOW);

      if (val < 1000)

    {

      //Low value capacitor

      //Clear everything for the next measurement

      pinMode(IN_PIN, OUTPUT);

      //Calculate and print result

      float capacitance = (float)val * IN_CAP_TO_GND / (float) (MAX_ADC_VALUE - val);

     // Serial.print(Capacitance Value = );

      Serial.print(capacitance, 1);

      Serial.println( pF );

      //Serial.print(val);        // optional for calibration

     // Serial.println(());     // optional for calibration

    }

    else

    {

      //Big capacitor - so use RCX charging method

      // discharge the capacitor (from low capacitance test)

      pinMode(IN_PIN, OUTPUT);

      delay(1);

      // Start charging the capacitor with the internal pullup

      pinMode(OUT_PIN, INPUT_PULLUP);

      unsigned long u1 = micros();

      unsigned long t;

      int digVal;

      //Charge to arbitrary level mid-way between 0 and 5 v

      //Best not to use analogRead() here because it's not really quick enough

      do

      {

        digVal = digitalRead(OUT_PIN);

        unsigned long u2 = micros();

        t = u2 > u1 ? u2 - u1 : u1 -

    Enjoying the preview?
    Page 1 of 1