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