Questing about simplifying LED schematic - Page 1
Forum section: electronics / beginners

author: Sjoerd
author_rank: Newbie
timestamp: November 17, 2024, 10:47:31 am
content: Hi guys,I'm new here.Last year I got an arduino for my birthday and loving it but now that I'm starting to do "more advanced" things with it, I just notice my knowledge about basic electronics is nowhere to be found. When it come to digital connectivity I think I'm good but when it comes to hook up analog components such as led, resistor and capacitors and such I fail to understand.Situation:Im working on some user-input logic around a 74hc165 to capture 4 push buttons and 4 on/off sensors.- The 4 push buttons are going through a 74hc14 first before they are fed into the 74hc165- The 4 on/off are high 12v so the go to a optocouple first (also because its an entire different circuit and want to keep them seperated - I'm using pc847 for that with an 1k resistor in series of the signals.)To see what signals are high/low I added 8 led's + 330 Ohm resistor to the 8 inputs of the like this (attachment 1),But I was wondering if that could be simplified but using only one resister (attachment 2)Or maybe - this way of "debugging" the inputlines is totally wrong?!Regards,Sjoerd

author: Andy Chee
author_rank: Super Contributor
timestamp: November 17, 2024, 11:11:46 am
content: Definitely do NOT combine the LEDs like the second image!The first image is the correct approach.

author: Sjoerd
author_rank: Newbie
timestamp: November 17, 2024, 11:24:22 am
content: Thank you, then my own logic to add resistors to each led is sound. I'm currently going to "transfer" the wiring from the breadboard to EasyEDA and already got like 18x 330Ohm, 12x 1k Ohm en 12x 10k Ohm and sometimes I come across schematics where there is actually only one 330 Ohm resistor is being used - so i guess they should reconsider.A question tho (I want to learn here to instead of taking it for granted)Why should Inotgo for the 2nd approach?RegardsSjoerd

author: Analog Kid
author_rank: Super Contributor
timestamp: November 17, 2024, 11:33:42 am
content: You can use a common resistor (like your 2nd diagram)ifandonly ifonly 1 LED will ever be lit at a time. Otherwise you'll end up with too much current through each, since the resistor value is correct only for a single LED. It won't be that much with just two LEDs, but with a bunch more there's a real risk of "letting the magic smoke out" from overcurrent.So individual resistors is the way to go.

author: Sjoerd
author_rank: Newbie
timestamp: November 17, 2024, 11:40:59 am
content: AhCheck !When everything is finished, one led isalwayson. 2 or 3 LEDs will be on quite frequently too and we don't want smoke :-)Thank you for the explanation.

author: Ian.M
author_rank: Super Contributor
timestamp: November 17, 2024, 12:41:21 pm
content: The problem isn't so much letting the magic smoke out (unless you make the single current limiting resistor too small), its cross-talk between the data pins via the LEDs junction capacitance (which affects fast changing signals), and uneven illumination of the LEDs. Worst case (but unlikely unless you use different color LEDs), one LED with a low Vf may steal all the current extinguishing all the other LEDs. Best case, every additional LED lit causes all the lit LEDs to get dimmer, and some dimmer than others.Individual resistors avoid this problem.

author: PGPG
author_rank: Frequent Contributor
timestamp: November 17, 2024, 01:19:10 pm
content: Quote from: Analog Kid on November 17, 2024, 11:33:42 amThis resistor sets the same current if one LED is on or 8 LEDs are on. So when 8 LEDs are on each one (ideally) will get 1/8 of that current what is certainly not a reason to 'magic smoke'.The problem with this solution is that the more LEDs are on they shine less brightly and because voltage drop at each LED can be little different their brightness will be different - some LED even switched on can get so little current that you sill not see it.

author: PGPG
author_rank: Frequent Contributor
timestamp: November 17, 2024, 02:12:27 pm
content: Quote from: Sjoerd on November 17, 2024, 10:47:31 amLook into 74HC14 datasheet:https://www.diodes.com/assets/Datasheets/74HC14.pdfIn table at page 4 see VOHfor IOH=-4mA for VCC=4.5V. According to it you can assume that output voltage will be no smaller than 3.84V. It is 0.66V lower than VCC (4.5-3.84=0.66). About the same voltage drop (not voltage, but voltage drop) will be for VCC=5V so you can expect (in worst case) 5-0.66=4.34V at output loaded with 4mA when VCC is 5V.You have no guarantee that output drop is linear - you can not assume that for 8mA load you will get voltage drop of 2x0.66=1.32V. For 8mA you can even get output being so small that it will not be read by next IC as logic 1 state.You are simply not sure what will be if you load HC14 output with higher than 4mA current.If your VCC is 5V and typical red LED voltage drop is about 1.8V then you assumed ( 5-1.8 )/330 = about 10mA for each LED. How it is to 74HC14 output load capacity?Even what I have written it have a chance to work because I took the worst case parameter from datasheet and with output voltage being lower the LED current will also be lower.But learn from start to design electronic the way giving you 100% chance of working as you want it.Notice that for VOL(with the same load, but in opposite direction) voltage drop is only 0.33V - two times smaller. It is typical for digital ICs that they have 'stronger' 0 than 1. So if you want to take some current from them it is better to take it from 0 state than from 1 state.Quote from: Sjoerd on November 17, 2024, 10:47:31 amI'm more curious about this your solution. Were you exactly used these resistors. Show schematic. I expect here more problems with your LEDs being driven from these signals.You can find what is going on in analog circuits using Spice to simulate it.In 2017 I decided that KiCad reached the level of used by me for years professional PCB design program (Protel 3) and moved to KiCad to design my PCBs. KiCad has also integrated Spice simulator but I spend with it only few days half year ago just top check that it works. From my point of view it is good to have the same tool to draw schematic to make PCB and to draw schematic to simulate it. You learn one drawing tool and not two.

author: MrAl
author_rank: Super Contributor
timestamp: November 17, 2024, 02:39:05 pm
content: Quote from: Sjoerd on November 17, 2024, 10:47:31 amHi,This is actually a very common question.The best way is to use one resistor per LED as others have pointed out. This is the ONLY way if the LEDs are different colors with different voltage drops.If all the LEDs are the same, you might get away with one resistor, but as each LED comes on it will mean all of them will be a little darker so you won't get the full brightness.There's another problem though, two actually.The first is that 330 Ohms is too small. The IC will not be able to put out that much current anyway.The second is that with several 330 Ohm resistors and so many LEDs, the total current out of the IC will be too high, meaning it's even possible the IC chip may blow out.With any LED driver setup like this, you have to consider both the individual currents through each LED, and also the sum of all the currents for any that will be turned 'on' simultaneously. For example, if 4 of the LEDs can be on at the same time and the current through each LED is 5ma, that's a total of 20ma for the IC chip. It will try to draw 20ma through the power supply pins. That could be too high. But imagine if you had 10ma through each LED and 8 of them turned on, the IC would see 80ma which could be too high. 20ma through each pin would mean 160ma, far too high.With that particular IC chip though, it would probably be impossible to draw 10ma from each output pin. Maybe 5ma but maybe less than that. That means the chip could get hot.Also, sometimes you can get a lot more current in one output state than the other. You may be able to get more current if you drive the cathodes low instead of driving the anodes high. You have to check the type of chip you are using to determine this. With 330 Ohm resistors through even one output may be overloaded with just one LED on.Typical series resistor values used for bright LEDs is 1k but you can even go higher and still be able to see what the state of each output is. The LED should still light up enough to see. You may even be able to use up to 10k. That's something to be tried with your setup. Connect a 1k to 10k resistor in series with an LED and see how bright it gets. You can go from there with the other LEDs.Now you can see why we have LED driver chips, and their only purpose is to drive LEDs. You could connect the driver chip to the outputs of your original IC chip, then connect the LED's to the outputs of the driver chip. In some cases you do not need resistors because the IC driver takes care of the current levels. In other cases you still need series resistors, and they may be able to go lower like 470 Ohms. That should provide plenty of brightness, maybe even too much brightness for looking at directly.Note the newer LEDs are very bright and need much less current, while the very old LEDs are very dim and need more current. Get the modern ones they sometimes call them "super bright" LEDs.

author: Sjoerd
author_rank: Newbie
timestamp: November 17, 2024, 03:57:09 pm
content: How a rather small question leads to more questions - love it..As I said I got it on a breadboard and slowly drawing it into easyeda but I'm also new to that program as well - If you like I can make a picture of the breadboard (if interested that is), but the 4 12v on/off lines are for now also push buttons attached to a 5v line. Also i dont have any leds hooked up to the 74hc14 since I only use that for debouncing the switches.So the pc847 - Currently the 4 inputlines are 5v (not able to test is yet with 12v) and since an optocoupler is a led I figured "if it's a led it needs a current limiting resistor" so euhm 5v is 330 ohm and 12v is 1k (I guessed)I never worked with any schematics program. I know about easyeda from youtube creators.Do you recommend kicad?

author: PGPG
author_rank: Frequent Contributor
timestamp: November 17, 2024, 07:36:55 pm
content: Quote from: Sjoerd on November 17, 2024, 03:57:09 pmIf you start to learn easyeda I certainly recommend to select KiCad. But take in mind, that I have never even seen easyeda.I just believe now there is no better than KiCad free PCB design tool.

author: MrAl
author_rank: Super Contributor
timestamp: November 18, 2024, 10:09:28 am
content: Quote from: Sjoerd on November 17, 2024, 03:57:09 pmHi,If you mean schematics for drawing the circuit diagram and simulating the circuit, then you can try LT Spice which is free and a lot of people use it so you can share schematics. That allows other people to test out your design too.

author: PGPG
author_rank: Frequent Contributor
timestamp: November 18, 2024, 10:27:51 am
content: Quote from: PGPG on November 17, 2024, 07:36:55 pmI decided to make a short look what easyeda is.My first impression is that you work somewhere there and not at your PC. It is not for me. I'm too old for such solutions. I just prefer to myself take care of my files and not let it to someone else.I don't know what are the rules for example if some day someone will just say: "We finish offering this and we just disappearing." What happens with all your work?It also looks for me that in free version you can't use your private libraries.What !?I am using only my own libraries to be sure that I take care of everything.I see easyeda is simply not for me, but may be it is really good piece of software.With KiCad everything works at my PC. If at any moment someone will decide to close that project (may be a commercial firm will find a way to close competition - don't know if it is possible, but...) I will have its last version working. Maybe I'm oversensitive, but even impossible things sometimes happen in this world.

author: Analog Kid
author_rank: Super Contributor
timestamp: November 18, 2024, 08:23:45 pm
content: I second that suggestion ofdownloading LTspice. It's free, lots of people use it so its files can be shared, it's easy to learn, and it's not in the "cloud". What's not to like?

author: tooki
author_rank: Super Contributor
timestamp: November 18, 2024, 11:38:57 pm
content: Quote from: Analog Kid on November 17, 2024, 11:33:42 amThat conclusion is correct.Quote from: Analog Kid on November 17, 2024, 11:33:42 amBut that rationale is wrong. The resistor is there to limit current, and it’ll limit to the same limit no matter how many LEDs are in parallel. But how the current divides can be unpredictable (due to manufacturing tolerances between individual LEDs) and even if it divides perfectly, at some point, too little current will flow per LED for them to light up.

author: Analog Kid
author_rank: Super Contributor
timestamp: November 19, 2024, 10:39:41 pm
content: Quote from: tooki on November 18, 2024, 11:38:57 pmYou're right: I stand (sit, actually) corrected.

author: Kleinstein
author_rank: Super Contributor
timestamp: November 20, 2024, 09:23:11 am
content: The LED part is better with separate resistors. 1 common resistor would work, but the LEDs would get less bright when more than 1 LED is on at the same time. 7 extra resistors is anyway not that much to worry about.Modern LEDs are quite efficient. 330 ohms cause rather bright LEDs. The current could be a bit much to directly drive from the optocouplers.The input part may drop the HC14 gates. With a shift register they are sampled anyway and one get debouncing this way.The optocouplers may want antiparallel diodes as protection (the LEDs may not like 12 V in the wrong direction).

author: Ian.M
author_rank: Super Contributor
timestamp: November 20, 2024, 12:59:04 pm
content: For breadboarding, I'm quite fond of DIL package LED bargraph modules + an 11 pin SIP 10x 1K resistor array. That gives you ten LEDs with individual resistors in only 11 rows (both sides of center) of the breadboard. At 5V the load is around 3mA per LED - OK for most CMOS outputs, and much less at 3.3V. The common pin of the resistor arrray saves a lot of wiring. Depending on which side of the LEDs you put the resitor array, you can wire them active high or active low. (Active low is preferred, as most logic families pull low better than they pull high, either with higher current capability, or lower voltage drop or both.)https://mou.sr/4fZdlDjten led DIL bargraphshttps://mou.sr/4hYn1j110x 1K SIL resistor array

author: Analog Kid
author_rank: Super Contributor
timestamp: November 20, 2024, 06:48:03 pm
content: FWIW, I use 220Ω resistors on circuits with 5V supply, with no problems.

author: tooki
author_rank: Super Contributor
timestamp: November 20, 2024, 07:59:22 pm
content: Quote from: Analog Kid on November 20, 2024, 06:48:03 pmAgain, your LED knowledge is outdated.Traditionally, indicator LEDs were driven at around 20mA, which gave a nice pleasant, visible indicator. But with the insane efficiency of many (not all, but many) modern LEDs, 20mA is often too much. In many cases, way, way too much!The “worst” LEDs in this regard are modern “true” green LEDs (around 525nm, almost emerald green, rather than the ~550nm yellowish green that was ubiquitous in the past), since they are both electrically efficient, but also closer to our eyes’ peak sensitivity than blue or red LEDs. I am using those as power LEDs on devices at work, and I run them at0.5mA. (Not a typo: half a milliamp. 18k ohm dropper resistor from 12V supply, ~3V forward voltage of the LED.) If I run those at 20mA, they are literally very uncomfortable to look at.What happens when you run many modern LEDs at 20mA is the blindingly bright power LEDs that literally light up the bedroom when you’re trying to go to sleep, as we saw in a lot of products from around 2010, when engineers had not yet gotten used to modern LEDs and kept running them at 20mA.The upshot being that you cannot make blanket statements like “I use 220 ohms for 5V with no problems” anymore, because that can be fine for some LEDs and completely unusable for others. There is no getting around either testing every LED model you buy to determine an optimal dropper resistor value, or using only LEDs with very thorough datasheets that let you determine exactly what current to drive them with to get a desired, known amount of light output.

author: Zero999
author_rank: Super Contributor
timestamp: November 20, 2024, 08:05:44 pm
content: Quote from: tooki on November 20, 2024, 07:59:22 pmTo be fair, perhaps he has a load of old LEDs in stock. There are plenty of old dim red, yellow and green LEDs still made and I've still got some blue, white and violet LEDs from the 1990s to early 2000s, which need to be hammered to be very bright.

author: tooki
author_rank: Super Contributor
timestamp: November 20, 2024, 08:54:48 pm
content: Quote from: Zero999 on November 20, 2024, 08:05:44 pmDid you miss where I said the following? I think it should be quite evident that I am aware of the existence of a) old LEDs, and b) inefficient LEDs still made today.Quote from: tooki on November 20, 2024, 07:59:22 pmAndQuote from: tooki on November 20, 2024, 07:59:22 pmThat was the crux of the matter: blindly applying the guidelines of yesteryear is not a reliable methodtoday.P.S. The reason I started my reply to Analog Kid with “Again, your LED knowledge is outdated” is this other thread:Quote from: Analog Kid on November 18, 2024, 11:28:27 pm

author: Analog Kid
author_rank: Super Contributor
timestamp: November 20, 2024, 10:39:55 pm
content: Quote from: Zero999 on November 20, 2024, 08:05:44 pmThat is exactly the case. The last time I bought any (non-super-bright) LEDs was quite some time ago.So evidently I'm a bit behind the times here. Good to know.BTW, my post wasnotmean to advise anyone else that they'd be perfectly OK with a 220Ω resistor @ 5V, just that that's been my experience so far.

author: Sjoerd
author_rank: Newbie
timestamp: November 23, 2024, 12:41:01 pm
content: Okay,Some of you said "show the schematics" and then "use KiCAD" so I had to learn kicad first and then transfer that what was on the breadboard to KiCAD - It's likely that I made some mistakes. I already noticed I'm missing one of the caps on the 74hc14 and there are no decoupling caps at all. Also the breadboard uses 5v on the "12v sensor input" (don't have a proper lab power-supply but its on it's way as we speak)So here is the breadboardAnd here is are schematics - I hope "I did a good job" since is kinda my first attemptAnd before any starts off with "that's all wrong" and such - the breadboard and what I tried to accomplish works - the code in de arduino works, even the receiver works. It's just more like - did I added the analog stuff correctly - Also the optocouplers are there because those input or from an entire different circuit and different ground and I want/need to keep it that way and I learned that using optocouplers would do the trickI'm here also to learn

author: PGPG
author_rank: Frequent Contributor
timestamp: November 23, 2024, 01:53:40 pm
content: Quote from: Sjoerd on November 23, 2024, 12:41:01 pm1. You should not drive HC14 inputs through serial capacitors as you are not sure what the input state is after some time. Debounce circuit will have RC low pass filters (R in serie, C to GND).2. Bi-directional LED is driven from Vcc/2. The better would be to connect it with one resistor in serie between two output pins.3. Are you sure you will need transoptors at inputs? Do the sensors will have separate supply?

author: Sjoerd
author_rank: Newbie
timestamp: November 23, 2024, 08:14:19 pm
content: 1. Oops - that'siswrong. Thank you. On the breadboard the caps are hooked to GND. On the schematic I clearly wired that incorrectly - will correct that.2. Regarding the bi-directional LED. I thought I was being clever since the arduino can also sink current so: If I make D5 HIGH, the current flows though the red LED to GND. If I make D6 LOW, the current flows from Vcc through the green LED sinking into D6.. This works. Also it save me a pin. I could wired it like "D6 - 330ohm - BI-LED - D7" but in think it's a waste of a pin and I need to alter the code so that D7 = ! D6.. The only extra benefit is that I could have a 3rd state: OFF when both D6 and D7 are either HIGH or LOW.3. The 4 sensor are on an entirely different circuit. They have a different power-supply and therefore different grounds - I do not want to mix those (I think I mentioned that before, not sure)

author: PGPG
author_rank: Frequent Contributor
timestamp: November 23, 2024, 09:09:25 pm
content: 2.You wrongly explain what is going on with currents. Through resistor you 'don't use' in one on second situation current flows all the time. So what you loose is 5/0.66 = 7.6mA continually lost current. Some my devices consumes less average current than you are losing hereTo count LED current replace this divider by equal source that is voltage source having Vcc/2 = 2.5V and resistor in serie equal to paralel connection of your resistors so 165Ω.So assuming LED voltage drop being 1.8V (red) and 2V (green) the current in LED is set by (2.5V-1.8V)/165Ω or (2.5V-1.8V)/165Ω.If you try to do such trick having VCC = 3.3V you will get voltage too small for LEDs.Saving pin is only important if you don't have spare one. If you really need to save a pin you can invert your output using for example 74HC1G14.You can also use Red/Green LED having 3 pins and not 2.

author: Sjoerd
author_rank: Newbie
timestamp: November 24, 2024, 09:31:45 am
content: At 2) - you are still talking about the radio status led? Because there are no led's attached to the 74hc14. Only the 4 of the data-in lines of the 1st 74hc165 (U2) have those and all of th data-out lines of the 74hc595. I'm not sure if I had any 3-pin leds laying around. I need to check the starter kits I have if there is one in there. Makes indeed more sense to use different pin for different LEDs now that you mentioned a 3pin LED.This is the altered "debounce circuit":

author: tooki
author_rank: Super Contributor
timestamp: November 24, 2024, 11:53:35 am
content: Quote from: PGPG on November 18, 2024, 10:27:51 amThere is a downloadable version of EasyEDA, too.

author: tooki
author_rank: Super Contributor
timestamp: November 24, 2024, 12:04:14 pm
content: Quote from: Sjoerd on November 24, 2024, 09:31:45 amYes, he means the radio status LED.What he’s saying is that the way you have it now wastes power because you always have current flowing (5V/660 ohms = 7.6mA) even with the LED off, and that because the voltage is ~2.5V, many modern LEDs won’t even work.He is saying you could create a single-pin solution by using another inverter so that you always have a complementary version of the arduino pin: if arduino pin is high, the inverter output is low; if arduino pin is low, inverter output is high. The bidirectional LED gets connected between the arduino pin and the inverter output. The downside to this solution is that you need the inverter, and that you cannot turn the LED off: it’s always either red or green.

author: PlainName
author_rank: Super Contributor
timestamp: November 24, 2024, 12:28:18 pm
content: QuoteDon't know about the workings, but it's refreshing to see a properly-drawn schematic that doesn't replace wires with labelled ports. In contrast to many shown by new users on this forum, yours is easily readable and conveys intent very well.

author: Sjoerd
author_rank: Newbie
timestamp: November 24, 2024, 12:51:36 pm
content: Thank you so much for this comment.About the workings - this is the "transmitter". The state of the four 12v sensors will be transmitted to a receiver which repeats the state of those sensor. The 4 user buttons are "overrides". I programmed the Arduino so the 4 user buttons behave like toggles. The 8 dips are for setting the address but not using them yet - this project was to learn about shift-registers in the first place and when I stumbled upon a Arduino nano with build in rf I figured lets make something.For the schematic, I've been looking at how others do it and some are a pain to read and more messy that a plate of spaghetti. Also, the founder of EEV, Dave, has a video I watched a couple of months a go (#1129 - Creating a Nice Readable Schematic) which gave me some good guidelines.There is still room for improvement though.I'm still struggling with KiCAD a bit but I will get there.

author: PGPG
author_rank: Frequent Contributor
timestamp: November 24, 2024, 01:52:37 pm
content: Quote from: Sjoerd on November 24, 2024, 12:51:36 pmIf it makes you happy, I can also confirm that I have the same opinion about your scheme.My schematic differs from yours in thet I am placing blocking capacitors near VCC pin and use GND symbol to connect their second pin (like you use VCC symbol). It is because GND I have always made as w whole filled layer so GND connection has small impedance while VCC not and the good place for blocking capacitor is near IC VCC pin.Quote from: Sjoerd on November 24, 2024, 12:51:36 pmYour debouce circuits have 1k*100n = 100us time constants. I don't know what are real time contacts can bouncing but much longer time is certainly not noticeable for human pressing the button and as HC inputs are very high impedance there is absolutely nothing agains using 100k+100n with 10ms time constant. IC with Schmitt input can get slowly changing signal with no risk of instability.Quote from: Sjoerd on November 24, 2024, 12:51:36 pmIt was me who suggested you KiCad.If you have any questions come to KiCad users forum. I'm there since 2017. You will identify me by my avatar (unfortunately here any logins I could think of based on my name were occupied).