Experiment 8 - Optic Diodes and Transistors
Please use the Arduino IDE version 1.8.18 or 1.8.19, with other versions you might run into problems using the serial plotter.
Edit: The serial plotter works with Version 2.2.1
- 1 1. Context of the Experiment
- 2 2. Learning Goals of this Experiment
- 3 3. Literature
- 4 4. Basics/Fundamentals
- 5 5. Technical Basics & Preparations
- 5.1 5.1. General instructions
- 5.2 5.2. Design / Circuit Preparations
- 5.3 5.3. Circuits
- 5.3.1 Photodiode BPW46
- 5.3.2 Prepare yourself!
- 5.3.3 Phototransistor LPT 80A
- 5.3.4 Prepare yourself!
- 5.4 5.4. Technical Preparations
- 5.5 5.5. Averaging sensor inputs
- 5.6 5.6. Do a sensor-software-calibration by calculating a linear correction factor and setting the voltage output
- 5.7 5.7. Output your measurement to the Analog IOs of the Arduino
- 5.8 5.8. Optional: PWM Monitoring with the oscilloscope
- 6 6. Experiment Procedure Test-Stand
- 7 7. Evaluation of Experiment Results
- 8 8. Entering the results in VIPS:
- 9 9. Datasheets
1. Context of the Experiment
Measurement of light and visible radiation is one of the key measurement techniques. Sensors are usually cheap as they rely on silicone-based-chip-technology. But they are also sensitive and delicate to use, as their performance is strongly dependent on several parameters. Among them, the direction of light impact and the spectrum. In this experiment you are going to use standard phototransistors and diodes and you are going to evaluate them. At the experimental place you will get used to the procedure, then at the experiment test-stand you will run a controlled reference experiment.
2. Learning Goals of this Experiment
Understanding the function of phototransistors and photodiodes with two examples
Understanding the operation of them in real-life conditions and read the values with an Atmel-controller
To evaluate and understand the impact of incidence of light and spectrum and intensity of light
To calibrate your light sensors compared to a photometric reference sensor and understand the difference in "light measurement" compared to radiation measurement
3. Literature
Please note the datasheets of sensors and experimental components attached at the end of this description.
There is no specific literature except for the datasheets or referencing to the standard literature for the lecture.
4. Basics/Fundamentals
Radiation in the visible spectrum and light are from a physical-unit-perspective two different things. Radiation's power is usually measured in Watt. Light is - of course - also radiation, but this raditation and its intensity is interpreted according to the visible perception. The key parameter to calculate/switch between power-oriented data and physiological-oriented-data are shown in the tables below (reproduced from the lecture) .
Physical Scale | Symbol | Relation | Unit | simplified |
---|---|---|---|---|
Radiation Energy |
|
| W s | Integral across all wavelengths |
Radiant Power | W |
| ||
Emittance / Radiant exitance |
|
| W m² | please note, this surface is the emitting surface, compare exposure! |
Radiant Intensity |
|
| W sr-1 |
|
Radiance (density) |
| W sr-1 m-2 | A reduction of Light in a certain solid angle on an equal surface in this direction | |
Radiant flux density / exposure rate |
|
| W m-2 | This surface A is now meant to be the receiving/exposed surface, compare emittance! |
Radiation |
|
| W m-2 s |
|
Optical / visible scale | Symbol | Relation | Unit | simplified |
---|---|---|---|---|
Luminous Energy |
|
| lm s | Integral across all wavelengths |
Luminous Flux, Luminous Power | lm |
| ||
Luminous exitance, luminous emittance |
|
| lm m² | , please note, this surface is the emitting surface, compare exposure! |
Luminous Intensity |
|
| lm sr-1; cd |
|
Luminance |
| cd m-2; lm sr-1 m-2 | A reduction of Light in a certain solid angle on an equal surface in this direction | |
Illuminance |
|
| lm m-2; lux | ; This surface A is now meant to be the receiving/exposed surface, compare emittance! |
Luminous Exposure |
|
| lux s |
|
When dealing with photoelements, it makes sense to be aware of these differences in units, because otherwise you are at risk to compare apples with pineapples.
The following sections give a very short introduction to the optical sensors you are going to use. There are more of them (some mentioned in the lecture), but the silicone-based photosensors are the most common and easily accessible in terms of availability and costs.
4.1. Photodiodes
Photodiodes are elements with a negative and a positive polarized region, same as a normal electrical diode. But as any silicon material in this charged area. there is a significant sensitivity to radiation. In case of photodiodes (and solar-cells, which are just large photodiodes), this sensitivity is tuned for a use with visual/optical radiation.
From a model-understanding, photodiodes can be assumed as almost ideal current source, producing a current proportional to the amount of incident radiation.
The photodiode can either be operated in reverse direction (3rd quadrant/ operating point) or in forward-direction (4th quadrant, photovoltaic). In this experiment you are going to operate them in the photovoltaic region.
4.2. Phototransistors
Phototransistors are transistors with a light-exposed-gate. The current towards the emitter is proportional to the light hitting the gate.
The collector current (and consequently the emitter-current) is almost ideally proportional to the impacting solar power (mW/cm2)
5. Technical Basics & Preparations
5.1. General instructions
You will prepare your measurement setup at your desk. After you are done, you will use the optical experiment test-stand to do some fast calibration measurements. At home you will use these measurements to calculate some proportionalities and values.
5.2. Design / Circuit Preparations
You will choose your resistors on your own for the experiment. Some previous students may have left some resistors in the box. You may of course use those, but control their values with the multimeter so they fit to your calculations.
There is a stock of resistors in the Working lab (see picture below), feel free to make your choice.
5.3. Circuits
The circuits you are going to build are different for the photodiode and the phototransistor.
For the photodiode you will use the diode directly as a converter from optical energy (light) to electrical energy. This energy is then going to be consumed by a resistor, where you can measure the voltage-drop. A photodiode is basically nothing else but a small solar cell (or solar cells are nothing else but really big photodiodes).
For the phototransistor we will use a different application. There you will apply the "high-side" to a 5V potential, and have a resistor in series. You are going to measure the voltage-drop along the resistor (v_out) as your measurement signal. You are going to need to choose proper resistors for this component.
Photodiode BPW46
The photodiode is a comparably insensitive component. Its main use is in the reverse direction as a switch. However, we will use it similar like a solar-cell in the forward region at positive voltages.
In this experiment we will not load the diode with a relevant current. So we will operate it "open-circuit" and measure the voltage (like a solar-cell), which should be proportional to the light hitting the diode. So we operate it in the forward-direction.
Phototransistor LPT 80A
To prepare the phototransistor please familiarize yourself with the datasheet attached at the bottom of this guide. We want to operate the transistor as shown in the circuit above.
To choose a proper resistor for current-measurement you have to understand the current to be expected. There is a nominal current mentioned in µA at 5V operational voltage across the transistor. We can not assume the full 5V to be used for the transistor only, as we will only have 5V as a maximum voltage (and we still need a resistor to measure a voltage drop). Because of this, we assume to use half the nominal current only.
Before assembly, please make sure to measure/control the resistor value once with the multimeter. If you choose a too low value or if a resistor was misplaced in the boxes, you may destroy the phototransistor easily.
5.4. Technical Preparations
Target is to mount your diodes on the breadboard in the following way, facing their sensitive element upwards
Prepare the Photodiode-Measurement
Wire your circuit according to the sketch below. Make sure to identify the cathode of the diode based on the geometrical information in the datasheet.
(from https://www.electronicshub.org/photodiode-working-characteristics-applications/)
The code you should use is inspired by the Arduino example on reading an analog input. This code enables an analog read from two pins (in this case A0 and A1) and provides this as an output to the serial port for visualization.
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue1 = analogRead(A0);
// read the input on analog pin 1:
int sensorValue2 = analogRead(A1);
// print out the value you read:
Serial.print(sensorValue1); //careful!!! this is "print" not "println"
Serial.print(" "); //some space between numbers, careful!!! this is "print" not "println"
Serial.println(sensorValue2); //this is the last number!
delay(1); // delay in between reads for stability
}
Open the serial monitor or the serial plotter. Check for the analog channel of the photodiode. When you are varying the brightness (e.g. by the light of your mobile phone or by holding your hand on top of the sensor), the expected outcome is going to look like this. Is this realistic? Check your calculations and convince yourself that you are measuring more than just noise.
Prepare the Phototransistor Measurement
Create a setup similar to the design below. Make sure to properly identify the cathode of the phototransistor before wiring. Use the resistor you chose during the preparation stage.
Use the same program as above. Play with the light (for example with your phone light or your hand to provide shadow) to modulate the light. The output in the serial plotter should look like this (depending on the resistor you choose). Adjust your resistor until it is hard to saturate the voltage level with your torch-light. Is this realistic? You may still change the resistor and see its impact if you want.
5.5. Averaging sensor inputs
The sensors input you have may be extremely noisy (much more than what you can see above), as the lamps in the WorkINGLab operate at a certain frequency by PWM or there may be stray-light or other electrical noise (e.g. a 50 Hz electromagnetic coupling from power-sources). So it makes sense to average data to get rid of noise. The analog-to-digital conversion of the Arduino-UNO takes around 100 µs according to spec. So if we can "afford" a 10 ms measurement we can do at least 100 readings and average them. For this, the readings are summed-up and averaged. Please note the data-types in the code.
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}// the loop routine runs over and over again forever:
void loop() {
long average1 = 0; //we need long here, as we are reading 100 times a value which is at a maximum 1024... so integer (16 bit) is not large enough
long average2 = 0; //we need long here, as we are reading 100 times a value which is at a maximum 1024... so integer (16 bit) is not large enough
int numberofreads=100;
for (int i=0; i < numberofreads; i++) {
average1 = average1 + analogRead(A0); //one read is about 100 us on arduino. So 100 reads should be 10 ms for averaging (x 2 because of two inputs)
average2 = average2 + analogRead(A1); //one read is about 100 us on arduino. So 100 reads should be 10 ms for averaging (x 2 because of two inputs)
}
average1 = average1/numberofreads;
average2 = average2/numberofreads;
int sensorValue1 = average1;
int sensorValue2 = average2;
// print out the value you read:Serial.print(sensorValue1); //careful!!! this is "print" not "println"
Serial.print(" "); //some space between numbers, careful!!! this is "print" not "println"
Serial.println(sensorValue2); //this is the last number!
//delay(1); // delay in between reads for stability - not required anymore, the loop is delaying enough
}
5.6. Do a sensor-software-calibration by calculating a linear correction factor and setting the voltage output
Notice the voltage differences between the diode and the transistor. You are going to create two analog outputs now for each of the two sensors. For both of the sensors the steps are the same. You will measure the output without light, and you will measure the voltage with identical light (ambiance light, or use an artificial light-source such as your phone).
The function you will apply in Arduino IDE is the map-function. It maps an input area of one variable to an output-variable. The maximum output range we can use later is an 8-bit-resolution. So the output range must end at 255 as a number (theoretically). Due to limitations of the test-stand analog inputs only a maximum of 180 can be read.
Your code may consequently then look like this (example, you will have different values and A0 and A1 may be differently connected)
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}// the loop routine runs over and over again forever:
void loop() {long average1 = 0; //we need long here, as we are reading 100 times a value which is at a maximum 1024... so integer (16 bit) is not large enough
long average2 = 0; //we need long here, as we are reading 100 times a value which is at a maximum 1024... so integer (16 bit) is not large enough
int numberofreads=100;
for (int i=0; i < numberofreads; i++) {
average1 = average1 + analogRead(A0); //one read is about 100 us on arduino. So 100 reads should be 10 ms for averaging (x 2 because of two inputs)
average2 = average2 + analogRead(A1); //one read is about 100 us on arduino. So 100 reads should be 10 ms for averaging (x 2 because of two inputs)
}
average1 = average1/numberofreads;
average2 = average2/numberofreads;
int sensorValue1 = average1;
int sensorValue2 = average2;// print out the value you read:
Serial.print(sensorValue1); //careful!!! this is "print" not "println"
Serial.print(" "); //some space between numbers, careful!!! this is "print" not "println"
Serial.print(sensorValue2); //careful!!! this is "print" not "println"
Serial.print(" "); //some space between numbers, careful!!! this is "print" not "println"int sensorDiodeMin=0;
int sensorDiodeMax=75;
int sensorTransistorMin=0;
int sensorTransistorMax=1005;int CalibOutputDiode = map(sensorValue1, sensorDiodeMin, sensorDiodeMax, 0, 180); //as 180 is the limit of the test-stand analog inputs
int CalibOutputTransistor = map(sensorValue2, sensorTransistorMin, sensorTransistorMax, 0, 180); //as 180 is the limit of the test-stand analog inputsSerial.print(CalibOutputDiode); //careful!!! this is "print" not "println"
Serial.print(" "); //some space between numbers, careful!!! this is "print" not "println"
Serial.println(CalibOutputTransistor); //this is the last number!//delay(1); // delay in between reads for stability
}
5.7. Output your measurement to the Analog IOs of the Arduino
Finally, you want to output your measurements to the test-stand and that it can record simultaneously your measurement and the measurement from the reference sensor. For this you will use a simple command: analogWrite and output analog voltages.
As output-pins you can use Pins 9 to 11 and 3, 5 and 6 (visible/readable with the symbol ~ on the Arduino-Uno-board).
As an example, to write a value of 240 to output pin 9, you have to use analogwrite(9,240)
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}// the loop routine runs over and over again forever:
void loop() {long average1 = 0; //we need long here, as we are reading 100 times a value which is at a maximum 1024... so integer (16 bit) is not large enough
long average2 = 0; //we need long here, as we are reading 100 times a value which is at a maximum 1024... so integer (16 bit) is not large enough
int numberofreads=100;
for (int i=0; i < numberofreads; i++) {
average1 = average1 + analogRead(A0); //one read is about 100 us on arduino. So 100 reads should be 10 ms for averaging (x 2 because of two inputs)
average2 = average2 + analogRead(A1); //one read is about 100 us on arduino. So 100 reads should be 10 ms for averaging (x 2 because of two inputs)
}
average1 = average1/numberofreads;
average2 = average2/numberofreads;
int sensorValue1 = average1;
int sensorValue2 = average2;// print out the value you read:
Serial.print(sensorValue1); //careful!!! this is "print" not "println"
Serial.print(" "); //some space between numbers, careful!!! this is "print" not "println"
Serial.print(sensorValue2); //careful!!! this is "print" not "println"
Serial.print(" "); //some space between numbers, careful!!! this is "print" not "println"int sensorDiodeMin=0; <--- enter your own values here
int sensorDiodeMax=75; <--- enter your own values here
int sensorTransistorMin=0; <--- enter your own values here
int sensorTransistorMax=1000; <--- enter your own values hereint CalibOutputDiode = map(sensorValue1, sensorDiodeMin, sensorDiodeMax, 0, 180);
int CalibOutputTransistor = map(sensorValue2, sensorTransistorMin, sensorTransistorMax, 0, 180);Serial.print(CalibOutputDiode); //careful!!! this is "print" not "println"
Serial.print(" "); //some space between numbers, careful!!! this is "print" not "println"
Serial.println(CalibOutputTransistor); //this is the last number!analogWrite(9,CalibOutputDiode);
analogWrite(10,CalibOutputTransistor);delay(1); // delay in between reads for stability
}
5.8. Optional: PWM Monitoring with the oscilloscope
The output of the Arduino-Uno is not a normal analog signal. It is created by a Pulse-Width-Modulation (PWM). If you have time and are interested, take the oscilloscope and measure your outputs to get an idea how it works and how it modulates based on the input.
6. Experiment Procedure Test-Stand
You are going to run three six very fast measurements (below 15 seconds each) for both sensors in parallel.
In these experiments, brightness curves are going to be recorded. A light-source will run from "dark to bright" in around five seconds. The Extech Reference Luxmeter Model 401025 (see datasheets) will be used as a reference sensor being illuminated in a very similar position as your two sensors on the breadboard. After the experiment, you will calculate the sensitivity of your sensors for each scenario, and compare it with the datasheet values.
8.1 Put your breadboard with the photodiode and the phototransistor on the test stand as shown in the picture below.
8.1.1 Connect your analog outputs (if you followed the instructions, it should be analog out pin 9 and 10) of your Arduino to the test-stands analog inputs (a white and blue cable with a pin, blue cable being input 1, white cable being input 2)
8.1.2 Connect the ground of your Arduino to the test-stand's Ground connection (black cable).
8.1.3 Make sure to reset the reference-sensor Extech 401025, it may have drifted since the last group measured. For this close the lid (black cap, which prevents light from falling on the sensor), and switch it off and on again. The right setting is shown below (lux-sensitivity-switch to a 2000 lux measurement range, fast measurements).
Open the app on the computer on experiment 8.
8.2 Execute the measurement at 0°
8.2.1 Position the source at 0°
8.2.2 make sure there is no filter between source and target
8.2.3 Run your code to record the analog voltages in parallel and replay the analog voltage to the test stand inputs. Write down which voltage corresponds to which input (phototransistor goes to blue cable, photodiode to white cable as an example).
8.2.4 Close the box of the test stand
8.2.5 Press "Start 0° WHITE"
8.3 Execute the measurement at 30°
8.3.1 Position the source at 30° to the left (as shown in the picture).
8.3.2 Run your code to record the analog voltages in parallel and replay the analog voltage to the test stand inputs. Note down which voltage corresponds to which input (if you did not change anything in the wiring, it is the same as in the 0° run).
8.3.3 Close the box of the test stand
8.3.4 Press "Start 30°"
8.4 Execute the measurement at 45°
8.4.1 Position the source at 45° to the left (as shown in the picture).
8.4.2 Run your code to record the analog voltages in parallel and replay the analog voltage to the test stand inputs. Note down which voltage corresponds to which input (if you did not change anything in the wiring, it is the same as in the 0° run).
8.4.3 Close the box of the test stand
8.4.4 Press "Start 45°"
8.10 When you feel you are done and all measurements have run well, let the system send you an email. It will contain a data structure with all the measurements (for each measurement run). It contains three columns of data with the reference value of the sensor (in volt) and the two voltages you fed to the test stand!
7. Evaluation of Experiment Results
Introduction to the results and how to work with them!
The results you received contain three voltages (reference-sensor-voltage, see info-panel for the calibration factor) and your two sensors' voltages.
They should look somehow like this. Please note that you will see different values depending on the chosen resistors and your individual calibration factors.
Example plot for 0° white: | Example plot for 30° white | Example plot for 45° white |
---|---|---|
In the next step you should calibrate the channel from the reference sensor to real lux-values. For this, multiply the values of this channel with the calibration factor.
We are going to ask you now for a couple of information. Please calculate from the values you measured. We suggest that you use the following views of your plots.
Example plot, both sensors at 0° | Example angle-sensitivity of Phototransistor | Example angle-sensitivity of Photodiode |
---|---|---|
8. Entering the results in VIPS:
1. Matriculation number
2. Select the sensor you assigned for channel 1 (Photodiode or Phototransitor)
3. Which resistor did you use for the phototransistor? (value in kOhm)
Phototransistor:
4. at 0°: What is your offset error at 0 lux based on your linear approximation? (extrapolate if necessary)
5. at 0°: Create a linear approximation (in Excel, Matlab, Pen&Paper, or any other mean, just the middle between up and down-measurement). After you did, what is your maximum absolute error (the linearity error) of your photransistor compared to the linear approximation? Check only between 300 lux and 1300 lux (ignore borders of the measurement range).
6. at 0°: What is the maximum hysteresis error between 300 lux and 1300 lux (ignore borders of the measurement range)?
7. From the datasheet, what angular reduction (in %) do you expect from the phototransistor at 45°?
8. From your raw measurement at 0° and at 45°: What average/mean angular reduction (between 300 lux and 1300 lux, ignoring borders of the measurement range) can you derive from your data?
Photodiode:
9. at 0°: What is your offset error at 0 lux based on your linear approximation (extrapolate if necessary)?
10. at 0°: Create a linear approximation (in Excel, Matlab, Pen&Paper, or any other mean, just the middle between up and down-measurement). After you did, what is your maximum absolute error (the linearity error) of your photodiode compared to the linear approximation? Check only between 300 lux and 1300 lux (ignore borders of the measurement range).
11. at 0°: What is the maximum hysteresis error between 300 lux and 1300 lux (ignore borders of the measurement range)?
12. From your raw measurement at 0° and at 45°: From your measurement, what average/mean angular reduction (between 300 lux and 1300 lux, ignoring borders of the measurement range) can you derive from your data? (0% is a valid answer)
9. Datasheets
Sensors Photodiode and Phototransistors
Source (not available in Winter Term 2022/23)
Other Components
Test-Stand Light Sources
Test Stand Reference Sensor
Related pages
Institut für Mechatronik im Maschinenbau (iMEK), Eißendorfer Straße 38, 21073 Hamburg