24 volt input to microprocessor - Page 1
Forum section: electronics / projects

author: deadlock
author_rank: Contributor
timestamp: October 24, 2014, 06:49:18 am
content: I am working on a device that will need to detect a 24 volt digital signal from a very old system.It is either 0v or 24v and I want to know which it is.How can I safely wire up the signal to a microcontroller without frying it and to protect if for long time use?1) Should I use a digital or adc input?2) I have seen simple voltage divider solutions that is supposed to handle this but I don't know if this is good enough and I would also prefer for this to work on a large range of voltages so for example:0v-0.5v = zero>0.5v - 50v = oneDon't know if that is easily achievableAny ideas or references appreciated

author: Rerouter
author_rank: Super Contributor
timestamp: October 24, 2014, 07:07:09 am
content: Digital input, with a resistor divider and a zener to clamp it to a level that is safe for the micro, e.g. 100K from the signal to the micro input, 27K from the micro input to ground, and a 4.7V zener in parrellel with the 27K resistor

author: krish2487
author_rank: Frequent Contributor
timestamp: October 24, 2014, 07:25:45 am
content: Or, if you have the feasibility. resistor divider network -> schmitt trigger (powered with 5V) -> digital input of the MCU.surely a 1$ IC can replace a $0.10 zener!!!

author: richard.cs
author_rank: Super Contributor
timestamp: October 24, 2014, 08:14:06 am
content: Or a high value series resistor and a small schottky clamping the input to the microcontrollers VCC, typically cheaper than a zener and works with less current, you just have to make sure there's never so little load on the supply rail that the input can push it up. Making the diode a schottky means the microcontrollers internal input diodes never conduct, you could use just a resistor (relying on the internal clamping diodes) and get away with it most of the time but it's a bit ugly and the injected charge can mess up the analogue inputs and the timers.

author: tggzzz
author_rank: Super Contributor
timestamp: October 24, 2014, 01:34:17 pm
content: You would be wise to verify that (1) there are no large common-mode voltages between the two circuits (2) earthing/grounding considerations aren't relevant (3) it is 24V without large spikes.There are solutions to all those potential problems, but from your description it is not possible to determine whether they might be relevant.

author: Richard Crowley
author_rank: Super Contributor
timestamp: October 24, 2014, 01:49:20 pm
content: Perhaps I am more conservative than the rest of you, but I would use an opto-isolator to protect the (rather delicate) microcontroller circuit and chip from the unknown hazards of the "very old system".Proper industrial systems make extensive use of optical-isolated input and output modules. "Opto22" is a very popular vendor of this kind of protection. They make modules for DC input, AC input, DC output, and AC output from microcontroller logic levels.

author: tggzzz
author_rank: Super Contributor
timestamp: October 24, 2014, 01:53:11 pm
content: Quote from: Richard Crowley on October 24, 2014, 01:49:20 pmVery true. Analog Devices makes some new higher speed fully isolated interfaces, and I'm sure other manufacturers do the same. But in this case an opto isolator is probably more appropriate.

author: dannyf
author_rank: Super Contributor
timestamp: October 24, 2014, 02:37:24 pm
content: I would put a resistor on the input and call it a day. The size depends on the current drop but 2ma or 10k or plus would work.

author: Seekonk
author_rank: Super Contributor
timestamp: October 24, 2014, 02:39:28 pm
content: >0.5v - 50v = oneHow set are you on that voltage? You could use a simple opto isolator. That has a LED on the input and a transistor on the output. Use a high value resistor on the pull up and you could easily accomplish 2V to 50V on the input. And that would give you electrical isolation.

author: motocoder
author_rank: Unknown
timestamp: October 24, 2014, 09:41:52 pm
content: Quote from: Richard Crowley on October 24, 2014, 01:49:20 pmThis is the solution that I would use as well (assuming the input signal is not something faster than an opto-isolator can handle).

author: Rufus
author_rank: Super Contributor
timestamp: October 24, 2014, 11:08:01 pm
content: Quote from: Richard Crowley on October 24, 2014, 01:49:20 pmThey are ridiculously large and expensive for simple DC inputs. I have used them but only because they allowed the same board to be easily customized for combinations of AC/DC Input/Output.

author: TonyStewart
author_rank: Contributor
timestamp: October 25, 2014, 03:24:21 am
content: If this design considers a low voltage unimportant, OK but>0.5v - 50v = onewould require a gain of 4 and clip to Vcc to detect this logic level.It would be much more logical to relax the requirement to match the digital input threshold of 0=<0.8, 1=>2V and in between is maybe, which is often 2 diode drops or 1.3V for the threshold. Then with 100K feed the logic input with a schottky diode clamp to Vcc inparallel with the built-in ones. or leave-outIn reality, all you need with ESD clamp diodes is a 100k series resistor

author: calzap
author_rank: Frequent Contributor
timestamp: October 25, 2014, 03:42:31 am
content: The frequency and current capacity of the 24 V source wasn't stated. If it's not too frequent and has sufficient current, the old school solution of a relay might work and would provide excellent isolation. 24 V relays are plentiful.Mike in California

author: Macbeth
author_rank: Super Contributor
timestamp: October 25, 2014, 03:58:26 am
content: Quote from: calzap on October 25, 2014, 03:42:31 amUrghh! That makes me want to spew! - He just needs a signal to a micro. A frikkin' relay is insane. The opto-isolator is belt and braces and I would go for that in a few off's. A simple pair of resistors would do the job adequately too if you were to mass produce at a cost.A relay? for a signal?

author: Richard Crowley
author_rank: Super Contributor
timestamp: October 25, 2014, 04:29:55 am
content: Quote from: Macbeth on October 25, 2014, 03:58:26 amYou seem to be making very critical assumptions about the "very old system" (such as ground referencing, noise tolerance, life-safety criticality, etc.) that could well prove fatal to the microcontroller circuit with a simplistic interface circuit.

author: tggzzz
author_rank: Super Contributor
timestamp: October 25, 2014, 12:49:35 pm
content: Quote from: Macbeth on October 25, 2014, 03:58:26 amYes, for many signals a relay will be the optimum solution - particularly for underspecified signals in an unspecified environment.There may be cheaper simple alternatives - in a smaller number of circumstances.Depending on the environment, "a simple pair of resistors" might be literally lethal. Or not. You don't have enough information to answer that question.

author: Tandy
author_rank: Frequent Contributor
timestamp: October 25, 2014, 01:32:43 pm
content: I would suggest using an optoisolator, connect the input LED to your 24V circuit, connect the optocoupler output to the microprocessor. No danger of having unwanted higher voltages on your low voltage circuit.

author: Zero999
author_rank: Super Contributor
timestamp: October 25, 2014, 10:32:54 pm
content: The problem with the relay could be the higher coil current and you need one with gold plated contacts for small currents.An opto-isolator is probably the safest and easiest solution.A single resistor could work but as others have stated, it could cause problems if the 0V rails aren't well connected.

author: TonyStewart
author_rank: Contributor
timestamp: October 27, 2014, 03:47:34 am
content: Quote from: TonyStewart on October 25, 2014, 03:24:21 am

author: tggzzz
author_rank: Super Contributor
timestamp: October 27, 2014, 09:14:34 am
content: Quote from: Hero999 on October 25, 2014, 10:32:54 pmFirstly, and importantly, you are have omitted the limited context in which that statement was made.Secondly it can be argued in either direction (without knowledge of the operating environment and objectives), for example...The problem with optoisolator could be the sensitivity to reverse voltage spikes or overcurrent spikes, or temperature range, or high speed response transmitting a noisy signal.A relay is probably the safest and easiest solution.For the avoidance of doubt, I don't believe "a relay is probably the safest and easeist solution" any more than I believe "an optocoupler is probably the safest and easiest solution". The system context and objectives are needed to discriminate between the two.

author: Rudolfo
author_rank: Contributor
timestamp: October 27, 2014, 09:51:00 pm
content: 24V input can easy be handled by the iC-JX IO-port, or seehttp://www.ichaus.de/wp1_mcu_interfacefor interfacing to 24V industrial world.

author: TonyStewart
author_rank: Contributor
timestamp: October 27, 2014, 09:55:46 pm
content: FWIW, Telecom Relays are gold plated and also known as (AKA) <2A contact rating.Power Relays >=2A will eventually fail unless wetted with cap dump or 10% contact rating.then we have sealed reed relays.But I prefer low EMI, well designed direct simple solutions for low cost, low failure mode, no Murphy's Law from inductive transients.