diy solar

diy solar

Arduino-Based IGBT PWM Charge Controller

bwinzey

New Member
Joined
Mar 11, 2021
Messages
36
So, after buying a bunch of random parts for my HVDC Franken-Inverter project and then putting it on the backburner for college, I'm finally done with classes and have ~1 month free before next semester. So time to get cranking!

I was daydreaming a bit about the inverter, and decided it would probably be a bit easier to work on the solar charger part. After all, it's pretty simple operation.

While I was planning the initial inverter (Using the Toshiba MG300J2YS40 300A-600V IGBT bricks, which got for $15 a pop, but left behind for a set of monstrous Infineon FF1000R17IE4 1400A-1700V bricks) I remembered I had also purchased a couple of these gate drivers:
3b9e136b4d604b208de71814f4eddf38.jpg

They are Fuji EXB841 IGBT drivers. Rated to drive up to 400A modules at up to 40kHz. Only cost around $4 each. Given that they're from the same era ~early 2000's, I figured they'd be a decent match with the MG300J2YS40's. And they are. The main reason why I didn't end up using these in the inverter part is b/c they are too weak to drive the large bricks I decided to go with.


So basically I was just looking through my component trays and realized I could just pair these up and make an Arduino (ESP32) PWM controller.

As I started writing the code I realized that you can do SO MANY things with a PWM controller by only changing a few things.
So I kind of deviated a little bit. I started adding options to my code, so that you can set different 'Modes' for the controller, such as Variable PSU, Fixed PSU, and Solar Charging. Also picked a 5000Hz carrier frequency as that's fast enough to not be loud and super noisy (in both terms of the word), but slow enough so that the gate isn't working overtime.
IGBT DRIVER SCHEMATIC.jpgIMG_20211212_042920.jpg
To be able to use the driver properly I figured I might as well just make a little breadboard. I was surprised by how little external circuitry it needed. There's only 4 other components on the board:
-a 2200uF capacitor on the 20v bus (I literally have a bag of them, I understand its overkill but I enjoy putting big capacitors on things)
-a 470uF capacitor placed parallel to the negative voltage drive of the driver (It's recommended in the EXB841 manual)
-6.8ohm 2w gate resistor. Manual for the EXB841 recommends 8.2ohm but I later tested with another in series to make 8.2 and it made no difference in ringing.
-200ohm resistor for the built-in optocoupler, to run it off of the ~3.27 volts from the ESP32 at ~11mA.

I put these terminal connectors I had laying around so I could make it at least somewhat detachable for when I inevitably have to move wires around.

I then used one of those proto-boards to set up my ESP32 with an INA226 Current & voltage sensor, a 1.3" OLED display for troubleshooting, and a potentiometer to input controls.

I then set it up, USB powering the ESP32, my adjustable bench power supply powering the IGBT driver with 20v, and a 12v server PSU as my power source to be controlled.
At first I used a 12V 5A halogen lamp for testing, and used the capacitors from the inverter as an output 'filter'. Although it wasn't doing much of that haha. As expected, nothing really worked properly. My code for AVR(automatic voltage regulation) was a bit exaggerated, and struggled to maintain low voltages. AND HOLY noise... Everytime the IGBT started purring, the IIC display connected to the breadboard went HAYWIRE. Spamming all sorts of ancient hieroglyphs and perhaps some alien alphabets in there as well. I connected my scope to the Emmiter-Gate, and there was the problem. A LOT of ringing.
IMG_20211212_014700.jpg
It was so bad that it was enough to re-activate the gate twice before dying down.
I stole one of the 3.0uF Snubber capacitors from the inverter and put it on the power supply side of the IGBT. It helped, there was now much less noise in the system (screen wasn't spazzing out anymore, current and voltage readings from the INA226 were MUCH more stable) but there was still enough gate ringing to cause problems.
So I started troubleshooting. First I assumed it was the gate drive, but after messing around with different gate resistors and making ZERO difference in the ringing, I went further back, to the output pin of the ESP32. And to my surprise, it was also ringing, which was in turn causing the IGBT driver to mimic the ringing and cause an excessive ringing. After some messing around, I tried turning off the 12v supply connected to the IGBT, and the signals cleaned up COMPLETELY. They were perfect. Back to square 1.
I then started messing around with a 470uF electrolytic cap, placing it in different parts of the circuit, and found that placing it right across the collector and emitter of the switching transistor (the module has 2 transistors, B1 is left open and used only as a diode) worked best. There was a HUGE decrease in ringing.

IMG_20211212_023903.jpg

Here's a drawing of where I placed it.


Untitled.png


Not only was the ringing drastically decreased, but the IGBT is now heating up much less. With a 160W draw (at the wall, by the PSU, take off maybe 15% for efficiency) in total say 136w, calculating at 12.5V of the PSU totals around ~10.88A flowing through the IGBT. Before the capacitor, the IGBT with the little heatsink just sitting on the table reached equilibrium at around 60C at the base, and around 55C at the heatsink.
After the capacitor, I felt confident and bumped up the load to 200w. Again, assuming 85% PSU efficiency equals to 170w at 12.5V, which means ~13.6A were flowing through the IGBT. And it was running significantly colder, staying under 50C throughout testing, which I'm quite pleased with. With the size of the heatsink and not having a fan, or thermal paste (used double sided thermal tape, it's not that good) it was nice to see. I'm sure with a proper heatsink and fan, I'd be able to push 100A continuous through this without issues, with a pretty large overhead.

The beautiful thing about IGBTs like this are the voltage ratings. Like right now, 13.6A at 12v isn't much power at all. But if this were a 320vdc bus connected to 400v of solar panels, you could literally pass 320*13.6=4.3kW of power in the state that it is right now, without even using a fan. At 100A, over 30kW!

IMG_20211212_042854.jpg

Sorry for how messy/ratchet everything is but I literally cobbled this together in like 2 hours. It's a proof of concept but I will definitely be polishing the code as well as making proper bus bars for it and adding proper filtering. With 2 snubbers the rest of the ringing should be minimized.

As of now, I've only really done the voltage portion of the controller, meaning that the variable PSU works halfway, as I haven't implemented current controls yet, and Fixed PSU works pretty good. The charger portion works but it's dumb, as in it basically just locks at 100% duty cycle until it reaches the target voltage and if it starts dropping, starts modulating at just the right duty cycle to keep the voltage at the target voltage. There's no phases or soaking or anything like that.

I just need to configure the current monitoring, right now I'm using an INA226 with a 750A 75mA shunt. (Yes, seven-hundred-fifty amps) as that's what I have on hand ATM. I have a 100A shunt coming sometime in the future to make measurements much more accurate, as the 750A shunt is understandably fidgety at low currents.

The IGBT gate driver has a built-in overcurrent detection system, which I have to figure out how it works, since the manual is very vague about it for some reason. Once I do that I just have to set up an interrupt in the ESP32 to shut down if and when such an event is triggered.

I also have a pair of EV200AAANA 500A 900V relays/contactors coming in, which I plan to use one for this charger. This will be extremely useful in situations where all solar power input is needed, where the PWM would just be locked at 100%, like every morning for example. The idea is that it will just bypass the IGBT and connect the solar straight to the output, until the target voltage is reached, in which case it will drop the contactor and begin working on PWM again. The idea behind it is to avoid the innate power losses in the IGBT. Even when IGBT's are fully on, they have a voltage drop of around 1.5-2V. Meaning, at 100A for example, it will be dissipating more than 200W+ of power, if not more (the drop slightly increases with current, my IGBTs manuals don't have the graph for it though. Which, if you consider you're charging 100A at 320v, that's over 30kW, so you can say 99% efficiency is still pretty good, but at lower voltages it it starts to add up. For example, if I had a 48v system charging at the same 100A, that's 4800w, but you still lose more than 200w at the IGBT. By using a contactor you save all that power.

In terms of MPPT VS PWM at these high voltages, there's really not much point in going MPPT. MPPT is for low voltages using higher voltage panels. In this case, the MAX open circuit voltage of whatever solar circuit I have connected must be less than 600V. That leaves room for a ~92S lithium battery hovering between 310V (minimum required to make to 220vac) (@3.4vpc) and 380v (@4.15vpc) charged. Plenty of headroom.

But anyways, still plenty of work to be done, but at least as a proof of concept works. Without proper filtering was able to maintain a ~+-400mv ripple at low duty cycles. Good enough for me. Might make a video soon in a couple of days if I make significant progress.
 

Here's a video I made playing around with it and talking about it.

I'm actually pretty happy with how the PWM and duty cycle modulation works with the ESP32. I know a lot of people don't like the idea of it but it works pretty flawlessly as of now.

The next thing I will do is mess around with more capacitors and see if I can fix the ringing/noise once and for all, but that may have to wait as they're still on the way.

I'll just be working on the current control code portion in the meantime. It probably won't be too accurate until the noise problem is resolved but at least something to fall back on. It might help to move the shunt outside the capacitor loop and connect it only to the loads. Once I finish that up I'll raise the duty cycle correction speed so it can react to voltage changes quicker.
 
Alright I've been going at it for a while today and realized that in my attempts to filter the output pwm into a smooth DC voltage, I accidentally turned it into a buck converter. At 12V 1A input I could get around 10A at 0.75v out on the other side. Didn't try anymore as that's what I set my current limit at for now.

I'm a little bit lost now. When a PWM charge controller charges a battery, does it just pump straight PWM like this into it?
IMG_20211213_210521.jpg
Because part of me thinks that would cause ripple problems elsewhere, but I can't think of another way to filter it without actually turning it into a buck converter.

Anyways I took off all the capacitors except the input snubber and well, it seems to be outputting pretty good pwm as seen below.
IMG_20211213_212930.jpg
IMG_20211213_213128.jpg
First image is the gate drive and the second is the completely unfiltered output, with ~4.3A flowing through it, trying to maintain a 9V output. I'll get a near-empty 12v battery and see how the ripple looks in. The problem now is that the voltage control lost a lot of accuracy and so did the shunt.
 
Decided to try it with a higher bus voltage, at 60V to see how it went. Not too good lol.

There is an ABSURD amount of ripple noise leaking into the 3.3v rail on the breadboard. I'm talking about +- 2v or even more, everytime the IGBT switches.
It's funny, I thought that the main issue would be getting the IGBT to switch cleanly, but it's the other way around... Got the IGBT switching on the dime but now, on higher voltages, over like ~40ish gets crazy noise. Like to the point where every single electronic was going haywire. Even took out the gate driver, which is optically isolated...

I know for a fact that the problem is the 3.3v rail. The input supply is stable when I connect the scope to it even when switching (I only tested with a ~4A load). The output looks exactly like it does in my previous post, no crazy spikes or anything, just at 60V except 12.

So I know the issue is that the noise is coming in from the switching, or something connected to it. I only have 3 separate connections:
1: Gate drive PWM+ and GND. It can't be the gate driver because it's opto-isolated, its basically just lighting up an LED.

2: VBUS/SHUNT: all three are functionally in the same place, connected to the positive rail of the supply. Vbus is put through a voltage divider to lower the voltage by a factor of ~5 so the INA226 which has a max Vbus of 36v can read without issues.

3:Ground is connected to the Output Negative. This is a bit confusing but basically every time the IGBT turns on/off its bringing the reference voltage with it. This was the main issue I believe. The problem is the INA226 needs to be across the output so it can measure the output voltage. But since this connection isn't for carrying any actual current, I attempted to make an RC filter with a pair of 470uF caps and a 4.7k resistor. From what I understand, that should've solved the problem, and it did help with the ripple, allowing the controller to actually work, albeit still an absurd amount of ripple.

I've also tried disconnecting the shunt, since it's not necessary for the program to run, and nothing. The ONLY thing I haven't tried disconnecting yet is VBUS, but the issue with that is that I'll lose all control of output voltage, so I'll have to make a dummy code that I can only manually change the duty cycle with.

I've also tried moving the reference to the actual ground of the power supply, and moving Vbus to the output-. This gives an inverse output, meaning when the IGBT is fully activated, the voltage across is 0, well in reality it's around 1.2 cause of Vce. So I had just made another version of the code that did 60-Vbus to get the Vbus correction, but obviously in practice it would need another voltage sensor on the positive rail to be able to see the differential voltage. But anyways, this did nothing to help, so I put it back to how it was.



If anyone here has any ideas I'll gladly try them, I'm a little lost here. Something tells me it has to do with Vbus and Ground but I genuinely don't know how I could supress this. I'm planning on making another RC filter but for Vbus to see how that goes, but we'll see.
 
Well today was VERY good progress. I did some research and everything pretty much has to do with the circuit layout. Of course with the breadboard I had all these really long thin wires going back and forth, all wrapped around eachother making a nest of all sorts of noises.

So I spent tonight making this.
IMG_20211215_043307__01.jpg


Moved everything to where it needed to be, the gate drive section is ~3cm away from everything else, the high-voltage bus input section has a 4-resistor (4.7k+4.7k+100k+100k) voltage divider spaced out enough to avoid problems, tapped in the middle gives a max voltage of 26v with a 600v input, so lots of overhead for the INA226's max 36v input. Put a 0.1uF ceramic capacitor between the tap and ground, to act as an RC Filter+decoupling.

Same with the ground. Since the whole ground of the microcontroller needs to be tied to the output ground but ONLY for voltage sensing, no actual current, made another RC Filter using a 220ohm resistor, with a 10uF ceramic capacitor which lays across the 3.3v bus.

Did the same with the current sense as well, put 22ohm resistors in series and a 0.1uF ceramic right at the base of the INA226. Ran a "thick" copper wire underneath to use as a ground plane which everything connects to.

Also put 2.2kohm pullup resistors on the I2C bus, to help with any noise that may still be entering (before was only using the built-in ones in the INA226)

Not planning to pass actual high voltage through this in a while but before I do I'll just dremel out gaps between the HV and LV components.

Didn't get to test it much since I'm passing out and it's 5AM now, but it's literally a COMPLETE night and day difference. Might even connect the starter motor at 60v to see what happens lol.
 
Nice work. Where are you going to school?
Ucf, but I'm studying Aerospace, nothing to do with electronics, and it shows...

The setup in the first video was completely wrong, and while testing a bit I realized that in trying to filter the output using only caps, I was turning it into a very bad buck converter. Bad as in, since I had no inductor before the output caps (to make an LC filter), the current through the caps and IGBT must have been huge.

Also found a paper mentioning IGBT based buck/boost converters and it turns out adding a CE capacitor does help with ringing but adds significant losses. And they recommend a 0.1uF... I had a 3uF on it haha. Just goes to show how little I know about all this.

But yeah I then removed that cap from between the IGBT C and E, added a ~18mH inductor I slapped together out of some spare 6awg wire I had laying around, and connected it to the 5400uF capacitor. Making a low pass filter, and turning it into a proper buck converter.

I was able to try it up to 60v input and it works fine. Ended up having to make an MPPT algorithm for the controller. Right now it's really basic, and every set amount for time does a sweep from 0-100% duty cycle and figures out which is the best. The whole thing takes around 0.8 seconds. Eventually I'll try to make one that is always tracking but for now that's what I was able to get working.

I'm pretty pleased with how it works though. I put a 12v 5a lamp in series with my 12v power supply, somewhat simulating the resistance inside solar panels. With the starter motor on the output it was tracked 13w output around 48% duty cycle. I made a headless version of the code where I can manually adjust the duty cycle with the potentiometer to basically do manual MPPT, and got pretty much the same result, around 48-50%.

Also made an Android app that connects to the esp32 through Bluetooth and displays the output like the little display I have but bigger and more organized.

But unfortunately haven't had time to work much more on it and classes have started once again so who knows when I'll be able to pick it back up.
 
Ucf, but I'm studying Aerospace, nothing to do with electronics, and it shows...

The setup in the first video was completely wrong, and while testing a bit I realized that in trying to filter the output using only caps, I was turning it into a very bad buck converter. Bad as in, since I had no inductor before the output caps (to make an LC filter), the current through the caps and IGBT must have been huge.

Also found a paper mentioning IGBT based buck/boost converters and it turns out adding a CE capacitor does help with ringing but adds significant losses. And they recommend a 0.1uF... I had a 3uF on it haha. Just goes to show how little I know about all this.

But yeah I then removed that cap from between the IGBT C and E, added a ~18mH inductor I slapped together out of some spare 6awg wire I had laying around, and connected it to the 5400uF capacitor. Making a low pass filter, and turning it into a proper buck converter.

I was able to try it up to 60v input and it works fine. Ended up having to make an MPPT algorithm for the controller. Right now it's really basic, and every set amount for time does a sweep from 0-100% duty cycle and figures out which is the best. The whole thing takes around 0.8 seconds. Eventually I'll try to make one that is always tracking but for now that's what I was able to get working.

I'm pretty pleased with how it works though. I put a 12v 5a lamp in series with my 12v power supply, somewhat simulating the resistance inside solar panels. With the starter motor on the output it was tracked 13w output around 48% duty cycle. I made a headless version of the code where I can manually adjust the duty cycle with the potentiometer to basically do manual MPPT, and got pretty much the same result, around 48-50%.

Also made an Android app that connects to the esp32 through Bluetooth and displays the output like the little display I have but bigger and more organized.

But unfortunately haven't had time to work much more on it and classes have started once again so who knows when I'll be able to pick it back up.
Is Professor Keith Klontz still there? He and I were at UW-Madison together a long time ago?
 
Is Professor Keith Klontz still there? He and I were at UW-Madison together a long time ago?
Don't think so. Looked him up in the registry and there's no Klontz. What I did find on LinkedIn is a Keith Klontz that was a professor in USF from 1995-1998. Looks like he left and started a company that deals with designing and manufacturing industrial motors/generators.
 
Back
Top