Construction of a Photometer as an Instructional Tool for Electronics and Instrumentation

Robert L. McClain

Supporting Information

I. Curricular Context

We use this experiment in our “Chemical Instrumentation” course, which is considered an advanced course. Most students in the course are junior and senior chemistry majors, but we do get students, both undergraduate and graduate, from other departments. The course pre-requisites are first semester analytical, two semesters of organic, and one year of calculus based physics. The topics covered in the course are chemical separations, mass spectrometry, , electrochemistry and electronics.

The laboratory experiments we use are timed to coincide with the lecture coverage of the topics. The students have one three hour lab session per week with all the students doing the same experiment each week. We do not use formal laboratory reports, but students complete a laboratory report sheet as they work on their experiments. The reports sheets contain the student’s data, calculations, plots, tables, observations, and answers to questions. We feel the report sheets help students think about what they are doing while they are doing it, as opposed to working through the procedural part of the experiment during the laboratory, and doing the analysis and thinking at home.

Each laboratory section has eight students and the students work in pairs. This requires our lab to have four identical experimental stations. We do not use any high-end, user friendly, commercial instrumentation in the laboratory, but instead use a “modular instrument” approach. Each station is equipped with a , various sources, a photomultiplier tube detector, a charge coupled device detector, a sample compartments, a potentiostat, a home built lock-in amplifier, oscilloscope, function generator, digital multimeter, various power supplies, and a computer with LabView software. We also have hot plates, stirrers, glassware, etc., which we use for separations and sample preparation. The experiments are all “hands-on” with a goal of getting students to think about chemical instrumentation at a fundamental level. The construction of the photometer fits well with our

1 overall approach, and provides a great introduction to practical electronics in the context of chemical instrumentation.

II. Experimental Procedures including detailed circuit diagrams

Day 1: Making a photometer with an LED light source and a CdS detector in a voltage divider

Students begin by making a voltage divider and confirming Ohms law for their circuit according to the circuit diagram shown in Figure 1. The voltage divider is a fundamentally important circuit that is often used to introduce basic direct current (DC) electronics. In this activity, the students learn to use a digital multimeter to make resistance, voltage and current measurements and how to lay out circuits on a breadboard.

R1 1k

Vs=12V Vm R2 1.5k R2

Figure 1. The voltage divider circuit used to introduce students to Ohms Law.

Students replace the 1.5 k resistor with a cadmium sulfide (CdS) photoresistor to make the detector circuit for the first version of the photometer. They construct the light source with a green LED and a 470 resistor as shown in Figure 2. The resistor limits the LED current to about 25 mA. They complete the photometer construction by placing a sample cell between the source and detector as shown in Figure 3. We make the cell holders with a small Keck clamp epoxied to a piece of printed circuit board that is also epoxied to a 16 pin integrated circuit socket.

2

470

1k

Vs LED Vs=12V V CdS m

Figure 2. The LED light source and CdS photoresistor circuits.

Figure 3. The completed CdS detection based photometer

After getting the photometers working, the students measure the output voltages for a series of standard chromium (VI) solutions complexed with the diphenylcarbazide and a water blank. The output voltage is used to calculate the resistance of the photoresistor from the voltage divider equation, and since there is an inverse relationship between resistance and light power, a Beer’s law plot can be generated.

R − log D(DI ) ∝ Absorbance . )1( R D(sample )

3

Days 2 and 3: Making the photometer more sophisticated with AC filters and operational amplifiers

Over the next two laboratory periods the students construct a more sophisticated version of the photometer as shown in Figure 4. The design contains 6 different sub-circuits providing students with experience working with resistors, capacitors, diodes, a transistor, and operational amplifiers. Each sub- circuit performs a basic function for the device. The students use an oscilloscope to measure the voltages at important points in the circuit in order to confirm the circuit is working, to help see and understand how the sub-circuit functions, and to troubleshoot problems in their circuitry.

100k rectified signal 10u +12V sample cuvette 10k + 10p A oscillator out 1N4148 10k 100k -12V 470 4 100nF 10k 10k -12V LED - 6 -12V 4700 pF -12V 2 OP27 - - + 2 + OP27 OP27 DC out to ADC - 100k 7 3 47k + + 6 +12V + + 741 2N3904 3 + +12V + -12V +12V 7 4 +12V I to V converter high pass filter 10k 22k active half wave rectifier active low pass filter

-12V relaxation oscillator transistor current amplifier

Figure 4 . A photograph and circuit diagram for the completed photometer.

4

Students begin the circuit construction of the more sophisticated design by replacing the CdS detector from Day 1 with a silicon photodiode. Light striking the photodiode detector induces a current that is proportional to the incident light power. The current is converted to a measurable voltage with a standard operational amplifier I to V converter as shown in Figure 5. The I to V converter is one of the most widely used circuits in chemical instrumentation and is the basis for the pre-amplifier circuitry in most optical and mass spectrometers and potentiostats. The photodiode in our detector circuit is reversed biased, which improves the linearity of the detector circuit. The students adjust Rf, to get an output voltage near 1.0 V when the LED light hits the detector. This usually requires a resistor between 100k and 1 M.

I f

Rf

V-- 4 cathode - Vout 2 6 PD I op27 sh + + anode 3 7 V++ -12V

Figure 5. The detection circuit made with a silicon photodiode and current to voltage converter

The detector responds to both the LED light and the background room light. To discriminate against the background light, the students modulate the LED light source near 1.5 kHz and add a high pass filter to the detection circuit. Students construct a relaxation oscillator using an open loop operational amplifier, as shown in Figure 6, to modulate their LED. The output current of the operational amplifier is insufficient to drive the LED, so a transistor relay is added to provide the current required to drive the LED. Students begin with a 1 µF capacitor for C to get the oscillator to work at about 2 Hz, which is visually seen in the flickering of the LED. After replacing the 1 µF capacitor with a 4700 pF to change the frequency to about 1.5 kHz. Oscilloscope traces at various points in the oscillator circuit are shown in Figure 6. To understand the oscillator, students must understand the voltage divider and the charging of a capacitor, two fundamental concepts in electronics.

5

+12V oscillator out 470

C 100k LED - 100k 741 transistor + +

10k 22k

-12V

Figure 6. Oscillator circuit and associated oscilloscope images. The orange trace is the output of the oscillator which oscillates between the positive power supply voltage and the negative supply voltage. The pink trace shows the voltage at the non-inverting input of the operational amplifier and cyan trace shows the voltage at the inverting input.

After the oscillator is complete, students add a high pass (R=47 k; C= 0.1µF) filter to the detection circuit. See Figure 7. A 10 pF capacitor is also added to the operational amplifier feedback loop to minimize any “ringing” in the detector circuit. The final stage of circuitry converts the AC signal of the LED light source to a DC signal. An “ideal” rectifier constructed from an op amp and two signal diodes followed by an active low pass filter are used for the AC to DC conversion. Figure 7 contains the oscilloscope images after the high pass filter, the rectifier and the low pass filter. The final output is a DC voltage directly proportional to the intensity of the LED light striking the detector.

6

I f A

10p 4 C - 6 2 op27 Vout + + 3 7 R -12V

Figure 7. Current to voltage converter for the photodiode detector and associated oscilloscope images. The orange trace shows the signal at pt A in the circuit. This signal is due to both the oscillating LED and room light striking the photodiode. The cyan trace shows the signal after the high pass filter which eliminates the DC component. A slight distortion of the square wave can also be seen due to the attenuation of the lower Fourier components of the square wave. The pink trace shows the signal after the half-wave rectifier, the signal is inverted due to the operational amplifier, and the green trace shows the final average DC output after the low pass filter. The active filter also inverts the signal so the final output increases in the positive direction as more LED light strikes the photodiode.

7

rectified signal 10u 10k

10k

10k 10k AC in - - op27 op27 DC out + + + +

active half wave rectifier active low pass filter

Figure 8. An AC to DC converter constructed from an “ideal” half wave rectifier and active low pass filter.

Day 4 Developing the microcontroller interface with Arduino

On the fourth laboratory day, the students complete a microcontroller tutorial that includes coding examples for parallel communication with the LCD, digital input and output, mathematical calculations, and analog to digital conversion. The most complex wiring of the entire unit is the wiring between the microcontroller and the LCD as shown in Figure 9. The LCD will be used to display the current voltage signal and the absorbance reading.

8

U7 LCD_2x8 U10 Arduino_Uno_Power

1 VSS VDD 2 IOREF 3 VLCD RS 4 RESET 5 R/W E 6 3.3V 7 DB0 DB1 8 5V 9 DB2 DB3 10 GND 11 DB4 DB5 12 GND 13 DB 6 DB7 14 Vin

U4 Arduino_Uno_Digital

13 12 11 10 9 8 7 6 5 4 3 2 1 TX 0 RX

Figure 9. Schematic for wiring the Arduino to the LCD.

9

When working with digital input-output, a push button is used for digital input, and an LED is used for digital output as shown in Figure 10. The push-buttons will be used to store the dark voltage and the reference voltage and the LEDs serve as indicator showing that the buttons are being pushed.

Pin 3 5V + 1k Pin 13 switch

LED R1 47k R1

Figure 10. Circuits showing digital input on microcontroller Pin 13 as either 5 V or 0 V depending on the switch state, and digital output on pin 3 , which lights the LED if HI , or turns off the LED if LO.

For the tutorial, a variable voltage signal is supplied to the analog input of the ADC for testing purposes as shown in Figure 11. This circuit provides a variable voltage between 0 and 1 V which is within the maximum range of the ADC input of 0 to 1.1 V.

5V + 39k

10k pin A0

Figure 11. Circuit for generating a variable voltage at the analog input of the microcontroller ADC.

The final photometer program can be tested using the variable voltage input from the circuit in Figure 11. Adjust the variable voltage so the LCD reads near zero volts and save this voltage as the dark voltage. Adjust the variable voltage to 1.0 V and save this as the reference voltage. Now the absorbance is calculated and displayed on the LCD for the any voltage reading by

10

V− V  Absorbance= − log reading dark .   Vreading− V dark 

Day 5 Developing the microcontroller interface with Arduino

The last step of the construction is to replace the variable voltage with the voltage signal from the photometer. Careful considerations of the power supply must be made at this step. During the tutorial, the +5V needed to supply the digital circuitry was supplied by the USB connection. The analog circuitry of the photometer is supplied by a +15/-15 V power supply. When the Arduino development board is removed from the USB, it can be powered by connecting the +15 supply to Vin (and Ground) on the development board. The development board has additional circuitry to convert the supply voltage to +5V necessary for the digital circuitry. The LCD and the microcontroller can be damaged if they are subjected to the +15 V of the power supply. The final version of the photometer interfaced with the microcontroller is shown in Figure 12. Once the students have the microcontroller interfaced with the photometer, they are ready to use their instrument for the chromium tests.

Figure 12. The completed photometer with microcontroller interface

11

III. Materials List

cost(as of item company cat number 10/27/2013) solderless breadboard 6.5"x2.25"(2) Mouser (USA) 589-TW-E40-1020 $7.11 16 pin IC socket Digikey (USA) ED90050-ND $1.12 enough for Unclad PCB board 3"x.5" Digikey (USA) PC5-UNCLAD-ND $4.72 12 5 minute epoxy Fisher Scientific(USA) NC9572975 $22.46 Keck Clamp, No. 12 violet Fisher Scientific(USA) 05-880B $57.21 pkg of 12 Plastic cuvette Fisher Scientific(USA) 13-878-123 $87.46 pkg of 100 Green LED Mouser (USA) 638-333-2SUGCS4003 $1.57 CdS photocell Digikey (USA) PDV-P9001-ND $1.58 470 Ohm res Digikey (USA) 470QBK-ND $0.10 1.5 k res Digikey (USA) 1.5KQBK-ND $0.10 1.0 k res Digikey (USA) 1.0KQBK-ND $0.10 Si PIN photodiode Digikey (USA) PNZ335-ND Note 1 ua741CP op amp Mouser (USA) 595-UA741CP $0.36 OP27 op amp(3) Digikey (USA) OP27GPZ-ND $3.12 100 k res(3) Digikey (USA) 100KQBK-ND $0.10 1 M res Digikey (USA) 1.0MQBK-ND $0.10 2N3904 npn transistor Digikey (USA) 2N3904FSB-ND $0.19 10 pF ceramic cap Digikey (USA) 399-4198-ND $0.28 4700 pF ceramic cap Digikey (USA) 399-4186-ND $0.22 1 uF ceramic cap Digikey (USA) 445-2851-ND $0.27 0.10 uF ceramic cap Digikey (USA) 490-3859-ND $0.15 22 k res Digikey (USA) 22KQBK-ND $0.10 47 k res Digikey (USA) 47KQBK-ND $0.10 10 k res(5) Digikey (USA) 10KQBK-ND $0.10 10 uF Ta cap Mouser (USA) 80-T356C106K10AT $1.30 1N4148 signal diode(2) Digikey (USA) 1N4148FS-ND $0.06 Push button switch(2) Mouser (USA) 693-1301.9301 $0.28 Red LED (2) Mouser (USA) 604-WP7113SRC/E $0.58 39 k res Digikey (USA) 39KQBK-ND $0.10 10 k potentiometer Mouser (USA) 72-T70YU $0.57 Arduino Uno Mouser(USA) 782-A000066 $25.00 LCD 2x8 Mouser(USA) 763-NHD-0208BZRNYBW $8.30

Note 1: This photodiode is no longer available from Digikey. We still have remaining stock that we use for our students. Vishay makes a suitable replacement, available at Digikey (USA) part #751-1017-ND ($0.95) that I have tested, and will make a suitable replacement for the PNZ-335ND.

12

IV. Possible Modifications

A. Use of materials other than chromium (VI)

In our current experiment, we use the colorimetric method for chromium (VI) determination because of it has local relevance in Madison, Wisconsin and we feel the hazards associated with chromium(VI) are manageable so that we can do our experiment safely. However, there are other alternative experiments that do not use as hazardous of materials that should work equally well. In earlier versions of our experiment, we measured the amount of Blue #1 food dye in powdered grape Kool-Aid using a red LED. An analysis of red #40 would also work with our green LED. An analysis of iron by complexing with o-phenthroline provides an appropriate color for the green LED. Figures 13-15 show the overlap of the absorbance spectra of these molecules with the emission spectra of appropriately selected LEDs.

0.5 3000 0.45 2500 0.4 blue #1 0.35 absorption 2000 0.3 0.25 1500 0.2 0.15 1000 Red LED RedLED emission Blue Absorbance #1 0.1 500 0.05 0 0 400 500 600 700 (nm)

Figure 13. Absorption spectra of FD&C Blue #1 food coloring overlaid with the emission spectra of a red LED.

0.7 1800 red #40 absorbance 1600 0.6 green LED emission 1400 0.5 1200 0.4 1000 0.3 800 600 0.2 red #40 red#40 absorbance

400 green emission LED 0.1 200 0 0 400 450 500 550 600 650 700

wavelength (nm) Figure 14. Absorption spectra of FD&C Red #40 food coloring overlaid with the emission spectra of a green LED with 510 nm maximum emission.

13

0.7 1800 1600 0.6 Fe phenanthroline complex 1400 0.5 green LED emission 1200 0.4 1000

0.3 800 600 0.2 400 green emission LED

Fe Fe phenthroline absorption 0.1 200 0 0 400 450 500 550 600 650 700 wavelength (nm)

Figure 15. Absorption spectra of Fe complexed with o-phenthroline overlaid with the emission spectra of a green LED.

B. The Digital Interface

We have only recently been using the Arduino digital interface for this experiment. Previously we used LabView programming and a National Instruments USB-6008 ADC. We decided to change to the Arduino platform to make an instrument that is more portable and not tied to a large computer. Our instrument could even be battery powered with two 9V batteries. We also wanted to provide students with an introduction to programming that is a little more general than LabView. Arduino is a C based language and its structure is similar to other general languages like Java, C++, and Python. We do use LabView programming in other experiments, so our students get an introduction to both LabView and Arduino.

V. Student Handout for the LED Photometer *

As you will see throughout the semester, the instruments used for chemical analysis can be quite sophisticated, complex, and expensive. Regardless of how complex an instrument appears, you should always keep in mind that these instruments are based on the fundamentals of chemistry, light, optics, and electronics. If you learn these fundamentals, you will not only be able to understand the operating principles behind the expensive commercial instruments, but you may even be able to design your own instruments for certain applications.

In this experiment, you are going to build your own photometer. In a general sense, a photometer is an instrument that measures the power of a source of light. The measurement of light power is extremely useful in chemistry, since it allows us to measure light that has been absorbed, scattered, or emitted by a chemical sample, which in turn provides information about the structure and the concentration of the molecules in a sample. In fact, the measurement of light power provides the basis for every spectroscopic instrument.

When building the photometer, you will work with the basic components (resistors, capacitors, diodes, transistors) of electronics as well as integrated circuits (operational amplifiers). You will interface your

14 photometer with a microcontroller and write your own firmware to acquire the data, calculate the absorbance and display the measured absorbance on an LCD. This experiment is designed to provide you with a practical introduction to electronics construction and measurement.

Finally, you will use your photometer to quantitatively determine the amount of chromium (VI) in an unknown sample. The Cr is analyzed using a colorimetric method where it is complexed with 1,5- diphenyl carbazide to form an intensely colored reddish complex. The red complex has λ max = 543 nm which is close to the λ = 525 nm maximum output of the green LED. You will also evaluate the important figures of merit of your photometer instrument.

Figure 1. Absorbance of Cr-diphenylcarbazide complex and emission spectrum of green LED

Visible Absorbance Specta of Cr-diphenylcarbazide Emission of Green LED complex 1 1800 0.9 1600 0.8 1400 0.7 1200 0.6 1000 0.5 800 Abs 0.4 Intensity 600 0.3 400 0.2 200 0.1 0 0 400 450 500 550 600 650 700 400 450 500 550 600 650 700 wavelength (nm) wavelength (nm)

15

Day 1. The voltage divider and use of a digital multimeter

Ohms Law You will build and analyze the following voltage divider circuit as an introduction to the digital multimeter (DMM.) A DMM is used to measure resistance and direct current (DC) voltages and currents. The two resistors provided are nominally 1 k, and 1.5 k but you should use the DMM to measure their actual values. Use the power supply at +12V for your source. Build the circuit and measure the voltage of the source, the voltage drops across resistors 1 and 2, and the current through the circuit. (Note: When measuring the value of a resistor, the resistor should be removed from the circuit and when using a DMM to measure current, the DMM must be placed in series with the circuit being measured) Are your measurements consistent with Ohms Law? Include your circuit diagram, your measurements, and your calculations in your lab report sheet.

R1 1k

Vs=12V Vm R2 1.5k R2

Now set up the voltage divider circuit as a light detector by replacing R 2 with the CdS photoconductive element (PDV-P9001). Measure the output voltage when the photoconductor is in the dark (block the photosensitive element from light), in room light, and directly exposed to light from a flashlight . Calculate the resistance of the photoconductor in each case. ( See voltage divider equation below.)

1k

Vs=12V V CdS m

The LED light source Build the LED supply circuit according to the following circuit diagram. The LED is a diode so current can only flow through it in one direction (from anode to cathode) so pay attention to the polarity as you hook it up. The 470 Ω resistor limits the current to about 25 mA.

16

470

Vs LED

Arrange the LED and detector on opposite sides of the cell holder and direct your LED onto the CdS detector through the sample cell. Verify that your detection system is working with the LED light source.

Calibrating the photometer Now that your source/detector system is working you can use it to measure the attenuation of the light for samples placed in the cell holder. Start by placing DI water in the sample cell and measure the detector voltage in the dark. Cover the detector with a small black cap and use the black cloth to shield the system further from room light. You get a voltage reading near your 0 V. Remove the cover and measure the detector voltage with the DI water in the cell. Finally measure the detector voltage for each of the Cr-diphenylcarbazide standard solutions. Prepare the standard solutions by combining 1.0 mL of each Cr standard and 0.2 mL of the 2mM diphenylacarbazide solution into a series of small vials.

To calculate the absorbance of the solution, you need to know the ratio of the intensities of light passing through the sample relative to the DI water. This is not so straightforward since the intensity of the light is related to the resistance of the detector (it’s actually a log-log relationship) and you are measuring the voltage drop across the resistor in a voltage divider circuit. The relationship between the voltage and the detector resistance is not linear and is given by the equation for a voltage divider:

 R   D  Vm = Vs    R1 + R D 

Calculate R D for the DI and each of the standard solutions. Your instrument can now be calibrated by R plotting − log D(DI) vs []Cr(VI) . R D(sample )

Create this calibration curve . Comment on the linearity of this calibration curve in your report sheet.

17

Days 2 and 3: Operational amplifiers, AC filters, diodes, and use of the oscilloscope

The current to voltage converter Build a new detection circuit for your photometer using a photodiode (PNZ335) and operational amplifier (OP27) according to the diagram below. The detection circuit (a current to voltage converter) will give an output voltage proportional to the current passing through the photodiode, which is dependent on the radiant power hitting the photodiode. Start with a 100k resistor for the gain resistor Rf, but keep in mind that you can change this value to change the output voltage. Notice the photodiode is reversed biased. This helps with the time response of the photodiode and also makes the response more linear. Be careful with this connection since you can destroy the photodiode if you forward bias it. Monitor the output voltage of this circuit with the voltmeter as you direct the light from the LED on to the photodiode. Verify that your detector is working properly. The voltage of the signal should be proportional to the light power hitting the detector.

I f

Rf

V-- 4 cathode - Vout 2 6 PD I op27 sh + + anode 3 7 V++ -12V

When your photodiode is completely blocked from incident light, your output should be very near zero volts. This small signal is called the background. The dark current in the photodiode and imperfections in the electronics contribute to the background signal. You should notice that room light also contributes to your measured signal. This is called stray radiation. Use a resistor for Rf that gives an output signal of a little less than 1 V from the LED.

The high pass filter and an introduction to the oscilloscope This section will provide you with an introduction to an AC filter and the use of an oscilloscope, which is an essential tool for working with electronic circuits. On a clear section of your breadboard, build a high pass RC filter using a 47 K resistor and a 0.1 F capacitor.

C

Vin R Vout

Use 1 V p-p sine wave from the function generator as V i, and measure the peak to peak V out and V in at several frequencies between 5000 and 1 Hz using your oscilloscope. Display both the input and output signals on your oscilloscope and look at the relative phase of the two signals. Use Excel to plot your

data as V o/V i vs. frequency. Be sure to get enough data points to clearly define the curvature of the

18 function. Also use Excel to generate a theoretical plot of the filter characteristics. How well do your values match the theoretical plot?

Modulating the LED light source The LED can be turned on at off at a desired frequency by combining an operational amplifier oscillator with a transistor as shown in the following circuit. First build the oscillator using a 1.0 uF capacitor for C and monitor the oscillator output with your oscilloscope. Also using your oscilloscope, measure the signals at the inverting and non inverting inputs simultaneously and sketch these waveforms in your report sheet . These sketches will help you understand how the oscillator works. After you verify your oscillator is working, connect up the transistor (2N3904 npn) and LED as shown. Pay attention to the polarity of the LED because it will only light when forward biased. You should now see the LED blinking at about 5 times a second. Once you have the LED working, replace C with a 4700pF capacitor that will increase the oscillation to about 1.5 kHz. You can no longer see this modulation rate with your naked eye, so use your oscilloscope to verify that your circuit is still working by monitoring the output of the I to V detection circuit. If your detection circuit is “ringing” add a 10 pF capacitor in the feedback of the I to V converter.

+12V oscillator out 470

C 100k LED - 100k 741 transistor + +

10k 22k

-12V

Adding the high pass filter to discriminate against room light . Now add the high pass filter to your detection circuit as shown in the diagram below. Look at the detector signal before (A) and after (Vout) the high pass filter. The signal after the filter should be due to only the LED light. Why? Include sketches of the signal before and after the filter in your report sheet.

19

I f A

10p 4 C - 6 2 op27 Vout + + 3 7 R -12V

Converting the AC signal to DC signal The final part of the circuitry is to make an AC to DC converter so that you have a DC signal that is proportional to the amount of LED light striking the detector. Construct the following AC-DC converter circuit in 3 stages and test the function of each stage as you go. This is good practice as you build more complex circuits. Stage 1: make the inverting half wave rectifier and include a sketch of the initial AC signal and the rectified signal in your report sheet. Stage 2: make the active low pass filter, but do not add the capacitor yet. This is just an inverting amplifier. Verify that this works. Stage 3: add the 10 uF capacitor to the feedback loop of the active low pass filter and confirm that the final output is a DC signal. Note that the 10 uF capacitor is a Ta electrolytic capacitor and it must be placed in the proper polarity.

rectified signal 10u 10k

10k

10k 10k AC in - - op27 op27 DC out + + + +

active half wave rectifier active low pass filter

Day 4: Programming the microcontroller , an introduction to ADC, digital IO and Arduino

Your set up so far has all of the elements of the photometer. To measure the absorbance of a solution, you would need to measure the output voltages of the dark signal, a reference blank, and the sample at then calculate the absorbance according to:

Vsample− V dark  Absorbance= − log   Vreference− V dark 

Instead of doing this manually, you will program a microcontroller to automatically calculate absorbance and display the absorbance on a small LCD. Complete the Arduino programing tutorial in Appendix A. At the end of the tutorial, you will have the microcontroller set up to help make the absorbance measurements.

20

Day 5: Completing your photometer and using it for a chromium(VI) analysis

When you were programming your microcontroller in the tutorial, the integrated circuit (IC) power came from the computer through the USB cable. The USB power is 5.0 V. Since you want your photometer to work independently from the computer, you will need to use the same power supply for the microcontroller as for your other circuitry. This is accomplished by connecting the +12 V and ground from the laboratory power supply to the Vin and GND connections on the microcontroller development board. The Arduino development board will bring down the power to the +5 V needed for your LCD and microcontroller. Make this connection and test your instrument. It should now be ready for making absorbance measurements.

To begin your measurements, block the LED and store the background Vout in your microcontroller. This is the small background voltage that is subtracted from each of the subsequent voltage measurements. Uncover the LED and measure and store the reference Vout with DI water in the sample cuvette. This is the reference measurement and now your LCD should display an Absorbance reading near zero.

Measure the absorbance for each of the Cr-diphenylcarbazide standard solutions. Prepare the standard solutions by combining 1.0 mL of each Cr standard and 0.2 mL of the 2mM diphenylacarbazide solution into a series of small vials.

Generate a calibration plot (A vs conc.) for the standards. Determine the linear range of your instrument.

Measure the absorbance of the complex in the water sample and determine its concentration from the calibration curve .

Record the standard deviation in the voltage measurement of the blank due to sample position. Use this as the limiting factor and calculate the detection limit for the chromium(VI) concentration in your instrument. Also determine the limit of quantitation, LOQ, the limit of linearity, LOL, and the dynamic range of your instrument.

Appendix A.

The Arduino web site, http://arduino.cc/en/ , contains all of the information you need to set up and begin programming your microcontroller. The examples below are intended as a

21 programming introduction and provide you with the code examples to you make your photometer controller.

Example 1. Serial Communication with computer

The following sketch (Arduino calls a program a sketch) illustrates how to send characters to the serial port. Enter the code and Upload (Arduino uses the term Upload for a Build). Test your program with the Arduino Serial Monitor. Push the reset button while monitoring your microcontroller. If you are new to programming, Congratulations, you have just completed your first “Hello World” program, which seems to always be the first application when learning a new language.

/*

Hello World

This code shows an example of serial communication of characters from Arduino to computer

created 2013

by Rob McClain-UW chemistry

*/

// Comments can be added using // or /* ...*/ Comment lines are ignored by the compiler and do not take up any program memory

void setup() { //The setup code is run only once after each program reset.

//The setup function is required for all Arduino programs

Serial.begin(9600); //Initialize serial port and add delay of 500 ms to allow port to open. Set the Baud rate to 9600 bits/s

delay (500); //Do not forget the semicolon after each line of code

} //The curly brackets are required for many Arduino (from C) elements

void loop() { // The main loop contains the heart of your program

22

Serial.println("Hello World"); // prints the characters to the serial port with a line feed

Serial.end(); //closes the serial port

} //The main loop will run continuously.

Example 2 Communicating with the LCD The next Arduino sketch will illustrate communication with the liquid crystal display(LCD). The following circuit diagram shows connections between the Arduino Uno and the LCD.

U7 LCD_2x8 U10 Arduino_Uno_Power

1 VSS VDD 2 IOREF 3 VLCD RS 4 RESET 5 R/W E 6 3.3V 7 DB0 DB1 8 5V 9 DB2 DB3 10 GND 11 DB4 DB5 12 GND 13 DB 6 DB7 14 Vin

U4 Arduino_Uno_Digital

13 12 11 10 9 8 7 6 5 4 3 2 1 TX 0 RX

/* This sketch sends Hello World to the 2x8 LCD display

Rob McClain UW Chemistry February 2013

23

*/

#include //This statement is needed to use the LiquidCrystal library

LiquidCrystal lcd(8, 9, 4, 5, 6, 7); //This designates the output pins for LCD communication RS on pin 8, enable on Pin 9, data on pins 4-7

void setup() {

lcd.begin(8, 2); //specifies the dimensions of the LCD; 2 rows, 8 columns

lcd.clear(); //clears the LCD display, and sets cursor to home (0,0) }

void loop() { //main loop

lcd.print("Hello");

delay (50);

lcd.setCursor(0,1); //sets cursor to second row

lcd.print("World");

delay(1500);

lcd.clear();

delay(500);

}

Example 3 Digital I/O

This example illustrates the microcontroller digital input and output functions. Construct the following circuits on your breadboard for this example. Pins 13 and 3 refer to the pin assignments on your Arduino development board. After you get one pushbutton and LED to work, construct a second switch and LED the same way using pins 12 and 2. The 2 switches will be used in the final photometer program to read and store the reference and dark voltages.

24

Pin 3 5V + 1k Pin 13 switch

LED R1 47k R1

/*

Digital I/O

Demonstrates digital input by reading a push-button switch on pin 13 and lighting an LED on pin 3.

The circuit illustrates the use of a pull down resistor on the input.

The circuit

* need a pushbutton and 47 k resistor for input and an LED and 1 k for the output

* connect 5 V to pushbutton to 47 k to ground with pin 13 between button and ground

* connect pin 3 to 1 k to LED to ground

*/

int pushPin = 13; //declares integer variable pushpin and selects pin 13 for the digital input

int LEDPin = 3; // declares integer variable LEDpin and selects pin 3 for the digital output

int switchPosition = 0; //integer variable variable to store switch setting

void setup()

{

pinMode(pushPin,INPUT); //sets the push button pin as input

pinMode(LEDPin,OUTPUT); //sets the LED pin as output

}

25 void loop()

{

switchPosition = digitalRead(pushPin); // read the input pin

digitalWrite(LEDPin, switchPosition); // turns LED on or off depending on pushbutton

}

Example 4 Analog to Digital Conversion (ADC)

This example illustrates the use of the microcontroller’s 10 bit internal ADC on input channel A0. Construct the following voltage divider circuit on your breadboard for this example. As you turn the potentiometer you should get a new value for the voltage reading.

5V + 39k

10k pin A0

/*

Analog Input

Demonstrates analog input by reading an analog sensor on analog pin A0 and printing the Voltage to the LCD

The circuit:

39 k resistor and 10 k Potentiometer in a voltage divider configuration center pin of the potentiometer to analog input pin A0

*/

#include //This statement is needed to use the LiquidCrystal library

26

LiquidCrystal lcd(8, 9, 4, 5, 6, 7); //RS on pin 8, enable on Pin 9, data on pins 4-7

int signalPin = A0; // selects the input pin for the signal and defines it as an integer variable

float signalValue = 0; // floating point variables to store the value coming from the circuit

void setup() {

analogReference(INTERNAL); //sets reference voltage to internal reference of 1.1 V

Serial.begin(9600); //Initialize serial port and delay to allow port to open

delay (100);

lcd.begin(8, 2); //specifies the dimensions of the LCD; 2 rows, 16 columns

lcd.clear(); //clears the LCD display,at sets cursor start

}

void loop() {

signalValue = analogRead(signalPin); // ADC conversion of the signal

lcd.setCursor(0,0);

signalValue = 1.1*signalValue/1024; // calculate the voltage from the ADC conversion

lcd.print(signalValue,3); // send voltage reading to serial port, sends 3 digits p decimal point

lcd.print(" V"); // send unit as a character string

delay(100);

}

Example 5 Advanced Math

27

This example illustrates floating point variables and uses the Arduino advanced math library for a logarithmic calculation.

/*

This sketch uses the arduino advanced math library for logarithmic calculations

*/

#include //This statement is needed to use the LiquidCrystal library

#include // adds the math library for the log10 function

LiquidCrystal lcd(8, 9, 4, 5, 6, 7); //RS on pin 8, enable on Pin 9, data on pins 4-7

float signalValue = 0.100; // floating point variables to store the values coming from the detection circuit float darkValue =0; float referenceValue=1.00;

double Transmittance=0; //floating point variables for T double Absorbance=0; // double float for A

void setup() {

Serial.begin(9600); //Initialize serial port and delay to allow port to open

delay (100);

lcd.begin(8, 2); //specifies the dimensions of the LCD; 2 rows, 16 columns

lcd.clear(); //clears the LCD display,at sets cursor start

} void loop() {

28

//calculate and display Absorbance

Transmittance = (signalValue-darkValue)/(referenceValue-darkValue);

Absorbance= -1*log10(Transmittance);

lcd.setCursor(0,1);

lcd.print("A=");

lcd.print(Absorbance,3);

delay(100);

}

The Final Program

The final program uses the circuitry and programming elements from the examples you have just completed. The program also illustrates for loops and if and else logic. Thoroughly test your final program while the Arduino is connected to the computer using the potentiometer test circuit as the voltage input. When you are satisfied that everything works, disconnect the USB connector.

/*

This sketch uses the Arduino to read the analog DC voltage from the photometer circuit and displays the voltage on the LCD.

The sketch reads the switch state of two switches to store both the dark voltage and reference voltage

The sketch calculates Transmittance and absorbance and displays the Absorbance result on the LCD

*/

#include //This statement is needed to use the LiquidCrystal library

#include // adds the math library for the log10 function

LiquidCrystal lcd(8, 9, 4, 5, 6, 7); //RS on pin 8, enable on Pin 9, data on pins 4-7

29

int signalPin = A0; // selects the input pin for the signal int pushPin1 = 13; //selects pin 13 for the push button input int LEDPin1 = 3; //Pin 3 for LED indicator output int pushPin2 = 12; //selects pin 12 for the push button input int LEDPin2 = 2; //Pin 2 for LED indicator output int darkSwitch = 0; //variables to store switch settings for dark and reference int referenceSwitch=0;

float signalValue = 0; // floating point variables to store voltages from the detection circuit float darkValue =0; float referenceValue=0;

double Transmittance=0; //floating point variables for T double Absorbance=0; // double float for A

void setup() {

analogReference(INTERNAL); //sets reference voltage to internal reference of 1.1 V

Serial.begin(9600); //Initialize serial port and delay to allow port to open

delay (100);

lcd.begin(8, 2); //specifies the dimensions of the LCD; 2 rows, 8 columns

lcd.clear(); //clears the LCD display,at sets cursor at 0,0

}

30

void loop() {

//acquire 10 ADC readings and average the result

long int signalValueAdd = 0; //long integer to store sum of 10 readings

signalValue = analogRead(signalPin); //read the value from the ADC

for (int i=1; i<=10; i++){

//delay(10);

signalValue = analogRead(signalPin); //read the value from the ADC

signalValueAdd =signalValueAdd + signalValue; //Add the recent value to sum

}

signalValue = signalValueAdd/10; //calculate the average ADC reading

lcd.setCursor(0,0); // ADC conversion of the signal

signalValue = 1.1*signalValue/1024; // calculate the voltage from the ADC conversion

lcd.print(signalValue,3); // send voltage reading to serial port, 3 digits past decimal point

lcd.print(" V"); // send unit as a character string

delay(100);

// check for updates from pushbuttons

darkSwitch = digitalRead(pushPin1); // read and store dark when switch 1 is pressed

if (darkSwitch !=0){

digitalWrite(LEDPin1,darkSwitch);

darkValue = signalValue;

}

31

else {digitalWrite(LEDPin1,darkSwitch);

}

referenceSwitch = digitalRead(pushPin2); // read and store reference when switch 2 is pressed

if (referenceSwitch !=0){

digitalWrite(LEDPin2,referenceSwitch);

referenceValue=signalValue;

} else {digitalWrite(LEDPin2,referenceSwitch);

}

//calculate and display Absorbance

Transmittance = (signalValue-darkValue)/(referenceValue-darkValue);

Absorbance= -1*log10(Transmittance);

lcd.setCursor(0,1);

lcd.print("A=");

lcd.print(Absorbance,4); // send voltage reading to serial port, sends 4 digits past decimal point

delay(100);

}

* R. McClain original developed in June 2002. Modified in May 2012.

32