Troubles with Optical Switch with Totem Pole

Thread Starter

Tomar

Joined Jan 28, 2015
7
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
 

Attachments

joeyd999

Joined Jun 6, 2011
5,234
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.
 

#12

Joined Nov 30, 2010
18,224
I'm going nuts trying to reconcile counter.png with the pdf of the opto. The pin numbers seem all wrong.
 

joeyd999

Joined Jun 6, 2011
5,234
I'm going nuts trying to reconcile counter.png with the pdf of the opto. The pin numbers seem all wrong.
I didn't look. I just assume his parts are partially interrupting the beam & giving multiple signal edges per part. Could be wrong.
 

Thread Starter

Tomar

Joined Jan 28, 2015
7
I'm going nuts trying to reconcile counter.png with the pdf of the opto. The pin numbers seem all wrong.
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
 

ronv

Joined Nov 12, 2008
3,770
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?
 

MaxHeadRoom

Joined Jul 18, 2013
28,617
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.
 

Thread Starter

Tomar

Joined Jan 28, 2015
7
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


I found the solution to my problem at this link:
https://www.sparkfun.com/tutorials/326
https://www.sparkfun.com/tutorials/326
https://www.sparkfun.com/tutorials/326
Thanks for your help!
 
Top