I need to use two push button switches in a project that includes a PIC controller. The switches have to be far away (let's say 15-20m) the microcontroller. Also, the environment is noisy: motors, contactors etc. In the circuit, I have a 5V digital source and a 24V for analog. I would like the 24V to be the cleanest possible. The analog circuits are being fed from it.
I don't have an special problem with bounces, will solve it in software. The button is expected to be pressed infrequently.
I want the solution to be cost-effective (the polite way for cheap). I have plenty power available, that's not an issue. By the way, I use the 24V rail but not sure if has any real advantage over 5V. It seems to me that a small problem on the 5V rail could cause a uC permanent failure or a freeze. Also, with 24V the voltage drop in wires is less significant.
I've seen a few circuits to protect the inputs, zeners, BJTs resistors... but what seems better to me is an optocoupler. As I only have one ground terminal, there won't be isolation, but for certain aspects I think it has advantages.
This is the circuit:
And these are the advantages I see for my application (maybe wrong):
1- As the long wire is always (but when the button is pressed) tied to ground, there won't be appreciable noise due to the EM fields around.
(I assume that won't be EM coupling in the 24v rail also)
2- When the button is pushed is unlikely that an EM interference could drive the LED.
3- In case of a electrostatic discharge, o wire inductance flyback voltage spike, the uC won't be harmed.
4- As the Optocoupler is a kind of slow device, it's a first debouncing system.
5- If wire gets cut, the uC can know
6- The chips are cheap and widely available.
Of course, if somebody connects the switch cable to 380V it will burn out... it's not a fool-proof system.
I would appreciate any comments, I'm not sure if the advantages I see are true or not.
Thanks in advance!
I don't have an special problem with bounces, will solve it in software. The button is expected to be pressed infrequently.
I want the solution to be cost-effective (the polite way for cheap). I have plenty power available, that's not an issue. By the way, I use the 24V rail but not sure if has any real advantage over 5V. It seems to me that a small problem on the 5V rail could cause a uC permanent failure or a freeze. Also, with 24V the voltage drop in wires is less significant.
I've seen a few circuits to protect the inputs, zeners, BJTs resistors... but what seems better to me is an optocoupler. As I only have one ground terminal, there won't be isolation, but for certain aspects I think it has advantages.
This is the circuit:
And these are the advantages I see for my application (maybe wrong):
1- As the long wire is always (but when the button is pressed) tied to ground, there won't be appreciable noise due to the EM fields around.
(I assume that won't be EM coupling in the 24v rail also)
2- When the button is pushed is unlikely that an EM interference could drive the LED.
3- In case of a electrostatic discharge, o wire inductance flyback voltage spike, the uC won't be harmed.
4- As the Optocoupler is a kind of slow device, it's a first debouncing system.
5- If wire gets cut, the uC can know
6- The chips are cheap and widely available.
Of course, if somebody connects the switch cable to 380V it will burn out... it's not a fool-proof system.
I would appreciate any comments, I'm not sure if the advantages I see are true or not.
Thanks in advance!