Realization About Buck/Boost Converters While Developing My First Power Box

Cypher618

New member
Joined
Jan 14, 2021
Messages
27
I have been developing my first battery project; a multifunction portable-ish power box based on 7s packs and a 1500w pure sine inverter.

I have decided to use a 40A rated CC/CV boost converter for charging. I'm going with a system voltage of 28.7V for 4.1V/cell. I want to have a DC input jack for charging but I want to be able to use just about any voltage and current DC supply up to the input voltage limit, set by the system voltage, and within the current limit of the converter. Other batteries, DC power supplies, solar, whatever.

Obviously the problem with this idea is that every DC supply will have different current limits which would necessitate constant trimpot adjustment, and that wont do. Well Arduino controlled digital trimpots are a thing so I am thinking about creating an automatic current control system to adjust the converter, by having some combination of an easy to change current limit set point in the Arduino, and in certain cases like solar panels, increasing the current until the voltage drops and finding the maximum power point. Starting to sound familiar?

That's when I came to the realization that mppt solar charge controllers are probably just glorified buck/boost converters with digital trim pots for CV and CC. CV trimpot to set system voltage, and CC trimpot to adjust the current and find the max power point. Maybe this is already obvious to everyone on the forum.

I am curious to know if anyone else on here has played around with making an Arduino controlled variable buck or boost converter for wide ranging DC input, and what your experience was.
 

italianuser

Member
Joined
Feb 25, 2020
Messages
84
Sounds good. I did some small experiments on this although I'm only at my second year on electronics so I'm no guru at all!

What I see is this. Yes, Arduino or any other microcontroller is good for doing the job; it would be even better finding some good schematics that work without Arduino. The biggest advantage of using Arduino could be the easy programming of a display to see what's happening (and also easily interfacing any other device, like TCP/IP devices).

For charging 18650 batteries I stick to a rate from 0.5C to 1C (Battery University BU-409: Charging Lithium-ion) using LM317 chips.
I had a good experience with LM317 chips, they are very simple to use and you can regulate output current and/or voltage and easily regulate it via an Arduino pin. From Arduino pin I control a PWM (sending from 0 to 255 you can vary output) signal going to an optocouple input pin (for e.g. PC817). The output pin of the optocoupler goes to adjust LM317 output.

My starting schematics were here, in Texas Instruments datasheet:
  • 9.3.2 Adjustable Regulator Circuit With Improved Ripple Rejection
  • 9.3.3 Precision Current-Limiter Circuit (this is the basic and easiest example)
  • 9.3.11 Adjustable 4-A Regulator Circuit
In my case, being a very first prototype, my needs were to charge a single 18650 up to 3.95V at a 0.5C rate; in your case voltage is obviously higher but current is the same, something like a 27.65V output at 1A for example. But... I don't know how LM317 would react to such a voltage, I suppose it would need a veeeeery big heatsink for a voltage so near to it's 37V limit, or maybe it would burn out after a couple of minutes LOL :D

Plus, in your case I don't think the problem is the kind of PSU you choose, any over-dimensioned PSU should be ok. The problem could be the difference between the PSU output voltage and the charging board input voltage, because the higher the difference in voltage and the more heat needs to be dissipated. At least that's what I measured in my playing with LM317. In my schematics the higher the delta between input and output voltage and the more heat needed to be dissipated: with a 5V input (a 5V output from PSU) and my maximum 3.95V output there was no heat at all; with a 12V input I needed a heatsink. For charging a 7S 18650 I would say a 32V 5A PSU should be ok.

Do share your next steps, I'm very curious!

Jes
 

Cypher618

New member
Joined
Jan 14, 2021
Messages
27
What's your major? Electrical Engineering? I always say that my undergrad taught me by not teaching me. I had to learn to go out and learn by myself. Sounds like you are well on your way! Well ahead of where I was during my undergrad.

In terms of the LM317 a linear regulator like an LM317 would not be suitable for my application, because my DC input voltage will always be below my system voltage of 28.7. The reason for this is that DC power supplies with voltages below 28.7 are extremely common, with 5VDC and 12VDC being extremely common. My goal is to be able to plug in any DC supply up to the limit voltage of the converter which is output voltage-2v, 26.7V in my case, and then have the arduino limit what the system pulls from the supply based on user input. IE some kind of pre-programmed supply type list on the arduino as well as some type of self adjusting mode for solar.

I'm curious why you didn't go for a dedicated charging IC like a TP4056? They cost pennies these days. If it was for the learning experience just to know you can do it with an LM317 I totally get it!

With boost converters being a switch mode type power supply loses are a little less straight forward than a linear regulator where input and output current are the same and you know input and output voltage. For example in the attached pictures I am using a boost converter to step up 12vdc from an ASIC miner PSU capable of 82A to my system voltage and charging two 7s10p packs at 10A on the high output side and about 24A on the low input side. And yes I up sized the input wires on the boost converter since this picture lol, that was just to test.

I ordered a couple X9C103s modules which can be digitally controlled via arduino. They are an array of resistors with transistors to connect them. I might need a different range IC but the 103 is the most common, so one step at a time.
 

Attachments

  • 20210130_205545.jpg
    20210130_205545.jpg
    4.1 MB · Views: 33
  • 20210130_205540.jpg
    20210130_205540.jpg
    4.2 MB · Views: 34

italianuser

Member
Joined
Feb 25, 2020
Messages
84
Oh, now I see what you mean, I searched your 40A boost converter and watched a video of how it works: you can regulate voltage and current using the two trimpots. So you want to remove the trimpots and control the resistance via Arduino and X9C103. Yes, I suppose it should work first go and the Arduino coding should be quite simple.

Or maybe not LOL :D I just searched some examples of X9C103P usage and there seems to be some problems when you reset Arduino. I didn't test it so I really can't say; this guy here did some testing: https://www.instructables.com/X9C103P-Basic-Operation/

He concludes like this:

"First a significant characteristic of the device is the programmable, non-volatile wiper position; this value cannot be communicated to the micro controller.
Second, the wiper position can be altered (adjusted) without storage and this value is retained while the IC is powered. An Arduino reset does not recall the non-volatile wiper position.
"

and

"the X9C103P is not a general purpose substitute for the mechanical POT nor an alternate for the I2C/SPI digital potentiometers in the DIY area".

:unsure:Uhm, dunno really, a good test will tell us the truth LOL -so we're awaiting on your tests now!

jes

P.S.
I study micro electronics for my own passion, this year I started making my own home made PCBs. Yes, you guessed, LM317 was the first IC I had on my desk after unsoldering all broken electronic devices I found at home... And, yes, my wife hates me when I stop the car and take home any electronic appliance I see thrown on the road!
 

ajw22

Well-known member
Joined
Nov 16, 2018
Messages
573
Most DC converters don't send any signals about its current capability, so you won't get around manually adjusting the current limit.

This won't allow for MPPT functionality, but how about replacing the tiny on-pcb trimpot with a larger unit attached to the case? With a proper big knob for easy adjustment. eg:

Or a rotary selector to have 12 pre-set current values? These need a bit more force to rotate (makes nice click-clicks), so less likely to change by accident.
 

nz_lifer

Member
Joined
Aug 26, 2020
Messages
80
I have decided to use a 40A rated CC/CV boost converter for charging. I'm going with a system voltage of 28.7V for 4.1V/cell. I want to have a DC input jack for charging but I want to be able to use just about any voltage and current DC supply up to the input voltage limit, set by the system voltage, and within the current limit of the converter. Other batteries, DC power supplies, solar, whatever.

Obviously the problem with this idea is that every DC supply will have different current limits which would necessitate constant trimpot adjustment, and that wont do. Well Arduino controlled digital trimpots are a thing so I am thinking about creating an automatic current control system to adjust the converter, by having some combination of an easy to change current limit set point in the Arduino, and in certain cases like solar panels, increasing the current until the voltage drops and finding the maximum power point. Starting to sound familiar?

That's when I came to the realization that mppt solar charge controllers are probably just glorified buck/boost converters with digital trim pots for CV and CC. CV trimpot to set system voltage, and CC trimpot to adjust the current and find the max power point. Maybe this is already obvious to everyone on the forum.

I am curious to know if anyone else on here has played around with making an Arduino controlled variable buck or boost converter for wide ranging DC input, and what your experience was.

Nice little project :)

This should be relatively easy to achieve. How I would do it.
DC Converter, CC CV. As you have chosen.
Digital pot.
Input voltage measure.
Input current sense. ACS712
Input isolation. Mosfet, relay, or DC converter shutdown pin.


-Operation
CC setting of module set to lowest.
Input isolated
DC power connected.
Check voltage.
If below / above indicate error. LED or LCD.
Slowly ramp up CC of module until supply voltage starts dropping or drops out or no further power is produced. Note CC value.
Isolate input. You may need to do this to allow a switch mode psu to self reset.
Reconnect input, ramp up CC to 80% of max recorded value.
If the PSU has been disconnected for more than 3 seconds, assume it is a new supply and self calibrate again.

With input current sense, we can run a MPPT algorithm if a solar panel is connected.

The DC module will have self limiting shutdown so we don;t need to know it's max power.
Although since we have a micro on hand and know total watts we can set a limit.

-Some potential issues I forsee
The Digital pot is not isolated so depending on the voltage across the original pot you may need to opto isolate the digital pot.
With a 40A DC-DC Converter there will be a minimum power supply wattage you need just to overcome the system loss.
If you run cells down to 3v (7s / 21v) you input voltage will be to be < 18v to allow the DC module to regulate.
 

Redpacket

Well-known member
Joined
Feb 28, 2018
Messages
1,263
Like nz_lifter suggests above, it should be possible to have a process where:
- on connection, measure connected input voltage with no load.
- ramp up load current, note overload dropout point.
- release loading to reset source device, wait a few secs.
- ramp up to say 75% of drop out current so you're not unsafely loading the source supply & have a bit of margin.
- reset to start if disconnected, or getting dropouts, etc

Probably not a good idea to run the source PSU too hard or above it's rated current, hence the margin idea?
A balance between not getting all the juice you could or frying it!

If you tended to use say two different devices regularly, you might just have two presets?

One method might be a PWM output of a CPU can be used to control a feedback loop for the CC convertor.
eg simple approach PWM > resistor > capacitor = averaged voltage, buffered with op amp if needed, etc
 

Cypher618

New member
Joined
Jan 14, 2021
Messages
27
My thinking is very similar you both of yours nz_lifer and Redpacket. For known fixed DC supplies I will have presets to limit current to the known limit minus some safety factor and for non-fixed supplies like solar I will use a ramp method measuring current and voltage. When the input is disconnected the system automatically ramps down and awaits new input.

It really does come down the the digital potentiometer and if it will be able to handle the voltage ranges of the converter. The CV pot sees quite a bit more than +/-5vdc limit of the IC I picked, dont know about the CC pot yet. The pwm idea is interesting and may be a way to get around the voltage limit and the need for the IC... if the circuit can be referenced that way. Also in that way I could level shift the PWM of the arduino through a transistor if I needed to for a higher voltage range. Its a very interesting thought.
 

Cypher618

New member
Joined
Jan 14, 2021
Messages
27
So I did some testing and yeah, this is almost definitely going to work with the digital pot. The PWM voltage idea I don't think will work.

The X9C103S IC has a 10k range, the CC pot on my board is 10k range. The working voltage is in the mv, so well within the voltage range of the IC. Its also within a few mv of ground. Verified this is also in the mv when under load and near the load limit, it is. 2.4k is 10A ish limit so with 100 steps on the X9C103S I should be able to get steps of 400ma.

Now I wait for my X9C103S to arrive!
 

italianuser

Member
Joined
Feb 25, 2020
Messages
84
Yes, and do please update the forum about possible problems with volatile memory the X9C103 has, are they real? :unsure:

Now that I think about it, I already said something about it up there: while using the LM317 I actually changed the value of resistor network (at ADJ pin of the chip) via a PC817 optocoupler driven by Arduino (bottom-center of the schematics). Maybe it wasn't exactly the same a driving a "digital resistor" but the effect was the same.

1612539073815.png
 

Cypher618

New member
Joined
Jan 14, 2021
Messages
27
My thinking is I can get around any memory issues in the X9C103S by creating a reliable reset routine. IE as long as I can write some function that is guaranteed to step down the resistance to 0 regardless of initial wiper position I should be fine. In that way I don't care about the initial wiper position. Since my intention is to always ramp down to 0 resistance whenever a source is disconnected anyway this should work out. I also intend to put a relay between the converter and load and will be monitoring current so I can build in a safety in case some weirdness causes too high a current.

Would the waveform output from your circuit not be a square wave as well? It may be a way to control the converter current but I wonder about four things: 1) the responsiveness of the ckt to changes in the CC pot can it really shift the limit that rapidly, 2) if it is responsive enough would my current waveform not be a square wave with high peaks, 3) if the current waveform is a square wave with high peaks would it even matter since the power delivery would be limited to the average current based on the PWM duty cycle, and 4) would it blow up, of course. Its worth some experimentation!

Your idea does present a very obvious way to create a few different preset levels without PWM if you have a board with a number of optos and various resistors, which is effectively replicating the function of the X9C103S.
 

italianuser

Member
Joined
Feb 25, 2020
Messages
84
My thinking is I can get around any memory issues in the X9C103S by creating a reliable reset routine. IE as long as I can write some function that is guaranteed to step down the resistance to 0 regardless of initial wiper position I should be fine. In that way I don't care about the initial wiper position. Since my intention is to always ramp down to 0 resistance whenever a source is disconnected anyway this should work out. I also intend to put a relay between the converter and load and will be monitoring current so I can build in a safety in case some weirdness causes too high a current.
Ah, yes, that sounds good. You got me really curious about X9C103S.
Would the waveform output from your circuit not be a square wave as well? It may be a way to control the converter current but I wonder about four things: 1) the responsiveness of the ckt to changes in the CC pot can it really shift the limit that rapidly, 2) if it is responsive enough would my current waveform not be a square wave with high peaks, 3) if the current waveform is a square wave with high peaks would it even matter since the power delivery would be limited to the average current based on the PWM duty cycle, and 4) would it blow up, of course. Its worth some experimentation!
Oh my, what speed do you need, light speed LOL? From Arduino it changes pretty fast, with the advantage not having to go thought a full rotation of a mechanical pot, just change PWM output from 0 (startup value after a reset) to <theValueYouNeed> and there you are. Didn't ever need to measure how many milliseconds it takes because I switch the output on only after PWM is set to the right value. The output waveform... well, here I went to see what really happened because I didn't know, so I had a quick look with my DSO-150 clone this is what I found.

PCB LM317 PWM.jpg

So, curiosity was killing me and I wanted to see what LiitoKala Lii-500 was doing output side (my first charger, sooner or later I'll get some more advanced model, promised). This was Lii-500 output waveform, seems better than mine uhm...

LIITIKALA Lii-500.jpg
Your idea does present a very obvious way to create a few different preset levels without PWM if you have a board with a number of optos and various resistors, which is effectively replicating the function of the X9C103S.
Yes, my concern was PWM resolution only having 1024 possible steps for raising/lowering voltage (from 3.00V to 4.10V) but it was ok in my case.
 

Bubba

Active member
Joined
May 9, 2018
Messages
301
Ah, yes, that sounds good. You got me really curious about X9C103S.

Oh my, what speed do you need, light speed LOL? From Arduino it changes pretty fast, with the advantage not having to go thought a full rotation of a mechanical pot, just change PWM output from 0 (startup value after a reset) to <theValueYouNeed> and there you are. Didn't ever need to measure how many milliseconds it takes because I switch the output on only after PWM is set to the right value. The output waveform... well, here I went to see what really happened because I didn't know, so I had a quick look with my DSO-150 clone this is what I found.

View attachment 23791

So, curiosity was killing me and I wanted to see what LiitoKala Lii-500 was doing output side (my first charger, sooner or later I'll get some more advanced model, promised). This was Lii-500 output waveform, seems better than mine uhm...

View attachment 23792

Yes, my concern was PWM resolution only having 1024 possible steps for raising/lowering voltage (from 3.00V to 4.10V) but it was ok in my case.

Could you add capacitance to the circuit to reduce the dips?
 

italianuser

Member
Joined
Feb 25, 2020
Messages
84
Could you add capacitance to the circuit to reduce the dips?
You're right. Actually I did put a capacitor on the output but I probably didn't do a good job there. I should study better how to have a neat output waveform (it wasn't my main goal at the time), just like TI's datasheet for LM317 shows at "9.2 Typical Applications" with ripple rejection and transient response capacitors.
 

Cypher618

New member
Joined
Jan 14, 2021
Messages
27
My though on the response speed is more about the boost converter than the Arduino. If I'm flipping between high and low current limits a few hundred to a few thousand times per second I have no idea how the converter, which is designed to see slow changes in the CC pot, will respond.

I kinda want to keep this converter for the digital pot... but if it did work you could turn any CC/CV converter into a rough variable current converter with just arduino PWM with an opto and no fancy digital pot, so its pretty tempting to try.
 
Top