Interfacing 24VDC to 5VDC. How decent is my solution?  - Page 1
Forum section: electronics / projects

author: 128er
author_rank: Regular Contributor
timestamp: April 24, 2015, 09:29:53 pm
content: Hi,for a small LED-signage project I need to handle 24VDC as input signals for a microcontroller. I come up with the circuit attached.The current through the opto coupler should be around 10 mA. The zener is intended to provide a threshold. So that the input is only triggered above 18-19VDC.I still have some doubts.- Is it a total no-go to share the same ground between the high and low voltage side. Does it make the opto coupler completely obsolete? The 5V logic circuit is supplied directly with a linear regulator from the same 24VDC supply as the inputs. I think with a isolated DC/DC converter it would be much safer and easier to reach the goal. I assume without isolated DC/DC supply I have to take a lot of care to protect the logic circuit (e.g. in case of reversed polarity), if it is possible at all.- In case of reversed polarity at the input, I have placed a diode antiparallel to the opto coupler. Would it be better to put the diode in series with the opto coupler? If the input voltage would be reversed in the circuit below, I would have to choose at least a >1W resistor for R10. With the diode in series and reversed polarity there would be no current flowing (except the leakage current) until the breakdown of the diode . And the diode drop would be negligible I think.- Should I add more protection to the input? Maybe I will use this circuit in a industrial environment. Perhaps a Varistor with a reasonable threshold voltage would be good, also for the case that someone could accidently connect 230V mains to the input. But then I also have to choose a big resistor or a fuse to handle the energy which is present.I get the feeling, that I do not come around an isolated DC to DC converter, to seperate all properly. From PLCs I know that they all have complete insulated inputs, therefore they always need a separate supply rail for the I/O modules.Thank you all for sharing your knowledge!

author: Mad ID
author_rank: Regular Contributor
timestamp: April 24, 2015, 09:51:10 pm
content: Hi.I always put a diode in series for a circuit like this one to safeguard from reverse polarity.Regarding the isolation, what is the point of isolation if both 24V and 5V are coming from the same source? There is no possibility of ground potential difference so this is good IMHO.And for transients to be honest I'm note sure but all of my designs manufactured in thousands never returned because of opto-coupler input failure. Guess they are quite robust..

author: paulie
author_rank: Frequent Contributor
timestamp: April 24, 2015, 11:26:23 pm
content: The isolator, diodes, and pull-up resistor are irrelevant. All that's required is a simple resistor of such value as to not violate MCU input zener max current. Typically 2ma so a 100k or even 1m would be orders of magnitude safe for most MCUs. I suspect some internet "expert" will come along shortly to explain why this is dangerous or impossible and suggest a more complicated/expensive solution.

author: retrolefty
author_rank: Super Contributor
timestamp: April 25, 2015, 12:45:09 am
content: Quote from: paulie on April 24, 2015, 11:26:23 pmIndeed I've seen a AVR application note showing how one could connect a 120vac hot lead to a digital input pin through a high ohm resistor for typical zero crossing detection applications. But i think they did note that it might have electrical code compliance issues.

author: Seekonk
author_rank: Super Contributor
timestamp: April 25, 2015, 12:53:39 am
content: A LED is just a diode and for 30 years I have never found one with less than 170V reverse breakdown. -5V has been stuck in data sheets forever.

author: paulie
author_rank: Frequent Contributor
timestamp: April 25, 2015, 01:06:15 am
content: Awwww... you guys are no fun at ALL!

author: Richard Crowley
author_rank: Super Contributor
timestamp: April 25, 2015, 01:26:04 am
content: Huh? If "The 5V logic circuit is supplied directly with a linear regulator from the same 24VDC supply as the inputs." then why do you even need an opto-isolator at all?If you want to use the "industry standard" solution:http://www.opto22.com/site/pr_details.aspx?cid=4&item=IDC5

author: David_AVD
author_rank: Super Contributor
timestamp: April 25, 2015, 06:57:48 am
content: If isolation is not a requirement, an NPN transistor with pullup (like the output of the opto) will do.The base of the transistor would have a series resistor (and zener for a higher threshold) as well as a resistor from base to 0V.

author: Mad ID
author_rank: Regular Contributor
timestamp: April 25, 2015, 07:10:40 am
content: Quote from: David_AVD on April 25, 2015, 06:57:48 amIsn't the optocoupler solution more robust in the case the cable is long and prone to noise pickup? With optocoupler circuit a 10mA current has to flow to trigger the input...with other suggested solution low noise current can switch the input?

author: ciccio
author_rank: Frequent Contributor
timestamp: April 25, 2015, 07:40:56 am
content: Quote from: Seekonk on April 25, 2015, 12:53:39 amI too believed this, but discovered that BLUE high efficiency LEDs did not like 30 V reversed DC...even with a 10 kohm series resistor. They break. All of them. A simple 1N4148 in antiparallel solved the issue.In the same board, GREEN LEDs did not have the same problem. They took the reverse voltage without problems.Best regards

author: Mad ID
author_rank: Regular Contributor
timestamp: April 25, 2015, 07:53:59 am
content: Quote from: ciccio on April 25, 2015, 07:40:56 amWhy do they die if current is limited with 10kR?

author: Zero999
author_rank: Super Contributor
timestamp: April 25, 2015, 08:01:31 am
content: Quote from: Seekonk on April 25, 2015, 12:53:39 amYou must be joking.The reverse breakdown for most LEDs is around the 20V to 30V range. Red LEDs tend not to be damaged by reverse breakdown which is why you can just connect them with a suitable series resistor to the mains but the more modern blue and green LEDs tend to be more sensitive and can be easily damaged by reverse breakdown.

author: Kjelt
author_rank: Super Contributor
timestamp: April 25, 2015, 08:12:58 am
content: Quote from: 128er on April 24, 2015, 09:29:53 pmSo where does this 24Vdc imput come from, from some other industral control board, a sensor? How long are the lines between the external device and your input.If the cables are long and the environment is noisy the ground voltage could be at the point of return on the input be different from your local ground and feeding it back you could create ground loop problems as often in av equipment that is more sensitive. But even a digital circuit can at some point have ground current problems.So normally you would use a two wired cable with 24Vdc out and the matching return 24Vdc-gnd and isolate those from the local ground .That is why you would use an opto. If you have no noise, short cables clean environment skip the opto as suggested. Perhaps we need some more detailed info on the exact ( industrial) application.

author: ciccio
author_rank: Frequent Contributor
timestamp: April 25, 2015, 12:21:04 pm
content: Quote from: Mad ID on April 25, 2015, 07:53:59 amDirect current was limited by 10 kohm, and they worked.. When the voltage was reversed they died, even if the 10 k resistor was there. Amen.. RIP

author: SeanB
author_rank: Super Contributor
timestamp: April 25, 2015, 12:39:04 pm
content: Not surprising, look at how close they are to burning out with forward current, then look at the power dissipation at reverse breakdown with the same current flow.

author: NiHaoMike
author_rank: Super Contributor
timestamp: April 25, 2015, 05:42:10 pm
content: Quote from: retrolefty on April 25, 2015, 12:45:09 amThe key is to use multiple resistors in series in order to get enough voltage rating. I have used that approach in multiple projects of my own and have seen it used a lot in various UPSes.

author: Zero999
author_rank: Super Contributor
timestamp: April 25, 2015, 06:27:59 pm
content: Quote from: NiHaoMike on April 25, 2015, 05:42:10 pmWhether it complies with the regulations depends on whether the microcontroller's power supply is SELV or FELV, i.e. whether it's sufficiently insulated from the user.

author: retrolefty
author_rank: Super Contributor
timestamp: April 25, 2015, 07:02:07 pm
content: QuoteBecause the failure mechanism is different for the two different cases. In forward current, max heat dissipation is the destructive force. In reverse it's a junction puncture failure.

author: Zero999
author_rank: Super Contributor
timestamp: April 25, 2015, 08:01:27 pm
content: It depends on whether the LED's junction is actually punctured by over voltage or not, some just act like zener diodes and tolerate it quite well, others die.Anyway, back on topic: if isolation isn't required, a potential divider is probably best. Of course, a single high value resistor will do but the threshold will still be low which will make it more susceptible to noise.

author: langwadt
author_rank: Super Contributor
timestamp: April 25, 2015, 08:24:27 pm
content: Quote from: paulie on April 24, 2015, 11:26:23 pmyes it will work just fine but the input protection diode is usually not a zener, it is diodes to ground and supplyand there is the caveat, you must be sure to always use more current than is injected in the supply via the protection diodes

author: paulie
author_rank: Frequent Contributor
timestamp: April 25, 2015, 08:31:39 pm
content: Yes, pretty much what I said.Anyway, what's up with all this "just use a resistor" stuff? I recall some years back suggesting that instead of expensive Maxim/Analog level converters would cause instant troll accusations and post reported for safety violation. Ahhhh... those were the days...

author: Richard Crowley
author_rank: Super Contributor
timestamp: April 25, 2015, 09:24:32 pm
content: It depends on the situation. If you are designing some completely isolated system that can run "hot-chassis" (i.e. directly powered from the mains without isolation) then indeed simply using a high value (~1M) resistor directly into the Atmel pin is even a technique features in Atmel Application Note AVR-182. q.v.http://www.atmel.com/images/doc2508.pdfNote particularly Fig. 1 on page 2 and the associated description.

author: David_AVD
author_rank: Super Contributor
timestamp: April 25, 2015, 10:24:14 pm
content: Quote from: Mad ID on April 25, 2015, 07:10:40 amYou can adjust the resistors to change the sensitivity but yes, there are times where an opto may be more appropriate. I've used both methods many times over the years.Using a plain resistive divider can be an issue where the micro may not be powered up when an input signal is applied.

author: 128er
author_rank: Regular Contributor
timestamp: April 25, 2015, 11:59:43 pm
content: Thanks for your input so far. Here are some more informations in which application this should be used.Often I need indication lights with very individual messages, to show different conditions of machines or product test systems. Very popular are these modular signal towers, where you can stack up different lights. They are very good for mounting them on top of switching cabinets. They shine 360° and are clearly visible from distance. And you can attach plates of acrylic glass to label them. But they quickly become quite large and impractical for close distance applications.Like this for example:http://www.tpautomation.de/shop/images/product_images/popup_images/8WD4408-0FA_2.jpgOverall size is, height: 500 mm, width: 200mmAnd to use HMI panels or some other type of display for this, would be total overkill.My goal is, to build a base unit with a small footprint, for which I can print individualized signs for the specific task. LEDs will act as a backlight to shine through the front cover. So I can make reasonable sized illuminated signs. For the first step I want to make a version with three LED modules, which I can independently control via 24VDC inputs. Or depending on the task, I could switch all three modules with a single input and use it as one big display. This functions should be adjustable by some DIP or rotary code switches.Let me know if there still exist a nice solution, or my idea is totaly dumb. Before I reinvent the wheel.Regarding to the environment where this will be used . . .In almost all cases there will be a 3-phase VFD or inverter for DC motors in the same switching cabinet from what my device will be powered and controlled. Or big thyristor power controllers for high temperature furnaces. I expect, that in most cases the cable that provides power and input signals is not longer than 20-30 m.I began to draw a schematic, but at the moment I have issues to export it from Eagle. But I have attached a picture how the thing could look like.

author: ciccio
author_rank: Frequent Contributor
timestamp: April 26, 2015, 08:32:14 pm
content: Quote from: SeanB on April 25, 2015, 12:39:04 pmExcuse me, I do not understand your point: direct current is limited at about 3 mA, dissipation is in the order of milli Watts.

author: Kjelt
author_rank: Super Contributor
timestamp: April 26, 2015, 09:58:57 pm
content: Quote from: 128er on April 25, 2015, 11:59:43 pmI would consider that medium length cables in a noisy environment (depending on motor wattage) but I would recommend using an optocoupler and isolate the ground as suggested earlier.

author: 128er
author_rank: Regular Contributor
timestamp: April 29, 2015, 12:30:22 am
content: Here is what I have done until now. It's not finished yet. Some connections are missing, values wrong. And I defenitly want to minimize the number of code switches. At the moment there is one for each input, to decide which modules should be switched on.

author: Kjelt
author_rank: Super Contributor
timestamp: April 29, 2015, 07:56:28 am
content: Make sure you test and get the layout around that led driver correct. My experience three years ago with a Maxim led driver doing 700mA was that it needed an additional small filter because it jammed around the 100MHz (FM band).not sure about this driver though, but is wort while testing before ordering large quantities of pcbs.

author: Jeroen3
author_rank: Super Contributor
timestamp: April 29, 2015, 08:55:45 am
content: You can turn those rotary selects into potentiometers with some resistors so you only need 1 ADC line per rotary, instead of 4.Or you can multiplex digitally, then you only need 7 inputs. Or multiplex analog, with 1 adc and 3 digitals.There is no need to give them up for the pincount.

author: 128er
author_rank: Regular Contributor
timestamp: April 29, 2015, 10:24:30 am
content: Quote from: Kjelt on April 29, 2015, 07:56:28 amThat's a good advice. But in this case it's a linear LED driver. And I think the PWM signal to it, won't make any significant difficulties, too.Quote from: Jeroen3 on April 29, 2015, 08:55:45 amThe pincount of the MCU is not a big deal. It's more about board space and minimizing the "user interface". And maybe minimize parts for cost. But I will think about the solution with the ADC as an input for the rotary switches. I have done that with Keypads before.