1

LABORATORY AUTOMATION: DECAY OF A CAPACITOR

Purpose:

As an introduction to laboratory automation, the decay constant of an RC circuit is measured using an IBM-PC computer. The computer is programmed using the graphical language LabVIEW to control the experiment, gather the data, and analyze the data.

References:

Using LabVIEW videotape, National Instruments, Austin, TX, 1996.

LabVIEW Tutorial Manual, National Instruments, Austin, TX, 1996.

(Refer to the other LabVIEW manuals as needed.)

Introduction:

Figure 1 illustrates the general idea of the experiment. When the switch is in position 1, a power supply with internal resistance Ri and emf E charges a capacitor C in series with a resistance R. When the switch is set to position 2, the capacitor is discharged through the resistor R. Rather than switching manually or switching via a relay (a relatively slow device), a transistor switch is employed. The transistor circuit (already constructed for you) is illustrated in Figure 2. The transistor switch position can be controlled by the computer’s logic. When a


Apotential difference of 0 volts (logical False) is applied via the digital output of the computer to the circuit, transistor A is turned off and B is turned on. Logical False means that the integer number zero is loaded into the register that controls the transistor switch. Current thenflows through the RC network, charging the capacitor. When +3.5 volts (logical True) is applied to the transistor circuit, the switching reverses causing current to flow through the setup resistor to discharge the capacitor.

The decay of the voltage of this circuit during a discharge cycle is exponential. An equivalent circuit for the network consists of a resistor and a capacitor in series in a single loop. It follows from Kirchhoff's second rule that IR + q/C = 0, where q is the charge on the capacitor. Differentiating with respect to time, one obtains R(dI/dt) + (dq/dt)/C = 0. Since dq/dt = I, then dI/dt +I/RC = 0. Rearranging, dI/I = -dt/RC. Integrating yields I = Ioexp(-t/RC). Using V = IR, we have V = Voexp(-t/RC). RC is often called the time constant of the discharge circuit.

Experimental:

1. Programming with the Windows95 version of LabVIEW is presented in the tutorial manual and the videotape. View the videotape before coming to lab with the goal of obtaining an overview of LabVIEW. During the first afternoon of the experiment, work through the exercises in the first five chapters of the tutorial manual. You can be selective with the material in the later chapters. Let you use of the tutorial be guided by the tools which you need to construct your virtual instrument. A list is given below.

2. During the second afternoon, develop a LabVIEW virtual instrument which accomplishes the following tasks:

a) charge the capacitor for ca. 5 seconds,

b) discharge the capacitor and measure the voltage across the network as a function of time for several half lives,

c) determine the value of the RC constant and associated statistics using linear regression,

d) plot the decay curve with axes on the monitor screen. Change the color of the background so that it is a light pastel color rather than black. You may need to change the color of the line so that it is visible.

Please save your .vi file and your other work on a diskette that you provide rather than on the hard drive.

3. Before you run the program, check the circuit connections. The electrical leads should be connected as follows:

computer in: 2-lead cable to the inputs on the connector block for bit zero of the computer digital I/O

cell: 2-lead cable to the inputs on the connector block for channel 0 of the ADC

power supply: 2-lead cable to HP-6261a power supply

4. Turn on the power supply and the box with the circuit and the transistor switch.

5. Set the voltage on the HP-6261A power supply to ca. 4.5 volts. Do not exceed 5 volts. The Meter Selection switch MUST be in the Volts position and NOT in the mA position. When the power supply is configured as a current supply (i.e. in the mA position) rather than as a power supply (in the Volts position), the voltage required to deliver the selected current may be sufficiently high to damage the acquisition board in the PC.

6. During the development phase of the experiment, you may wish to use the Fluke multimeter to measure the voltage across the capacitor. The multimeter will give you a quick indication of whether you are charging or discharging the capacitor. However, during your production runs, remove the multimeter leads as they might change the RC constant of the circuit.

6. Once you have a functional program, use it to explore the art of data sampling and experimental design. Normally one samples a decaying waveform over 2-4 halflives. Note that the value RC and the halflife are related by the equation  = RC(ln 2). If the sampling period is too short, the data will appear linear irrespective of the actual relationship between voltage and time. Recall that according to the Taylor theorem of calculus, any continuous function will appear linear over a small interval. In contrast, if the sampling period is excessively long, the dataset is dominated by very small voltages that are heavily contaminated by error and a biased value of RC will be obtained. This sinister source of systematic error whereby one region of the dynamic range (low voltages in this case) receives excessive weight is referred to as stratified sampling. Use your program to explore the dependence of RC on the measurement period (short, medium, and long) and on the voltage output of the HP power supply. (Short, medium and long are defined by the ratio of the actual sampling period to the half life of the decay. Make multiple runs at two acceptable sampling periods, e.g. two half lives and three half lives. Calculate the mean value of RC and the 95% confidence interval of the mean. Repeat the measurements at a different setting of the power supply.

Hardware Description and Programming Hints

The apparatus is interfaced to a National Instruments Lab PC+ DAQ (digital acquisitions) board which is installed in slot 3 of the PC bus. Windows95 assigned a DMA (direct memory access) channel 1, an IRQ (interrupt request) channel 5, and a base I/O address of hex 140 to the device. You will not use these numbers in your program. They are provided here in case the computer or the interface card need to be replaced.

You will need the LabVIEW configuration data for the interface. The LabVIEW device number for the card is 1 (one). The board has one 12-bit analogue-to-digital converter (ADC) with 4 variable-gain channels in differential mode, two 12-bit 5 V digital-to-analogue converters (DAC), a versatile clock, and digital input/ouput (I/O). The DAC is also bipolar, i.e. the voltage range is V Volts where the value of V depends on the gain setting. The voltage range of the DAC without amplification is 5 V. The leads from the capacitor are connected to inputs 1 and 11 of the connector block which are assigned to channel 0 (zero) of the ADC. The leads controlling the transistor switch are connected to inputs 14 and 13 of the connector block which are assigned to bit 0 (zero), port 0 (zero) of the digital I/O and digital ground, respectively. You will address the digital I/O device twice in the program, first to initiate charging and later to initiate discharge. The device only needs to be configured prior to the first use (i.e. set the Iteration parameter to 0 (zero)) and not on the second use (i.e. set the Iteration parameter to 1 (one)).

With the aid of the Controls pallete, create a virtual instrument panel with inputs for the acquisition rate and the number of acquisitions and a graphical display of Voltage versus time. You may wish to add other bells and whistles to your virtual machine. To construct your diagram, you will use the following LabVIEW ikons which are found via the Functions palette. The name, path, and use of these ikons are summarized below.

path and name function

Data Acquisition configuring and controlling the

Digital I/O digital output of bit zero of

Write to Digital Line the digital I/O

Data Acquisition configuring the ADC and

Analogue Input measuring Voltage at a

AI Acquire Waveform predetermined rate

Structures performing the steps of the

Sequence experiment (charge, initiation

of discharge, measurement and

analysis)in a set order, one

frame per step

Structures generating an array of the times

For Loop at which the Voltage is measured

Analysis fitting an arrays of Voltage and

Fit to an exponential function and

Exponential Fit calculating the RC constant

Time and Dialogue determining the charging period

Wait(ms) of the capacitor

Cluster connecting the output of the ADC

Bundle to the Waveform Graph ikon

The LabVIEW manuals provide examples of how to wire or connect the ikons. The wiring tool and the on-line Help utility provide a graphical display of the inputs and outputs of each ikon. The exponential fit routine requires two arrays: Voltage and time. The "AI Acquire Waveform" ikon has an output which produces the Voltage array. However, you need to construct the time array with the aid of a "For Loop" sequence from the number of acquisitions and the time increment.

You will want to write, test, and develop your program in a modular fashion. That is, write a section, save it, test it, and modify it until the program works. Then move on to the next section. A digital multimeter is available to monitor the voltage across the RC network. Resist the temptation to write the entire program first before testing. Use the sequence structure in your program; this guarantees that the hardware is addressed in an orderly manner and one does not attempt to control too many features simultaneously. The first frame should set the digital switch for charging and run a clock for the charging period. The second frame should have one operation: set the digital switch for discharged. The third and final frame should contain the code for acquisition, processing, and display.

Experimental Report:

Print using the Print command under File the windows showing the Panel of your virual instrument and the Diagram. The Diagram is the graphical equivalent of a conventional program. These printouts, the answers to the questions on the report sheet, and the entries from your laboratory notebook constitute your lab report. If you are unable to complete this experiment by 5:00 p.m. Friday, an additional afternoon can be scheduled. Much of the work including in this experiment is performed before you begin the lab. Write a flowchart (outline) for your experiment before you come to lab.

decay-lv.doc, WES, 16 Aug. 1999

DECAY OF A CAPACITOR

LAB AUTOMATION VIA LABVIEW

NAME:______

1) VALUES OF THE MEAN VALUE OF RC

RC(sec)95% C.I. (sec)V0(Volt)sampling period (sec)

a)

b)

c)

d)

2) Did RC vary significantly with the sampling period when you sampled over the time period of ca. 2-3 half lives? Discuss.

3) Did the value of RC depend on the voltage of the HP power supply? What did you expect? Discuss.

4) Did you observe any anomalies in measurements over long sample periods? Discuss and interpret the results.