View Full Version : Circuit for Photoresistor with high sampling rate

11-10-2006, 11:04 AM
I was wondering if anyone knew how to make a circuit on the basic stamp that would allow me to sample light intensity detected by a photoresistor faster than the example presented in the "What's a Microcontroller" manual.

Imagine an application in which a piece of reflective tape is placed on a rotating shaft. A small circuit is created that shines an IR LED at the shaft and a photoresister is connected to the basic stamp that detects the reflection of the IR light off the tape during each revolution. I would like to monitor for a momentary spike in light intensity, however the event might only last 1ms. Using a timer, I can calculate shaft RPM. I've followed the example in the book, and even after removing the "Pause 100" line, the refresh rate of the photoresister appears slow. It seems that when the light intensity is low (and the RCTIME time is high) it takes about 500ms+ to recharge the capacitor. Is there a more direct approach to using a photoresister without the use of a capacitor that gives a reading of the light intensity faster?·

(Figure 7-2) Photoresistor RC-time Circuit Schematic
P2 ----/\/\/------+---------+
···· (220 Ohm)··· |········ |
················· |········ |
········ (Photeresistor)··· =· (0.01 uF)
················· |········ |
················· |········ |
················· +---------+
················· |
················· |
················ Vss

Example Program: TestPhotoresistor.bs2 on Page 192 - What's a Microcontroller?
' {$STAMP BS2}
' {$PBASIC 2.5}
time····· VAR···· Word
·· HIGH 2
·· PAUSE 100
·· RCTIME 2, 1, time
·· DEBUG HOME, "time = ", DEC5 time

Martin Hebel
11-10-2006, 11:33 AM
RCTime is relatively slow, and photoresistors by their nature are slow. If you are looking for a high speed optical tach, I'd recommend a photo-transistor instead. There is much information on this in Process Control available from Parallax including how to optimize the circuit for very fast counting.

The COUNT command is used to count the number of pulses per a unit time to determe RPM.


Martin Hebel
StampPlot - Graphical Data Acquisition and Control (http://www.stampplot.com/)
AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers (http://www.selmaware.com/appbee)·

Chris Savage
11-10-2006, 11:54 AM
Another possibility is to create a circuit using an A/D converter and read that with the BASIC Stamp.

Chris Savage
Parallax Tech Support

11-10-2006, 12:15 PM
Thank you Martin and Chris for the information and feedback. It appears to me that the Process Control (or Indrustrial Control Kit) is what I need to purchase in order to complete the project I've set for myself. The online manual provides a lot of in depth information about making an optical tachometer and the kit has all the components.

I'm very impressed with the Basic Stamp community and their ability to help others. Keep up the great work!