View Full Version : How to install a photodiode?

01-09-2009, 09:50 PM
I have bought a photodiode (SFH203P Osram) does some one know how to connect this on a Propeller Proto Board and how I can program it.

Thank you

Mike Green
01-09-2009, 10:22 PM
You will need some kind of high speed amplifier / comparator between the photodiode and the Propeller since the photodiode produces a very small current in response to light and the Propeller requires a 3.3V logic level signal. Once you have a logic signal, there's no special programming required. If you want to measure the analog output of the amplifier, there's an application note (AN001) that describes the external circuitry needed for the Propeller to do analog to digital conversion and includes sample code (www.parallax.com/tabid/442/Default.aspx (http://www.parallax.com/tabid/442/Default.aspx)).

You would need to give more information about your application to get more specific advice.

01-09-2009, 11:05 PM
Do you think I must make something like an ADC?
Something like this: http://forums.parallax.com/showthread.php?p=631354
Or is there something easier to make?

Thanks for your quick reply!

Mike Green
01-09-2009, 11:12 PM
A photodiode amplifier is not a simple thing. Here's a lecture on the subject:

www.national.com/onlineseminar/2004/photodiode/PhotodiodeAmplifers.pdf (http://www.national.com/onlineseminar/2004/photodiode/PhotodiodeAmplifers.pdf)

There are other articles available on the web if you search for "photodiode amplifier".

Like I said, you need to give much more information about your application to get specific advice.

01-09-2009, 11:46 PM
I want to make a robot that follows a line. I want to take a red-light and a photodiode abreast.
The photodiode must see three different colours: white, silver and black.
The Qti sensor is not an option because the track has differences of height.
I have a Propeller Proto Board and I program in Spin.

Mike Green
01-10-2009, 12:43 AM
A photodiode is not a good choice for this sort of task because of the need for amplification. Also, you may or may not get enough difference in reflectivity between the white and the silver to reliably distinguish them. You'll have to experiment there. The two options I'd consider would be a phototransistor (www.parallax.com/Store/Components/Optoelectronics/tabid/152/CategoryID/30/List/0/SortField/0/Level/a/ProductID/179/Default.aspx (http://www.parallax.com/Store/Components/Optoelectronics/tabid/152/CategoryID/30/List/0/SortField/0/Level/a/ProductID/179/Default.aspx)) or the TSL230R (www.parallax.com/Store/Sensors/ColorLight/tabid/175/CategoryID/50/List/0/Level/a/ProductID/88/Default.aspx?SortField=ProductName%2cProductName (http://www.parallax.com/Store/Sensors/ColorLight/tabid/175/CategoryID/50/List/0/Level/a/ProductID/88/Default.aspx?SortField=ProductName%2cProductName)) . There's an object in the Propeller Object Exchange that demonstrates the use of the TSL230R with the Propeller (obex.parallax.com/objects/236/ (http://obex.parallax.com/objects/236/)).

If you want to use the phototransistor, you should connect the collector to +3.3V (Vdd) and connect the emitter to a resistor. The other end of the resistor connects to ground (Vss). The resistor should have a value roughly between 1K and 10K depending on the phototransistor and the light level involved. You'd connect the junction of the emitter and resistor to the circuit shown in AN001 and use the code shown there (ADC.spin) to measure the voltage at the junction. The more light, the higher the voltage.

Post Edited (Mike Green) : 1/9/2009 5:49:05 PM GMT

01-10-2009, 12:56 AM
Hello James,

As Q is on holiday I try to help instead.

detecting white/black is easy as the difference in reflection-degree is big.
Deteccting white and silver as different depends on the difference of the reflection-degree between white and silver
for the red-light. I would do some basic testing about the current difference the photodiode has "seeing" white silver or black.

Does it have to be silver ?

Detecting white, green, and black combined with a red and a green light and a red and green filter would be much easier.

Anyway why do you need THREE colors to follow a line.

Post more about your concept. Maybe three colors is not nescessary or there are other solutions.

How big is the distance between the line the light and the photodiode?
Some millimeters? 10 centimeters ?

How about using a light to frequency sensor (http://www.parallax.com/Store/Sensors/ColorLight/tabid/175/CategoryID/50/List/0/Level/a/ProductID/88/Default.aspx?SortField=ProductName%2cProductName)?

The output-signal is already digital as it is a frequency no additional components needed.
Measuring a frequency can be easily done on one propeller-IO-PIN

As you can see from this little example. You posted more details about your project.
"Robot following a line "and the forum can make sugestions about alternative solutions
that are easier to handle.

best regards


01-10-2009, 01:50 AM

In June 2009 I am going to the WK/EK Robocupjunior. For more information about the completion go to http://rcj.sci.brooklyn.cuny.edu/rescue.html (http:// http://rcj.sci.brooklyn.cuny.edu/rescue.html ).
The distance between the line the light and the photodiode is about 1centimeter.

Before I had a Propeller Proto Board I have worked with Mindstorms NXT.
To follow the line and see colours I had used a light sensor shop.lego.com/Product/?p=9844 (http://shop.lego.com/Product/?p=9844) everything worked perfect.
But I wanted a new challenge and I had bought a Propeller Proto Board.
The light sensor worked with a photodiode and a red led.
I think I am going to buy a light to frequency sensor or some photo resistors.
I thought it was better to take photodiodes because they are much faster than photo resistors.

Thanks every body
Sorry about my bad English.

Best regards,

Joost Fijn

Post Edited (yoow007) : 1/9/2009 8:49:40 PM GMT