I'm not going to lie, i don't have a lot of experience with electronics. However, I have an Arduino lying around and i thought it wouldn't take much work to turn it into an ad hoc data capture device for an optics project i'm running.
A laser goes through a bunch of optic dealies and hits a detector with an intensity, the detector then outputs a voltage which corresponds to that intensity. Until now i've just been reading it with a multimeter, however, it would be a lot less tedious if i could log the data directly into my computer.
The problem is that the detector will output anywhere from nothing to 0.7v when the experiment is running, but will spike to 12v when the main light is turned on between sets. I talked to some friends and they suggested using an op amp as i could tune it so that the voltage wouldn't exceed 5v for the arduino, yet i could also amplify small signals.
After some reading, I thought i'd give the circuit below a try with a TL081 Op Amp.
The pot is so the amplification could be tuned as the maximum input varied.
Running it for the first time, the arduino just returns a slew of values in the ~830-833 range when i would have expected anything from 0 to ~1000. The software side seems alright, so i'm assuming it's the hardware that's letting me down. Is the circuit i picked just plain ridiculous or is there something else i might be doing wrong?
I think all you need attenuation, not amplification. Two resistors in voltage divider 12 to 5 configuration. Your reading 830 most likely due saturation of the OPA, so it's output max voltage what it could (~4V for non rail-to-rail OPA).
It looks to me that you are interested in signal levels between 0 and 0.7v, but you also have to handle signals as high as 12v, which you don't need to measure. You have a few possibilities:
Magician has suggested that you attenuate the signal to 5/12 of its original value using a voltage divider. This means that the signal you want to measure will range from 0 to 0.3v at the Arduino pin. The Arduino has a resolution of around 5mV using the default reference of 5v, so your resolution will only be about 1 in 60.
Feed the signal to an Arduino pin through a series resistor. the Arduino has protection diodes on its input pins, so the 12v input will not be a problem provided that the series resistor is high enough. If you're only interested in slowly varying signals, I would use a 100K series resistor, along with a 0.1uF capacitor from the pin to ground. 100K is well above the recommended source resistance for the ADC, but in practice the ADC can handle that if you take the correct precautions and you're not looking for tremendous accuracy. This will give you a resolution of about 1 part in 140.
Amplify the signal using a single-rail op-amp powered from the 5v supply, with the op amp configured for a gain of about 7. The circuit you sketched would be OK with an op-amp designed for single rail 5v operation, but not with the TL081 (which needs dual supplies and a higher total voltage). The op amp part of an LM392 should be suitable. You should have a resistor between the detector and the op amp input to protect it against the 12v from the detector in bright light conditions, and (depending on the op-amp) maybe a diode from the non-inverting input to +5v for the same reason.
Hey, thanks a lot guys and sorry for the slow reply. I'm trying the other op amp now because i'd rather have the higher resolution, if that fails due to my electronics skill i'll go back to the protection tutorials and hope for the best. Thanks again!