Monday, February 11, 2013

The Sensor - Rediscovered!

I've now selected and tested the sensor I will use for both the transmission and reflection portions of my densitometer.  The TI OPT101, is a integrated photodiode and transimpedance amplifier.  I ordered three of the OPT101 ICs from Mouser Electronics about a year ago for this project and then forgot about it when the project took a back seat to other things.  At the time that I ordered the sensors, I had been researching photosensors heavily and probably knew exactly how each type of sensor worked and the pros and cons of each.  However, all these months later, I've forgotten the details, but remember that this was the sensor I had selected.  Basically, from what I can recall, the photodiode in this circuit produces a current when exposed to light and the transimpedance amplifier converts that current into a voltage. 


Using the basic configuration described in the data sheet and my Arduino UNO, I was able to get a nice data output with the following sketch: 

int sensorPin = A0;
float sensorValue = 0;
int outputValue = 0;

void setup()
{
  Serial.begin(9600);
}

void loop() {
  sensorValue = analogRead(sensorPin);
  outputValue = map(sensorValue, 0, 1023, 0, 255);
 
  Serial.print("sensor = ");
  Serial.println(sensorValue);
  Serial.print("output = ");
  Serial.println(outputValue);
  delay(200);
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.