I have been through some labs and have been able to create my own circuit with some LED outputs and a push button input. Now I want to replace the push button input with a laser sensor. The laser sensor is a 10-30Vdc PNP sensor and I have a 24vdc power supply. Could someone help me with how to wire this up to the board? I'm using the Arduino Uno.
other solution exist like resistor + zener diode, resistor divideror optocoupler but this one is simple and reliable and avoid to have the 24v going to your board in case of resistance faillure.
use a small signal NPN transistor like BC548/2N2222 etc or NMOS like 2N7002 with two resistors and use it as "common emitter".
your arduino input will be low when the PNP laser sensor will be high
Think to set the arduino port as input after reset and never set it as output and high level to avoid short circuit to the ground thru the transistor.
You can add a 100 ohms resistor between the port input and the transistor collector to protect the arduino in such case (marked as optional in the drawing).
The second solution use only a resistor and an optocoupler such 4N25, 4N27, 6N136, PC817 etc.
the difference is about safety where in this case your sensor (and 24V supply) is totally isolated from the arduino side. the ground GNDI and GND are no longer connected
with this solution, if the diode fail or is reversed by error, the arduino board is immediately killed.
Even the simple voltage divider to decrease the 24v to 5v is more secure than this solution. do you not think so?
At least you have one resistor to limit the current into the UC clamp diode with the "voltage divider" solution. but it's my opinion
with this solution, if the diode fail or is reversed by error, the arduino board is immediately killed.
Yes, reverse orientation will be destructive.
Even the simple voltage divider to decrease the 24v to 5v is more secure than this solution. do you not think so?
It depends.
In defense of using this circuit, the maximum current through the diode will be limited to 10.9mA, and the maximum reverse voltage will only be 24V, so it will be next to impossible for it to fail if orientated correctly. Also, if the Arduino input is inadvertently configured to output, it will cause no problem.
For a voltage divider solution, the ground connection needs to be secure, or 24V could hit the Arduino input. This possibility could be accounted for by sizing the resistors high enough so that <1mA would go through the Arduino's internal input protection diode.
For a transistor solution, the orientation / pin configuration needs to be observed: CBE, EBC, BCE, ECB, BEC or CEB.
Opto Isolation: Wins hands down (or anything wireless). Bandwidth / latency may need to be considered.
Genesis92, I like the optional 100R series resistor in your circuit suggestions. Pullup resistors are not shown, so INPUT_PULLUP would need to be used for pin configuration in the code.
yes the input pull up must be enabled
i'm using the 100R resistor on most of my designs to be sure xD anyone can make a mistake
about the diode solution care must be taken about the Ir value (and more when using high reverse voltge) 500uA or more reverse current is quickly reach and even more at high temp. So schottky barrier diode must not be choosen for such application. A standard 1N4001 with 30uA Ir is fine
like all the things in the life, each solution have their advantages and disadvantages
Hi, do you have a DMM, if so, connect the circuit up without the arduino.
Use the DMM on DC Volts and measure the sensor output with respsect to gnd, with and without a laser activating it.
What is the part number of the sensor?
TomGeorge:
Hi, do you have a DMM, if so, connect the circuit up without the arduino.
Use the DMM on DC Volts and measure the sensor output with respsect to gnd, with and without a laser activating it.
What is the part number of the sensor?
Tom......
Without the Arduino I'm getting 2Vdc from the voltage divider as per the first circuit. With just the sensor and the power supply i'm getting 23.1Vdc.
The sensor part number is FBP-LP-0E from Automation Direct.
Now setting this up to the Arduino, what do I have to set the pin as? (Input)???