Go Down

Topic: Need help with npn proximity sensor (Read 2577 times) previous topic - next topic

timo

I have an Arduino NG board that I'm trying to interface with a NPN proximity sensor.  The sensor needs 10-24VDC power to function, so I'm using a 12V battery to power it.  What I find is that when I attach the sensor alone to the battery it outputs either 0V or just over 5V when something moves near the sensor.  
To interface with the Arduino, I connected the negative terminal of the battery to the ground on the Arduino board (is this necessary?  It seems correct) and the output now only comes out either as just over 0V or 4.2V.  Now the crazy part:  When i plug the sensor output into either the analog input or the digital one on the board, my multimeter reads only 2.3V as the high, and it seems to be fluctuating based on the serial output?!  I don't know if this matters, but I'm powering the board with a usb port off my laptop because I'm using the serial.println function so that I can read the sensor output on my mac.  Is plugging a sensor into the board supposed to change its output voltage?  This seems odd to me.  Please advise.

RuggedCircuits

The NPN prox sensor can be modelled as a switch that closes and connects to ground when it senses something, and is open when not. That explains why your signal is fluctuating -- it doesn't have a well-defined logic level when open (i.e., it is "floating").

Try the following circuit for interfacing. The 10k resistor keeps your board input near 5V when the sensor is "open", and the sensor should pull the input to 0V when "closed". The zener diode is just a little bit of protection to make sure your board doesn't ever see 12V!

timo

Thanks so much for the diagram and explanation.  It works flawlessly now.  I guess I just need to understand how the components I use are meant to function.  I had been wondering if the 12VDC that the sensor was given to function had any relation to the output voltage, and now I see that it really doesn't.  Thanks again!

valquire

for me this is one step further forward for my problem but.. I'm sorry, I still don't get it.

I have different sensor with 5V powered by the Arduino itself, I plugged in the ground from the sensor to ground and the digital out from the sensor to the digital in on the Arduino. With your diagram I see there has to be a pull resistor somewhere but it don't get where.

In between the out and in? Where in your diagram is the digital input?

Thanks for helping out.
Regards,
Chris

AWOL

#4
May 14, 2009, 12:49 pm Last Edit: May 14, 2009, 12:50 pm by AWOL Reason: 1
The pull-up is connected at one end to +5V and at the other end to the digital input you're using.

In the diagram above, the input is on the left, at the junction of the resistor and the Zener diode.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up