Triggering PICAXE inputs with photointerrupters

Circuit

Senior Member
I need to use photointerrupters as limit switches on a PICAXE project. The ideal size of device for my project appears to be met by the GP1S094HCZ0F from Sharp. (datasheet- http://docs-europe.electrocomponents.com/webdocs/0d1b/0900766b80d1bdb9.pdf ).

The sheet shows the wiring thus;
photointerrupter.JPG
I have placed RL in the diagram with a 10K and I am powering the IR-LED from 5V with a 180R (RD)resistor intervening - I measure 20mA through the diode.
When I put a voltmeter at the point marked "Output" on the diagram I get 5V when the slot is blocked but when open the voltage remains around 3.1V. It is very consistent; open slot 3.1V; occluded 5V.
Now I guess that I could be using the ADC to detect this, but I would prefer to be using a high/low; where I am going with this? Do I need another intervening component or am I choosing the wrong photointerrupter - or using it incorrectly?
Advice from the global experts would be most appreciated.
 

techElder

Well-known member
GP1S094HCZ0F is a compact-package, phototransistor output, transmissive photointerrupter, with opposing emitter and detector
Not much information in the "data" sheet, but assume the LED is a visible light source. Be cognizant of letting extraneous bright light into that slot.

You didn't say anything about any requirements on the speed of detection, or whether the detection is for "vane present" or "vane absent."

As long as the low voltage output can be detected, a digital input can be used, but test that under various environmental conditions. Also, consider using a schmitt input.

Consider changing the resistor RL to higher values and see how that affects your low output voltage. Less current through the transistor will change the output voltage.

EDIT: Sorry, Circuit, I didn't get all the pages of the datasheet on first try.
 
Last edited:

AllyCat

Senior Member
Hi,

The first part of the data sheet is rather misleading in referring to a collector current of 20 mA. If you look down to the "Electro optical" section, the collector current with 5 mA diode current is only between 40 and 400 microamps. Scale the diode current up to 20 mA and you'd expect a collector current of 160 - 1600 uA.

160 uA through your 10k collector load will drop 1.6 volts (from 5 volts) to give a collector voltage of 3.4 volts. So what you've measured is consistent with the "low end" of the performance specification. Maybe there is a fault, or perhaps you've just got an "unlucky" device.

Note that the saturation voltage is specified at 10 mA diode current and 40 uA in the collector, which represents over 100 kohms pullup to 5 volts! Also the response time is specified at 100 uA into 1k, that's only a 100 mV pk-pk square wave !

In practice, you probably just need to increase the collector pullup resistor to 22k and use any digital input.

Cheers, Alan.

PS: The data sheet on page 6 says it uses Infra Red (950 nm).
 

Circuit

Senior Member
Gentlemen, thank you - you have solved my problem and most speedily as well. I am most grateful.

I increased the value of RL to 100K and the value of RD to 330R.
This now registers an IF of 11mA through the diode.
The output voltage is now 0.146V when the slot is open and 4.97V when occluded.

Alan, a spot more advice if I may...there is a note on page 6 of the datasheet regarding taking degradation of the IRED into account. This amounts to 50% over 5 years. The device I am working on will require constant illumination of the IRED and therefore would it be better to increase the IF of the IRED to the 20mA as in the section on Page 3 -"Electro-optical Characteristics" (given that the absolute max rating is 50mA) to allow for fading, or would it be better to work it at a lower current as I am now with the view that the output will remain stronger for longer if not so stressed?

Again, my thanks.
 

AllyCat

Senior Member
Hi,

Yes, generally any additional heat (power dissipation) will accelerate the "degradation" of most electronic components, so I'd be inclined to keep the LED current lower in the range of 10 - 20 mA. The data sheet indicates that even at elevated temperatures the leakage in the transistor should be less than 1 uA, so up to 1 Mohm might be possible, if speed (risetime) is not an issue.

Therefore, the main problem might be the effect of any stray light, which doesn't seem well documented. There is a reference on page 6 to using an "Opaque board", but I can't really see what is intended. It will depend what your ambient light level might be, so you may need to do some experiments. A traditional solution is to use modulated light, but that's a considerable complication, better avoided if possible.

Cheers, Alan.
 

techElder

Well-known member
Circuit, consider the seriousness of a failure at the interrupter and make appropriate adjustments.

With correct wiring, you could double up on the interrupter if a failure would have very serious consequences.

Regarding the ambient light exposure, I once ran across a system that had intermittent problems that someone thought was the limit switches. I opened the back up and caused all manner of problems just by shining my flashlight around.
 

hippy

Technical Support
Staff member
On the degradation of the IR LED it might be worth temporarily increasing the Ro resistor, decreasing the current and dimming the LED, to see what effect that has on the output.

The more you can push Ro up with the output still working, the less problem there is likely to be with degradation. It may prove to be something you don't have to worry about.
 

Circuit

Senior Member
Thank you again; all suggested experimentation validated.
Alan/Hippy - I ran the RL to 1Mohm as Alan proposed and the device does indeed still work but I suspect the rise-time may be an issue as you say. I also tried reducing the current in the IR-LED as Hippy suggested and the gate still triggers satisfactorily with an IF of 5mA. Much less and it collapses. I am coming around to the idea that the value of RL at 100K and the value of RD to 330R is about optimal. This gives an IF of 11mA through the diode and a very satisfactory switching differential of 0.146V when the slot is open and 4.97V when occluded.
Tex, I think there is little value in doubling up the devices because they would both fade at approximately the same rate, sharing a similar life expectancy. As it is, the device is non-critical, it would just be a major nuisance to swap in 5 yrs time. Regarding your comment on ambient lighting, yes I am aware of that issue and the device will be in a dark enclosure. Interestingly, I thought that perhaps I could use black Perspex as the blade in the slot but it turns out that not only is this IR permeable, but it actually increases the illumination of the detector, acting as a light conductor. I didn't expect this because 3mm of black Perspex is totally black to visible light.
 

Circuit

Senior Member
Given Alan's indication that the value of 1M for RL could work - and that I verified this experimentally - together with my decision to optimise the value at 100K, I suddenly thought on that the weak pull-up on the 14M2 that I am using is in that region. So I removed RL and activated the pull-up and it works beautifully. However, I have not used the pull-up in this type of situation before...are there any disadvantages that I am oblivious to?
 
Top