View Full Version : OT- photo interrupter question

02-04-2012, 10:14 PM
I wonder if anyone here has any direct experience with photo interrupters-

What I want to do is use one as a linear device. A disc of smokey plastic will pass through the gap, and the disc is tapered in thickness around the edge. Where it is thin, the most light will pass, and where it is thick less light will pass. I want to produce a variable voltage as the disc is rotated. I know this will work, and I can figure out how to bias both the emitter and the detector to give a more or less linear output voltage as the disc is rotated. I am wondering though how stable the translation would be. In other words, a year from now will I be able to rotate the disc to say 5.5 on the scale of 10, and find that the output voltage is still 5.5 on its scale of 10? Or will it have drifted? A related question is will it drift with moderate temperature changes?

A PI device is normally used in a switching mode, where you choose the parameters to ensure a full on and off condition. In all my years in electronics, I've never tried to use one in a linear or analog fashion. Thanks for any enlightenment anyone can offer.

02-04-2012, 10:18 PM
Not sure about photointerruptors, But I know optoisolators are known to loose gain with age. Also you might consider the propertys of the plastic might change, and it might get dirty.

The Artful Bodger
02-04-2012, 10:19 PM
All I can offer Darryl that in days of long ago when they were using a light on a photo tube or somesuch they would use things like a tapered slit in a moving mask.

I fear one problem with your scheme would be having to keep the surface of the plastic clean to achieve reliable transmissance of light.

02-04-2012, 10:25 PM
It will vary over time, as that is the nature of nature. Aging of components, variations in voltage, accumulation of stuff on the disc, the basic changes over time the PI will experience. The system will have to be calibrated regularly.

Whether that regularity will have to be daily, weekly, monthly or annually, will depend on the quality of the items in the circuit and the feedback/redundancy you build in.

I would expect you to be able to build an item which will be stable to within 1% or less over several years, with care. Keeping the disc clean will be the hardest part, I think. I have designed and built control circuits that are within 2% of design specs after 25 years. All are operating in controlled environments, however, and none are using a PI for analog purposes.


Bruce Griffing
02-04-2012, 10:32 PM
Photo interrupters are designed to be inherently non-linear. So I would not use one. You could accomplish your goal with an LED photodiode combination. Depending on the accuracy you need, you may have to either control the LED to a constant output or measure its output in another channel and use a division circuit to maintain accuracy. For this application, I would use a PIN diode operated into a virtual ground (transimpedence) amplifier. I am not sure what you are trying to do - a little more detail on the problem would make it easier to suggest a solution.

02-04-2012, 10:34 PM
It will vary over time, as that is the nature of nature. Aging of components, variations in voltage, accumulation of stuff on the disc, the basic changes over time the PI will experience. The system will have to be calibrated regularly.

Whether that regularity will have to be daily, weekly, monthly or annually, will depend on the quality of the items in the circuit and the feedback/redundancy you build in.

I would expect you to be able to build an item which will be stable to within 1% or less over several years, with care. Keeping the disc clean will be the hardest part, I think. I have designed and built control circuits that are within 2% of design specs after 25 years. All are operating in controlled environments, however, and none are using a PI for analog purposes.

I second that , also PI 's are not always reliable in a dusty enviroment.

02-04-2012, 10:34 PM
In the 1970's I worked on an autopilot design for private boaters. It was common at the time to use compasses with a photo cell and light source and a compass card with one half opaque and one half transparent. With mechanical feedback from the rudder it was possible to hold a reasonable coarse.

The system I worked on had a gradient compass card as you describe and as such needed no mechanical feedback. After much experimentation it was found that fixed-width opaque radial lines with varying transparent spacing produced the most accurate analog output. The lines were very close together at the least transparent and quite far apart at the greatest transparency. It also was unaffected by gimbal errors. Our greatest source of error was the incandescent lamp filaments throwing uneven light, and poor voltage regulation. Solved with LED lamps.

02-04-2012, 10:49 PM
Some photo interrupters are quite linear and others are not. Assuming you have one with a linear photo transistor the problem will lie with the IR emitter. In that application it will most likely have a rated lifetime around 100,000 hours. Usually, the lifetime rating of an LED is based on the time it takes to drop to 80% brightness. None of this is guaranteed but those are pretty common values used in the industry.

02-04-2012, 11:20 PM
Thanks for the inputs. I have considered the effects of contamination- and possibly it will be more than I would be willing to deal with. In the last hour or so I've also been thinking that milling the taper on the plexiglass disc will be troublesome. The machining marks are likely to interfere with a smooth translation of the rotation of the disc to the output voltage.

What I want to achieve is a linearly varying voltage with rotation of a shaft, with no contact. That leaves out potentiometers- otherwise that would be the choice. I also want to keep the circuit simple, as that is quicker to build, smaller, and usually more reliable.

Much more immune to contamination would be a frequency to voltage converter, using a pair of rf oscillators at its heart. One has a fixed frequency, while the other has a variable capacitance in its tuned circuit. An offset aluminum disc sits between a pair of tuning plates, and as the disc is rotated the frequency shifts. The chip produces a voltage based on the difference in the two frequencies. I know this works, but it's much more complicated. Maybe there's a chip out these days that does all the work with little in the way of outboard components- I'll have to look into that.

I've tried to think of a way to do this magnetically, say with hall effect sensors, but I don't know if it would be any better than the photo interrupter method. There could also be some effect transferred to the shaft by using magnets. Ideally, I would avoid anything responsive to magnetic fields, as there's likely to be external magnetism in varying proportions nearby.

I could still go optical, using a device which would average the light coming through an area on the smokey plastic. That would mean a spot of light, not a narrow slit of light, and this should help to cancel out irregularities in the smokey plastic vane. This would be a bit more immune to dust, but still would be affected by debris like hair, etc. As far as the emitter led, I can operate it at a lower level which would prolong its life and probably make it more stable. This might be required anyway to get the detector to output in its linear range.

The Artful Bodger
02-05-2012, 12:04 AM
Magslip/selsyn transmitter?

Bruce Griffing
02-05-2012, 12:23 AM
You could build a rotor with a varying width of metal on an insulating substrate - pcb for example. Use a couple of fixed capacitor plates and a high frequency source to couple to the rotating strip. Plan the design so the coupling increases with angle as you rotate the wheel. Then sense the level of high frequency present.

Paul Alciatore
02-05-2012, 12:25 AM
I have worked with such systems and can confirm the aging behavior. I once had to replace a photo-diode detector assembly that had nine diodes precisely located on a PCB and epoxied in place. The old one was about 10-12 years old and had degraded just enough to cause erratic operation. Fun to see a 30" diameter wheel loaded with 2" video tape cassettes the size of bricks oscillating at high speed. The whole machine would move about on the floor if the cassette load was not even. The accountant thought a $1000 price tag for an item called simply "diode" was something to question. I guess he had been to Radio Shack and saw diodes for 98 cents a dozen.

There are different types of detectors and some incorporate high gain which makes them only useful for digital output: hi or lo. A simple photo diode detector can be operated in a linear fashion and can last for many years with occasional adjustment of the circuit if needed. I would just be sure to leave provision for this in the circuit. The aging situation is something you can live with if the application is not too critical.

On the other hand if you need a precise and stable output, I would consider using an encoder wheel and a digital to analog converter. You will need some circuitry between them: probably just an up/down counter and a chip or two to drive it. D-A converters are relatively cheap and very available in a variety of precision levels. Get an encoder wheel with the extra indexing hole to mark the ends of the rotation and maintain absolute positioning as it turns.

02-05-2012, 01:25 AM
Magnetically driven rotary indicator with rotational position feedback. There's much more to this that I want to talk about at this time, but that's the gist of it. It's a mechanical display under electronic control, having inertial damping, controllable settling time, and high resolution and repeatability for even small changes in the input.

'measure the strength of the high frequency present'- that's another way to do it.

I don't mind the need to do an occasional calibration, and in fact there would be a control to calibrate it in the first place.

I could arrange my own emitter and detector setup if it would be better than existing opto devices. But I know that capacitive devices operate very well, smoothly and consistently. It's more complex, but I would only have to develop it once. Now I'm going to try to think of as many ways as I can to alter the frequency of a signal reliably without snags.

It could turn out that the encoder feedback idea is not any more complicated than capacitive or frequency change based methods. I'll have to look into that then as well.

thanks for giving me all these ideas ( I think :))

02-05-2012, 01:32 AM
You could print a gray code on a disc and get absolute position from that. You will need to decode it, you can use a little microcontroller to do that.


Also you could use an open frame brushless resolver.


02-05-2012, 01:45 AM
Angular resolvers are a quite accurate method of providing both angular position, but also rotational direction and rate of change.


EMI used quadrature resolvers to provide synchronized sweep of the PPI screen on their radar systems - it ensured the radar antenna and the display's rotating sweep pointed the same direction relative to the vessel's keel line.

The Artful Bodger
02-05-2012, 02:58 AM
Resolvers, close relative of the magslip/selsyn family of devices. My recommendation too.

OT, I salvaged a mast head radar scanner from the wreck of a Taiwanese deep sea fishing boat on a remote South Pacific island (Niue). It ran into the island in the middle of the night at full cruise speed and managed to get well above high water mark. When we got the scanner done and took it apart I found a small resolver(?) geared to the scanner main shaft, the grub screw was loose!:eek:

02-05-2012, 03:27 AM
The only bad thing about resolvers is they cost a small fortune. Try and find one on ebay. Something like this might work:


Use one of these to interface to it:


And the send the data to a digital to analog converter to get your voltage signal. You might need a microcontroller to glue it together. An arduino would be more than powerful enough to do this.

The Artful Bodger
02-05-2012, 03:44 AM
I dont understand exactly what you are trying to do, big or small budget, resolution/precision etc, however I made an aneomometer, wind speed and direction, once which had only two wires coming down the mast.

I had a permanent magnet that was connected to the wind speed cups and swung past two pickup coils, one coil was fixed in position and the other was fixed to the wind direction vane.

As the cups turned the magnet swept past one coil then the other, the two coils were connected in series but were reverse connected so that one induced a positive going pulse and the other a negative going pulse. Measuring the rate of pulses gave wind speed and the phase between negative and positive pulses gave wind direction. There was one dead spot where the two coils were being swept at the same time, I could have avoided that by running another pair of wires.

Does that give you any ideas?


02-05-2012, 05:32 AM
But how do you know what direction the wind is blowing when there is no wind!??

That is a pretty neat idea.

02-05-2012, 05:39 AM
How about something like this;


02-05-2012, 07:17 AM
Behringer use opto sliders in the cross faders in their DJ mixers

they can be had cheaply..



(oops ...just read the word rotary....)

02-05-2012, 07:54 AM
I would like to dissuade you from trying to use an optical method, there will always be dust and degradation. If you insist, work up some kind of differential measurement, so you are at least compensating for it a bit.

In general, all nasty environment sensors use magnetic methods. You could use capacitive as well if you can garuantee no moisture/oil/grease.
Don't dismiss hall effect because of the magnetic field, there are plenty of hall sensors used in electric motors. You don't always have to shield them.
Eddy current sensors don't care for the rest of the magnetic field.

If your indicator doesn't have to rotate more than one revolution, you could use something like a differential hall cell (=one part) with a bias magnet, looking at a moving edge.
Real fancy solution would be two linear eddy current displacement sensors, looking at an eccentric target.
I could go on forever, but you'll need to give some more information to the rest of us regarding:
- location options for the sensor (radial, axial on/off axis, space)
- environment/contaminants
- cost target
- accuracy target (most imporant)
- misalignment of shaft
- complexity of the electronics
- do you need a linear output signal from the sensor
- 1-off, or 1 million

(currently trying to whip up a shaft displacement sensor on my day job)

02-05-2012, 09:33 AM
You could consider using two discs of polarized material - one rotating, one fixed, with light passing through both. Light transmission will cycle from min to max twice per rotation.

To get away from dirt contamination issues, you could use a magnetic circuit with a linear Hall Effect detector such as those made by Allegro. Take an iron disc and cut the surface on the bias so that the edge wobbles when the disc rotates. Set up a circuit to read the distance between the edge of the disc and a stationary magnet and Hall Effect detector. In this case, you get one min/max cycle per rotation. If the disc is turning fast, remember to balance it.

For us old timers trained in analog electronics, these methods can be used to coordinate actions to rotating motion without getting involved with digital encoders and microprocessors.

02-05-2012, 04:19 PM
Gentlemen. I appreciate all of your input. A few answers- first, this is a one-off at this point, and not likely to exceed a dozen or so units in total. It is basically a voltage measuring device, with the display being a single very narrow led shining through from the back of a scale printed on photo paper. The led is rotated for almost a complete circle, at a diameter of about two inches. In other words, the scale is circular, and the total device has to fit within about 2x2 inches height and width- length behind the panel can be up to about 3 inches. This is not a lot of room for actuators, circuit boards, etc. It will have to be enough.

I will likely be using a small dc motor to direct-mount the led arm onto. Because there will be some friction, I will need a method of determining the position of the led, then send that signal into a comparator and then a current driver circuit to run the motor. There will be some critical adjustments to make in the design to provide critical damping for the motion of the led.

My questions have related only to the method by which the rotational degree of the motor shaft is detected.

This method of providing a readout has a few inherent benefits to me, some of them strictly personal. I don't like digital displays for one thing. For another, I like the fact that an analog display can give an appropriate indication of small changes, whereas a digital gives a meaningless shifting of numbers. An interesting benefit, again from my perspective, is that I'll have not one, but two leds serving as the 'pointer'. One will light to indicate on one scale, while the other lights when the full scale parameter of the first has been exceeded. Where this will be important to me is reading current draw. The scale would be in two parts, one reading up to say 200 ma, the other possibly to 20 amps. You can't resolve a 20 or 25 ma draw on a 20 amp scale, and you can't resolve a 3.5 amp draw on a 200 ma scale. This display device will give it to me automatically without me having to switch anything.

By the way, the scale is calibrated after all the electronics and mechanics are built and tested. Whatever non-linearities exist across the full scale will be eliminated in the actual reading. When a re-calibration is required, it should be possible to keep the entire scale accurate at all points along it to a close degree.

Weston Bye
02-05-2012, 05:02 PM
Some years ago I was tasked with coming up with a cheap method of measuring armature position in a solenoid. As a proof-of-concept I came up with an optical method using a retroreflective sensor like this:


The device bounced the beam from an LED off the back of the armature back to the phototransistor. While the output was not linear, (see the charts on the device) it was repeatable and reliable. This was a linear application, but a rotary target with a varying grey scale, possibly shaded to compensate for the curve in the sensor output, would work.

I have also done a lot of work with linear Hall sensors. Again, in mostly linear motion applications. Surprisingly, I have had good results in environments (transmissions and differentials) contaminated with ferrous chips.
You might consider a rotary application where the rotation turns a screw with a magnet on the end. Turning the screw would move the magnet closer or farther from the linear Hall sensor, with a corresponding truly linear output.

Another possibility would be to position the magnet eccentrically so that the rotation presented the boundary of the magnetic field to the sensor, varying the field strength with rotation. This would require some experimentation.

I authored a pair of articles in the Summer 2008 issue of Digital Machinist on linear Hall sensors and simple rotary encoders.

02-05-2012, 05:03 PM
Behringer use opto sliders in the cross faders in their DJ mixers

they can be had cheaply..


I see nothing that suggest this part is 'optical' in any way, And as it suggests it can be used as replacement for existing mixers, and is only $12 (VERY CHEAP for a mixer slider!!!!), I suspect its just a medium/low end electromechanical slider control.

The Artful Bodger
02-05-2012, 06:30 PM
But how do you know what direction the wind is blowing when there is no wind!??

That is a pretty neat idea.

You have no idea how hot it gets around here when we have a blistering 'northerly calm'.:D

The Artful Bodger
02-05-2012, 06:36 PM
First generation consumer level echo sounders for boats had a spinning wheel behind the scale carrying a small led that flashed at the appropriate position around the scale............but I think that might be the opposit to what you want to do.:o

02-05-2012, 06:54 PM
Hm- I could use a hall sensor with a magnet, then have a cam disc between the two. The disc would be steel, and would slowly interfere with the strength of the magnetic field reaching the hall sensor. Seems like it would be sensitive to other motions besides strictly rotary motion. I'll have to think about that. It probably can be done successfully though. I think the cam surfaces would have to be very smooth to avoid errors due to flux pinning.

No different than doing it optically, in that regard. The optical disc would have to have very smooth surfaces as well to prevent optical distortions from creating errors.

I can make the housing to be a sealed unit, so dust may not be a problem. Variable moisture could be a problem, but a sealed unit could have some silica gel included within it to combat this.

Well, I must get out and enjoy the day before it gets dark.

02-05-2012, 07:32 PM
First generation consumer level echo sounders for boats had a spinning wheel behind the scale carrying a small led that flashed at the appropriate position around the scale...

My recollection is that they used a neon lamp.

02-05-2012, 07:58 PM
Darryl, if you have a regulated supply you could use an incandescent bulb. If they are run at 80% of rated voltage they will produce about half the normal light but will last 200 times as long with very little change in brightness. A 756 14 volt mini bayonet pilot lamp bulb is rated for about 7000 hours. Run it at 9 volts and it will last longer than we will. At full voltage it draws 80 ma so should only draw around 50 ma at 9v. It should be run on ac to prevent darkening but at that low voltage DC won't be much of an issue. You can do the same with just about any small incandescent pilot light bulb.

For a sensor a small amorphous silicon film solar cell from a calculator will provide a very linear and very consistent sensor. They are sensitive to red and near IR. They are extremely linear with light changes and have a nearly flat curve with temperature from zero to 80C with a change of only about 2% over that range.

02-05-2012, 09:34 PM
I haven't been following this thread very closely, but every time I do get into it a thought keeps recurring: this sounds very much the same basic operation as a light meter. (For what it is worth, my other business is photography.)

I was doing some research for a student this evening and ran across this entry on google, which might be of some interest to you (or not, as the case might be. :D )


The basic search algorithm was "light meter schematic."


The Artful Bodger
02-05-2012, 10:11 PM
My recollection is that they used a neon lamp.

Maybe they did, I dont remember exactly.

02-05-2012, 10:15 PM
wow- I've never seen so many schematics on one page at one time. I guess there are a lot of photographers with interest in light meters-

In any event, yes this is basically a light meter on one side and a light source on the other. I can mount the whole thing inside the case so that no external light can interfere. I've been thinking about this more, and have decided to try the optical way. I've just been in the shop making a disc holder with which I can mill the side of the disc to give a steady decrease in the thickness of the outer part of the disc while still leaving about 20 thou of thickness at the thin end. I'll take some pics when I have one milled out.

Evan, I'm not sure how much brightness I'm going to need, but offhand it seems like an incandescent would give too much, although it can certainly be controlled down to any level. I have some grain-of-wheat bulbs I could use, but I'm intrigued by your idea to use an incandescent instead of an led. I can also run the led at a lower level, which should allow it to give a very steady light output for a long time. Possibly your idea to use a solar cell dictates the use of the incandescent, since any that I've tested recently respond poorly to leds, visible or otherwise.

You're saying the amorphous cell is very linear with light changes and temperature. Linear in what sense- current output, or voltage output? I'm thinking current, since voltage is going to hit a knee at some point, depending on how many cells are in series. In other words, you would probably use a load resistor with it, and measure the voltage across it with a high impedance input- probably a fet op amp with some gain.

I'm concerned that the cell would be too large also to work with the small area where light would shine through the disc. Maybe not- maybe all I have to do is define a small area where light hits one side of the disc, then the cell can pick up what it can from the other side. The dot of light might be 3/16 of an inch across, possibly as large as 1/4 inch. Any larger and it won't be confined to the tapered edge and errors will exist.

Have to go now- I'll check back later.

02-05-2012, 10:22 PM
My recollection is that they used a neon lamp.

The first ones I worked on, Apelco and Raytheon, did. The LED's came later but were not popular owing to being nearly invisible in daylight. That lead to a plethora of digital units and since they could not find anything reliably except the bottom, they were also a tough sell.

Digital LCD screens finally brought back viewable multi-feature (meaning targets at multiple depths) depth/fish finders. Commercial systems used wet and dry paper, and metalized paper like the original drum FAX systems had.

Some refinements were added to prevent double bounces - when the echo would bounce off the bottom then off the surface then off the bottom again. We (BenMar) used a tracking window that was adjustable. It was a squelch window whose position and width in time could be initialized by the user, and which would track bottom changes automatically while preventing false alarms from multiple bounces.

02-05-2012, 10:30 PM
The dot of light might be 3/16 of an inch across, possibly as large as 1/4 inch. Any larger and it won't be confined to the tapered edge and errors will exist.

At least one autopilot compass I'm familiar with used a transparent wedge that wound around the compass card. It was also sensitive to the poor light distribution of incandescent lamps (a problem that plagued hobbyist photo enlargers, too). This is seen in light patterns from flashlights, for example. Even with the reflector removed, the light thrown by small lamps, including LED's, is rich with intensity variations.

It was only when we went with the "bar code" mask that we removed all such sensitivity. Our original thought was to use dot gradients such as used in news print and that was a disaster.

02-06-2012, 02:20 AM
Well, I machined up a test disc. My jig worked, but since I'm turning it by hand I've got stop and start marks on the taper. I tried to take a picture but I couldn't get one in focus- something's funny here. I don't know how to use the camera, obviously. Try again tomorrow.

Anyway, the smokey plastic is 1/8 thick to start with, and my jig advances the disc towards the endmill at the rate of .1 inch per turn. I end up with .028 or so at the thinnest, and of course .125 at the thickest. Holding the disc in front of the computer on this page, it almost seems as if it's too much light coming through- I can still read these words through the thickest part of the disc. Against a bit darker background the contrast is better.

I will have to experiment to see how an emitter/detector pair will work with this.

Before I do this, I will need to clean up the machining. I used an end mill to start with- now I'll have to switch to something else to refine the result. Not quite sure what- maybe I'll try the carbide straight sided router bit.

I wasn't sure how to bring the machined surface back to looking glossy, then I tried NeverDull- that worked pretty good actually.

Fun fun fun.

02-08-2012, 01:19 AM
In case anyone is interested- I just did a test with my smokey plastic disc and a photo-interrupter. It seems that in order to give a good range in output voltage from the sensor, I have to operate the emitter at a fraction of a ma. At the same time the sensor has to be fed through a very high value resistor, otherwise I don't even get a full volt of range as I rotate the variable opacity disc through the slot.

Currently (sic) I'm feeding .00025 amps through the IR emitter. That is enough light through the thin part of the disc to almost bring the voltage across the sensor down to zero. With a 1 meg resistor in series with the sensor, and the thickest part of the disc in the slot, I can get up to about 2 volts. That's not a bad range of voltage to work with, but I think that's too low a current to run the sensor at. Chances are leakage currents will affect the voltage as temperature changes. Now I need to look up some technical specs for these devices to see if there's a stable region of operation to shoot for.

As far as the emitter, I don't think there's going to be any aging problem running it at 1 ma or less-

02-08-2012, 12:31 PM
Unless there is a completely overwhelming reason to make this directly analog, I'd think using an IR LED and some phototransistors to read a scale like the one in the wikipedia article below would be much more reliable than your solution although the complexity could get a bit high if you need a lot of resolution. On the bright side however, you can do all of the markings with paint rather than trying to mill the plastic.

See http://en.wikipedia.org/wiki/Rotary_encoder for examples of the types of patterns you can use.

If you're into digital electronics, you could read a numeric representation of position into a microcontroller with an absolute encoder of the type in the article and control the whole system digitally like this. Alternately If what you are doing truly requires an "analog" signal and you aren't going to use a microcontroller then I would latch the results from the encoder and feed them into a analog to digital converter. This would require a latch, a a voltage reference and an ADC and also, possibly a clock for the latching.