photoelectric sensor feasibility

Originally it was my intent to take the wire from the sensor itself and wire the other end to a usb and plug it into my computer. Im a hobbyist programmer and so im still learning the basics so im not sure how to go about reading it that way so i had the epiphany that I could just use my arduino for the same effect. I just started my degree for computer science and I'm a complete novice with electronics so I'm not sure if my original usb idea would have even been possible. the above link is to banner electronics and that specific sensor and has all the data required hopefully.

my question is how would i wire this sensor to my arduino.

It looks like you require a power supply of 10-30 volts DC at up to 35mA. So say 12 volts DC.

The 2 outputs of the device you have appears to be NPN transistor (open collector) outputs. You need a voltage divider for each output to ensure that no more than the maximum voltage appears on the arduino pin (for a Uno, its 5 volts)

Each voltage divider would be made of 2 resistors, say 12k and 8.2k (for a 5 volt arduino and 12 volt power supply for the device) :

``````  +12v ----- 12k resistor ----- device output ---- 8.2 k resistor ---- Ground ( common)
``````

You'd connect the arduino pin to the point marked device output and the ground of the Arduino to the ground of the device.

Also look at an opto-coupler as an alternative (and possibly nicer) way of doing this.

Im using a machine at my work as my guinea pig. Its a folder gluer machine and we run up to 16000 pieces an hour with some of the boxes being about 1/4 inch thick. would the optocoupler handle that? or are you saying i would wire the sensor through the optocoupler? I tried to attach a picture with the wire diagram but the picture was too large of a file.

BRN: +dc BLU: dc BLK: N.O. output WHT: N.C. output

You could wire it like this:

16,000 readings per hour is the equivalent of less than 5 Hz . An opto coupler pair would also work to better isolate the Arduino from your sensor. How appropriate your sensor is to your application is something I can’t judge.

If it is indeed open collector output, all you need is a pull-up from Arduino pin to Vcc (+5V), connect pin to output, and connect the grounds. For that you can even use the built-in pull-up resistor, so no external components needed at all. The same way for connecting 3.3V devices to open collector output.

Thank you, and the wiring diagram is EXTREEMLY helpful ,but whether its an appropriate sensor i wouldn't know. these are the sensors that trigger our glue computer that's all i know. since this is what my job uses and stocks its why im wanting to use it.

For my project, the sensor is just to count boxes. i also want to do something like a tachometer to read the speed of the machine. the arduino would have to log both the rate of boxes per hour and the speed of the machine so that the data could later be graphed. right now my plant has a system that simply counts boxes but doesn't keep track of the machine itself which got me thinking and i started throwing around ideas. I know that is redundant and probably stupid but its mainly just a learning opportunity since i havent really done anything interesting with my arduino and im still new to the world of electronics. i also want to do a windows forms app that would receive the data and then graph it and do all the fun stuff. Obviously the Arduino would have to be able to store all of the data until I could get it home and plug it into my computer and upload it to that. but i wanted to start with the sensor and see if it was even possible

OK. The diagram I supplied could even be simplified as @vwmarle pointed out in the case that you are using a sensor dedicated to your application. If, however, you are simply going to 'tap in' to a sensor which is currently also being used for something else, like the gluer machine, you have to be much more careful. My diagram also did not respect anything else using the sensor.

Maybe you'd be better of with a dedicated cheap infrared proximity sensor: example

To get data from the arduino so you can process it later on a PC, maybe look at an SD card module.

6v6gt:
If, however, you are simply going to ‘tap in’ to a sensor which is currently also being used for something else, like the gluer machine, you have to be much more careful.

I didn’t think of that either.

If so, add a diode between the pull-up resistor and the sensor, anode to the arduino (so the arrow away from the Arduino). This way any higher voltage on the sensor pin can not reach the Arduino, but the sensor can still pull low the pin. Maybe best to add an additional resistor between the diode and the Arduino, to limit the current as the diode recovers (the first moment upon change of voltage a diode conducts in reverse).

``````                      +5V
|
|
<
< 10k
<
|
|
Sensor --- |<|---VVV------Arduino pin
D1    1k
``````

(hope the ASCII art is clear enough :-))

That looks a more complete solution. I guess the only risk is that if any existing circuit is connected which has, say, 3.3 volt logic or lower, then it may also require diode protection to isolate it from the arduino 5 volt supply.

my apologies if I was confusing, i wouldn't dare tap into the actual system. I have a spare sensor in my locker at work is what i mean. that's what i was planning on using. still very helpful information thanks for the support and direction.