PDA

View Full Version : 12V PLC sensor to 3.3V input



Jumper
- 17th April 2012, 14:22
Hi,

I need to connect a 12V powered PLC proximity sensor that has a normally open NPN output to a pic running on 3.3V. Obviously it is not just to connect it straight to a pin since it will need some level converting.

Does anyone have a nice solution for this that is already tested and proven. I was thinking optocoupler but I dont really have the need for an electrical isolation between them so is there any better way?

Thanks!!

HenrikOlsson
- 17th April 2012, 16:19
If I'm not mistaken having an NPN sensor means that the output is open collector so all you'd need to do is pull it up to 3.3V thru a resistor (say 1k) and connect it to the PIC input. (Edit: Or use the internal pullup if available).
If the sensor actually outputs 12V when "active" a simple voltage divider will do. Sensor->2k7->1k->GND, then connect the PIC input across the 1k resistor.

/Henrik.

Jumper
- 18th April 2012, 11:47
Tack för dina förslag!

I had to mix a litle from both your ideas. The sensor seems to have a really weak internal pullup to 12V so as soon as I connect the resistor divider the voltage drops alot. And without the divider the PIC gets 12V on the pin.

So I ended up introducing a new pullup resistor to 12V to the output .. and then a resistor divider from that. Weird but working

tufail74
- 2nd October 2012, 13:31
Is this a 2-wire or 3-wire proximity. As for 3-wire nothing wrong to use resistor devider but for 2-wire, the sensor will not get enough voltage across it or minimum current to function properly.