Looking for feedback on LED PWM circuit to be driven from uC - Page 1
Forum section: electronics / beginners

author: v81
author_rank: Regular Contributor
timestamp: July 13, 2022, 11:34:37 pm
content: Context = A small group of us are working on flight sim cockpits and we're on to back-lighting of panels.The LEDs surround MFD's (see Digital Combat Sim screen cap below for Multi Function Display).4 narrow boards surround the MFDs with Shift Registers for the buttons, logic is 3.3VWish to avoid running separate gnd for LEDs by using high side switching instead.I'm kinda the electronics brains, but I'm really not all that clever.I've done a little reading and cobbled together the circuit pictured below.Whilst i have bread boarded it and it does function I'm looking for feedback on anything i might have overlooked or anything that might be a concern.My main issue and hurdle that i encounter is my lack of knowledge of transistors and FETs, and the wide variety available.We have some cheap assortment boxes from AliExpress of components which i have used to cobbled together a breadboard sample that seems to work fine.There is a lag on the trailing edge of the wave when the output is measured on the scope, but this disappears with more load added in the form of 50ohms in parallel with the LED's (2x100R 5W resistors in parallel).Chances might be that once the circuit is naturally loaded with more LED strings this might not be an issue?Not sure what total load will be yet, possibly in the realm of 150 - 300 mA, seems very much within the FETs capability.Online circuit i referenced...https://electronics-diy.com/electronic_schematic.php?id=1012Here is the schematic...FET on actual breadboard is IRF9530N (or Chinese counterfeit)Below attachments are the MFDs for an Apache AH64D from Digital Combat Simulator.MFD buttons via shift registers to open source joystick firmware 'FreeJoy' on STM32 BluePill board.Backlight brightness is picked up from sim on PC with DCS_BIOS and feeds a PWM out on an Arduino.Also the Scope trace without and then with the 100R across the FET.Ultimate question...is this good enough?Have i made any terrible component choices?Have i fallen into any unknown trap?No looking to guild any lilies, but want the circuit to last and not cause any issues, and maybe a learn a thing or 2 in the process.Wanted to show work done, but hope I haven't over done it.Any advice appreciated.

author: Benta
author_rank: Super Contributor
timestamp: July 14, 2022, 12:52:08 am
content: Looks OK to me.2.6 V seems a bit high for green LEDs, but I don't have the data sheet.The only thing is that your drive circuit is really slow. I'd go for a PWM frequency not higher than 1 kHz.Cheers.

author: v81
author_rank: Regular Contributor
timestamp: July 14, 2022, 04:23:52 am
content: Quote from: Benta on July 14, 2022, 12:52:08 amNor do I unfortunately.I was actually going to post a question about finding the forward voltage of LEDs.On my multimeters (Hameg HMC8012 + EEVBLOG 121GW) i get a measurement of 1.9v, but when calculating and applying current limiting resistors for this theory the LED's don't light well and only draw a few mA.I jumped on this site (https://ledcalculator.net/) and it suggests 2.6v for green, and the math adds up and the current draw is as expected.It's seeming like maybe a multimeter doesn't do so well measuring for forward voltage of LEDsAny thoughts on this?QuoteI was surprised the Arduino UNO output was that slow too, i thought it would have been higher than 1kHz.Are you suggesting something higher than that, but lower than / not higher than 1 kHz?I'll read the Arduino / Atmel docs to see if I can adjust this.

author: ledtester
author_rank: Super Contributor
timestamp: July 14, 2022, 04:36:55 am
content: Quote from: v81 on July 14, 2022, 04:23:52 amJust set up this circuit:Code:+12V --- /\/\/ --- LED --- GND1Kand measure the voltage across the LED.

author: tooki
author_rank: Super Contributor
timestamp: July 14, 2022, 05:30:02 am
content: Old-school GaP or AlGaInP lime green (~570nm) LEDs have a Vf around 2.2V. The newer InGaN emerald green (~520nm) LEDs have a Vf around 2.6V.FWIW, more and more I’ve just been using addressable RGB LEDs. They dispense with the need for external drivers, and because the PWM smarts are in the LED itself, it means even a puny MCU can control lots of LEDs, with the PWM frequency determined by the LED model.

author: v81
author_rank: Regular Contributor
timestamp: July 14, 2022, 06:59:59 am
content: Quote from: tooki on July 14, 2022, 05:30:02 amMay indeed be the second type I have here.QuoteFor the cockpit panel we have push buttons that have a green LED inbuilt to backlight the button itself, rules out using WS2812's or similar.They're so damn easy to use when you can use them.

author: v81
author_rank: Regular Contributor
timestamp: July 14, 2022, 02:56:22 pm
content: Quote from: ledtester on July 14, 2022, 04:36:55 amInteresting.. different reading..2.1vAny reason why the multimeter gives a different reading?Maybe multimeter not meant for LEDs?, maybe just regular diodes?Maybe it just isn't able to measure that well outside of a circuit?

author: tooki
author_rank: Super Contributor
timestamp: July 14, 2022, 03:07:46 pm
content: Quote from: v81 on July 14, 2022, 04:23:52 amI think they meant the speed of your BJT/MOSFET driver stage.Out of the box, an Arduino’s PWM frequency is a puny 490Hz, which is flickery to a lot of people, especially at low duty cycles, which i think might be common in a gaming man cave.Quote from: v81 on July 14, 2022, 06:59:59 amGotcha. I had exactly the same situation in the project I’m wrapping up now. I instead used the PCA9634 LED driver: 8-channel, 8-bit 97KHz PWM (plus another 190Hz global dimming PWM), up to 5V/25mA per channel (but with config bits to properly support external power transistors/MOSFETs). In another project I just did, I used the nearly identical (software compatible) PCA9624, which is exactly the same except that it has 40V/100mA per channel drivers built in (but does not support external drivers). Not bad for a $2 part. Should you decide to use these, drop me a line and I’ll send you my code, which fixes some issues in the PCA9634 Arduino library.

author: tooki
author_rank: Super Contributor
timestamp: July 14, 2022, 03:19:32 pm
content: Quote from: v81 on July 14, 2022, 02:56:22 pmDiodes are not resistors: the voltage/current curve is very non-linear. A multimeter is just intended to give you a general idea of a diode’s characteristics. The test current in most multimeters is around 10mA (some use proper constant-current sources, but some cheap ones just use a series resistor.) Assuming it’s an exact 10mA, consider that an LED’s Vf is likelynotspecified at 10mA. Traditionally, 20mA has been the drive current for indicator LEDs. But modern ultra-efficient LEDs may be specified at only 1-2mA (because they’re blindingly bright at 20mA), while power LEDs used for lighting may be specified at far higher currents (like the ones I used recently that are 2x2mm and whose Vf is specced at various drive currents, from 2.8V at 350mA all the way to 3.15V at 1500mA).Thus, your multimeter is only giving you one datapoint on a very non-linear curve. This is true of all diodes, by the way, not just LEDs. The Vf of a rectifier diode at 10mA is often very significantly lower than its Vf at a few amps of current like in real-world use.The test circuit shown is also just giving you one datapoint (one more poorly defined than a constant current source), since the current depends on the Vf of the diode, and the Vf in turn depends on the current!

author: v81
author_rank: Regular Contributor
timestamp: July 14, 2022, 04:55:41 pm
content: Quote from: tooki on July 14, 2022, 03:07:46 pmFigured that...Been a big day of learning.Found out I could write to the timer registers to get different frequencies.The "I'd go for a PWM frequency *not* higher than 1 kHz" got me though, i thought higher would be better?Based on the info here..https://youtube.com/shorts/iKpQcznjYN4?feature=shareI have the PWM at 7.8kHz currently, looks like i can go as high as 62kHz if that's worth doing.Code isn't a strong point either, learning along the way.This discovery was interesting as i wasn't aware I could 'bend' an Arduino from within it's own IDE.Who thought 490Hz was a smart idea?Seems a gotcha is to avoid modifying timer 0 as Arduino dely and timing code references that timer.QuoteI'll make a note of those IC's and check them out in the morning.The Cockpit is looking like we might re-purpose a PC power supply to run all the pieces, the PCA9624 with its 40v/100mA capability might just work with a few 12v strings.Much appreciated!QuoteReally appreciate the detailed explanation.Hadn't considered it that way, i thought it was a fixed value.I wonder if EEVBLOGs magical 121GW has some settings for test current, will look into it.

author: Benta
author_rank: Super Contributor
timestamp: July 14, 2022, 06:44:34 pm
content: Quote from: v81 on July 14, 2022, 04:55:41 pmSince you already have the KiCAD schematic, why not run a simulation (you'll have to add the SPICE models first)?You'll see the horrible switching performance of your circuit with your own eyes.There's another thread running at this time also concerning this subject:https://www.eevblog.com/forum/beginners/led-backlighting-suggestions-(4-in-cc-config-3-2-3-4v-20ma)/EDIT: I had on hand an old schematic like yours that I ran a simulation on. 10 kHz, 10% PWM. The blue trace is your PWM input, the red trace is the MOSFET gate voltage. The 1.4 nF cap is a place holder for the IRF9540 gate (I don't have the SPICE model). Not impressive.

author: v81
author_rank: Regular Contributor
timestamp: July 15, 2022, 03:36:30 am
content: Quote from: Benta on July 14, 2022, 06:44:34 pmSo when you say the drive circuit is slow I took that to mean the source of the PWM signal being ~480HzWere you actually referring to the rise time of the output of the transistor?I'm barely aware of what spice is, not even close to being able to employ it in a practical sense.At this point i just breadboard things up and connect scope probes.Had i had a second probe on the bench it might have made sense to probe the input of the FET as well.I feel like i maybe should devote some time to SPICE, but with the current information load on this and other things i have going on I'm feeling a bit saturated.Appreciate the info.

author: Benta
author_rank: Super Contributor
timestamp: July 15, 2022, 08:57:27 pm
content: Quote from: v81 on July 15, 2022, 03:36:30 amYes.Technically, your circuit is simple and easy to understand. But it doesn't work very well, sorry.I attach a schematic with much better performance that's also much cheaper (IRF9540: $1. 20 x BC847C: $1. 20 x BC857C: $1) and not more complicated (well, OK, it adds two small transistors).It's more difficult to understand, I agree. But you can precision PWM it at 10+ kHz without problems.I also attach a trace of the LED current at 10 kHz, 2% PWM.PS: if you want to breadboard, the BC547/557 are the leaded equivalents.

author: v81
author_rank: Regular Contributor
timestamp: July 18, 2022, 07:28:48 am
content: If it doesn't work well that's fine, no need for apologies, I'm here because i lack knowledge and experience and was relying on someone honestly saying, "yep, nice try but it's not very good, here try this!".In the example schematic you provided every LED string has it's own transistor.Can this be done with 1 single FET driving all the LED arrays in parallel?We're hoping to drive multiple panels each with their own backlighting in multiple places from a single source.At this point total number of LED strings and configuration of those strings is undetermined.The Strings will be up to 2 meters away from the dimming controller.This will end up on protoboard as it's a one off at this point.

author: Benta
author_rank: Super Contributor
timestamp: July 18, 2022, 06:25:49 pm
content: Quote from: v81 on July 18, 2022, 07:28:48 amYou already did that and you saw the result.Nothing stops you from having the control circuit (with one 5-cent transistor per string) in one place and the LEDs somewhere else.Did you notice that the resistors are all the same (39 ohms)? That's because this is a constant-current LED driver. You can use 1...4 LEDs per string, and they all get the same current. No reason for individual resistor values per string.And you can add more strings (with the same BC857, 39 ohm resistor pair) as you like (to a certain limit).

author: v81
author_rank: Regular Contributor
timestamp: July 19, 2022, 11:14:11 am
content: Quote from: Benta on July 18, 2022, 06:25:49 pmOne multi function display might have 8 strings in it, there are 3 of these, we'd end up 24 wires coming from the dimmer.... bit of a mess unless I'm misunderstanding you.QuoteThe leds in the strings are different brands and makes from different vendors, and also have different amounts of material to shine through, so we're looking at running different strings at different current levels.We were intending to adjust the resistor per string once the panels is partly assembled to get the light balance 'good enough', we are under no illusion this is imperfect.I might not be explaining this too well, but I hope I'm conveying the idea.The PCB's that make up the back lighting and buttons are just about complete, and there is barely enough room to have 1 pin for the backlighing, let alone trying to implement an input pin for each individual string.I hope I'm not sounding difficult, and I do appreciate the help.

author: Benta
author_rank: Super Contributor
timestamp: July 19, 2022, 04:31:02 pm
content: For 8 strings you need 8 wires (plus a neutral) making nine. I don't understand why this is different from your original circuit. You talk about "different panels", how this will be implemented without a wire to each is unclear to me.Current adjustment is done with the 39 ohm emitter resistors.

author: v81
author_rank: Regular Contributor
timestamp: July 17, 2023, 01:49:52 pm
content: Didn't mean to bail out on this, but life has funny ways.Here i am back almost a year to the day.I appreciate your help Benta.Trying to communicate what I'm wanting to do is probing difficult.Basically, a fighter jet cockpit...The circuit in my OP is an example of one single panel, lets say the VHF radio panel.There are 10 or 20 panels total around the cockpit.We have the panel backlight level coming to 1 single micro behind the cockpit somewhere, and we want that one micro to control the brightness of all panel back lights.Each panel has access to 12v and gnd. Each panel has its own mixture of strings.We'd like to use 1 wire running through the pit to set the brightness of each panel.Basically, power the LEDs locally, just get the brightness from a single source to all panels.

author: v81
author_rank: Regular Contributor
timestamp: July 17, 2023, 01:58:19 pm
content: Quote from: Benta on July 15, 2022, 08:57:27 pmI'm just looking at this with new eyes... and i think it can do what i want.This circuit is simple enough to implement in each panel, and i can inset the PWM signal from the micro at the pulse point.This might be it, i'll source some components and give it a go.Also this looks like it might be current driven? so no need to calculate different resister for different number of series LEDs?

author: Benta
author_rank: Super Contributor
timestamp: July 17, 2023, 06:21:12 pm
content: NQuote from: v81 on July 17, 2023, 01:58:19 pmThat was my intention with the circuit: place one in each panel and just distribute +12 V, GND and PWM from a central point.Mind you, think about what kind of cable to use, you need to shield it somehow. 10 kHz PWM with very sharp edges generates a lot of EMI noise.

author: Benta
author_rank: Super Contributor
timestamp: July 17, 2023, 11:37:08 pm
content: Quote from: v81 on July 17, 2023, 01:58:19 pmYes, it's a constant-current design. The LED voltage you have at your disposal is around 9 V maximum, so it'll work with up to four LEDs in series per transistor.Note that the LED current is set by your 3.3 V output. If you drive it from eg, 5 V logic, LED current will increase accordingly.