Troubles with Optical Switch with Totem Pole

Discussion in 'General Electronics Chat' started by Tomar, Jan 28, 2015.

  1. Tomar

    Thread Starter New Member

    Jan 28, 2015
    7
    0
    Hello ... I am brand new to this site, and a beginner in electronics. I have designed a circuit to count parts as they fall through the slotted optical switch. I have a prototype of the system operational, however, there are problems. I will include a schematic of my project, and the data sheet for the switch. The project involves counting parts about the size of a drop of water. The output from the switch goes to an Arduino, which is suppose to count the parts. In the sketch, I found that just by using "counter", the parts were twice as many that actually fell through. So the output is counter divided by 2. The system works fine, as long as the parts fall through slowly, around 1 per second. If I speed things up, to 3 parts per second, the count gets pretty far off. I have tried changing the interrupt to RISING, and LOW, but only RISING gives me the correct count, as well as FALLING. (Until things speed up.)

    I believe the problem lies with my wiring of the optical switch. I started with a 100 ohm resistor to the LED and worked up to 560 ohms. My reasoning was that the circuit is dependent on the LED, so the dimmer it was, the more accurate the reading would be. I added the 180 ohm resistor to the Totem pole circuit to see if this would improve things. I'm not sure it did anything.

    My questions are as follows:

    1. Shouldn't the output from the totem pole be 1 or 0?
    2. It seems like the output from the totem pole is erratic, hence the count divided by 2. Also, when things speed up, things get really erratic. How do I get rid of the erratic output?
    3. How do I wire this up so the output is 1 or 0?

    Thanks in advance for any help with this.

    Tomar
     
  2. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,689
    2,750
    You may get better results polling the pin and debouncing the signal in software (like you'd do with a switch) rather than using the interrupt.
     
  3. #12

    Expert

    Nov 30, 2010
    16,313
    6,817
    I'm going nuts trying to reconcile counter.png with the pdf of the opto. The pin numbers seem all wrong.
     
  4. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,689
    2,750
    I didn't look. I just assume his parts are partially interrupting the beam & giving multiple signal edges per part. Could be wrong.
     
  5. Tomar

    Thread Starter New Member

    Jan 28, 2015
    7
    0
    Sorry, the pin numbers may be wrong, I used the wire color in the pdf
    The pin numbers are wrong, .... I used the wire colors in the pdf .... sorry
     
  6. Tomar

    Thread Starter New Member

    Jan 28, 2015
    7
    0
    I am adding a revised pin number .png counter2.png
     
  7. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,689
    2,750
    You do have a common ground with the arduino, yes?
     
  8. Tomar

    Thread Starter New Member

    Jan 28, 2015
    7
    0
    Yes
     
  9. ronv

    AAC Fanatic!

    Nov 12, 2008
    3,291
    1,255
    Your original values should be good.
    The part is very fast, so I think Joeyd is correct in that you should only allow 1 count every few ms.
    Does it always count more than went through?
     
  10. #12

    Expert

    Nov 30, 2010
    16,313
    6,817
    OK. You software guys seem to have this handled.
     
  11. Tomar

    Thread Starter New Member

    Jan 28, 2015
    7
    0
    No, usually less.
     
  12. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,689
    2,750
    You said it was counting 2x.
     
  13. Tomar

    Thread Starter New Member

    Jan 28, 2015
    7
    0
    Yes, when the parts are moving through the slot at about 1 per second. If 3 per second go through, the count is low.
     
  14. ronv

    AAC Fanatic!

    Nov 12, 2008
    3,291
    1,255
    Maybe you need to guide them to the middle of the sensor?
     
  15. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,553
    2,375
    What is the exact nature of the object, the C.L. of the optical sense is .11" down from the top of the slot.
    For use with the Arduino I would have considered the O.C. version instead of the totem output.
    Max.
     
  16. Tomar

    Thread Starter New Member

    Jan 28, 2015
    7
    0


    I found the solution to my problem at this link:

    https://www.sparkfun.com/tutorials/326

    Thanks for your help!
     
Loading...