4: Using Op Amps: A Practical example
Measuring light level with a photodiode
Photodiodes are used in many every day electronic devices such as cameras, smoke detectors, burglar alarms, safety equipment, medical applications, CD players and surveying instruments. They can be used to detect a wide range of electromagnetic radiation, from infra-red through the visible to ultraviolet and even x-rays. They aren't just for visible light.
How they work
When a photon (a bit of light or other EM wave) hits the semiconductor junction of a photodiode it causes a current to flow - in the OPPOSITE direction to the normal forward conduction. There are different ways of detecting this, and you CAN measure the voltage generated; but this circuit uses the "short circuit current" - so the voltage across the device needs to be kept at zero.
This circuit uses an "Op Amp" to do just that.
Components:
I used an MCP6022 but any CMOS Op Amp capable of "rail to rail" single supply operation at 5V will do; see my chart above. Also any silicon photodiode will work, and if you just want to test the circuit and dont have a photodiode you can use an LED. The circuit IS polarity sensitive so if it does not work just turn the diode connections around.
This circuit is very like the "Inverting amplifier" described in reply 3.
The above diagram was produced using "Circuit Diagram"
/*
* Sketch written for Arduino Uno to read current generated by photodiode
* J. L. Errington skillbank.co.uk Jan 2021
* Uses an Operational Amplifer powered from the Arduino to measure the current
* which is then read on Analog input A0 and displayed on the Serial monitor
*/
//Analog input pin assignments
const byte lightPin = A0; //
//reading ADC and converting to current measurement in microamps
const int vRef = 1100; //value of reference voltage in mV
const int rFeedback = 220; //enter value of feedback resistor in kOhms
long temp; //value read from ADC
long mVolts; // mV on analog input
int uAmps; // Diode current in microAmps I(uA) = V(mV) * 1000 / R
void setup() {
Serial.begin(57600);
analogReference(INTERNAL); //using a 1100mV reference - so a reading of 1 = 1100/1024 millivolts
}
void loop() {
temp = analogRead(lightPin);
mVolts = (temp * vRef)/1024; // the multiplication is done first to keep precision - so temp needs to be a long
uAmps = (mVolts * 1000 ) / rFeedback; // the multiplication is done first to keep precision - so mVolts needs to be a long
Serial.print("ADC reads: ");
Serial.print(temp);
Serial.print(" Voltage is: ");
Serial.print(mVolts);
Serial.print(" milliVolts");
Serial.print(" Current is: ");
Serial.print(uAmps);
Serial.print(" microAmps");
Serial.println("");
delay(500);
}
How the circuit works:
When a current I1 is generated by the photodiode the op amp "self-adjusts" to keep the input voltage at zero by producing an output voltage that will cause the exact same current (I2) to flow through the feedback resistor. If the voltage is measured and the value of the feedback resistor is known (here 220 kOhms) the current can be calculated using Ohms law.
Note the op amp is powered from the +5 and 0V from the arduino. This is called "single supply" operation and (as for "rail to rail" operation) is discussed further in reply #6.
The above diagram was produced using "Circuit Diagram"