## "Peak Efficiency" Control Mode?

General topics and discussions about the VESC and its development.
devin
Posts: 253
Joined: 08 May 2017, 01:55
Location: San Francisco, California, US

### Re: "Peak Efficiency" Control Mode?

devin wrote:please note: if X>0 & 0/X=error then this code won't work and the 9/28/17 12:25 (12 lines) code post will be necessary to use. if X>0 & 0/X=0 then this code should still work.

Here I believe is a solution in theory to the potential error caused by zero division and division by zero in the control loop algorithm:

-----------------------------------

K= 90 = Desired Efficiency % Setting
L= 500 = Desired Min Watts Available Setting
P= 4500 = Desired Max Watts Available Setting
M= 100 = Throttle % Setting (min value: 0.000001) <------Negligible minimum value, yet always M>0 (for 0% throttle)

G= 48.2 = Battery Voltage
F= 0.025 = Winding Resistance Ohms
D= 16.94 = Back EMF Voltage (min value: 0.000001) <------Negligible minimum value, yet always D>0 (for standstill)
Y= 120 = Max Motor Amps
Z= 95 = Max Duty Cycle %

N= XX.XXX = Desired Full Throttle Wattage
C= XX.XXX = Duty Cycle %

Where:

N=L
&
if D>((sqrt(F)*K*sqrt(L))/(10*sqrt(100-K))) then N=(-1)*((100*(D^2)*(K-100))/(F*(K^2)))
&
if N>P then N=P
&
if ((1/10)*((sqrt((25*(D^2))+(F*M*N))/F)-((5*D)/F)))>Y then C=(100*((Y*F)+D))/G
&
if ((1/10)*((sqrt((25*(D^2))+(F*M*N))/F)-((5*D)/F)))<=Y then C=10*((sqrt((25*(D^2))+(F*M*N))/G)+((5*D)/G))
&
if C>Z then C=Z
&
repeat

Therefore:

M= 100% = Throttle % Setting <------ Wildly Dynamic Variable
K= 90% = Desired Efficiency % Setting <------ Adjustable Static Variable
L= 500w = Desired Min Watts Available Setting <------ Adjustable Static Variable
P= 4500w = Desired Max Watts Available Setting <------ Adjustable Static Variable

G= 48.2v = Battery Voltage <------ Wildly Dynamic Variable
D= 16.94v = Back EMF Voltage <------ Wildly Dynamic Variable
F= 0.025ohm = Winding Resistance <------ Adjustable Static Variable
Y= 120a = Max Motor Amps <------ Adjustable Static Variable
Z= 95% = Max Duty Cycle % <------ Adjustable Static Variable

N= 1417.10w = Desired Full Throttle Wattage <------ Wildly Dynamic Variable
C= 39.049% = Duty Cycle <------ Wildly Dynamic Variable

Total: (5) Wildly Dynamic Variables & (6) Adjustable Static Variables

----------------------------------

Simply in theory to avoid mathematical logical errors as a result of dividing zero by another number or dividing a number by 0, we must define a negligible but greater than 0 minimum value for the throttle % and back emf voltage variables when inputting them into the control loop algorithm.

The best analogy I can make is to traditional gas powered cars when we release the brake pedal at a green light, but before we manage to push down on the gas pedal, the engine is supplying a small (and in this case minuscule) amount of torque to the wheels at "0% throttle & standstill."

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

### Re: "Peak Efficiency" Control Mode?

Just a quick question. Say I have a 50V motor, currently running at 25V BEMF. Suppose the motor can do 50A, but the torque required is only 5A. The motor has 20mOhm resistance. What is the effective voltage that you propose and what is the efficiency of the motor? (the last example that I read, and that was a while back, had the "normal" and your proposed settings very close together.).

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

### Re: "Peak Efficiency" Control Mode?

rew wrote:Just a quick question. Say I have a 50V motor, currently running at 25V BEMF. Suppose the motor can do 50A, but the torque required is only 5A. The motor has 20mOhm resistance. What is the effective voltage that you propose and what is the efficiency of the motor? (the last example that I read, and that was a while back, had the "normal" and your proposed settings very close together.).

@rew

Left Side Of Table:

M= 3.26 = Throttle % Setting
K= 90 = Desired Efficiency % Setting
L= 1 = Desired Min Watts Available Setting
P= 4500 = Desired Max Watts Available Setting

G= 50 = Battery Voltage
D= 25.00 = Back EMF Voltage
F= 0.02 = Winding Resistance
Y= 50 = Max Motor Amps
Z= 95 = Max Duty Cycle %

C= 50.20 = Duty Cycle

Effective Voltage: 25.10V
Motor Amps: 5.01

Efficiency: 99.60%

Right Side Of Table:

M= 100 = Throttle % Setting
K= 90 = Desired Efficiency % Setting
L= 1 = Desired Min Watts Available Setting
P= 4500 = Desired Max Watts Available Setting

G= 50 = Battery Voltage
D= 25.00 = Back EMF Voltage
F= 0.02 = Winding Resistance
Y= 50 = Max Motor Amps
Z= 95 = Max Duty Cycle %

C= 52.00 = Duty Cycle

Effective Voltage: 26.00
Motor Amps: 50.00

Efficiency: 96.15%

^Getting the motor on the right "down to 90% efficiency" requires more than 50a motor amps at this rpm, simply.

(before factoring motor friction and iron loss)

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

### Re: "Peak Efficiency" Control Mode?

@rew Suppose I have a (4) 140kv 0.02ohm hub motors on an electric skateboard with 84mm tires which can do 80A and a 10ah 30C 50V battery. During a lighthearted ride through the park I'm willing to draw up to 300a battery amps for a short time, & on the VESCs I use a 75a battery amp limit and an 80a motor amp limit... I might experience something like this:

----------------------------

Now suppose I engage efficiency control with the following settings:

Desired Efficiency Setting: 96%
Min Desired Watts Setting: 100w (per motor)
Max Desired Watts Setting: 3700w (per motor)
Max Motor Amps Setting: 80a (per motor)
Max Duty Cycle Setting: 95%

Now I might experience something like this:

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

### Re: "Peak Efficiency" Control Mode?

So, I managed to find a situation, a not so theoretical example, where you fail to reach the "desired efficiency" by getting a much higher efficiency. Now I'm going come up with an example where you fail to reach the desired efficiency by coming short a long ways....

Same motor, but now we're moving at 1.0km/h, and want close to full throttle to accelerate to that 25km/h as quickly as possible. My guess is that you can't get more than about 50% efficiency. (*)

Sure, most of the mechanical energy will go towards increasing the kinetic energy of the vehicle that will quickly accelerate, so this situation won't last long.

In slightly other applications, say when winding a string onto a coil, where the force on the string and the rotation speed of the coil can vary by a lot, then this situation with low efficiency may persist for quite a while.

A quick glance at your latest plot shows that the most important difference between "classical" and your method is that you reduce the throttle by as much as 75% at low speeds (15% of max). So... At low speeds, high throttle settings will result in low efficiency. Low throttle settings (especially when combined with a high speed) result in high efficiency. Of course, you can reduce the throttle to maintain a desired instantaneous efficiency. The user of your algorithm will feel the board accelerate, hold back and then pick up speed quicker and quicker.

(*) This situation will persist if say you're pulling a load up a hill where things just won't start moving quicker.

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

### Re: "Peak Efficiency" Control Mode?

rew wrote:So, I managed to find a situation, a not so theoretical example, where you fail to reach the "desired efficiency" by getting a much higher efficiency. Now I'm going come up with an example where you fail to reach the desired efficiency by coming short a long ways....

Same motor, but now we're moving at 1.0km/h, and want close to full throttle to accelerate to that 25km/h as quickly as possible. My guess is that you can't get more than about 50% efficiency. (*)

Sure, most of the mechanical energy will go towards increasing the kinetic energy of the vehicle that will quickly accelerate, so this situation won't last long.

In slightly other applications, say when winding a string onto a coil, where the force on the string and the rotation speed of the coil can vary by a lot, then this situation with low efficiency may persist for quite a while.

A quick glance at your latest plot shows that the most important difference between "classical" and your method is that you reduce the throttle by as much as 75% at low speeds (15% of max). So... At low speeds, high throttle settings will result in low efficiency. Low throttle settings (especially when combined with a high speed) result in high efficiency. Of course, you can reduce the throttle to maintain a desired instantaneous efficiency. The user of your algorithm will feel the board accelerate, hold back and then pick up speed quicker and quicker.

(*) This situation will persist if say you're pulling a load up a hill where things just won't start moving quicker.

rew wrote:I managed to find a situation, a not so theoretical example, where you fail to reach the "desired efficiency" by getting a much higher efficiency.

@rew Yes with an arbitrarily set motor amp limit, the arbitrarily set desired efficiency may not be possible at all rpms, because it would exceed the motor amp limit.

rew wrote: I'm going come up with an example where you fail to reach the desired efficiency by coming short a long ways....

@rew if you want to calculate the back emf voltage necessary to achieve the minimum electrical wattage setting at the desired efficiency setting you can use:

D=((sqrt(F)*K*sqrt(L))/(10*sqrt(100-K)))

F= 0.02 = Winding Resistance Ohms
K= 90 = Desired Efficiency % Setting
L= 500 = Desired Min Watts Available Setting

therefore:

D= 9 = Back EMF Voltage Necessary for Desired Minimum Watts at Desired Efficiency

rew wrote:Same motor, but now we're moving at 1.0km/h, and want close to full throttle to accelerate to that 25km/h as quickly as possible. My guess is that you can't get more than about 50% efficiency.

@rew before factoring motor friction and iron loss, assuming 50v, 0.02ohm winding, 140kv, 84mm tire, 1km/h (63.15695rpm), 0.001 min wattage, 3700 max wattage, and 96% desired efficiency setting, the duty cycle necessary to achieve 96% conversion efficiency at 1km/h is 0.939% duty cycle resulting in 0.008 battery amps, 0.441645 electrical watts & 0.424001 mechanical watts, by my calculations:

0.424001w mechanical /0.441645w electrical = 96.00% conversion efficiency @ 1km/h

rew wrote:A quick glance at your latest plot shows that the most important difference between "classical" and your method is that you reduce the throttle by as much as 75% at low speeds (15% of max).

@rew I'd say with efficiency control, it is in theory impossible to make the efficiency dip below the desired efficiency setting, regardless of how the rider uses the throttle, once she is above a certain minimum speed (and therefore back emf voltage) which depends on the desired minimum wattage setting and desired minimum efficiency setting (before factoring motor friction and iron loss).

rew wrote:Of course, you can reduce the throttle to maintain a desired instantaneous efficiency.

@rew with the "classical" algorithm, i believe it would be impossible for a typical person to adjust the throttle quickly enough as the speed of the rotor changes to maintain a constant desired efficiency.

rew wrote:The user of your algorithm will feel the board accelerate, hold back and then pick up speed quicker and quicker.

@rew I think of the algorithm as almost like providing the rider with an automatic first, second and third gear... the first gear gets you through the inefficient low speed regime by supplying a desired minimum wattage. Second gear kicks in when the desired efficiency is reached at the desired minimum wattage, and accelerates the user at constant efficiency until the rpm at which peak power at desired efficiency is reached. Third gear kicks in at peak power at desired efficiency, determined by max motor amps and/or max duty cycle, and continues to accelerate the user at greater than desired efficiency, because an arbitrary desired efficiency may be impossible above a certain back emf value in relation to the pack voltage, or above the rpm at which the motor amp limit or duty cycle limit have been reached.

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

### Re: "Peak Efficiency" Control Mode?

You suggest that while I command 50A of motor current through the throttle, I would accept getting only 0.8A. Well, I don't. I think most people would agree that such a big difference is unacceptable.

The general idea is that the more throttle you use, the worse the efficiency becomes. At low speeds you'll have to accept that the instantaneous efficiency is low.

Again the thing is: WHAT are you trying to optimize. If you're designing the solar car to race across australia, then the steady state efficiency matters a lot because the stretches where you're already at speed are so long. The energy use during starting and stopping can (at first) be neglected.

But in general, you're riding an electric skateboard. You've charged the battery at home, and you could ride 5km/h to arrive at your destination in one hour. This is way more energy efficient than riding at 25km/h and arriving at your destination in 12 minutes. I would hazard a guess that even you would prefer to ride for 12 minutes at 25km/h than an hour at 5km/h. You are willing to spend some energy to get to your destination quicker.

So.... to travel, the energy-per-meter-traveled goes up the faster you go.

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

### Re: "Peak Efficiency" Control Mode?

rew wrote:You suggest that while I command 50A of motor current through the throttle, I would accept getting only 0.8A. Well, I don't. I think most people would agree that such a big difference is unacceptable.

The general idea is that the more throttle you use, the worse the efficiency becomes. At low speeds you'll have to accept that the instantaneous efficiency is low.

Again the thing is: WHAT are you trying to optimize. If you're designing the solar car to race across australia, then the steady state efficiency matters a lot because the stretches where you're already at speed are so long. The energy use during starting and stopping can (at first) be neglected.

But in general, you're riding an electric skateboard. You've charged the battery at home, and you could ride 5km/h to arrive at your destination in one hour. This is way more energy efficient than riding at 25km/h and arriving at your destination in 12 minutes. I would hazard a guess that even you would prefer to ride for 12 minutes at 25km/h than an hour at 5km/h. You are willing to spend some energy to get to your destination quicker.

So.... to travel, the energy-per-meter-traveled goes up the faster you go.

rew wrote:You suggest that while I command 50A of motor current through the throttle, I would accept getting only 0.8A. Well, I don't. I think most people would agree that such a big difference is unacceptable.

@rew i thought you were asking how would it be technically possible to achieve 96% (or greater than 50%) efficiency at 1km/h, not what is the duty cycle necessary for 50a motor amps?

rew wrote:The general idea is that the more throttle you use, the worse the efficiency becomes. At low speeds you'll have to accept that the instantaneous efficiency is low.

@rew I'd say the more wattage applied at the same rpm on any BLDC, the worse efficiency becomes, and at very low speeds a "practically" desirable amount of wattage is generally impossible at a "high" desired efficiency... however if any amount of wattage is acceptable to achieve the desired efficiency than consistent efficiency would be possible at almost every rpm, by applying low wattage at low speed and much higher wattage at higher speeds.

rew wrote:Again the thing is: WHAT are you trying to optimize. If you're designing the solar car to race across australia, then the steady state efficiency matters a lot because the stretches where you're already at speed are so long. The energy use during starting and stopping can (at first) be neglected.

@rew Test Question: I'm an electric skateboard vendor, and a previous customer asks me what options they have to achieve greatest possible range and efficiency on their electric skateboard when commuting in start and stop city traffic. The customer's route to work features many stop signs and stop lights, so they start and stop very frequently, but they live in a completely flat area and don't expect to encounter any hills. The board we are discussing has a battery which typically runs at 45.98V, (4) 81.42kv hub motors which are 0.136ohms and has 83mm diameter tires. The customer states their only requirements are they want to ensure the board is capable of 30mph top speed on flat ground, and aside from that requirement, they also want highest possible range and electrical to mechanical conversion efficiency while repeatedly accelerating at full throttle during their start-and-stop morning commute. Should I recommend "efficiency control" or the "classical algorithm" to achieve this customer's requirements (at least 30mph top speed on flat ground and greatest possible range & conversion efficiency while repeatedly accelerating at full throttle in start and stop city commuter traffic.)

---------------------------
Rider's current VESC settings achieve 30mph top speed: 9.98 battery amp limit & 120a motor amp limit

^30mph is possible with his current settings and classical algorithm, but is the customer getting his highest possible desired efficiency?

---------------------------
Potential "Efficiency Control" Settings: Desired Efficiency Setting: 96%, Min Watts Setting: 100w, Max Watts Setting: 459w

^Same 30mph top speed is possible using efficiency control, but efficiency is now improved at all rpms

(both cases 100% throttle at all rpms)

-----------------------------

Animated Comparison:

---------------------------

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

### Re: "Peak Efficiency" Control Mode?

devin wrote: they also want highest possible range and electrical to mechanical conversion efficiency while repeatedly accelerating at full throttle during their start-and-stop morning commute. Should I recommend "efficiency control" or the "classical algorithm" to achieve this customer's requirements (at least 30mph top speed on flat ground and greatest possible range & conversion efficiency while repeatedly accelerating at full throttle in start and stop city commuter traffic.)
So your algorithm gets to propose a throttle setting to amp conversion depending on more than just the throttle, right?

Well if your algorithm limits "max throttle" to < 5A at < 5km/h, then you will lose customers fast. Acceleration on my bike is unacceptably slow with 20A motor current. It's just an AID for me, so I don't care. But on an electric skateboard, it is the main propulsion, right?

Your "test question" almost includes "world domination" in the requirements. It wants "everything". That is just not possible.

We can formalize your theoretical commute to something like: Accelerate to 15mph, slow down for a stop every 500m repeat 10x or something like that. Now the math simplifies to optimizing the battery usage over just one of these cycles.

Your proposal: Aim for a specific efficiency in the motor is not going to be acceptable: Way too slow startup (if at all).

So you should compare "my algorithm": floor it until I reach 15mph and then cruise along at 15mph at say 30% throttle with yours, but do compare both in terms of energy used, and time spent.

If you assume just a static friction force, then the energy lost towards getting the distance constant. So that doesn't matter. But say wind resistance that goes up with the square of the speed and accounts for say 50% of the energy used at 15mph does make a difference.

I challenge you to come up with a strategy that manages to travel the 500m in the same amount of time as the "floor it" algorithm, but uses less energy. I think it can be done, but not with your "stay off the throttle until you're moving fast" algorithm.

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

### Re: "Peak Efficiency" Control Mode?

rew wrote:So your algorithm gets to propose a throttle setting to amp conversion depending on more than just the throttle, right?

Well if your algorithm limits "max throttle" to < 5A at < 5km/h, then you will lose customers fast. Acceleration on my bike is unacceptably slow with 20A motor current. It's just an AID for me, so I don't care. But on an electric skateboard, it is the main propulsion, right?

Your "test question" almost includes "world domination" in the requirements. It wants "everything". That is just not possible.

We can formalize your theoretical commute to something like: Accelerate to 15mph, slow down for a stop every 500m repeat 10x or something like that. Now the math simplifies to optimizing the battery usage over just one of these cycles.

Your proposal: Aim for a specific efficiency in the motor is not going to be acceptable: Way too slow startup (if at all).

So you should compare "my algorithm": floor it until I reach 15mph and then cruise along at 15mph at say 30% throttle with yours, but do compare both in terms of energy used, and time spent.

If you assume just a static friction force, then the energy lost towards getting the distance constant. So that doesn't matter. But say wind resistance that goes up with the square of the speed and accounts for say 50% of the energy used at 15mph does make a difference.

I challenge you to come up with a strategy that manages to travel the 500m in the same amount of time as the "floor it" algorithm, but uses less energy. I think it can be done, but not with your "stay off the throttle until you're moving fast" algorithm.

@rew At 5kmh (16.27a motor amps & 2.17a battery amps per motor times 4 motors) the virtual board we discuss supplies 41.35lbs or 18.76kg of total thrust full throttle using the adjustable efficiency control settings I chose for the scenario (min 100 watts per motor, max 459 watts per motor, 96% desired efficiency times 4 motors). If this wasn't sufficient thrust for the rider at 5 kmh, they could certainly increase the minimum wattage setting, and at higher speeds should they desire more power they could lower the desired efficiency setting from 96% to 95% or 94%, or raise the max wattage setting.

If the customer in the scenario states he lives in a completely flat area, and wants greatest efficiency while repeatedly accelerating at full throttle during his start and stop traffic morning commute, I struggle to understand why 41.35lbs or 18.76kg thrust at 5kmh (3.11mph) would be insufficient to meet his requirements?

PS How many kg thrust does your electric bicycle put out at 20a motor amps at 5kmh, just for curiosity?

---------------------------

Calculations:

devin wrote:@rew Test Question: I'm an electric skateboard vendor, and a previous customer asks me what options they have to achieve greatest possible range and efficiency on their electric skateboard when commuting in start and stop city traffic. The customer's route to work features many stop signs and stop lights, so they start and stop very frequently, but they live in a completely flat area and don't expect to encounter any hills. The board we are discussing has a battery which typically runs at 45.98V, (4) 81.42kv hub motors which are 0.136ohms and has 83mm diameter tires. The customer states their only requirements are they want to ensure the board is capable of 30mph top speed on flat ground, and aside from that requirement, they also want highest possible range and electrical to mechanical conversion efficiency while repeatedly accelerating at full throttle during their start-and-stop morning commute. Should I recommend "efficiency control" or the "classical algorithm" to achieve this customer's requirements (at least 30mph top speed on flat ground and greatest possible range & conversion efficiency while repeatedly accelerating at full throttle in start and stop city commuter traffic.)

rew wrote:Well if your algorithm limits "max throttle" to < 5A at < 5km/h, then you will lose customers fast. Acceleration on my bike is unacceptably slow with 20A motor current. It's just an AID for me, so I don't care. But on an electric skateboard, it is the main propulsion, right?

My understanding is:

F * L = W * X
F = (W*X)/L

where

F = Force Required For Equilibrium
L = Length to Fulcrum
X = Length to Fulcrum

Source: https://www.engineersedge.com/calculators/levers/page_levers_1.htm

&

1 newton is equal to 0.10197162129779 kilograms
Source: https://www.convertunits.com/from/newtons/to/kilograms

&

In the efficiency control scenario we are discussing at 5kmh:

16.27 motor amps per motor (x4 motors)
255 mechanical watts (total 4 motors)
1.90922 newton meters torque per motor (x 4 motors)

Source:

Therefore:

1.90922 newton meters torque is:

1.90922 * 0.10197162129779 = 0.19468 kilogram meters force

&

Wheel Diameter = 83mm

therefore:

F * L = W * X
F = (W*X)/L

F = XX.XXX = Force Required For Equilibrium
L = 41.5mm = Length to Fulcrum
W = 0.19468kg = Total Load
X = 1000mm = Length to Fulcrum

F = (W*X)/L

4.69108kg = (0.19468kg*1000mm)/41.5mm

18.76kg Thrust = 4.69108kg Thrust Per Motor * 4 Motors

&

1kg = 2.2046 pounds
Source: http://www.metric-conversions.org/weigh ... pounds.htm

Therefore:

Thrust @ 5kmh = 41.35829lb=18.76kg*2.2046

------------------------

The board is putting out 41.35829lb=18.76kg thrust at 5kmh=3.11mph simply.