MPPT directly in VESC?

Support for creating custom user applications on the VESC.
petertaylor
Posts: 3
Joined: 13 Aug 2017, 02:17
Location: San Francisco

MPPT directly in VESC?

Postby petertaylor » 13 Aug 2017, 02:43

Hey All,
just getting my feet wet with VESC, and liking the control a lot so far. Starting to test motors on a home-made inertia dyno with great success. Regardless...

I'm working on a Solar Boat project, and wondering if i might be able to run an MPPT algorithm directly in the VESC.

Basically, the issue with solar power directly to a load is that the load may not "drag" the voltage down to the point where the most power can be extracted from the solar panels. It's to do with the I-V curve of the panels.

https://jinkosolar.com/ftp/US-MKT-250P_v1.0_rev2013.pdf

For the solar panels in question (JKM240P), the open circuit voltage is 37.2v, the short circuit current is 8.56amps, and the stated voltage at maximum power/efficiency is 30v (delivering 8.01amps). However, this ideal voltage moves when the panels are warmer, colder, more clouds etc. Oftentimes people use dedicated MPPT controllers, but these are geared towards battery charging, which are not allowed in our races.
The VESC has extra processing power, and monitors voltage and current from the "battery".

So,
my first set of related question are:
If i increase the throttle on the VESC, will this drag the voltage down, pulling more current?
What's happening when i control the VESC in current mode? How is this current control being achieved electrically?


It sure seems like some simple control code could increase the current/throttle whilst constantly sampling the voltage, finding the sum of the two, and implementing a "hill climbing" algorithm. Move a touch to the left, see what the result is. If better than previous, keep it, if worse, move back. Now test the same way on the right side.

Anyone done this? I couldn't find a mention of MPPT on these forums yet... Is it as reasonable as it seems? Am i crazy?

Thanks in advance!
Peter

ps. I'm a reasonable programmer, but not really that well versed in electrical hardware; bear with me, i learn quickly...

rew
Posts: 898
Joined: 25 Mar 2016, 12:29
Location: Delft, Netherlands.

Re: MPPT directly in VESC?

Postby rew » 13 Aug 2017, 08:57

What you would want is a "custom app". Those are not too difficult to make. I've made an app that displays some of the measured parameters on a display. But doing some calculations and inserting "set-the-current" commands is not that difficult. (all the other apps actually DO something like setting a current setpoint).

When you increase the commanded current, you will ALWAYS drag the voltage down. On batteries there is the internal resistance of the batteries, the resistance of the wires.

The situation is indeed a bit worse with solar panels.

If you would command a current that put you past the maximum power point, the available power would drop and the VESC would keep on trying to drive the motor at the power-setpoint and the whole thing would become unstable. (voltage would drop really quickly to battery min voltage, and you'd get a fault).

I would think that using duty cycle setpoints is a lot better. When you DO pass the MPP, the voltage will drop, and so will the RPM of your screw. Things will be stable.

Then you can simply implement a slow MPPT algorithm in the "custom app". Every second you measure the used-energy (vesc already does that). Every odd second you increase duty cycle a bit. Every even second you decrease it a bit. If performance of the last second is WORSE than of the second before that, you do a double-sized-step. You'll end up oscillating around the MPPT. As the steps are small, this will have little influence on the power-draw.

Maybe a better way to explain the algorithm is to say: when the performance is BETTER than before, the next step in the opposite direction will be HALF the normal size. So when you normally step the duty cycle by 1%, if performance got better with the last step, your step in the opposite direction will only be 0.5%. That way you can effectively step 0.5% every 2 seconds. To get tot the MPP quicker you might additionally add something that adjusts the step even more dynamically: if steps are consistent, you can increase the stepsize.

Oh wait! it's even easier! Just step every second, if things got better, you step in the same direction, if things got worse, you reverse. This is quicker and easier to implement.

As you can see, I started writing before thinking this through.... :-)

petertaylor
Posts: 3
Joined: 13 Aug 2017, 02:17
Location: San Francisco

Re: MPPT directly in VESC?

Postby petertaylor » 14 Aug 2017, 02:05

Cool,
We're thinking about it in much the same way then.

I'll update this post when i find something more out about this, and have code to share.

Initially, i think i'll run stock VESC firmware, and a custom arduino sketch to do the logic, since i'm a little worried about bricking the VESC. I think there isn't really anything to fear, but baby-steps, you know? I've got plenty of arduino experience, and i'll port the code/algorithm over to the VESC once i'm sure i'm on the right path with this idea.

I'm very curious about the VESC load properties as it's presented to the solar array. I do think it'll yank the voltage down as i attempt to "pull" more amps, but i'm not really sure. How exactly does the VESC pull a specific current from the power source? Does its internal resistance change?

...

(did some googling, i guessed right?)
"A MOSFET may be thought of as a variable resistor, where the Gate-Source voltage difference can control the Drain-Source Resistance. When there is no applying voltage between the Gate-Source , the Drain-Source resistance is very high, which is almost like a open circuit, so no current may flow through the Drain-Source. When Gate-Source potential difference is applied, the Drain-Source resistance is reduced, and there will be current flowing through Drain-Source, which is now a closed circuit."
https://oscarliang.com/how-to-use-mosfe ... -tutorial/

...

With the idea that the VESC's resistance changes, one can assume that the solar panel voltage will indeed be pulled down, and that means this MPPT control will be pretty easy to implement, as expected.

rew, and other ideas to implement? Any good sources/examples for VESC custom apps that i should start with, other than Vedder's blog post here? (http://vedder.se/2015/08/vesc-writing-c ... lications/)

Thanks!

devin
Posts: 223
Joined: 08 May 2017, 01:55
Location: San Francisco, California, US

Re: MPPT directly in VESC?

Postby devin » 14 Aug 2017, 16:29

petertaylor wrote:Hey All,
just getting my feet wet with VESC, and liking the control a lot so far. Starting to test motors on a home-made inertia dyno with great success. Regardless...

I'm working on a Solar Boat project, and wondering if i might be able to run an MPPT algorithm directly in the VESC.

Basically, the issue with solar power directly to a load is that the load may not "drag" the voltage down to the point where the most power can be extracted from the solar panels. It's to do with the I-V curve of the panels.

https://jinkosolar.com/ftp/US-MKT-250P_v1.0_rev2013.pdf

For the solar panels in question (JKM240P), the open circuit voltage is 37.2v, the short circuit current is 8.56amps, and the stated voltage at maximum power/efficiency is 30v (delivering 8.01amps). However, this ideal voltage moves when the panels are warmer, colder, more clouds etc. Oftentimes people use dedicated MPPT controllers, but these are geared towards battery charging, which are not allowed in our races.
The VESC has extra processing power, and monitors voltage and current from the "battery".

So,
my first set of related question are:
If i increase the throttle on the VESC, will this drag the voltage down, pulling more current?
What's happening when i control the VESC in current mode? How is this current control being achieved electrically?

It sure seems like some simple control code could increase the current/throttle whilst constantly sampling the voltage, finding the sum of the two, and implementing a "hill climbing" algorithm. Move a touch to the left, see what the result is. If better than previous, keep it, if worse, move back. Now test the same way on the right side.

Anyone done this? I couldn't find a mention of MPPT on these forums yet... Is it as reasonable as it seems? Am i crazy?

Thanks in advance!
Peter

ps. I'm a reasonable programmer, but not really that well versed in electrical hardware; bear with me, i learn quickly...


@petertaylor The main degree of control the VESC has over the wattage supplied to the motor is via the "duty cycle" or "percentage of second voltage applied to motor winding".

It turns out that the %time or %dutycycle correlates with %battery voltage.

In other words with a 50V battery, 50% duty cycle or 50% ON time correlates with 25V applied to the motor, due to the high frequency of the pulse width modulation and the high inductance of the motor circuit.

During the time that voltage isn't applied to the motor, a different combination of mosfets allows the current generated during the ON time to continue circulating during the OFF time.

The end result is 50% duty cycle correlates to 50% battery voltage applied to the winding.

At motor stall you can use ohm's law to find the resulting current if you know the motor's winding resistance which can be detected using the FOC detection, and the multiplying this number times 2, because it is calculated from lead to virtual ground point rather than from lead to lead.

Once the motor begins turning, the situation becomes more complicated to calculate the motor and battery currents because while you are applying voltage from the battery to the motor, the motor is applying voltage from the motor to the battery in the opposite direction, and this back voltage or back emf varies with rpm. This results in the interesting phenomenon where at exactly the no load rpm of the motor (battery volts x kv @ 100% duty), in theory the wattage applied to the motor is 0 watts, even with 100% duty cycle. In practice some power is always drawn at "no load rpm" due to friction, wind, mechanical, eddy current losses etc. which are inherent to a real working motor.

rew
Posts: 898
Joined: 25 Mar 2016, 12:29
Location: Delft, Netherlands.

Re: MPPT directly in VESC?

Postby rew » 15 Aug 2017, 06:29

First you have to understand the I-V curve of the solar cell.
IV-ISC.gif
IV-ISC.gif (7.44 KiB) Viewed 476 times

If you start with the solar panel unloaded, you start at the point on the X axis on the right. You can then try to draw more and more current, and this results in the so called working point of the solar cell moving up the red line. If you go past the maximum power point, you start moving left along the top of the red line.

Now you have to know a thing or two about loads. You can have a resistive load. Basically the current increases once the voltage increases. For a real resistor, the relations is linear: there is a constant ratio between current and voltage. In an I-V graph such a relationship shows as a straight line through the origin. Such a line always crosses the IV curve of the panel exactly once. Connect them together and the ssytem will quickly converge on the crossing point of the two lines.

There are also "switching DCDC converters". These are like the powersupply in your computer. Independent of the input power they try to provide the computer with enough power to work, at the voltages that it needs. If we neglect losses, the input power equals the output power.

Now if we put some numbers to the graph I've given I can explain a bit better. Assume the VOC is about 10V. And ISC is about 10A. Suppose the computer needs 45W. The system starts at the VOC point on the X axis. The current rises to about 5A (halfway up) while the voltage drops a bit. Maybe to about 9V, so now we''re at 45W.

Suppose the computer needs a bit more power... So... the current increases a bit, the voltage drops a bit and the result is more power: Good. But once we reach the maximum power point somewhere in the top-right of the graph, trying to increase the current further will make the voltage drop A LOT, resulting in less power being available. So with less voltage, the module requires even more current. Once this happens the system quickly moves to the left across the red line to the "ISC" point. (at zero voltage there is no power available, -> computer has crashed due to too little power....)

Now when you command a certain current in the VESC, you have more or less told the system howmuch power you want. This is an unfortunate load for the solar panel. As long as the power curve crosses the solar panel curve on the right, things are fine. You'll be tempted to try to increase the current. The thing is that increasing the current will slowly increase the effective voltage on the motor and therefore, with stable current it will increase the power. So once you hit the maximum power point, things quickly come to a halt: The VESC will try to draw more current than the panel can deliver and you'll quickly move to less and less power along the top line in the curve.

But if you try to command dutycycle, things are inherently stable. You might be suboptimal, but at least the system will find a stable point somewhere. Now your arduino has the time to figure out what to do.

petertaylor
Posts: 3
Joined: 13 Aug 2017, 02:17
Location: San Francisco

Re: MPPT directly in VESC?

Postby petertaylor » 15 Aug 2017, 07:29

Yep, i know all about IV curves, and thus the talk of MPPT, and specific numbers for the panel in question
"For the solar panels in question (JKM240P), the open circuit voltage is 37.2v, the short circuit current is 8.56amps, and the stated voltage at maximum power/efficiency is 30v (delivering 8.01amps). However, this ideal voltage moves when the panels are warmer, colder, more clouds etc. Oftentimes people use dedicated MPPT controllers, but these are geared towards battery charging, which are not allowed in our races.
The VESC has extra processing power, and monitors voltage and current from the "battery". "


The real question, and i think it's been answered already (by you), is whether or not the VESC actually acts like a resistor on not (at least with the lens of the IV graph).

If i command 1% increase in duty cycle(/battery amps) every x milliseconds, and test each new setting for I and V, i'm confident i won't fall off the cliff on the right of the graph. If i command it to jump 10% increments in duty cycle(/battery amps), i've got serious problems. I think if i command the VESC to pull x battery amps instead of x duty cycle, it'll be safer, and will be more specific about what i want from the controller. Duty cycle might run away on me (i think).

Incidentally, when i said
"It sure seems like some simple control code could increase the current/throttle whilst constantly sampling the voltage, finding the sum of the two, and implementing a "hill climbing" algorithm. Move a touch to the left, see what the result is. If better than previous, keep it, if worse, move back. Now test the same way on the right side. "
the left/right i was talking about was the power on the IV curve.

I do appreciate this conversation though. Wondering more about the VESC specifics than the solar/motor stuff, which i have a decent grip on. The VESC stuff is a little more black-boxy to me right now. With some testing with real panels (not batteries which don't really have much of this MPP stuff going on) i'll get definitive answers, and post them here.

Peter

rew
Posts: 898
Joined: 25 Mar 2016, 12:29
Location: Delft, Netherlands.

Re: MPPT directly in VESC?

Postby rew » 15 Aug 2017, 14:57

petertaylor wrote:If i command 1% increase in duty cycle(/battery amps) every x milliseconds, and test each new setting for I and V, i'm confident i won't fall off the cliff on the right of the graph. If i command it to jump 10% increments in duty cycle(/battery amps), i've got serious problems. I think if i command the VESC to pull x battery amps instead of x duty cycle, it'll be safer, and will be more specific about what i want from the controller. Duty cycle might run away on me (i think).

When you command a duty cycle the VESC will most closely resemble a resistor.

Excercise for you: Take an IV curve of a panel, and draw the expected IV curve of the motor at 10, 30, 70 and 90% dutycycle.

If you command the VESC to do XX Motor AMPs, your IV load-curve will resemble a constant power curve. Excercise, draw a few power-curves.

Actually, as a preparation you should draw the POWER curve of your system: how much power is required to run at XX speed?


If you command the VESC to do a certain amount of battery amps, there are two problems. First: If you command more than the actual "short circuit" current, the VESC will simply drain any input capacitors and end up in the low voltage cutoff FAULT condition. So: Not stable, not good.

Secondly you cannot command the stock-VESC to draw a certain amount of battery current. The way to achieve this behaviour is to configure a "max battery current" that you want and then command 100% dutycycle or max-motor-amps, causing the VESC not to achieve that target because of the battery current limit that you've set.

If you command a duty cycle that takes you beyond the max-power-point, the solar panel will drop in voltage. As you've commanded a linear relation between input voltage and the motor-effective-voltage (the ratio is the duty cycle), the effecitve motor voltage will drop, and the power requirement will be lower. Stable. Now.. reducing the dutycycle will cause the current to drop, the panel to provide a higher voltage, that will cause the motor to speed up in tandem, possibly resulting in a higer total power output.


With some testing with real panels (not batteries which don't really have much of this MPP stuff going on) i'll get definitive answers, and post them here.
You can test on a lab powersupply. They have a very much stylized solar panel IV curve.


Return to “Custom Applications”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest