Learn how to build a USB-powered LED filament circuit using an ESP32 microcontroller and DC boost converter. This project explores the use of a gate driver, inductor, diode, and capacitor to create a circuit that can power multiple LED filaments from a 5V USB supply.
[0:00] Big Clive did a video a few months back showing these LED filaments
[0:04] and I thought it would be fun to do a little project with them.
[0:07] There are 18 LEDs in each filament all in series
[0:10] so to get them to light up weāll need around 43 volts or more.
[0:14] Now obviously big clive just connected his straight to the mains using a capacitor dropper
[0:18] But as Iāve pointed out before Iām not Big Clive.
[0:21] Iād quite like to power mine from a 5-volt USB supply
[0:24] so weāre going to need to boost our power supply up by quite a bit.
[0:28] So DC boost converter circuits are conceptually pretty simple.
[0:32] All we need is an inductor, a switch, a diode, and a capacitor.
[0:36] So Iāve set this circuit up in KiCad and I thought it would be interesting to try and simulate it.
[0:41] Iāve added a 4K7 load onto the output
[0:45] Weāll see how well it actually drives that
[0:47] We should get around 10 milliamps at our target voltage
[0:51] For the capacitor and the inductor, Iāve used the standard PSpice simulation symbols
[0:56] If we look in the component library and search for PSpice
[1:00] we can see that we have some built-in models
[1:02] We have the capacitor and we have the inductor
[1:06] For the diode, Iām using a Schottky diode.
[1:09] Iām using a 100 volt 1 amp Schottky diode and I have a spice model that Iāve downloaded for this
[1:14] The only thing i had to do was change the node sequence to 2 1
[1:18] instead of 1 2 because i found my diode was being simulated in the wrong direction
[1:23] For the switch, we have an IRF640N
[1:26] Iāve downloaded a spice model for this and we should be able to simulate this fairly accurately
[1:32] To power the circuit Iāve set up a 5 volt DC voltage source
[1:36] And to power the gate of the MOSFET Iāve set up another voltage source
[1:39] And on the spice model for this,
[1:41] Iāve set it up with a 25 microsecond period which should be 40 kilohertz
[1:46] And Iāve set up a 12.5 microsecond pulse width which should give us 50% duty cycle
[1:52] Letās try simulating this
[1:53] The only thing we need is some instructions for the simulator to tell you what to do
[1:57] So this bit of text tells the simulator to run a transient simulation
[2:01] running with 0.1 microsecond steps for 0.2 seconds starting from 0 seconds
[2:06] On KiCad 6 we go to inspect and then click the simulator button
[2:11] We can now hit the run stop simulation and it will start to simulate our circuit
[2:18] So thatās our simulation completed letās have a look at the output voltage
[2:24] If we bring up a cursor we can measure this exactly
[2:28] We click show cursor and now we can drag this cursor around
[2:31] and we can see weāre getting around 58 volts on the output
[2:35] Letās go back to our voltage source thatās driving the gate and change the period to slightly lower
[2:40] Letās change our period to 10 microseconds which should be a duty cycle of 40
[2:46] Weāll change that and then weāll go back to the simulation and re-run it
[2:54] Our simulation is completed and weāve hit our magic number of 47 volts on the output
[2:59] If we add the current going through the load resistor we should see around 10 milliamps
[3:05] Which we do so letās just double-check that
[3:07] Weāll show the cursor
[3:09] and we can see we get almost exactly 10 milliamps going through our load resistor
[3:14] So I think our circuit should work pretty well
[3:16] Letās move over to the workbench and build it and see how it performs in the real world
[3:20] Do you like PCBs?
[3:21] Do you want to make a PCB in a weird and wacky colour like purple?
[3:25] Maybe youād like a flexible PCB?
[3:27] Or maybe youād like someone to do some CNC work for you?
[3:31] Check out the link to PCBWay in the description
[3:39] So Iāve built the circuit on a breadboard and Iāve wired up to my signal generator
[3:44] Iām running the signal generator through a gate driver chip just
[3:47] to make sure we get a nice clean signal on the gate of the MOSFET
[3:52] Letās slowly ramp up the duty cycle and see what happens to the output voltage
[4:02] At around 42 or 43 duty cycle we get 47 volts going across our 4k7 resistor
[4:10] The circuit works pretty well and actually matches the simulated circuit fairly accurately
[4:15] Letās try it with one of our LED filaments and see how well it works lighting one up
[4:19] Iāve plugged one in and Iāve put a 100-ohm resistor just to measure
[4:23] the current going into it and limit the current
[4:26] So my multimeter is currently set on the millivolt range
[4:29] so if we divide this number by 100 we get the current going through the filament in milliamps
[4:36] This is around two milliamps running through the filament
[4:39] Iāll need to change the range on the multimeter now
[4:44] so weāre at 2.3 milliamps as we ramp up we get to around 3 milliamps
[4:50] itās actually pretty bright now and as we keep going up this is now five milliamps
[4:57] six
[4:58] seven
[4:59] eight
[5:00] nine
[5:01] and now weāre at 10 milliamps going through the LED filament
[5:04] Itās actually quite hard to look at
[5:06] The camera is doing quite a good job at capturing the dynamic range of the video
[5:12] So letās turn this down letās try on a slightly harder problem
[5:15] Weāll try plugging in seven of the led filaments
[5:18] Weāll just unplug this one
[5:25] And once again Iām just using the 100-ohm resistor to limit the current
[5:29] and Iāve plugged in seven filaments so letās ramp up the duty cycle again
[5:35] Iāve left the multimeter on the 20-volt range
[5:38] so this is currently around five milliamps driving these seven LED filaments
[5:45] Now we have 10 milliamps going through them
[5:48] Letās just check the components are not getting hot
[5:50] and the finger test says theyāre all okay
[5:53] So letās ramp it up some more
[6:05] 20 milliamps
[6:09] 30 milliamps
[6:15] thatās 40,
[6:16] 50,
[6:17] 60 milliamps
[6:18] So with seven filaments, thatās just under 10 milliamps per filament
[6:23] and our circuitās still performing well
[6:27] So letās measure the voltage thatās actually running across our load
[6:30] So weāll move our multimeter around and switch it to the 200-volt range
[6:36] and we have 44.5 or 44.6 volts going across our load
[6:41] and what happens if we remove our load?
[6:43] suddenly it jumps up
[6:44] itās now 116-120 volts
[6:48] this is actually out of spec for most of our components
[6:51] if we now plug back in our little single filament then it drops down to 46.1
[6:58] but then if we remove our filament it jumps up again to over 100 volts
[7:04] and we can see this as we add and remove the load,
[7:07] the voltage swings around quite dramatically
[7:09] So what we need to do is add some feedback to this circuit so the duty cycle is controlled
[7:14] So as the load comes on and off the circuit
[7:17] we adjust the duty cycle to maintain the output voltage
[7:22] Now I know right now lots of you will be thinking:
[7:25] āChris, you can just buy chips that will do this. Stop messing aroundā
[7:29] And you are right
[7:31] But in my project Iām going to need an ESP32
[7:34] anyway - so we might as well use it to drive the MOSFET as well.
[7:38] The ESP32 can output PWM signals and itās got an Analog to Digital Converter
[7:43] So we should be able to use it to monitor the output voltage
[7:46] and update the duty cycle that is driving the MOSFET
[7:49] For the feedback from the output,
[7:51] we do need to be careful not to put more than 3.3 volts into the ESP32
[7:56] Iām going to have a voltage divider on the output with a
[7:59] trimmer potentiometer on the bottom and quite a high-value resistor on the top
[8:03] but Iām also going to be extra careful
[8:05] and Iām adding a 3.3-volt zone diode across the output of the potentiometer.
[8:10] This should mean itās impossible for the voltage to go over 3.3-volts.
[8:15] Weāll compare the voltage coming from the potentiometer against a reference
[8:18] voltage in our code and try and drive the duty cycle so that we get zero error.
[8:24] This is the circuit weāre going to build.
[8:26] Itās not very complicated we have the ESP32
[8:29] driving the MOSFET of the boost converter through a gate driver
[8:33] and we have the voltage divider on the output feeding back into the ESP32.
[8:38] There is one small gotcha that we have with the ESP32:
[8:41] the Analog to Digital Converter on the ESP32 is notoriously noisy
[8:46] Iāve hooked up a potentiometer on the input and you can see just how noisy it is on this trace.
[8:52] To help fix this problem iām going to be taking multiple readings from the ADC
[8:57] and Iāll take the median value of these readings.
[9:00] So Iāve added this filtered output to the trace alongside the raw value
[9:03] and as you can see itās now a lot smoother and almost all the noise has been removed.
[9:08] Now that we can monitor the output voltage we just need to compare it
[9:11] with a reference value and adjust the PWM output until the error is zero.
[9:16] Initially, I was thinking of making a PID controller but in the end,
[9:20] I found it was sufficient just to use the āIā from the PID.
[9:24] So weāre just adjusting the duty cycle by adding the voltage difference times a constant factor.
[9:29] One interesting thing to note on the ESP32 is you canāt use floating
[9:33] point instructions in an interrupt routine
[9:36] So Iām using fixed point arithmetic and just multiplying everything by 1000
[9:41] So letās plug it all together and see if it works
[9:47] Iāve got the same boost circuit as before except Iāve now got the gate driver connected to an ESP32
[9:53] And Iāve got feedback from the output voltage going back into this ESP32 via a voltage divider
[9:58] And Iāve got my safety Zener diode so i donāt accidentally blow up the esp32
[10:03] On the top right, Iām monitoring the signal on the gate of the MOSFET
[10:07] and in the bottom right Iām logging out the duty cycle and Iām logging out the voltage on the ADC
[10:13] Iāve multiplied this voltage by 10 so itās on a similar scale to the duty cycle
[10:17] Iāve adjusted the trim pot so that we have the lowest possible voltage
[10:21] which gives us a duty cycle of just under five per cent
[10:25] Thereās currently nothing connected to the output apart from our voltage divider
[10:29] letās ramp up the output to 46 volts
[10:40] you can see as Iām ramping the voltage up the value on the ADC is staying pretty constant
[10:52] so to get our voltage of 46 volts we need a duty cycle of around 17.5 per cent
[10:58] Letās try adding some led filaments to our load
[11:01] Iāll run each one with a 100-ohm current limit resistor
[11:07] with one filament we need a 22% duty cycle
[11:12] with two we need just over 25%
[11:16] with three itās just under 27%
[11:20] and four just under 32
[11:24] five we need just over 33%
[11:27] and six itās 36.5%
[11:30] I donāt have any more room on my breadboard for more so six weāll have to stop at
[11:34] But we can bump up and bump down the voltage on the output
[11:38] So we can dim and make the LEDs go brighter
[11:41] So even at 47 volts we just need 65% or 64% duty cycle
[11:47] So thereās quite a lot of headroom in this circuit
[11:49] So we could easily make it much brighter or add more filaments
[11:53] And youāll notice the output voltage has stayed pretty consistent throughout adding the LEDs
[11:59] We can also measure the current going into one of the LEDs
[12:02] So letās have a look at this
[12:04] and we can see we have around 3.7 milliamps going through this LED filament
[12:09] So we could definitely make it brighter or we can add more led filaments
[12:12] Iām aiming for seven so Iāve got six at the moment seven seems really achievable
[12:17] So this is going to work pretty well for my project Iāll do a follow-up video soon
[12:21] when I do the next phase of this exciting project
[12:24] so Iāll see you soon
[12:29] So Iāve just been browsing AliExpress and I found 3-volt versions of the LED filaments
[12:35] So Iāve ordered some of these theyāll take a
[12:36] few weeks to arrive so Iām going to carry on with the existing project
[12:40] but Iām quite interested to see how well these ones work
[12:42] So Iāll see you in the next video