LED backlighting suggestions (4 in CC config, 3.2-3.4V 20mA) - Page 1
Forum section: electronics / beginners

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 08, 2022, 08:37:43 pm
content: I'm looking for ideas on how to do better backlighting for my2.8" 240x320 IPSpanels (datasheet).There are four white diodes in common cathode setup – so I have access to the anodes of each (LEDA1 through LEDA4 in the datasheet diagrams), but they're internally connected together at the cathode (LEDK1(-) in the datasheet diagrams).The forward voltage of each white LED is 3.2V to 3.4V, and maximum current is 20mA per LED (80 mA total), although I'd prefer to use at a slightly lower current (and brightness). I'd also like to have MCU brightness control, maybe via PWM or something (although I'll only use it for smooth on-off transitions).I'm using a Teensy 4.x, so all of my logic levels are 3.3V. I do have 5V available (USB), but I'd prefer to avoid that. During experimentation, I've just used a common current-limiting resistor (a few in parallel to get a suitable resistance around 25 ohm or so) and a 5V supply.A charge pump LED driver would let me use the 3.3V, and there are chips that would suit me perfectly (TI LM27951 for example), but they're either out of stock (chipageddon...) or have BGA footprints which is on the outer edge of my electronics skills. It is particularly annoying that the forward voltage is right around the supply voltage level, which makes controlling the current difficult.I could use a single transistor from 5V in constant-current mode, and PWM it using a high-side (P-channel) or low-side (N-channel) MOSFET. This will give me approx. 66% efficiency (3.3V out of 5V dropped in the LEDs), with just a few components; quite acceptable. Is this the best I can do?So, any suggestions, advice? Especially, any known reliable designs and parts you'd recommend?(I am just a hobbyist, but I do intend to do a carrier board (for Teensy) and this display panel in EasyEda, and license it under CC0-1.0, i.e. OSHW, as far as anything I'm contributing. My other stuff isthereas well.)

author: Zero999
author_rank: Super Contributor
timestamp: July 08, 2022, 09:42:53 pm
content: Use a voltage doubler? In this instance you'll need to run it off some sort of buffer, as an MCU output won't be powerful enough.

author: Benta
author_rank: Super Contributor
timestamp: July 08, 2022, 09:46:35 pm
content: What's the problem with USB power? By far the simplest solution: five resistors, four transistors and two diodes (without PWM) for the current control. Perhaps 30 cents all in all.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 08, 2022, 09:53:35 pm
content: Quote from: Zero999 on July 08, 2022, 09:42:53 pmAs shown,would immediately burn out the LEDs due to overcurrent.If the supply voltage is higher than the forward voltage of the LED, then that circuit fails to limit the current in any way.And if I just stick a current-limiting resistor in there, I'm back to where I am right now – except that I'm down to 50% efficiency.Quote from: Benta on July 08, 2022, 09:46:35 pmI did ask whether it was the best I could do! Remember, I'm a hobbyist with very little real world experience in electronics, and I'd like to hear some words of experience.I shall draw up the one I think I should use for illustration and comments. The issue is that my PWM output can only swing between 0 and 3.3V, and higher voltages could fry the I/O pin, and I'd also want the LEDs to be dark if the PWM output floats (during bootup). Apologies, Ishouldhave done this to begin with.

author: MikeK
author_rank: Super Contributor
timestamp: July 08, 2022, 09:54:26 pm
content: What about a 555 voltage doubler?

author: Zero999
author_rank: Super Contributor
timestamp: July 08, 2022, 10:02:23 pm
content: Quote from: Nominal Animal on July 08, 2022, 09:53:35 pmI thought your power supply voltage was 3.3V? The diode in series with the LEDs would give a minimum forward voltage of 3.8V, so very little current will flow through the LEDs.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 08, 2022, 10:27:19 pm
content: Quote from: Zero999 on July 08, 2022, 10:02:23 pmAt 75mA? (Checks datasheets.. yes, about 0.5V forward voltage for many diodes.) I was thinking of a Schottky diode there, it seems; apologies.Yes, I do have 3.3V supply, and also a 5V USB VCC supply available. Routing both to the carrier board increases a risk of someone like me accidentally connecting the 5V to an I/O pin, and Teensy 4.x pins are not 5V tolerant. (Yes, they do have ESD protection, so with a 4k7 or higher resistance current-limiting resistor, they can be considered to be.. but I don't need to cut corners here, this is a hobby project and not a commercial product where every cent counts.)However, I don't see any current limiting in your schematic; that must be controlled by software, keeping the PWM duty cycle within acceptable limits?

author: Benta
author_rank: Super Contributor
timestamp: July 08, 2022, 10:45:41 pm
content: This how I'd do it using the +5 V from the USB.In normal times, cost will be around 15...20 cents, in today's strange market it's probably 50 cents.Current to each LED is not just limited, but actually regulated, which should give you a nice even backlight.Cheers.EDIT: as MK14 pointed out, there's a typo in the schematic which is corrected now.An additional comment: depending on PWM frequency, a "bleed" resistor across D1/D2 of ~100k could be a good idea.

author: MK14
author_rank: Super Contributor
timestamp: July 08, 2022, 11:15:05 pm
content: R0 at 47k, would seem to be too high, to give enough current to the current regulating transistors, to reliably be able to give 15 milliamps. Perhaps 2k2 or less, would be more like it?

author: Benta
author_rank: Super Contributor
timestamp: July 08, 2022, 11:20:09 pm
content: Quote from: MK14 on July 08, 2022, 11:15:05 pmGood catch, it's a typo. It should be 4.7k. Thanks.EDIT: schematic's been corrected.

author: MK14
author_rank: Super Contributor
timestamp: July 09, 2022, 12:40:54 pm
content: Quote from: Nominal Animal on July 08, 2022, 10:27:19 pmAlthough on the one hand you are thecustomerand boss of this project and can specify what you like.5V is a pretty standard thing to be lying around, and I'd prefer to see your hobbyist techniques, grow/improve a tiny bit, and be brave enough to cope with it. While at the same time, hoping to NOT sound too patronizing here.Basically, if something WON'T work from 3V3 directly, which seems to be the case. You have to either give it 5V (with necessary current limiting circuits or resistors, after the 5V, to protect the LEDs), boost the 3V3 voltage up, live with any backlight brightness limit, that 3V3 gives you, or choose another display, which works from no more than 3V3.Boosting the voltage, is undesirable, because it can introduce noise, especially if implemented by someone, who is increasing their electronics knowledge, which can worsen A2D readings, and other issues.Can't you use a polarized connector (which DOESN'T allow it to be connected the wrong way round), or headers with a blank pin, which is physically filled in, so it can't be put in the wrong way ?PC motherboards have similar problems, and they have come up with various polarized connectors and/or ingenuity as to how the signals are arranged, so misconnecting it, hopefully doesn't damage anything.

author: Zero999
author_rank: Super Contributor
timestamp: July 09, 2022, 03:59:44 pm
content: Quote from: Benta on July 08, 2022, 10:45:41 pmSince the 3.3V PWM is regulated, then how about using it as the reference, rather than the diodes?

author: Benta
author_rank: Super Contributor
timestamp: July 09, 2022, 04:07:53 pm
content: You could also use the LM2660 voltage doubler from TI.The constant current driver circuit doesn't care whether it's fed from 5.0 or 6.6 V.

author: Benta
author_rank: Super Contributor
timestamp: July 09, 2022, 05:02:15 pm
content: Quote from: Zero999 on July 09, 2022, 03:59:44 pmIntriguing idea, but with some serious drawbacks.First, the 3.3 and 5.0 V supplies would need to track perfectly. This would complicate the power supply unnecessary.Second, the temperature-compensating effect of the diodes is gone.Not worth it to save 2 cents IMO.

author: Zero999
author_rank: Super Contributor
timestamp: July 09, 2022, 05:38:11 pm
content: Quote from: Benta on July 09, 2022, 05:02:15 pmNo they don't. The current is purely set by the 3.3V supply. Changing the 5V supply will make little difference.QuoteEach circuit has its advantages and disadvantages. Yours is more temperature stable. Mine has better stability with regards to the 5V power supply variability.

author: Benta
author_rank: Super Contributor
timestamp: July 09, 2022, 06:35:56 pm
content: Quote from: Zero999 on July 09, 2022, 05:38:11 pmMy bad. I didn't look properly at your circuit (dinner time) and thought it was my own repeated for reference. Sorry. I see your point now.So your circuit assumes that the logic output of the MCU is 3.3 V. Probably is, unless that output is loaded otherwise or has other voltage specs. I don't know the MCU in question.The last comment I don't understand 100%, unless you're referring to (very small) changes in the diode forward voltages due to QPWM current varying a bit with supply voltage.But I'm flattered that you bring improvements and other suggestions to my idea.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 09, 2022, 07:16:01 pm
content: This is exactly what I was hoping for! Thanks, everyone. I owe ya.I did notice in QUCS simulations of this circuit that a 10 kOhm resistor across the diode pair (D1 and D2) helps quash the trailing edge; but still, even a short 1µs pulse causes the LED currents to rise to their maximum in a few microseconds, limiting the operating range to audible frequencies. I assume this is due to the inherent capacitances in the transistors.I doubt something like 1 kHz dimming would actually cause audible noise in any of the componentsat these currents, but DACs like Microchip MCP48 and MCP49 series are cheap and still available, and therefore:How could I keep the per-LED maximum current adjustment, but scale them all using a control voltage? Replacing PWM with analog dimming, in other words.(I don't expect hand-holding; I'm studying this in a simulator that does have BC847C and BC857C models as those are cheap and easily available in SOT-23. But further advice would be greatly appreciated, before I start burning out components on a breadboard.)The other alternative I'm looking at is making four Howland voltage-controlled current sources, using one or four DACs with a suitable voltage shunt reference. Absolute precision is not important here, stability is, and that it can go down to zero (but I'll use a separate P-channel MOSFET as a high side shut-off switch anyway). Everything happens at human-observable intervals, too.

author: MK14
author_rank: Super Contributor
timestamp: July 09, 2022, 07:28:36 pm
content: With backlights, it is not always that simple. The colour rendition quality, may only hold up when the LEDs receive a significant amount of current (for arguments sake, let's stick with the 15 milliamps, previously discussed). So, if you PWM the LEDs, the on part of the cycle is always at the same 15 milliamps, which can help give the best colour rendition (colour gamut).But, as nice as it might sound, if you linearly controlled the current, it may not give the full/correct colour balance (gamut), at lower current levels.This depends on the LEDs they have used, and your sensitivity/importance to this possible effect. So it may not matter.I suppose you could breadboard both options, and see if it matters.

author: Zero999
author_rank: Super Contributor
timestamp: July 09, 2022, 08:08:29 pm
content: How about simply moving the resistor from the collector to the emitter? Now a base resistor is unnecessary, the circuit will be less sensitive to variations in the 5V supply and it will draw less current from the MCU's output pin.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 09, 2022, 08:14:29 pm
content: Quote from: MK14 on July 09, 2022, 07:28:36 pmThis is absolutely true, and I was aware of this.During operation, I want the LEDs to be driven at a constant current (somewhere between 10mA and 20mA each, haven't decided yet; need to test in different lighting conditions to decide). However, I want both turn-on and turn-off to be smooth; so between zero and the max, there is only a ramp (that is not linear either) that takes about half a second or so. I can easily generate the desired PWM or PDM pattern, and adjust the max current by tuning the resistors or replacing them with pots, so you could say that the fixed version of Benta's circuit is the solution I was looking for.There probably is a way to do the ramping in hardware as well, but I prefer to have the option to just switch the backlight on and off at command, with the ramping optional and configurable. And yes, I am aware of that I could also do this in software, using either the gamma control (available on ILI9341 and similar display controllers I'm using) or by just blending in the framebuffer from black, but that loses color resolution. I'm not after quick-and-easy; I want to know the different ways of doing this stuffright, but without going completely Blabbo the Verbose Overboard on it.Having more than one tool to do the job is always a plus. Because this is a hobby project, I'm using the opportunity to find out the different ways of doing this kind of stuff, and exploring them in simulators (QUCS since easy UI) and EasyEDA (as actual schematics and boards).While the upper half of the current range is used for steady state operation, it'd still be nice to be able to get the LEDs down to really dim, so that the ramp does actually feel and seem like a ramp, and not like a light stabilizing after being turned on. With Benta's circuit, the minimum maximum-intensity current pulse across the LEDs takes about 20µs, which means that at 250 Hz PWM, the minimumeffectiveduty cycle is 0.5%; at 1 kHz, 2%; at 5 kHz, 10%. So, for my purposes, I'm really limited to PWM frequencies between 250 Hz or so (because I hate flicker, and can definitely see 100Hz flicker) and 1000 Hz (because otherwise I lose the resolution at the low end).With current control, especially with say 20mA/256 steps = 0.078125mA per step (or 12.8 steps per mA, or 0.4% of full range per step), the minimum current would be around 0.1mA or so, which is definitely dim enough to not be perceived as "fully on". And even dual and quad 12-bit DACs with internal bandgaps (MCP47CVB24, MCP48CVB24) (giving a resolution of about 5µA at the upper half, for balancing the LED currents digitally) are within realm of possibility since they are actually somewhat available still, although they would double the price of the panel (from about $10).

author: Benta
author_rank: Super Contributor
timestamp: July 09, 2022, 08:18:29 pm
content: Actually, you should look at Zero999's modifed version of my original circuit (Reply #11).The more I look at it, the better I like it. It has the potential for much better/faster switching characteristics, and if you want softer switching edges for noise considerations, adding a little RC time constant to the base of QPWM will do that.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 09, 2022, 09:22:36 pm
content: Quote from: Zero999 on July 09, 2022, 08:08:29 pmExcellent!I ran a simulation (with 4×BC875C + 1×BC847C, R1=25 (for max. 19mA), R2=30 (for max.16mA), R3=37 (for max.13mA), R4=50 (for max.10mA), R0=1k, RB=2k, and PWM input from 1.7V to 3.3V. I got perfect results!The current-voltage relationship is perfectly linear from around 2.2V to 3.3V, and between 1.7V and 2.2V curves exactly as desired (i.e. starting slow and smooth), so that I have the extra precision at low current range.Now, I can stick a $1 SPI or I2C DAC there with a 3.0V reference (say, LM4040-N-3.0) from USB 5V, giving me some 110 effective steps (since 0=0.0V, 145=1.7V, 255=3.0V); and I can calibrate the maximum current per LED by shorting the reference to the DAC output (before soldering it in). That lets me use the DAC at 3.3V VDD, leaving 10% room for VDD sagging a bit. The 19mA-10mA current range then corresponds to 35 to 17 Ohms. I shall draw up the exact schematic for comments forthwith.

author: MK14
author_rank: Super Contributor
timestamp: July 10, 2022, 09:22:02 am
content: Quote from: Nominal Animal on July 09, 2022, 09:22:36 pmGreat, I look forward to seeing the new schematic.

author: Benta
author_rank: Super Contributor
timestamp: July 10, 2022, 08:31:25 pm
content: Ok, third proposal, partly based on Zero999's modification.This one does not rely on specific input logic voltage levels for the PWM.Also, it should be very fast for high-frequency PWM, as all transistors operate in linear mode (no turn-on, turn-off, storage-time problems). In fact, you may have to tame it a bit with a cap across D1/D2.Some interesting points:QPWM acts as a level shifter, so supply voltage to the LEDs is unimportant as long as it's higher than VLED+ 1V. Even the cathode voltage to the LEDs doesn't matter.The transistors and diodes compensate well for temperature.With a higher RB, higher logic level inputs can also be accommodated (eg, 12 V).Cheers.

author: MK14
author_rank: Super Contributor
timestamp: July 10, 2022, 11:22:01 pm
content: Quote from: Benta on July 10, 2022, 08:31:25 pmI'm not convinced by some parts of that circuit, and don't want to spend time extensively analyzing/simulating it, to make sure by criticisms are solid/valid. But anyway.RB, 15k, at 2.5V drive (from your schematic), would only attempt to give D1 and D2, 0.166mA. My understanding is that if you want to use diodes like that, for a somewhat stable reference voltage. It needs a reasonable amount of current, of perhaps a milliamp. Otherwise, in some cases, the diodes, will have a significantly lower voltage, than intended.Secondly, RC, 620 Ohms. Is going to potentially have significant amounts of the current,stolenby the 4 transistors (bases), Q1 through to Q4, as they will tend to lose Hfe, because the 15mA to 20mA per transistor, is perhaps a safe value of maybe 50 to 100 (Hfe), depending on how you interpret the graphs and safety margins. They seem to be specified for a minimum of 125 at 2mA.https://assets.nexperia.com/documents/data-sheet/BC856_BC857_BC858.pdfSo for arguments sake, let's say it happened to be exactly 100 (Hfe) at 20mA (typical values would give a higher Hfe, but less device to device safety margin). Then 4 x 0.2mA per transistor = 0.8mA, which would tend to leave RC with around 1.2mA (in this example), potentially leading to inaccurate current levels.In the typical case, the diodes would tend to work with the values shown, and the transistors would probably have a more generous Hfe in practice. I.e. It would tend to work in a 1-off situation, but not be a good idea for production or if high reliability was desired.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 10, 2022, 11:32:44 pm
content: Here's what I cobbled together in EasyEDA:This uses oneBC847C,235and fourNexperia BC857C,235transistors, just because they're cheap, (well under USD $1 for 20 at LCSC, about 1€ for 10 at Mouser), QUCS has a simulation model for them, and I can handle the SOT-23 SMD footprint fine.I did check the datasheets that they ought to handle what I'm asking for them without getting anywhere near their limits: even if dropping all of 5V at 20mA, that'd be 100mW, and the maximum total power dissipation allowed at 25°C is 250mW according to the datasheet.I used 1k (R5) and 2k (R6) resistors based on simulations and anticipating simplifying the BOM, and because the BC8x7C,235 have somewhat better DC current gain (hFEbetween 420 and 800 at VCE=5V, IC=2mA) than the other BC8x7 variants.The 20 Ohm resistors should then set the LED currents at about 16.5mA, but I expect I will tune these a bit further. I listed some of the other options in the schematic.TI REF3333provides both the 3.3V reference voltage for the DAC (and therefore the current regulation for the LEDs), but also its supply. It can provide up to 5 mA, and this circuit should need less than 1mA. The 1µF cap on the output of REF3333 is required, but it also acts as a bypass cap for the DAC. I did the selection based on availability and price, after comparing datasheets on the various available parts. Seemed a good fit here, including price ($2 at LCSC, 2.5€ at Mouser), but I have no practical experience with this part either.For the DAC, I choseTI DAC5571. Small, volatile (I didn't want to deal with nonvolatile stuff), low power (so I can power it from the reference voltage), low noise, stable, cheap (no stock at Mouser, but LCSC does, at under $1 apiece). The address is either 0x98 (0x4C) or 0x9A (0x4D) depending on whether A0 is tied low or high; I will be pulling it low to minimise noise. Instead of pulling the SCL and SDA lines to the reference voltage, they're pulled to 3.3V provided by the host, to limit the load on the reference, and to avoid problems when the host 3.3V does not exactly match the 3.3V reference voltage from the REF3333.Instead of the DAC, one can also use a plain old 10k linear potentiometer (say, a thumbwheel) instead. The additional 10k resistor then limits the range of the voltage divider to 1.65 V to 3.3 V, and thus nicely covers the practical range of the VLED input. That is, there isn't much dead space on the low end of the pot range. I like this option too. I guess one could even combine both by using a voltage divider; the current to the base of the BC847C,235 is in the microamp range, so a 10k linear pot ought to work just fine.(I'm tempted to experiment with a Pi filter using a P-channel MOSFET to replace the DAC with a PWM+low pass filter (pi filter, maybe, PWM'ing the reference voltage at ultrasonic frequencies – I'll probably run my Teensy 4 at 600 MHz, so no problem there), just to see if that too would work here. It'd be a darn nice backlight circuit if that works as well.)Comments? Suggestions?

author: MikeK
author_rank: Super Contributor
timestamp: July 10, 2022, 11:41:13 pm
content: If you want all the LED's to have the same current, does it make sense to use a current mirror?...With one transistor as the "master", or whatever you call it, and all the others will mirror that? Of course they have to be matched, but transistors in the same batch may be. Is that any better, or worse?

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 10, 2022, 11:53:25 pm
content: Quote from: MikeK on July 10, 2022, 11:41:13 pmWell, no, not really: the 20 Ohm resistors can be tuned for each LED individually; that's the point. Call me paranoid; I want to be able to adjust them if necessary, even though I may notneedto. Even the dimming is just a niceness I'd like, not a necessity. (But I do hate flicker, and high-frequency/near-ultrasonic buzzing PWMing often causes. I can hear up to at least 20kHz myself.)The four LEDs in this backlight are in common cathode arrangement, and quite well matched in the units I have. I bet most gadgets using this display panel just parallel them and use a single, 77mA or so, constant current source.(I won't go as far as planning to use multi-turn 50 or 100 ohm pots for this, though. Those things cost $1.5 apiece, but moreover, are far too bulky, really. Maybe 50 Ohm Bourns SMD trimpots...)

author: MK14
author_rank: Super Contributor
timestamp: July 11, 2022, 11:40:30 am
content: Quote from: Nominal Animal on July 10, 2022, 11:53:25 pmI'm wondering if you might be better off, starting with a simple resistor, with a value calculated to give perhaps 70mA (so 10mA worth of safety margin), so voltage variations on the 5V rail and resistor tolerances, don't exceed the LED's maximum of 80mA (all 4 combined, 4 x 20mA).Hopefully that will work out just fine, and you can check the current with a multimeter.Later, you can PWM that 5V rail bit, with a transistor (or similar), to modulate the brightness level, if necessary.Or simply use a three way switch (other numbers of ways, possible), which selects between high, medium and low brightness levels, via three suitably valued resistors. Assuming that doesn't affect the colour gamet, significantly.There is quite a lot to learn, to design your own decent transistor circuits. Especially ones which will control the current well, and cope with what can be quite wild (big), variations in Hfe and other transistor parameters.What you seem to have drawn out, looks like you are somewhat nearer the beginning of such a journey, rather than being close to the end of such a journey.I might get torn to pieces, for saying this, on the forum. But I have been led to understand, that even if you design transistor circuits, every day, for a living, and have done so, successfully for the last five or ten years (which was much more common in the 1960s and 70s). You still have much to learn about electronics and transistors.If you're determined for precise/individual current control, and designing it yourself. You could either go the op-amp route, or the various integrated circuits, specifically designed for driving LEDs, at precise currents. But I don't think those are necessarily/usually used in relatively simple backlight schemes, which your display, seems to have/need.

author: Zero999
author_rank: Super Contributor
timestamp: July 11, 2022, 12:11:49 pm
content: Quote from: Nominal Animal on July 10, 2022, 11:32:44 pmHow constant is the temperature?Asmentioned by Bentathe diodes have a temperature compensating effect. The base-emitter voltage of the transistors has a negative temperature coefficient, so your circuit andthe one I posted herehave a positive current temperature coefficient. As the temperature rises, the base-emitter voltages fall, causing the voltage drop across the emitter, resistors thus the current through them to increase.The circuit shown below should be reasonably temperature stable. The current through D1 and D2 is fairly stable and the voltage across them will fall, as the temperature rises. It will probably have a slightly negative temperature coefficient, as there are two diodes and only one base-emitter voltage drop on the driver transistors. It should be possible to reduce the temperature coefficient, perhaps by replacing on of the diodes with a resistor, or replace both diodes with at BJT, preferably thermally coupled to the driver transistors.How accurate does the current need to be? If it needs to be well-regulated, then the only sane way is with an op-amp and voltage reference.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 11, 2022, 06:35:51 pm
content: Quote from: MK14 on July 11, 2022, 11:40:30 amWell, that's what I have now.Quote from: MK14 on July 11, 2022, 11:40:30 amThis is to be a display for an LTE modem/firewall (based on Mikrotik RBM33G with a 4G/LTE modem), in a remote cottage, only used to show the connectivity and other information in an user-friendly way. (Instead of just a simple OLED or similar display, I wanted a nice display so I could use Tux or similar mascots: I've got some artists in my family that can do stuff to make it not only informative and intuitive, butfunnyand personally relevant.)Essentially, the optimum brightness of the display will vary on the environment it will be placed in. If in a dark corner somewhere, a dimmer display is better, otherwise I might need the maximum brightness. But the dimming (PWM or DAC-controlled) is mostly to make the display turn on and off smoothly, especially if I choose to let it turn on automatically for a few minutes if connection drops or reconnection is made. Having something flicker on/off too suddenly can be distracting; hence, the popularity of "breathing" indicator LEDs.Quote from: MK14 on July 11, 2022, 11:40:30 amI am, absolutely! I am a complete Uncle Bumblefuck in the early Suck-Hard-and-Fail-Often part of the learning curve in electronics circuits, definitely! Especially so when it comes to current control. I've played with sensors and voltage-based stuff, but not much with current-controlled/dependent things like LEDs. I do have done electronics courses (but I focused on digital logic!), so I know how to read and draw circuit diagrams (badly that, I admit!); I just have almost no experience with practical circuits and especially known good approaches. Which is why I asked, and am very grateful for everyones support in this thread, yours definitely included.Quote from: MK14 on July 11, 2022, 11:40:30 amBah (to being torn to pieces); the same applies to software development as well. Even though I've been paid to write code in half a dozen different programming languages off and on during the last three decades, Istilllearn more just about every day. And I still have much to learn about programming.Quote from: MK14 on July 11, 2022, 11:40:30 amTrue, and I agree: this is quite over the top.Perhaps a better way to look at this project of mine is to consider it a tool for hobbyists like me using this display (with Teensy 4 or similar microcontrollers –– I do intend to use parallel I/O for this), with lots of options on tuning it. The component count (7 SOT-23 packages and 10 passives in 0805, 14 passives if I double the positions for the current setting resistors) may seem high, but I find it acceptable due to adjustability it gives me.Quote from: Zero999 on July 11, 2022, 12:11:49 pmAmbient will be between +15° and +40°C, and I do not care if the display brightness changes a bit (say, current varies by 5% within this range) depending on the ambient temperature.Quote from: Zero999 on July 11, 2022, 12:11:49 pmOnly accurate enough to not yield visible artefacts. Say, 1% peak-to-peak maximum noise.The reason for using REF3333 is that theremightbe some step-like fluctuations on the 3.3V rail from the MCU. It is quite true that a couple of capacitors or a Pi filter would probably stabilize it just fine, but considering how easy and cheap it is to just throw a reference and a couple of capacitors there to be sure, I'm, uh,happierwith the latter.Something likeMCP6009(quad RRIO op-amp) could drive the LEDs directly, is cheap (Mouser has stock, <0.5€ apiece), and if driven from +5V, should be able to drive up to 20mA per channel, in Howland current pump configuration –– but I don't see how to have the pumps share resistors, so that makes for 16 of them. To allow adjusting the maximum current for each LED individually, I could just use a voltage divider between the reference and the positive input of each quad op-amp (or one in serial for global physical brightness knob, followed by one per op-amp positive input for tuning the per-LED maximum brightness). Thing is, I don't have the experience to have an opinion how this would compare to the schematic I showed above.

author: Benta
author_rank: Super Contributor
timestamp: July 11, 2022, 06:41:58 pm
content: Quote from: MK14 on July 10, 2022, 11:22:01 pmSo, you don't want to do the calculations, but still stand on Speaker's Corner? Right.To your first point: I'm not using 1N4007 diodes, but small-signal diodes for this. They'll operate fine a low currents, but will only exhibite a VFof 0.55...0.6 V. Compare this to the VBEof the BC847, where the current will be even lower.Second, your "current stealing" scenario. There's nothing "significant" about it, in fact it's negligible. The worst case HFEfor a BC857B is 220, so taking (15 mA x 4) / 220, the maximum current that will be "stolen" is 0.27 mA. That, by the way, is the reason that the resistor is 620 ohms and not 600 ohms as might be expected.But if it's an issue, increase the collector current of the BC847 (just reduce the 300 and 620 ohm resistors).Please keep in mind that the main goal of this circuit is to ensure good and stable currentmatchingbetween the LED strings, not absolute precision (that can be fixed with PWM or trimming the 300 or 620 ohm resistors).

author: MK14
author_rank: Super Contributor
timestamp: July 11, 2022, 06:50:24 pm
content: Quote from: Benta on July 11, 2022, 06:41:58 pmWell I DON'T agree with you. But we can agree to disagree if you like.

author: Benta
author_rank: Super Contributor
timestamp: July 11, 2022, 06:57:19 pm
content: Quote from: MK14 on July 11, 2022, 06:50:24 pmI'm fine with that. But please argue with facts and maths, not postulates and feelings. Then this discussion is fruitful.

author: Benta
author_rank: Super Contributor
timestamp: July 11, 2022, 07:07:16 pm
content: Quote from: Nominal Animal on July 10, 2022, 11:32:44 pmI have a problem with the 20 ohm resistors. Did you really simulate the current in the LEDs?For a 3.3 V VLED input, I get a collector current of around 1.35 mA through Q1. This will give around -1.35 V over R5 as base voltage for the PNPs.This again gives a voltage of around -0.7 V at the PNP emitters. 0.7 V / 20 ohms = 35 mA.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 11, 2022, 07:54:35 pm
content: Quote from: Benta on July 11, 2022, 07:07:16 pmYes, in QUCS 0.0.20 (using qucsator) and its (Diodes Inc.) built-in models of BC847C and BC857C. But, apparently used 3.0V instead of 3.3V for the maximum DAC voltage. Oops; at 20 Ohms, 3.0V gives 17mA, but 3.3V gives almost 22mA, so that will need to be fixed (22 Ohm resistors are more easily available anyway); but I don't see the source of error.For a 3.3 V VLED input, I do get the same collector current, 1.35mA, through Q1, but -1.12 over R5, and V_BE = -0.76V at Q2 with a 20 Ohm resistor, with an additional drop of -0.36V in that resistor. Yet, a current probe in series with the LED (using blue LED model, 3.3V forward voltage) does show 22mA.Dammit, I should've used KiCad (since it uses ngspice), with proper spice models of the components I'm using. Will switch.

author: MK14
author_rank: Super Contributor
timestamp: July 11, 2022, 08:13:17 pm
content: Now that I better understand what the problem (goal) is.I'm thinking on the lines of an ambient light sensor. There are a number of somewhat low cost, specialist ones (often intended to be put into mobile phones or monitors), that can tell you the ambient light level. Then, (forget precision current control). Just set the PWM to always be, perhaps 500Hz or 1,000 Hz, and write software which varies the PWM on duty cycle, depending on the ambient light sensor readings.Cheaper alternatives would just be to use a phototransistor, but then you would have to do more work to use it.You can then just use a simple transistor or mosfet, to do the actual switching of the backlight LEDs, via the MCUs PWM output pin.I don't think there is any need to attempt to precisely control the current level, assuming the 500Hz or 1,000Hz PWM, does not cause you any issues.Then, it would be able to automatically keep the displays brightness in check, throughout the day (assuming windows) and/or when lights are switched on and off.EDIT: But just to be clear. To alternatively, precisely control the current, rather than PWM'ing it. To completely eliminate possible flicker and/or resolution issues, is also a perfectly valid design decision/goal. The solution I presented above, is just one of millions of possible ways, of sorting this project of yours out.I.e. I'm NOT saying current control, is necessarily bad or wrong, just that PWM, when a viable option, is often cheaper, easier and quicker, in many cases.

author: Benta
author_rank: Super Contributor
timestamp: July 11, 2022, 08:40:28 pm
content: Quote from: Nominal Animal on July 11, 2022, 07:54:35 pmTwo things stick out:1: your Q1 collector current is too low. 2 mA is absolute minimum, try to set it around 4 mA just for testing (R6 680 ohms, R5 330 ohms). This gives an R5 voltage of around -1.25 V.2: Your BC857C model sucks. VBEshould be around -0.6 V, leaving 0.65 V for the emitter resistors. For 15 mA, this gives around 40 (43) ohms.And the hFEin the model is apparently also far too low.Get a good SPICE model from Nexperia or other reputable sources.EDIT: just had an idea: I don't know the QUCS simulator, but in ngspice you have to be hellishly careful about the pin number sequencing. Could it be that collector and emitter are swapped in your simulation? In ngspice, the BC8x7 pinout does not conform to standard. That might explain the odd VBEand low hFE.

author: Benta
author_rank: Super Contributor
timestamp: July 11, 2022, 08:49:59 pm
content: Quote from: Nominal Animal on July 11, 2022, 07:54:35 pmBe careful what you wish for.EEschematic: goodPCB layout: goodERC: goodngspice: Gaaaah!Cheers.

author: Zero999
author_rank: Super Contributor
timestamp: July 11, 2022, 09:24:27 pm
content: Quote from: Nominal Animal on July 11, 2022, 06:35:51 pmThe problem is the transistors will heat up. Here's a sweep of the temperature from 15oC to 60oC.

author: Benta
author_rank: Super Contributor
timestamp: July 11, 2022, 09:33:15 pm
content: @Zero999, Thanks, nice sim.Since you already have the circuit and sim set up, I'd be really interested to see the result with the two diodes on the base of Q1 (plus series resistor) as in reply #23

author: MK14
author_rank: Super Contributor
timestamp: July 11, 2022, 09:35:50 pm
content: Quote from: Zero999 on July 11, 2022, 09:24:27 pmIt doesn't look anyway nearly as bad, as I was expecting, from that circuit. I thought the error, would be much worse than that.The great thing about just PWM'ing it, on and off, is there is then no need to worry about the actual current level, either measuring it, or trying to control it. The PWM ratio, will deal with it, all by itself. You only need to choose the 0 to 100% of full brightness, job done.

author: Benta
author_rank: Super Contributor
timestamp: July 11, 2022, 09:42:03 pm
content: Once again:this is about Backlighting, meaning priority #1 is currentmatching. Not precision.And I agree, a 10% current increase over 15...40 degrees is fully OK to my mind. The resistors are probably 5% anyway.

author: MK14
author_rank: Super Contributor
timestamp: July 11, 2022, 09:56:35 pm
content: Quote from: Zero999 on July 11, 2022, 09:24:27 pmWhat about very low brightness levels, for dark situations. Would a very low backlight current, of perhaps 0.5mA per LED, increase to (perhaps) 5mA per LED (+1000% error), at low current levels, as the ambient temperature changes ?

author: MK14
author_rank: Super Contributor
timestamp: July 11, 2022, 10:14:58 pm
content: Quote from: Benta on July 11, 2022, 09:42:03 pmI'd prefer to know for definite, if the LED current affects the colour gamit, for their display, in a noticeable/problematic way. If it does, then PWM would probably be the best way forward.If that means the display noticeably increases in brightness, all by itself, as it self heats, over time. Some people, might find that annoying/distracting.I have a display which does that sometimes, and it somewhat annoys me when it does it. I don't think it is because of heating effects, it probably is because its ambient light sensor, sometimes decides to move the brightness level around (probably because of an ambient light sensor, that sometimes gets covered by a finger or something).EDIT: In all fairness. You're basically right in what you just said, and the temperature changes are probably small and slow enough, to probably NOT be noticeable anyway. Also I have a sneaking suspicion the LEDs colour gamat will be just fine, at lower currents.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 12, 2022, 01:24:33 am
content: (In QUCS, if I use 330 and 680 ohm resistors, with 17 Ohm current set resistor, I do get ~ 37mA or so LED current.)I'm also really liking the belt-and-suspenders approach where I can use resistors (footprints for at least two in parallel per LED) to control the maximum current per LED; an I2C DAC controlled by MCU to ramp brightness up and down; and a physical potentiometer that controls the overall/maximum brightness (as a voltage divider following the DAC); and a P-channel MOSFET to turn the entire backlight subsystem off when not needed by cutting off +5V LED supply.The benefit of a physical potentiometer instead of MCU control is that I don't need to store the state in nonvolatile memory (EEPROM, Flash).Quote from: Benta on July 11, 2022, 08:49:59 pmTrue. I duplicated the schematic and got garbage results (attoamp currents). I then made a simple voltage divider, but couldn't get that to work properly either; the voltage supplies stay at zero. I don't care which one of us (me or KiCad) is at fault, but that workflow doesn't work for me, that's for sure.Canedapassed the same test, and it supports defining transistor SPICE models, using ngspice. Nexperia does have spice subcircuit models for bothBC847CandBC857C, with B=1 C=2 E=3 pinning, so I think I'll play safe, and create the proper symbols too. (The BC847C,235 and BC857C,235 in SOT-23 I intend to use are from Nexperia.)And then, I'll simulate the base-emitter voltage as a function of collector current and DC current gain, and compare to the datasheet curves.It'll take a bit of extra effort, but hey, then Iknow.Quote from: MK14 on July 11, 2022, 10:14:58 pmI don't have suitable measurement hardware, and I don't trust my eyes alone for time-dependent data. (I cannot right now compare two side by side.)My personal opinion in this case is that I care less about the color reproduction – I mean, these are pictograms and illustrations and not photographs –, and more about flicker (low PWM frequencies) and avoiding possible PWM whine. If photographs or video were to be displayed, then I'd probably feel differently.Quote from: MK14 on July 11, 2022, 10:14:58 pmTrue; I find brightness pumping very annoying. Hmm.. Perhaps I should switch to two diodes in place of R5 in my schematic.Any suggestions on a suitable SOT-23 diode pair to use here? Nexperia BAV99,215 is dirt cheap, available, and according to its datasheet, its forward voltage per diode at 1mA current is 0.35V (150°C ambient) / 0.5V (85°C) / 0.6V (25°C) / 0.75V (-40°C ambient), at 0.1mA 0.20V/0.35V/0.5V/0.75V correspondingly; and it can handle 125mA across both diodes. So, seems like a good fit here (and I also found itsspice model)?

author: MK14
author_rank: Super Contributor
timestamp: July 12, 2022, 02:00:08 am
content: You might find this article interesting. It seems to include details on how to use an op-amp and resistor, with optional DAC brightness control, for LED backlight dimming.https://www.allaboutcircuits.com/technical-articles/the-basics-behind-constant-current-led-drive-circuitry/So, you'd need at least a quad pack op-amp IC and 4 resistors to detect/set the current levels. Plus your DAC chip, or PWM to voltage circuit, to control the brightness level (current demands).

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 12, 2022, 02:44:57 am
content: Quote from: MK14 on July 12, 2022, 02:00:08 amI've read that. The circuit shown – LED between inverting input and output of the op-amp, with resistor from LED cathode to ground – only works for separate LEDs; mine share a common cathode.If I understand correctly, the Howland current pump op-amp configuration would work (I mentioned this in#30) with e.g. MCP6009, but I don't see any way of reducing the number of resistors down from 16 for the opamps alone: four per opamp, all the same resistance.(Interestingly, there are small I2C and SPI DACs available with an internal 1.2 V to 1.24 V reference, often with a ×2 optional gain, so if one had completely independent LEDs, one could use such a DAC and a 60Ω/62Ω or 120Ω/124Ω resistors for the maximum 20mA current. I.e. DAC → global dimming voltage divider → optional divider to adjust max. current per LED → op-amp per LED.)

author: MK14
author_rank: Super Contributor
timestamp: July 12, 2022, 03:48:54 am
content: You're right. I failed to appreciate how hard it would be, with the complication of NOT having separate access to BOTH LED leads. It was only when I finished drawing the schematic, I found out, the difficulty.There are LED driving ICs available, but the ones I saw use PWM, at around 32kHz or 65kHz, but I remembered you don't want any PWM, so I haven't posted about them.I'm surprised, to see transistor circuits, beating op-amps here, because of the common connection LED issue.You could use a single op-amp, to control the current through all 4 LEDs, using an external pass transistor. But you don't seem to want to, because of concerns over possible inter-LED brightness variation.EDIT: I suspect it can be done, by using an additional transistor, for each op-amp. But I was trying to offer a simpler alternative, and failed to do that.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 12, 2022, 04:53:01 am
content: Quote from: MK14 on July 12, 2022, 03:48:54 amThis happens to me all the time –– so much so that I need to sketch out or test my suggestions first, before posting it (wrt. programming advice; hence the archive of test cases I have).Quote from: MK14 on July 12, 2022, 03:48:54 amPWM over 30kHz is okay, since it's inaudible even to me. The diode-compensated one seemed (simulated using QUCS, using models I now suspect are bad) to be limited to sub-kHz PWM frequencies, as otherwise I'd lose the low end; I'd like to be able to get under 1% PWM duty cycle (in the LED current).The common cathode ones like TI LM27951 seem to be difficult to obtain, that's all. Do you know of any suitable parts that are still available?Quote from: MK14 on July 12, 2022, 03:48:54 amYes; negative input to emitter of an NPN transistor, base to output, positive input gets control voltage. Load is between collector and ground, and sense resistor from positive supply to emitter. Very similar to what we have here, just more stable (due to feedback) and somewhat more complicated, replacing the common BC847C NPN transistor with per-LED op-amp.I do believe MCP6009 (quad op-amp I have spice model for) would work, and is cheap enough, so it would be feasible, especially with a DAC that has an internal voltage reference, say MCP47FVB01, so one could omit the reference voltage (again, absolute accuracy is not as important as stability is, and temperature range is rather limited). So, DAC from 3.3V supply with internal bandgap reference at 2.44V, followed by a potentiometer in a voltage divider configuration for physical brightness control, followed by quad opamp with PNP FET or P-channel MOSFET each.So much to try and experiment, so much to learn!

author: MK14
author_rank: Super Contributor
timestamp: July 12, 2022, 05:05:26 am
content: Quote from: Nominal Animal on July 12, 2022, 04:53:01 amIt's so very, very easy to miss one, ever so tiny detail, in electronics. But that then ruins the entire concept/idea, and needs a major rethink. Like you power it up for the first time, there is a huge bang, you then goas you immediately realize the mistake, such as 'of course, those regulators are only good to around 40V input, but it is currently 50V in'.EDIT: Made much shorter.

author: MK14
author_rank: Super Contributor
timestamp: July 12, 2022, 05:39:45 am
content: Quote from: Nominal Animal on July 12, 2022, 04:53:01 amNo, I tried, but no luck. Either dodgy (significantly poor) feedback ebay China sellers, an apparently trustworthy seller from ebay Israel, with x15 TI LM27951 for around 30 to 40 Euros (depends on currancy conversion factor), so way too expensive overall, including postage, but not necessarily taxes. The rest seem to turn out to be common-anode, or unavailable for too long, from suppliers such as Digi-key.I'm surprised there isn't more noise (complaints) on the public news, about this electronic component shortage situation. It does rather rarely get mentioned, very briefly (I suspect). But is almost entirely absent from the news, the vast bulk of the time.I suppose, in practice, shops mostly seem have the right final goods for sales, so most people are probably unaware of the situation.EDIT: £15 + £15 postage (approx) for 15. Too much, but I'll let you do some window shopping and crying (joke):https://www.ebay.co.uk/itm/274790185466

author: Zero999
author_rank: Super Contributor
timestamp: July 12, 2022, 11:33:00 am
content: It's true a Howland pump could be used. The trouble is, 20mA, into 3V LEDs off a 5V supply, is marginal for most rail-to-rail op-amps.The only way to get rid of the thermal effects is to move the voltage reference to the positive rail and put an op-amp in the feedback loop of each of those transistors. A pass transistor could be used with a Howland pump but it's much more complicated and needs well-matched resistors, so it's not worth it.

author: MK14
author_rank: Super Contributor
timestamp: July 12, 2022, 03:44:36 pm
content: Given the partial difficulties caused by the lack of availability of the ideal parts you wanted, or decent substitutes. How about the "Any port in a storm" or "Don't look a gift horse in the mouth".So, as you seem to have better explained the goals and requirements. Why not stick to the existing/working hardware, but add a mosfet (other solutions are possible), between the ground and LED-common-cathode connections. Then use the 600 MHz MCU, to PWM it at (with or without speedup assistance, such as gate drivers), 22KHz (or 32KHz, or whatever), then that should give you the adjustable brightness capability. Which should be significantly better than what you have now, as regards display brightness.I don't think it would be a good idea to worry too much about the LEDs being fractionally out of balance, or the PWM minimum width, being too big, for minimum brightness. You can always modify the software, to reduce any problems, at least as regards the brightness.Using 4 separate anode resistors (if not already done), can allow re-balancing them if necessary. I suspect it won't be necessary, especially for the use case, you seem to be describing.Hopefully, eventually the chip shortages will be history. Then you can more easily be adventurous. I really like the look of that LED driver chip you pointed out earlier, it seems really neat.

author: Benta
author_rank: Super Contributor
timestamp: July 12, 2022, 04:58:34 pm
content: This is slowly blooming into a "Defense" project.I like the "Skunk Works" approach better (aka KISS).

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 12, 2022, 06:36:05 pm
content: Quote from: Zero999 on July 12, 2022, 11:33:00 amRight. MCP6009 (and MCPthat I looked at lists output short-circuit current at at least 20 mA at 5 VDD for all temperatures, about 25mA at 25°C, but I've only played with op-amps in the voltage domain –– sensor buffers, instrumentation amplifiers, and so on. I have no experience to say what margin is safe, and this current control/regulation stuff is completely new to me.Mouser search for quad op-amps in stock, yields LM324D's, LM2902's, MCP6009's, TL074H's, TL084Hs.. The first promising one isRohm LMR934FVJ-E2, which can dissipate over 400mW at +85°C (5V×80mA=400mW), double that at 25°C, and source enough current. The datasheet lacks a "Output Source Current vs. Output Voltage" curve at Vdd=5V, but the Vdd=2.7V curve shows that for 20mA output, output voltage needs to be under (Vdd+ - 1V) or so (at +85°C).Quote from: Zero999 on July 12, 2022, 11:33:00 amRight; I've read about the resistor balancing in the TI appnote.Now, this schematic is very interesting. The only annoying thing is that DACs using internal bandgap references can only swing to 2.5V or so, so I still need a second, 3.3V reference.By the way, which simulator and schematic capture programs do you use to do those you attached?Quote from: MK14 on July 12, 2022, 03:44:36 pmI'm not in any hurry, nor is this "blocking" me in any way. It is research to find out how to do it in a way that gives me the most options going forward, without doing early compromises, and to learn about this stuff in practice.Sure, many people are quite happy with Arduino stuff that works only when their tongue is exactly in the right position. I'm not, I want to learn to do it better.Now, if this was a commercial project, or I was making these to give out or something, then sure. It would have made sense to not waste time and just go with 100 Ohm current-limiting resistors per LED, limiting the total current to between 58mA and 78mA (14.5mA to 19.5mA per LED), depending on the supply voltage swing and the forward voltage of the LEDs.I've already done this.Quote from: Benta on July 12, 2022, 04:58:34 pmI do this exploration to learn, and understand what is possible and how.This is a hobby project, for literally single devices. I might make five of the boards, and even populate them, but I only have two of the displays, and no use for more right now. Maybe a different sized panel, which means a different controller, and quite likely a different backlight arrangement. (Most are common anode, not common cathode like this is).Yes,KISSis good, practical advice. However, this is not a practical project; see the above two points.Thus, to be precise, this is ahobby research projectfor me, done at a nearly zero budget, but with basically no limit on time spent. I do intend to work this until I either find a solution that caters to all needs I have, or until I get bored. It is a very good way to learn.Therefore, all of your (all of youallses!) advice, suggestions, schematics, and points are greatly appreciated; even the"Uh, you're going too deep, NA"ones.

author: Benta
author_rank: Super Contributor
timestamp: July 12, 2022, 07:38:42 pm
content: Quote from: Nominal Animal on July 12, 2022, 06:36:05 pmI understand your motivation 100%. But a question anengineeralways has to ask is: "Is this good enough for what it's supposed to do?"If yes, then any added effort is money out the window.If no, back to the drawing board.For a hobby project, you can use a 32-bit DSP with 24-bit D/A converters if you like. But that's not engineering.I'm too much of an engineer to appreciate over-engineering.

author: Zero999
author_rank: Super Contributor
timestamp: July 12, 2022, 09:29:45 pm
content: Quote from: Nominal Animal on July 12, 2022, 06:36:05 pmIt's the transistors which carry the current in my circuit. Note the common mode input range of some op-amps doesn't include the positive rail, even if the output sometimes does.QuoteI use LTSpice, a Windows program which runs well under WINE.That circuit divides the 1.235V from the LT1004-1.2 down to -200mV referenced to the positive rail. There's no reason why a different voltage couldn't be used.You probably don't need any references or DACs. PWM from the regulated 3.3V will probably do. Here's a circuit based on Benta's original design, but it only uses one diode rather than two, which minimises the temperate coefficient. Two diodes overcompensated the effect of the voltage changing due to temperature. Using one just the right amount of temperature compensation.I think PWM is better than changing the current because there's less change the colour of the LED will drift, which can sometimes happen at very low/high currents. PWM makes it more constant. The frequency needs to be high enough to avoid flicker, but there's no point in going too high. I've found 1kHz is generally good enough.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 12, 2022, 10:34:32 pm
content: Quote from: Benta on July 12, 2022, 07:38:42 pmI can appreciate that. I share the sentiment when it is about actual stuff handed to other people, just not when it's for research and learning.Quote from: Zero999 on July 12, 2022, 09:29:45 pmYep; I'm reading the relevant datasheets quite carefully. I was also referring to the Howland op-amp only pump configuration, not to your schematic there, with the op-amps. (In that Mouser search, I selected only higher-current quad op-amps.)Quote from: Zero999 on July 12, 2022, 09:29:45 pmTrue, but the DAC needs a reference to negative rail, and using an extra op-amp or something is just not worth the effort.Quote from: Zero999 on July 12, 2022, 09:29:45 pmOh, I fully agree that I don'tneedthose. It's just that for my purposes, having an analog potentiometer control overall brightness without having to store the brightness value in EEPROM (emulated in Flash in Teensy), but still be able to turn it on or off in software either instantly or smoothly makes mehappy:I like it.Now that I have these circuits, my next task is to do a lot of simulations, to understand how they behave and so on.Any kind of decisions as to what I'll go with will depend on those simulations.After I've verified my simulation models reproduce datasheet curves, this will be the circuit I'll start with.Thank you, Zero999, Benta, MK14; I definitely owe you one!

author: Zero999
author_rank: Super Contributor
timestamp: July 13, 2022, 08:39:25 pm
content: Don't simulate. Build it.In the circuit I posted above, D1 should ideally be thermally coupled to Q2 to Q4, which should be matched. It's unlikely it's practical. Using transistors from the same batch will improve the matching and you could place D1 as close to one of the transistors as possible, with a nice thick trace to conduct the heat.If you're using through hole components for prototyping, the BC857 can be substituted for the BC557, as it has very similar characteristics.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 13, 2022, 09:39:24 pm
content: Quote from: Zero999 on July 13, 2022, 08:39:25 pmThis too is good advice (just like Benta's and MK14's KISS): I will, as soon as I decide what I'll go with.One reason for simulation is that I don't have any parts I trust at hand, just assortments (of fakes) off eBay, and will have to order stuff anyway from a reputable seller. A hundred of these transistors in SOT-23 costs about 2.5€, so it makes sense to experiment to get a real feel for sure.I am now usingQucs-Swith the Nexperia-provided SPICE subcircuits modeling BC847C and BC857C, including at different temperatures (which the stock BC847C and BC857C parts do not support), and I've replicated the base-emitter voltage curves as a function of the collector current as shown in the datasheets (with minor differences as to be expected; as Zero999 said, there quite a lot of component-to-component variation in real life).I do fear I might have to start working on creating a better ngspice GUI interface for us Linux users, because this is exactly the kind of UI task where multiple CPU cores and many threads (and processes, running individual ngspice simulator instances) can make a big difference. The biggest thing that needs fixing is the awkward interface to SPICE simulation subcircuits, and having to discover things by hand, instead of the UI examining the SPICE definitions to find out the tunables and ports and part names available and such. Qucs-S does a pretty good job at this, though there still is a lot of looking up by hand and knowing SPICE parametrization and such. What Qucs-S does not have, is a SPICE visual symbol editor, so you can easily represent a subcircuit as a part in a schematic. There are only a few built-in ones, and there is no real editor for them yet. The currently working approach is to edit a subcircuit as a schematic/drawing, and then copy-paste its source to a symbol file. Something dedicated to simulation only –– that is, schematic and part symbol editor, with on top of a ngspice or compatible backend –– with import/export to KiCad and others, could fix all that stuff quite cleanly.I really like Unix philosophy and modular design, and the idea that any SPICE model or subcircuit is a symbol usable in a simulation, with the simulator handling the recursion down to SPICE level. Multiple ngspice instances in parallel are useful when you want to simulate the same circuit in different temperatures, or with different models or subcircuits for specific components, and have cores to spare. For transient simulations, just calculate the results, and give me a virtual timeline at the bottom of my window, so I can "virtually probe" different parts of the circuit (including relative voltages, current flowing through a point, and so on), and don't make me define graphs. Same for DC simulations (without the timeline), too.Project sprawl, the enemy of every hobbyist.Quote from: Zero999 on July 13, 2022, 08:39:25 pmI'll get a bigger batch of the transistors anyway (I like the SOT23 footprint better than TO-92), and will try to pick units that match best. As to the component placement, my carrier board will be larger than the display module (68mm by 74mm), with components on the open backside, so with SOT-23 footprints probably in a line, I can use thermal adhesive to glue a "heat spreader" over all five (one diode, four PNP transistors). I'll probably need (low) forced air cooling in the enclosure anyway as 4G/LTE modems do tend to generate a bit of heat occasionally.

author: Benta
author_rank: Super Contributor
timestamp: July 13, 2022, 10:31:06 pm
content: Quote from: Zero999 on July 13, 2022, 08:39:25 pmThe thing about "same batch" is wishful thinking. The only thing that the date code tells you is the assembly/final test date. The die come from anywhere, no one knows.Now, I've done a bit of experimenting (MK14's scepticism about the diode/transistor matching got me thinking).That led me to explore further, and I found that voltage and temperature matching between the two does not work well. Until now I've only used thediode/transistor current source for totally uncritical applications.That led me to the attached schematic instead.Voltage tracking is great, simply due to using the same devices.And VBEspread is much narrower and more precise than diode VF.As BC847s or BAS16s are in SOT-23 anyway, what's the difference?Comments to the schematic: the LED current spread is due to different input voltages (I wanted to make it universal). At 3.3 V it's pretty much spot-on at 15 mA.Fun project! I've stored it in my library for future reference.EDIT: just for fun, I checked how fast the circuit really is (OP had reservations about PWM accuracy in an earlier post). I attach a trace showing input PWM (blue trace) and "LED" current (red trace) at 200 kHz, 10% PWM.The soft tops of the "LED" current may be due to my using Zeners instead of white LEDs, impossible to say. But I'd say that there's no reason to worry about PWM imprecision, no?

author: Benta
author_rank: Super Contributor
timestamp: July 13, 2022, 10:42:44 pm
content: Quote from: Zero999 on July 12, 2022, 09:29:45 pmFor a circuit with a 3.3 V fixed (or PWM) input, my only improvement suggestion is: replace the 1N4148 with a BC857 E-B junction (see my previous post). Then it's almost perfect.Your ICof around 2.6 mA is absolutely right.

author: eugene
author_rank: Frequent Contributor
timestamp: July 13, 2022, 11:36:06 pm
content: Not being as smart as you guys, I would do something like this and expect it to work fine.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 14, 2022, 12:02:16 am
content: Quote from: eugene on July 13, 2022, 11:36:06 pmA smart person would have kept to the four 100 Ohm resistors per LED, and dealt with the brightness by manipulating ILI9341 gamma curves...One interesting detail I learned from the simulations that even if one were to give the transistor a short pulse, the capacitances et cetera involved means that the transistor will turn on, and then off, in a much more longer period than one would think from the pulse itself. This in turn means that the shortest "blink", i.e. time that the LEDs are turned on, can be quite long, somewhere in the tens of microseconds. And that in turn means that if you want to reach low intensities, say only 1% of maximum intensity, your PWM period needs to be 1/1% = 100 times as long; i.e. on the order of a millisecond, i.e. 1 kHz PWM.At these currents, that will/should work absolutely fine. Even I don't perceive flicker above 250 Hz or so (but I do 100 Hz, especially in peripheral vision).But, when the currents are higher, the pulses can cause the affected components to generate actual physical noise. I think this most often occurs with inductors and capacitors. I can also hear the whine from many cheap switchmode supplies. With the old CRT TVs and monitors and their horizontal retraces in the 16-20 kHz range, I didn't need to see the CRT to be able to tell whether it was on or not; most TV's I could tell if they were on in the next room. I am definitely more on the sensitive side about those.A lot of the stuff in this thread may not seem like sensible solutions the stated problem, but they do provide options when the simple solutions no longer cut it, and provide ways of understanding how the underlying idea, current control works; and what considerations (like temperature effects, supply voltage dependence) one should be aware of, and how to deal with those. And that makes it very valuable, in my opinion.

author: MK14
author_rank: Super Contributor
timestamp: July 14, 2022, 12:30:28 am
content: Quote from: Nominal Animal on July 14, 2022, 12:02:16 amWhich will be just fine. Until the smart super genius, tries it in practice. (I just did something somewhat similar, to confirm my suspicions). Unfortunately, they will find in near complete darkness, the backlight will continue to (dimly but perfectly visibly), shine through. On my reasonable or better quality IPS, display.Usually LCD's are NOT perfectly black/opaque, and so controlling the backlight level, is a good idea, as well. Especially in dark or very dark environments.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 14, 2022, 12:49:11 am
content: Quote from: MK14 on July 14, 2022, 12:30:28 amHa! Just shows you how non-smart I am!Really doing the research and work to understand how things work, i.e. honest practical experience and intuitive understanding, seems to beat 'smart' any day anyway.(But really, remember that I only intend to use the PWM or DAC when turning the display on or off, smoothly, instead of instantaneously; steady state will be either off or completely on. But I do want an analog pot to adjust the overall brightness down from the maximum a bit if necessary; say 10mA .. 19mA per LED or so. No menu hassle, physical "memory" to keep the setting across reboots and brownouts, etc; what's not to like?)

author: MK14
author_rank: Super Contributor
timestamp: July 14, 2022, 12:49:24 am
content: Quote from: Benta on July 13, 2022, 10:31:06 pmI'm disappointed, with (myself) my earlier response, to you, as regards that, on later reflection. To say "agree to disagree", is still fine and ok.But, I should have pointed out, that the first claim (signal diodes, need a reasonable bias current), was because of an apparently, rather decent (very reliable looking), report on the issue, which ideally, I should have both mentioned and linked to.But unfortunately, I just can't either find it, or remember what it was called, or where it was from (other than the internet, somewhat obviously).Secondly, it is fine to have different opinions or ways of doing it, relative to that report. Because it is more of a strong recommendation, for some groups of engineers. Rather than a strictly definitive issue.Thirdly, my other disagreement, later turned out, to be NOT because what you had done was wrong as such. But because I was significantly over-optimistic, as to the accuracy specification, I thought you were trying to achieve.I.e. Your circuit may well have met your specification. My issue, was I assumed a different specification, instead of checking/asking/clarifying with you, what the intended accuracy was suppose to be. I didn't realize, it was as inaccurate (but still somewhat reasonable), as it was later, specified to be.

author: Benta
author_rank: Super Contributor
timestamp: July 14, 2022, 06:41:39 pm
content: MK14, I don't understand why you're berating yourself this way.The remark about the diode biasing was enough to lead me to explore it, and you were right. I found a much better solution, and will use it in the future.Good for me (and perhaps other readers of this thread).Pat yourself on the back instead.

author: MK14
author_rank: Super Contributor
timestamp: July 15, 2022, 12:08:01 am
content: Quote from: Benta on July 14, 2022, 06:41:39 pmThanks for the nice reply!Your latest circuit in simulation, seems to be responding VERY quickly (high speed current regulation, is not necessarily easy), and using the identical type of transistor, to compensate for some of the changes, is a neat (and somewhat under used) technique.

author: Zero999
author_rank: Super Contributor
timestamp: July 15, 2022, 08:44:35 am
content: The LM317L can be used as a reference.There are also transistor array, such as the MMPQ3906 and MMPQ2907A, which have better matching than discrete parts.

author: MK14
author_rank: Super Contributor
timestamp: July 15, 2022, 11:06:52 am
content: Quote from: Zero999 on July 15, 2022, 08:44:35 amI think I see how you expect it to work, and it seems to have been cleverly engineered!Also neat idea to use cheap, transistor arrays, to get nicely matched transistors.But the LM317L's, can be a bit tricky. So I raise the following possible concerns (friendly technical comments hopeful, NOT argument starting).Minor thing, I think R3 .. R6, would have around 600mV, so around 27mA, but the LEDs want (a max of) 20mA. So, perhaps 30 Ohms or more, might be better.The LM317Lhttps://www.ti.com/lit/ds/symlink/lm317l.pdfseems to need at least 2.5 volts across it, input to output terminals.VI – VO Input-to-output voltage differential, which seems to be specified as 2.5V minimum.But it also needs around 1.2V to be across R7 470 Ohms, to create the minimum 2.5mA output current (for it to be regulated).Which would be rather tight, because the 5V rail may be a bit under, Q1 (assuming saturated), may still have a bit of voltage drop, and then Q6, could be more like 0.7V (transistors tend to be doped (complicated subject area, but needed to make it a good transistor) to have ever so slightly higher Vbe voltages, than typical small signal diodes).2.5V (VI-VO) + 1.2V (to get current via R7) + 0.1V Q1 (could be less or more) + Q6 Vbe 0.7 + R1 220 Ohms (at desired current), 0.6V = 5.1VN.B. Opinions on some of the figures I just estimated, can easily vary. E.g. Some will say Vbe is 600mV, also some might say Vsat on Q1 is zero, etc.But anyway, my estimate seems to be it would need 5.1V or more on the 5V rail, and good design should allow a 5% or 10% drop on the 5V rail, and it should still be expected to work well.Sorry if I seem to be nit picking.Also the LM317L can be a bit tricky to analyse (for me at least), so I readily accept I could be mistaken.EDIT: Where I have doubts in my criticism. Is can the adjustment pin of the LM317L, count as the minimum current source. If it can, then you could be good to go, or does it have to come from the output pin, which the wording of the datasheet seems to imply (to me).EDIT2: Because the currents are so low, and the datasheet bit I mentioned, is a recommendation, rather than an essential requirement. My estimates could easily be too high, which could easily make the real minimum voltage, perhaps 4.8V (wild estimate), which would begin to be fine.

author: Zero999
author_rank: Super Contributor
timestamp: July 15, 2022, 11:30:38 am
content: Quote from: MK14 on July 15, 2022, 11:06:52 amData sheets will often give figures like this, based on the full load, over the entire temperature range, but it's important to take into account how the part is being used in the design. The differential of 2.5V between the input and output is specified with a load current of 100mA. In this case, the current is 2.7mA so the drop-out voltage will be much lower, more like 1.8V so there's more than enough headroom. Older LM317L data sheets used to have a graph on them with the drop-out vs load current. This has vanished from the more recent one. It does frustrate me when manufactures remove information from data sheets.To answer your question about the adjustment pin: no it can't be used as a current source. The circuit works because the voltage drop between the output and adjustment pin is fixed at 1.25V, which appears across the sense resistor.

author: MK14
author_rank: Super Contributor
timestamp: July 15, 2022, 11:38:16 am
content: Quote from: Zero999 on July 15, 2022, 11:30:38 amThat makes a lot of sense, I agree.My estimating mechanism, is too use to there being a fair wack of current being thrown about, which would have made my estimates more realistic. Hence my edit2, done at around the time you made this NICE reply. Because rather low currents (such as 2.7mA's), will tend to make the voltage drops/losses, significantly less, especially in the LM317L, like you just mentioned.Thanks, your answer has taught me more about the LM317L's and LM317's.

author: Benta
author_rank: Super Contributor
timestamp: July 16, 2022, 08:47:42 pm
content: Quote from: Zero999 on July 15, 2022, 08:44:35 amThe LM317 is a slick idea for a current sink, sure.But I seriously question it's dynamic response to PWM.I've simulated several of the discrete circuits here.The most precise is the one using the PNP VBEjunction for temperature compensation:20...50 C sweep: ILED15.3...16.0 mA.Unfortunately it has inferior switching characteristics (which was to be expected) with a significant "current tail". Not recommended for use above 1 kHz.The fastest is the one using only transistors and resistors, but the temperature response is worse:20...50 C sweep: ILED13.3...15.1 mA.But it will perform beautifully at 20 kHz PWM, and with a bit of lack of PWM precision up to 100 kHz.As always, it's a design decision: which is more important? Temperature stability or PWM precision? I can't decide, it's your choice.I keep both designs in my my arsenal for future use.

author: Zero999
author_rank: Super Contributor
timestamp: July 16, 2022, 09:24:38 pm
content: Good point about the speed of the LM317.I wouldn't have thought he would PWM at 20kHz.How about the LM334?I didn't bother with a model for the simulation so I made one with a behavioural current source. Here's a practical example.

author: Benta
author_rank: Super Contributor
timestamp: July 16, 2022, 09:42:07 pm
content: This is getting a bit exotic, somehow.Sure, you can throw silicon at the design, but the two basic discrete circuits still stand. And at around 30 cents (hobbyist pricing) you can't do it cheaper or simpler.Temperature stability or PWM precision?That's the decision. I'd go for the 2nd choice every time. The first can be compensated with the PWM (every system has a temperature sensor these days).Cheers.

author: Zero999
author_rank: Super Contributor
timestamp: July 17, 2022, 09:43:49 am
content: I'm just having a bit of fun. In all honesty, if it were my design, I'd opt for thecircuit posted by Eugene. It's simple and the the 5V rail should be stable enough to make plain old current limiting resistors a viable option. I'd select high enough resistor values to ensure the maximum current rating of the LEDs isn't exceeded at the upper tolerance of the 5V rail (5.5V is reasonable) and lower forward voltage of the LEDs: 3.2V.R = V-VF/IF= (5.5-3.2)/0.02 = 2.3/0.02 = 115RIt makes no sense to use 115R, an E96 value, so the closest E24 value of 120R can be used instead.Of course the forward current will be approximately halved on the lower end of the tolerance of the 5V rail, which we can assume to be 4.5V, but 10mA should be enough and the user can simply adjust the brightness setting to compensate.

author: Benta
author_rank: Super Contributor
timestamp: July 17, 2022, 08:59:39 pm
content: I've removed my last posts due to wrong information.I'm unsure what happened here. I'm certain that the data sheet I found on the display showed four separate anodes and four separate cathodes. Perhaps I found the wrong data sheet? No idea, and I can't solve it. Sorry.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 27, 2022, 10:19:43 am
content: After a lot of simulation, I've decided to start practical experiments by building the following circuit:The VLED is provided byMicrochip MCP4801SPI (/CS, SCK, MOSI) DAC with an internal 2.048V reference, with the output varied between 0 and 2.048V only when the display is turned on or off; it will stay at 2.048V during normal operation. So, for the simulations I describe below, VLED=2.048V.At 15°C, the LED current is 18.5mA, and current over Q6 6.0mA.At 25°C, the LED current is 18.8mA, and current over Q6 6.1mA.At 65°C, the LED current is 19.8mA, and current over Q6 6.4mA.So, the model suggests about 5% drift upwards at 40°C ambient rise, which I consider acceptable.Replacing Q5 (BC857C, PNP) with BC847C (NPN) and adjusting the per-LED resistor to 74 Ohms, I can even invert the temperature dependence: 15°C/19.4mA, 25°C/18.9mA, 65°C/17.0mA, giving 10% downwards drift in current at 40°C ambient rise.I don't exactly trust those simulations (mostly becauseIconstructed them; I don't doubt the Nexperia SPICE models), but it does give me a solid place to start testing; I already ordered a heap of components I can experiment with.

author: Benta
author_rank: Super Contributor
timestamp: July 27, 2022, 06:18:55 pm
content: Looks fine to me, your results seem OK.From a design point of view, I find the Q6 current unnecessarily high. but that's your decision. With the BC857C you have an hFEof over 220 to play with.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 27, 2022, 07:32:16 pm
content: Quote from: Benta on July 27, 2022, 06:18:55 pmTrue! I do not have a good grasp of the design criteria to determine what a suitable current would be.You did mention 2mA as the absolute minimum, so I thought 6mA ought to be safe, but not too much.(I do not know how you arrived at that, but would like to know for sure. The only thing I can see in the NexperiaBC847Cdatasheet is that with VCE=5V and IC=2mA, hFEis specced to be at least 420. And that below 3mA, the collector-emitter saturation voltage is flat. Do these matter in practice?At or below 20mA,BC857Chas hFE> 400. If we use 200 so we have a reasonable margin, then the base current per PNP is max. 0.1mA, right? So, my theoretical understanding says that even with four PNPs, 1mA over Q6 would suffice. But would it, in practice?)How exactly do you determine a suitable practical collector current in this kind of a circuit?If I switch R5 and R6 to 470 Ohm, current over Q5 and Q6 would be almost exactly 3mA, without meaningful changes in e.g. thermal behaviour.With 1 kOhm, about 1.3mA.

author: MikeK
author_rank: Super Contributor
timestamp: July 27, 2022, 07:48:09 pm
content: When driving a transistor as a switch the gain (beta) used is usually 10 or 20, and this can be found in the datasheet where it gives the conditions for saturation voltage. For the BC847 I'm reading Ib=0.5mA and Ic=10mA...that's a gain of 20. So if you're expecting a collector current of, say, 20mA, a base current of 1mA is enough to do it.

author: Benta
author_rank: Super Contributor
timestamp: July 27, 2022, 07:56:32 pm
content: Quote from: MikeK on July 27, 2022, 07:48:09 pmThis circuit is running 100% linear, so totally irrelevant. Sorry.

author: Benta
author_rank: Super Contributor
timestamp: July 27, 2022, 08:34:45 pm
content: Quote from: Nominal Animal on July 27, 2022, 07:32:16 pmThe 2 mA I mentioned were for a slightly different design using B-types and different base drive, so let's leave that aside.But basically: it's all about experience, a bit of gut feeling and a lot of design iteration. With the BC847C857C type you have plenty of gain (it drops a bit when operating at -55 C )At a LED current of around 20 mA, a base current for the driver transistors of 4 x 25 uA = 0.1 mA is reasonable. That's what Q6 has to pull through its collector in addition to the bias current through Q5. At 6 mA, this corresponds to 1.6%. At 2 mA it's 5%.That's one part of the "error current" in the Q6 emitter resistor (which sets the reference for the full circuit). The second part comes from the Q6 base current (which is negligible).Now start adding in other error sources such a VBEvariations (both between devices and over temperature), resistor tolerances etc., and you'll see that the Q6 current is the very smallest part of all this.There's absolutely nothing "wrong" about your 6 mA and absolutely nothing "right" about my 2 mA. It's a design choice/balance.The target of my original circuit, now modified to the current one, was to have as close a matching between the LED currents as possible for an even backlight.Absolute precision was never the target.And I'm pretty certain, that the backlight LEDs are much worse matched than the currents from this circuit.Saturation voltages are irrelevant here.

author: Zero999
author_rank: Super Contributor
timestamp: July 27, 2022, 08:41:27 pm
content: Quote from: Benta on July 27, 2022, 07:56:32 pmTrue, the figure quoted by MikeK is for the saturation region. The original poster's design is working in the linear region. The data sheet specifies an hFEof about 500, when VCE= 5V. It'll be a little lower with VCE= 3V, but not by much. IBfor Q6 will probably be around the 12µA mark.

author: RoGeorge
author_rank: Super Contributor
timestamp: September 05, 2022, 05:48:29 pm
content: I didn't read all the previous messages, have the MOS-FET + coil (SMPS - Switching Mode Power Supply) solution been considered instead, so the energy won't be wasted as heat dissipated in the BJT transistors and the limiting R/68 ohms?A SMPS can be set as a DC current source, that would be great for a non-flickering back light. PWM might get nasty beats with the display's own refresh rates.There might be dedicated ICs with I2C or alike, to control a LED intensity without flicker, in DC.For a discrete components design, see if any of these SMPS topologies seem appealing:https://www.ti.com/lit/ml/sluw001g/sluw001g.pdfBriefhttps://www.ti.com/seclit/ug/slyu036/slyu036.pdfHandbook

author: Benta
author_rank: Super Contributor
timestamp: September 05, 2022, 06:34:13 pm
content: Quote from: RoGeorge on September 05, 2022, 05:48:29 pmDo that first, before posting something generic about switching converters, please. We all know how to do an internet search.

author: Nominal Animal
author_rank: Super Contributor
timestamp: September 05, 2022, 06:48:24 pm
content: Quote from: RoGeorge on September 05, 2022, 05:48:29 pmEven when dissipating the difference in the transistors and resistors, the design is still 67% efficient (producing at most 136mW of waste heat). Diminishing returns: I'm balancing design simple enough for a hobbyist, easily adjustable and customizable, component count, and overall price here. Since this is wall-wart powered and not battery-powered/portable device –– it is a display for routers and other Linux SBC-based appliances ––, the waste heat is an easily managed problem, compared to the other facers.Quote from: RoGeorge on September 05, 2022, 05:48:29 pmI'm using an 8-bit DAC with an internal reference –MCP4801T-E/SN–, not PWM. I have a physical potentiometer as a voltage divider to control the actual brightness, with the DAC providing smooth turn-on and turn-off effects. These are personal choices not dictated by the circuit, though. Similarly, I want four separate resistors, one of each LED, in case one of my displays has unmatched LEDs. (Unlikely, but possible; since these are all one-off designs for my own purposes and not something I intend to make in batches, I definitely want to spend some extra for flexibility and configurability.)The circuit shown above takes a 0 - 2.048V control voltage; I omitted the circuit I'm using to produce that control voltage. (Right now I'm traveling, and don't have the circuit with me.)Quote from: RoGeorge on September 05, 2022, 05:48:29 pmYes, especially switched-capacitor pumps likeTI LM27951orLM2794, but they're unobtainium right now.

author: RoGeorge
author_rank: Super Contributor
timestamp: September 06, 2022, 07:24:08 am
content: For a DAC, you may want to consider our senses about intensity are logarithmic, while a DAC has linear output, therefore most of the values will translate to almost full light, and only a few very small DAC values will get a good dim. You may want to experiment first, and see if an 8 bits DAC is enough to implement a logarithmic output.For example, this is a 1 minute showing LEDs browsed with 8 bits linear dim. Note how most of the time they are mostly on, dimming happens linear for the average current, but not for the eye:Video is from this demo:https://hackaday.io/project/6356-delta-sigma-versus-pwmhttps://github.com/RoGeorge/Delta-Sigma_versus_PWM/blob/master/main.cSince you already have an MCU and a few pins to control the DAC, I would just pulse those DO to dim the LEDs instead (and remove the DAC). To minimize flicker, I wonder if a C in parallel with the LED will worth, thinking about this as we speak, didn't calculate/simulate, anything. I mean, you have the series resistor, then the LED, but in parallel with the LED, add a capacitor to store some energy for the periods when the pulse from the MCU is off. Tempting?With the risk of getting boo-ed even more, I'll prefer just a logarithmic (mechanical) potentiometer in series with the LED's and nothing more, not sure if such a potentiometer (with a small enough value) could be found.

author: Nominal Animal
author_rank: Super Contributor
timestamp: September 06, 2022, 12:04:56 pm
content: Quote from: RoGeorge on September 06, 2022, 07:24:08 amLike I said, it's only used to ramp the backlight on and off smoothly. Similarly, even though the potentiometer is linear (even logarithmic and antilogarithmic ones are usually just piecewise linear), as it controls the overall brightness, its response and dynamic range is much more important than the overall curve.There is also the fact that the luminosity-current curve of the LEDs is definitely non-linear. Eight bits – or in my case, a bit over seven effective bits, since the current turns off at about 0.7V control voltage, leaving 2.048V-0.7V ≃ 1.35V effective control range – is enough even in linear form to achieve a nice smooth ramp-in and ramp-out; that is, the resolution suffices at both ends, regardless of the ramp function I choose. Most likely a fifth or seventh-degree polynomial with fixed coefficients, as the MCU I'm using (Teensy 4.0, i.MX RT1062) has hardware single-precision floating point support.(I'm very familiar with psychovisual effects, having done real research into both sonification and visualization wrt. representations of molecular simulations.)Quote from: RoGeorge on September 06, 2022, 07:24:08 amThey tend to be piecewise linear. However, I think you can compensate both the LED luminosity-current curve and the human psychovisual response by using the potentiometer as a variable resistor, as the next-to-ground part of a voltage divider; possibly with a fixed resistor in parallel to the voltage divider.However, there is no need for the potentiometer to precisely match the inverse of the perceived luminosity. It is much more important that at every possible position, there is immediate response. (A mathematician would say that if the perceived response is the same at all points, then the potentiometer precisely matches the inverse of the perceived luminosity.. the thing is, with human perception, a difference of 10% - 20% is insignificant here, and even 50% in the difference of the immediate response is acceptable here, so theoverallcurve can be quite far from the inverse of the perceived luminosity!)

author: RoGeorge
author_rank: Super Contributor
timestamp: September 06, 2022, 03:01:36 pm
content: I see now this thread has settled down 2 monts ago before I replied (arrived here from a PM link, and didn't check the last post's date, my bad, sorry, shouldn't have necropost), but since that already happened ...Took a brief read and this seems to be the current version, right?If so:1. - I wouldn't have used a REF3333. That's a very stable reference, a total waste for the purpose (and in the current chips shortage), especially because Teensy already has a 3.3V stabilized voltage. Use the existing 3.3V from Teensy's 3.3V stabiliser as reference.2. - Eugene gave the proper solution, 1 transistor to control all 4 LED's. 4 transistors controlled all at once doesn't make much sense to me.3. - If I must have 1 transistor/LED, at least I would control them individually, so the ON pulses will be the same duty factor, but shifted in time, so to quadruple the flickering frequency.4. - You were saying something about observing in simulation the switching regime. Indeed, when driven into saturation, switching off a BJT will lag behind the control signal. Have to either avoid entering saturation (easiest with a clamping diode to collector), or to remove the charges from the base in a "forced" way, so to turn off the transistor faster (can be done many ways, the simplest would be an RC parallel circuit in series with the base).5. - I would prefer switching MOSFETs than BJTs.6. - VLED signal is output from the DAC, yet tied to the cursor of a potentiometer and to the base of Q1. You were talking in the OP about PWM, so are the LED pulsing or controlled in DC? If pulsing, then who's pulsing them, if DC, then who's stabilising the current? Controling LEDs by voltage doesn't work well, there are to bigger variations with temperature and from one batch of LEDs to another to count on Voltage vs Light intensity charts. You said you want pulsed so to not change the spectrum of the light, then you seem to control it with DC, and in voltage? What am I missing?7. - AFAIK (disregarding light intensity with the die temperature, which are not really visible do the eye), the forward current Ifvs Vfis an exponential, and Light intensity (I think flux, not sure) is directly proportional with If. The eye perceived flux is logarithmic.8. - If I were you I would choose a display with less power hungry LEDs. The ones you have will need typical 70 million A (MA)according to page 11 of the datasheethttps://www.buydisplay.com/download/manual/ER-TFT028A2-4_Datasheet.pdfAnyways, if you made the circuit already and it works upon your wish, then well doneand please don't waste time to clarify the above points I didn't understood from the 4 pages.Posting again only because you just wrote something else that I'm very interested in:Quote from: Nominal Animal on September 06, 2022, 12:04:56 pmDoes this happen to cover any effects of very low frequency blinking lights (less than 10Hz)?Asking because I did once a blinking toy with two (monochrome) LEDs, and the effects to the brain were very unexpected. It was possible to perceive full colors (which were other colors than the LED's color) with the eyes closed (light from the LEDs through the eyelid), and other visual illusions like patterns depending of the blinking type, some people were reporting sleepiness, others nausea, etc.That experiment was very interesting, then forgot about it and it stayed dormant in my bucket list researches for about 15-20 years now, and you just summoned it again.

author: Nominal Animal
author_rank: Super Contributor
timestamp: September 06, 2022, 05:09:09 pm
content: Quote from: RoGeorge on September 06, 2022, 03:01:36 pmNope; it's something like the following:Quote from: RoGeorge on September 06, 2022, 03:01:36 pmWhile they are usually well enough matched, I just want the option to slightly adjust the balance between the LEDs, in case they are not.Quote from: RoGeorge on September 06, 2022, 03:01:36 pmNo, I did not. I said that I want the display to be driven with constant current, and that I was aware of the slight change in the light spectrum depending on the current. I did not say that I wanted to do PWM (or PDM), only that it was one option I was considering. Any slight bias in the backlight spectrum is irrelevant, because this is an information display, not something that attempts to reproduce photographs or similar.In the very first post, I wrote that"I'd also like to have MCU brightness control, maybe via PWM or something (although I'll only use it for smooth on-off transitions)."That is, the backlight brightness is only controlled by the MCU when turning it on or off. At all other times, either the backlight is completely off, or it is on at whatever maximum brightness the end user wants it. Having the physical brightness control be a potentiometer not under MCU control is simple and robust, which I like; it also makes it easier to both simulate and breadboard-test the design.I was hoping that having this thread here might help other hobbyists investigating how they want to control their LED backlights. Some might note that I chose particular transistors which I could easily both simulate and obtain (I now have 100 of BC847C,215 and BC857C,215 each from Nexperia); I tried to de-emphasize my own choices, and emphasize the reasons why one might make particular choices, so that others with different design criteria could benefit from this thread, too. So, if one reads this thread just to see what I was going after, it can definitely look odd. Do not forget, I learned a lot about practical circuits (especially driving LEDs) in this thread, too, soprogressionis to be expected!Quote from: RoGeorge on September 06, 2022, 03:01:36 pmNo, I focused more on color-depth perception, edge/outline thickness in relation to perception of structure and connectedness, and such. Basically, anything that could be useful in trying to answer the question"How do I control the information in this illustration, so that it gives thedesired intuitionin the viewer?"You see, making "nice" or "photorealistic" pictures of atoms and molecules gives completely incorrect intuition about what the illustration attempts to describe, and controlling the information conveyed – by minimizing superfluous information (so cel-shading instead of photorealistic reflections and shadows) and controlling the visual cues that generate the intuition. There is a lot of empirical knowledge about this in visual arts. For sonification, I wanted to find methods that would complement the visual information (and thus be useful to those without problems in vision) like "tracers"; there are already quite a lot of ways of describing statistical data, distributions and curves.I'm personally very prone to visually induced headaches by blinking lights –– I particularly hate bicyclists that use blinking headlights: if I'm tired, and it is dark outside, the blinking ones can induce me to vomit.Quote from: RoGeorge on September 06, 2022, 03:01:36 pmYes; human visual perception being such that if you look at a picture for more than a few seconds, looking at a constant background makes you perceive the original picture in negative. There are many such effects, some dealing with depth perception (including color), others dealing with structure and outline and persistence (like how you can easily see through a picket fence from a moving car, even though the spaces between the pickets are only a small fraction of the width of the pickers)... and then there is the sleight of hand, or controlling the focus of attention. To blow your own mind, I recommend you watch theselective attention test from 1999 by Daniel Simons and Christopher Chabris.

author: RoGeorge
author_rank: Super Contributor
timestamp: September 06, 2022, 06:41:10 pm
content: Quote from: Nominal Animal on September 06, 2022, 05:09:09 pmHe, he, nice one indeed, know that one from when it first came to YouTube. I failed that test!Back then I was not watching YouTube at 2x speed (speed shift was not yet an option), and I remember I was looking at that video only, and paying attention to it. So I payed full attention and still failed.That video was one of the clues that consolidated one of my pet theories about what a conscious mind most probably is:Quote from: RoGeorge on August 21, 2022, 07:37:12 amAnd that is what I think self-awareness/conscience is: it's the continuous simulation, the driven illusion we keep adjusting to match reality. This ability is not specific to humans only. Most of the other animals having a brain are obviously conscious and self-aware, too, just like us humans. I'm not yet sure about more exotic lifeforms, e.g. a bee-hive, or an ant-colony, or a fungi-network.Oh, and about those blinking LEDs, I could see the colors, too, and I have no aversion against blinking lights. It was something else. Back then it was quite trendy, I think it was first introduced by the same guy that did the TVBgone, an IR remote control gadget able to shut down almost any brand of TV, good to shut them off in shops, small bars, hotels lobbies, etc. (back than it was always a TV on somewhere in public spaces continuously brainwashing everybody around, very annoying). I digress.Will search again for the timing of those blinking LEDs, and post it for fun (not here, sorry for the OT).My interpretation back then was the pulses were producing some sort of a Heaviside steps, and that was full in many other frequencies than the usual, in regards to the normal nervous activity rhythms, so the pulses were ringing in the nervous paths giving birth to colors and patterns.Would like to test the hypotheses by using pulses with soft edges instead, like a Gaussian with the same energy as the square pulse (because the Fourier of a Gaussian is also a Gaussian shape, so no harmonics). I would expect for the colors and patterns illusions to not form when the LEDs are blinking with Gaussian instead of square pulses.

author: Nominal Animal
author_rank: Super Contributor
timestamp: September 06, 2022, 07:35:24 pm
content: Quote from: RoGeorge on September 06, 2022, 06:41:10 pmPerception is more complicated than that, as we can perceive extremely short pulses of light, without "decomposing" them into lower frequency components somehow.However, there is something there, because soft-edged pulsing (roughly sinusoidal) gives me very little nausea (typically none, except around 10-15 Hz) compared to hard-edged pulsing at the same frequency, while the duty cycle does not seem to matter much (although 50% is the easiest to tolerate).I suspect the root phenomena is deeper in the human brain, something related to motion perception, instead. (That could explain the nausea, too, as a dissonance between visual stimuli and the vestibular system in our ears.)

author: RoGeorge
author_rank: Super Contributor
timestamp: September 06, 2022, 08:19:37 pm
content: Quote from: Nominal Animal on September 06, 2022, 07:35:24 pmHave you noticed how much more sensitive is the peripheral vision in regards to faint-light blinking or movement?Especially during night, even the faintest light makes you turn the head there (i.e. the blinking blue light of the heartbeat "alarm armed" LED in a car parked 100m away somewhere at the lateral edge of the field of view), only to see nothing when looking directly.For some strange reason only the peripheral vision can spot such a faint blinking light. When looking directly to the car, you see nothing blinking. Then when you turn the head away, you see it blinking again, very annoying!

author: RoGeorge
author_rank: Super Contributor
timestamp: September 07, 2022, 07:51:13 am
content: About the OT, opened a new project:https://www.eevblog.com/forum/projects/visual-hallucinations-induced-with-two-blinking-leds/Regarding the 4 transistors controlled the same, one for each LEDQuote from: Nominal Animal on September 06, 2022, 05:09:09 pmIndeed, LEDs from the same batch are so well matched that, in commercial LED light bulbs, the LEDs are often connected in parallel without any balancing resistor, and there is no visual difference in intensity, not even at very low currents and over a wide range of temperatures.A visual example to illustrate how well they match in practice, 3 groups of 2 parallel LEDs (from a former mains light bulb). Note how each of the two LEDs that are in parallel looks identical in light intensity even at very low light levels (where the eye is able to spot any differences more easily):Just in case the LEDs might not be very well matched, a small balancing resistor in series to each LED might be enough for balancing, while they are all controlled from one transistor.

author: Nominal Animal
author_rank: Super Contributor
timestamp: September 07, 2022, 08:10:23 am
content: Quote from: RoGeorge on September 06, 2022, 08:19:37 pmYes, this is well known phenomenon. (I can see the flicker in most fluorescent lights here (50 Hz mains, so 100 Hz flicker) in my own peripheral vision, and it annoys the heck out of me.)The entire vision setup in humans is weird. First, we have four types of receptor cells in our retina, one dedicated for low-light conditions ("scotopic", most sensitive in the blue-green region, around 555 nm), and the three for color perception. Second, the retina is not uniform: there is a rather small spot of dense receptors (fovea), with fewer receptors outside that spot. The brain automagically keeps track of objects and movements outside the sharp vision cone, so that we think weperceiveeverything in sharp focus. Third, the eyeball is not static nor does it always move smoothly: they "twitch" (saccades, or saccadic movement) to compensate for the slowness of the visual processing in the human brain. (Human eyes are only attached to six muscles each, plus the nerve bundle to the brain.) Fourth, while those color receptors are for red, green, and blue, our brains actually processes them somewhat as "red-green" (blue-green to magenta) and "blue-yellow" (yellow-green to violet). The color receptors also react faster than the low-light receptors.So, there are at least three completely different facets to human vision: physical, due to properties of the eyeball and cells involved; visual, due to the processing chain in the brain; and perceptive, due to the 'interpretation' of the former two in the brain.It is notable that many devices have switched from blinking leds to "breathing" leds, with roughly sinusoidal intensity curves, exactly because the abrupt on-off-on transitions are so taxing/annoying to us humans.This does tie into this thread in that it explains why some humans are more susceptible to being annoyed by certain visual effects, but more importantly, why one might choose a different backlighting method depending on thepurposeof the device.In my case, this display is intended to convey state information (about current wired and wireless networks) to non-technical users in a relaxed, usually not very brightly lit common room or media room or such; definitely not an office.If I were to use PWM, I'd need it to be above 1 kHz or so, just to be sure I avoid perceptible flicker. However, I also hate audible coil/capacitor whine, so I'd prefer to push the frequency above human hearing, to say 30 kHz or above. At those frequencies, we already have effects like even a very short pulse on the transistor base yielding a relatively long pulse of conductivity, which limits the minimum on-time (as I discovered earlier in this thread). Using the transistors in their linear region does mean the difference between the supply voltage and the forward voltage of the LEDs is wasted as heat (in the transistors and the resistors), but avoids the aforementioned issues completely, plus makes it easy to control the LED current with a control voltage basically linearly; which in turn allows me to use a DAC for fade-in and fade-out, and a physical pot to control the steady-state brightness, as that seems to me to be the optimum for this particular use case.The one quirk in this design is that I specifically wanted to be able to easily adjust the current to each LED (if possible), in relation to each other, to account for any imbalance in light output at the same current between the LEDs. Here, the 68 ohm resistors will actually be pairs of 0805/0603 resistor footprints, so that if I do need a bit of adjustment, I can do so by putting two resistors in parallel. For example, a 100 ohm in parallel with a 200 ohm one yields 1/(1/100+1/200)=200/3≃67 ohm. I do not expect to need to do this, but since I'm making only one or two of these, I want the ability to do so if needed, rather than having to order another display (which typically takes weeks to arrive).