• #optical #photo #sensor #solid #state #switch #photosensor #enstop

    When something moving has to stay within limits, has to 'find zero' on power-on (calibration), or its particular position has to be detected, end stop / zero position detectors are to be used. There are several options:

    1. Mechanical switch
    2. Magnetic switch - reed switch, hall sensor
    3. Optical switch - photo sensor

    I opted for slot-type photo sensor, where LED generated infrared light exits a slot, passes a detection gap, and enters a slot to finally hit a photo transistor.

    I just had them on hand... and very quickly some surprises as well....

    Purple bordered inset in attached image of data sheet (modified page 1) shows my 'final' circuitry. The goal was to run with VCC = 3.3 V in order to not have to worry about pin input 5/3.3V compatibility and extra external components - even though it may be border line for the photo transistor to work.

    The selection of the resistor for the LED was simple... I decided to go first with a 10 [mA] current and related 180 Ohm.

    For the emitter resistor, I picked at first 1 K resistor, but it did not work with intended digitalRead(C4).

    To see what's going on, I switched to analogRead(C4) and added (prallel) ditigalRead(A8). Now I noticed some analog changes, but not enough to make a dent for the digitalRead(): they were in the realm of tens of millivolts... then I started to do some trial and error and testing all (four) sensor.

    I wondered why not better results... and you would not believe what it was: I used a piece of black plastic to interrupt the light flow. The plastic piece is about 1/16" / 1.8mm hick and is the actual lid of the car cassette tape player from where one of the switches was scavenged.
    For no reason I had a (light) dollar bill at hand and put that into the gap instead of the dark plastic piece and it worked! I thought I was smart to use the black, not shiny plastic which to the naked eye did not pass any light what so ever even when held against a bright light source, but obviously let the pass most of the infrared light. I'm now planning to mount a dollar bills on the machinery to enter the gap for zeroing... just kidding ;)

    On top of that, the first sensor I worked with was a failing - or extremely out average - switch (S_4), because the other 3 behaved in acceptable range. S_4 I could get to work by increasing the emitter resistor to 18 K.

    If all sensors had such a marginal delta voltage between on and off as the first one, I would have to add an op-amp as comparator to every sensor - so much about 'no extra external components'.

    I know that more modern devices are available that include amplifiers... but I would first have to order them. After all, my 'instant gratification' with things at hand was not really that 'instant'.

    For now, I hope my 0.4..0.5 [mA] are enough to resist eventual noise that could be picked up by unshielded, 6 feet long cable between the sensor and Espruino.


    1 Attachment

    • EE-SJ5_p1_Omron.png
About

Avatar for allObjects @allObjects started