Optical endswitch as "analog" sensor


These things are usually used as on/off switches, right? They usually come with a tiny circuit, which cleans out the signal to be true digital high or low. But what we see in the image is the core of the thing, which is a light diode (probably IR) and a phototransistor. These can be set to produce an analog signal.

Do you have experience in using these sensors as analog sensors, where the magnitude of the analog signal would be of interest? I might test this at some point, but I'd like to know if someone has tested this in any way before.

I'm working on a music box, which will play music decoded on laser cut paper strips. So far the idea is that this kind of sensor only detects when a paper strip is fed into the machine. This will start the motor. And of course it will detect the end of the paper strip.


This is how the paper strips look like in my laser cutter software. The green horizontal lines mark the 70 mm wide paper strips. The tiny circles mark the coded music.
My idea was to cut holes of different sizes near the edge of the strip for the sensor to read. The size of the holes would be measured by the sensor. This could give me a way to code tempo variations in the music. Or set the tempo in the beginning. Tempo variations in the middle of a tune can of course be achieved by widening or narrowing the gaps between holes, but as my system works now, it just reads note values and places the holes to a grid according to that.

So the sensor should be able to detect paper (no light), no paper (full light), and, minding a threshold for full light and no light, a region somewhere inbetween, which could translate to tempo settings from 60 to 120 BPM, a precision of 5% to 10% might be enough. Note that the Arduino involved would do nothing more than monitoring the sensor and adjusting the motor speed accordingly. All music happens in the mechanical music box.

Hi,
Like they place the sound track on the side of film.

It would be interesting to experiment, I have in my travels seen photo-interrupters in pairs used to centre a flag on a lever.
The flag obscures the LED to Opto-Transistor path equally in both units when it is centred.
Each unit returning the same analog signal.

Get you Arduino out, an opto-coupler and see with the analog input of the controller.

Tom... :smiley: :+1: :coffee: :australia:
PS, You won't damage anything with a simple circuit and a strip of paper with various hole sizes in it.

Before you get too involved in designing this project, test your sensor with paper to see how much IR goes right through your paper.

The phototransistor requires a load resistor to produce a signal, and the voltage at the junction could be read by an Arduino ADC. Just choose a resistor value that gives a reasonable signal swing and you are all set! The LED intensity can also be controlled by choice of resistor, to set a reasonable operating level.

An off the cuff first impression: It may be easier to use the interruptor in its designed on/off sense mode and decode tempo info by varying widths of dark/light - think barcode encoding.

I thought the same but from what I gather Tempo is speed of the tune, so the speed of the paper strip will be changing on a change in tempo.
So any timing of the opening in the strip will be different on each tempo change.

Tom.. :smiley: :+1: :coffee: :australia:
PS, I hope I explained it well, Blood level in Caffeine Stream is still a little High.. :coffee: :coffee: :coffee:

Yes. But, if you could get speed info from a roller, or the motor control, that could be accounted for. The mark/space ratio would be the same at different speeds.

Great replies, thank you all.
My first thought was to cut small slices of varying width to produce varying analog signals. But after your suggestions I might skip the whole analog approach and just create a binary barcode kind of thing. One start mark that sets the timing, then maybe five to eight bits with data.
So far I have no Arduino attached, and no motor either, for that matter. Just cranking by hand the music box. But the next step will be building a box, where you just feed in the paper strip through a slot and it starts to play, reading the tempo as well as tempo variations.


J. S. Bach: Prelude 1 from Das Wohltemperierte Klavier 1.

Hi,
Nice project.
Would like to see your final outcome.
The laser cut looks really good.

Tom.. :smiley: :+1: :coffee: :australia:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.