A few new interns started this week. They need to learn LabVIEW and our academic hardware so we have been giving them fun projects to do like characterizing a solar panel, finding the maximum voltage out of a small peizo sensor when flicking it, and, in this case, implementing an auto-dimming light using a photocell. This particular intern approached me to find a photocell; however, looking through my box of wonderful sensors, all I could find was this weird phototransistor-looking device:
After magnifying a few times and finding the datasheet I discovered that it is a light-to-frequency converter. No, I had never heard of that either. So I let the intern go figure out how to interface his myRIO with it but I secretly kept another to characterize it for myself. I took out my Analog Discovery 2 to use the variable power supply and the scope and here's what I found:
The light-to-frequency converter, with a VCC of 5V, gives me a 5V square wave with a 50% duty cycle, as the spec sheet says, and in ambient light gives me around 20kHz. Shining a phone light directly on the sensor consistantly gave me a frequency of 200kHz.
With that in mind I wanted to design a quick and dirty light detector which will light up an LED in ambient light and turn off the LED when I shine my phone flashlight on it. Of course I simulated the circuit first in Multisim Live then just went for it on my tiny breadboard. First going through a lowpass filter with a cutoff frequency at 80kHz to decrease the amplitude of the signal when I shine a light on the converter, then putting the resulting signal into a comparitor with a potentiometer to adjust the reference voltage.
I wasn't able to model the light-to-frequency converter all that well in simulation so after some experimentation I figured out that I needed an extra capacitor to get rid of the DC component coming from the sensor. After fiddling with the potentiometer for a bit it worked! In the above photo you can see that the LED is turned on. Then, when I turn the flash on my camera on the light turns off as in the photo below.
It turns out after all of this procrastinating I did have a photocell in my sensor box and didn't need to go through the trouble of using this light-to-frequency converter.
Keep all of the sensors you find or pull from old projects into a neatly organized box for future projects.
It won't stay organized so check all of the dividers to make sure the part you are looking for is actually missing.
The new intern taught me that acquiring the square wave directly with the myRIO then controlling the output based on the frequency is easier than trying to make the limited components I have at my desk work.