12V PLC sensor to 3.3V input
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!!
Re: 12V PLC sensor to 3.3V input
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.
Re: 12V PLC sensor to 3.3V input
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
Re: 12V PLC sensor to 3.3V input
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.