True FOC: definition and examples
Re: True FOC: definition and examples
Just to throw another definition out there, on page 38 of this ST presentation it states:
"The objective of the [FOC] algorithm is to control the vector components of the stator magnetic field (i.e. the phase currents) in order to obtain the target intensity and phase relation with the rotor magnetic field."
https://www.st.com/content/ccc/resource ... s_pres.pdf
There is also plenty of other good information/diagrams in the presentation.
"The objective of the [FOC] algorithm is to control the vector components of the stator magnetic field (i.e. the phase currents) in order to obtain the target intensity and phase relation with the rotor magnetic field."
https://www.st.com/content/ccc/resource ... s_pres.pdf
There is also plenty of other good information/diagrams in the presentation.
Last edited by bww129 on Jun 04 2020 1:51pm, edited 1 time in total.
Re: True FOC: definition and examples
Factoid from another relevant thread on IPM specifically, using Lebowsky as an example.
viewtopic.php?f=30&t=105572&start=25#p1554542
I inferred from the above that FOC calculations could be (usually are at least in the ebike world?) based on instantaneous tracking of the individual phase current levels.
Also, any clarification as to how "true FOC" can work in a sensorless setup would be greatly appreciated.
viewtopic.php?f=30&t=105572&start=25#p1554542
Aren't the latter what is referred to as "encoders"? Are either also referred to as "resolvers"?amberwolf wrote:Phase current sensors have nothing to do with motor position sensors.
I inferred from the above that FOC calculations could be (usually are at least in the ebike world?) based on instantaneous tracking of the individual phase current levels.
Also, any clarification as to how "true FOC" can work in a sensorless setup would be greatly appreciated.
Re: True FOC: definition and examples
Re: True FOC: definition and examples
Vector control for dummies is a very good read with some excellent animations: https://www.switchcraft.org/learning/20 ... or-dummies
Re: True FOC: definition and examples
Wow, thanks!bww129 wrote:Vector control for dummies is a very good read with some excellent animations: https://www.switchcraft.org/learning/20 ... or-dummies
-
- Posts: 35
- Joined: May 20 2019 12:13pm
- Location: Cambridge, MA
- Contact:
Re: True FOC: definition and examples
Prof. Kirtley gives a definition in his MIT course notes (Chapter 7, Section 3.3)
https://ocw.mit.edu/courses/electrical- ... rse-notes/
https://ocw.mit.edu/courses/electrical- ... rse-notes/
For high performance drives, we will generally assume that the power supply, generally an inverter, can supply currents in the correct spatial relationship to the rotor to produce torque in some reasonably effective fashion. We will show in this section how to determine, given a required torque (or if the torque is limited by either voltage or current which we will discuss anon), what the values of Id and Iq must be. Then the power supply, given some means of determining where the rotor is (the instantaneous value of θ), will use the inverse Park’s transformation to determine the instantaneous valued required for phase currents. This is the essence of what is known as “field oriented control”, or putting stator currents in the correct location in space to produce the required torque.
Re: True FOC: definition and examples
Your well above me on this but I can give some real world data from the same test mule with from 3 differing types of controller.
The motor is a cheap my1020 48v 1600w (didn't want to burn out anything fancy) and picked a complete scooter up £90 fee years ago it was a steal guy couldn't adjust the chain proper city guyich richer than me so each have they own uses but no to topic
Square wave 2.2kw would get it boiling hot climb 300m 20% incline tap out time
Same climb trapiz controller with a 125% over speed which I think is a set amount of field weakening by the controller non programable set to 4.4kw max on the stunts same climb it would take 2 runs to get the same heat yet i got to the top nearly half the time.so much less heat seemed to made.
Then a vesc 6.6 no field weakening in FOC 2.8kw and I can go up and down till the battery dies there's less heat for sure and the sound is much smoother the range went from 16 miles to 20 but my speed dropped 12 mph or so to dropping volts etc.
I'll be converting my bike to FOC in time it's a no brainer only difference being I won't have to take a power drop so that will be a win win.
Hope thats not to far of topic as I've not mentioned vector algorithms etc.
The motor is a cheap my1020 48v 1600w (didn't want to burn out anything fancy) and picked a complete scooter up £90 fee years ago it was a steal guy couldn't adjust the chain proper city guyich richer than me so each have they own uses but no to topic
Square wave 2.2kw would get it boiling hot climb 300m 20% incline tap out time
Same climb trapiz controller with a 125% over speed which I think is a set amount of field weakening by the controller non programable set to 4.4kw max on the stunts same climb it would take 2 runs to get the same heat yet i got to the top nearly half the time.so much less heat seemed to made.
Then a vesc 6.6 no field weakening in FOC 2.8kw and I can go up and down till the battery dies there's less heat for sure and the sound is much smoother the range went from 16 miles to 20 but my speed dropped 12 mph or so to dropping volts etc.
I'll be converting my bike to FOC in time it's a no brainer only difference being I won't have to take a power drop so that will be a win win.
Hope thats not to far of topic as I've not mentioned vector algorithms etc.
Re: True FOC: definition and examples
Lebowski's controller and explanation is fantastic, and even more so when you realise he wrote the whole lot without knowing about Clark and park but perhaps doesn't answer your question concisely.Lebowski wrote: ↑May 12 2020 10:00amYou can read the explanation of my stuff here :
viewtopic.php?f=30&t=104895#p1533225
Any FOC algorithm requires knowledge of the rotor angle at any instant. FOC does not implicitly know this... Something else has to determine the angle.
In lebowskis code, the loop filters are essentially doing this. I'm not picking through his assembly to work it out exactly. In ST library there is a phase locked loop based on a luenburg observer (it makes a prediction of the next measured current given it's current knowledge of speed, voltage, and position, then adjust itself given the error observed in the prediction when it next measures current) in vesc i think it is done by integrating the observed voltages and knowing that over a revolution the integral will equal zero (equal positive and negative).
Once the angle is known, the FOC proceeds as normal with no knowledge as to where the angle measurement came from.
Interestingly, sensor less algorithms can be more accurate than sensored since they are directly taken from the magnetic field not assumed from accurate encoder/Hall alignment.
Writing the code for my version of it now, I'm realising at the moment is a complete




Re: True FOC: definition and examples
I'll add to the above that typically, observers of whatever type are done in the 2 phase alpha beta frame (after Clark transform) since 1) at high voltages one phase won't have good measurements of current and 2) why mess with 3 phases when you have two nice perpendicular ones that are much easier to deal with.
Starting the motor is tricky. Low speed gives high densities error so usually algorithms just feed max possible current into the stator and then switch to the observer once it's spun up to speed.
Starting the motor is tricky. Low speed gives high densities error so usually algorithms just feed max possible current into the stator and then switch to the observer once it's spun up to speed.
-
- Posts: 35
- Joined: May 20 2019 12:13pm
- Location: Cambridge, MA
- Contact:
Re: True FOC: definition and examples
VESC cites this paper and uses only relatively few lines of code to update the phase:
http://cas.ensmp.fr/~praly/Telechargeme ... stolfi.pdf
Code: Select all
const float L_ia = L * i_alpha;
const float L_ib = L * i_beta;
const float R_ia = R * i_alpha;
const float R_ib = R * i_beta;
const float lambda_2 = SQ(conf_now->foc_motor_flux_linkage);
...
float err = lambda_2 - (SQ(*x1 - L_ia) + SQ(*x2 - L_ib));
float x1_dot = -R_ia + v_alpha + gamma_half * (*x1 - L_ia) * err;
float x2_dot = -R_ib + v_beta + gamma_half * (*x2 - L_ib) * err;
*x1 += x1_dot * dt;
*x2 += x2_dot * dt;
...
*phase = utils_fast_atan2(*x2 - L_ib, *x1 - L_ia);
https://doi.org/10.1109/TCST.2010.2047396
They do integrate the observed voltages (and include resistance and inductance effects). But I don't see where they integrate over a revolution. TBH, I'm still trying to understand the basics of this paper though.
Re: True FOC: definition and examples
The integration over a revolution is not done by the code, it's a property of the motor that means the above code works. If it were not a property, those integrals would fly off to infinity. Since it is a property of the motor, the x1 and x2 are oscillatory around zero with the frequency of rotation, and a phase difference (90 degrees) which allows angle calculation by arctangent.ProgramThyself wrote: ↑Nov 13 2020 10:43pmv_alpha, v_beta and i_alpha, i_beta are the measured voltages and currents in the stator frame. I thought this reference was a little clearer:
https://doi.org/10.1109/TCST.2010.2047396
They do integrate the observed voltages (and include resistance and inductance effects). But I don't see where they integrate over a revolution. TBH, I'm still trying to understand the basics of this paper though.
-
- Posts: 35
- Joined: May 20 2019 12:13pm
- Location: Cambridge, MA
- Contact:
Re: True FOC: definition and examples
In a hypothetical situation the motor could always rotate faster during one part of the electrical cycle and slower during the other. Then v_alpha would not necessarily integrate to zero. But I think the observer would still work because of the additional terms in the update equation.mxlemming wrote: ↑Nov 14 2020 12:01pmThe integration over a revolution is not done by the code, it's a property of the motor that means the above code works. If it were not a property, those integrals would fly off to infinity. Since it is a property of the motor, the x1 and x2 are oscillatory around zero with the frequency of rotation, and a phase difference (90 degrees) which allows angle calculation by arctangent.
Re: True FOC: definition and examples
Not the case. The integral remains the same regardless of speed, since as speed increases, back emf also increases, while the integral time goes down.ProgramThyself wrote: ↑Nov 14 2020 5:45pmIn a hypothetical situation the motor could always rotate faster during one part of the electrical cycle and slower during the other. Then v_alpha would not necessarily integrate to zero. But I think the observer would still work because of the additional terms in the update equation.
This is a pretty much fundamental property of any motor, the integral of back emf over a revolution remains constant, and is determined by the magnetic field strength, the number of poles and the number of turns.
Re: True FOC: definition and examples
The voltage is the derivative of magnetic flux. So integrating voltage gives magnetic flux, for a coil this equates to 0 after a north and a south poled have passed a coil.mxlemming wrote: ↑Nov 15 2020 2:15pmNot the case. The integral remains the same regardless of speed, since as speed increases, back emf also increases, while the integral time goes down.ProgramThyself wrote: ↑Nov 14 2020 5:45pmIn a hypothetical situation the motor could always rotate faster during one part of the electrical cycle and slower during the other. Then v_alpha would not necessarily integrate to zero. But I think the observer would still work because of the additional terms in the update equation.
This is a pretty much fundamental property of any motor, the integral of back emf over a revolution remains constant, and is determined by the magnetic field strength, the number of poles and the number of turns.
Re: True FOC: definition and examples
I think I mangled my words a bit... I meant at any angle within a revolution the integral should remain constant... Or the integral between any two given angles... Like if you start integrating from 0 angle then at X degrees regardless of the speed your integral should be the same. And over the full 360 degrees it should be 0.Lebowski wrote: ↑Nov 15 2020 2:21pmThe voltage is the derivative of magnetic flux. So integrating voltage gives magnetic flux, for a coil this equates to 0 after a north and a south poled have passed a coil.mxlemming wrote: ↑Nov 15 2020 2:15pmNot the case. The integral remains the same regardless of speed, since as speed increases, back emf also increases, while the integral time goes down.ProgramThyself wrote: ↑Nov 14 2020 5:45pmIn a hypothetical situation the motor could always rotate faster during one part of the electrical cycle and slower during the other. Then v_alpha would not necessarily integrate to zero. But I think the observer would still work because of the additional terms in the update equation.
This is a pretty much fundamental property of any motor, the integral of back emf over a revolution remains constant, and is determined by the magnetic field strength, the number of poles and the number of turns.
Lebowskis explanation is good. Nice and visual.
-
- Posts: 35
- Joined: May 20 2019 12:13pm
- Location: Cambridge, MA
- Contact:
Re: True FOC: definition and examples
mxlemming wrote: ↑Nov 15 2020 2:15pmNot the case. The integral remains the same regardless of speed, since as speed increases, back emf also increases, while the integral time goes down.ProgramThyself wrote: ↑Nov 14 2020 5:45pmIn a hypothetical situation the motor could always rotate faster during one part of the electrical cycle and slower during the other. Then v_alpha would not necessarily integrate to zero. But I think the observer would still work because of the additional terms in the update equation.
This is a pretty much fundamental property of any motor, the integral of back emf over a revolution remains constant, and is determined by the magnetic field strength, the number of poles and the number of turns.
You're both right, my example was flawed. But I think current could still be adjusted during each revolution to make the time integral of v_alpha be non-zero for one revolution. After all, the effective magnetic flux can be modified by changing i_d, field-strengthening during one half and weakening during the other half revolution. That may seem contrived, but the observer will surely receive noise inputs with those components and shouldn't random-walk all over the place.
Edit: I'm trying to make two points here: 1. I don't believe this conservation law exists where the time integral of v_alpha is claimed to be zero over each revolution (but admittedly I could be wrong). 2. The observer does not rely on such a law, because the observer is still stable even if noise or commanded behavior make the integral deviate from zero.
Edit #2: I appreciate the explanations. Questioning things is how I learn. Thanks for the technical discussion.
Re: True FOC: definition and examples
Integrating v_alpha does not necessarily add up to zero, because of phase resistance and inductance. But that is not the same as integrating the observed voltages - note in the VESC code you posted, the v_alpha and v_beta are adapting to account for resistance and inductance and then integrating. You need to be specific about what is and is not another value...ProgramThyself wrote: ↑Nov 15 2020 7:47pm
You're both right, my example was flawed. But I think current could still be adjusted during each revolution to make the time integral of v_alpha be non-zero for one revolution. After all, the effective magnetic flux can be modified by changing i_d, field-strengthening during one half and weakening during the other half revolution. That may seem contrived, but the observer will surely receive noise inputs with those components and shouldn't random-walk all over the place.
Edit: I'm trying to make two points here: 1. I don't believe this conservation law exists where the time integral of v_alpha is claimed to be zero over each revolution (but admittedly I could be wrong). 2. The observer does not rely on such a law, because the observer is still stable even if noise or commanded behavior make the integral deviate from zero.
Edit #2: I appreciate the explanations. Questioning things is how I learn. Thanks for the technical discussion.
The observer is stable because it contains correction- the float err = lambda2... etc... is rolled into it and drags the result back towards zero in the event of noise, error etc.
Code: Select all
const float L_ia = L * i_alpha;
const float L_ib = L * i_beta;
const float R_ia = R * i_alpha;
const float R_ib = R * i_beta;
const float lambda_2 = SQ(conf_now->foc_motor_flux_linkage);
...
float err = lambda_2 - (SQ(*x1 - L_ia) + SQ(*x2 - L_ib));
float x1_dot = -R_ia + v_alpha + gamma_half * (*x1 - L_ia) * err;
float x2_dot = -R_ib + v_beta + gamma_half * (*x2 - L_ib) * err;
*x1 += x1_dot * dt;
*x2 += x2_dot * dt;
...
*phase = utils_fast_atan2(*x2 - L_ib, *x1 - L_ia);
Re: True FOC: definition and examples
Google released all the code for the Makani wind kite project on github.
The motor firmware (for the TMS570) runs the Yasa motors, and yes it is "true FOC":
https://github.com/google/makani/tree/m ... r/firmware
Very nice code with great comments, as one might expect from a Google X project .
The motor firmware (for the TMS570) runs the Yasa motors, and yes it is "true FOC":
https://github.com/google/makani/tree/m ... r/firmware
Very nice code with great comments, as one might expect from a Google X project .
from amberwolf in another thread
From Amberwolf, elsewhere and closely paraphrased:
Per-phase current sensing is required for FOC
though it is not required for sinusoidal control
_____
but I thought true FOC was possible completely sensorless?
Per-phase current sensing is required for FOC
though it is not required for sinusoidal control
_____
but I thought true FOC was possible completely sensorless?
Re: True FOC: definition and examples
It may be possible sensorless in the motor, not in the controller..
viewtopic.php?f=6&t=98533 Commuter
viewtopic.php?f=6&t=98723 "Bomber"
viewtopic.php?f=12&t=103800 KTM exc
viewtopic.php?f=12&t=109878 Yamaha YZF250F
viewtopic.php?f=6&t=98723 "Bomber"
viewtopic.php?f=12&t=103800 KTM exc
viewtopic.php?f=12&t=109878 Yamaha YZF250F
- amberwolf 100 GW
- Posts: 31684
- Joined: Aug 17 2009 6:43am
- Location: Phoenix, AZ, USA, Earth, Sol, Local Bubble, Orion Arm, Milky Way, Local Group
- Contact:
Re: from amberwolf in another thread
"sensorless" (no hall sensors in motor) has absolutely nothing to do with current sensing (in controller).
This was covered earlier in this thread, such as here:
viewtopic.php?f=30&t=105139#p1537712
If you found this advice helpful, supporting contributions are accepted here.
"if it ain't broke, improve it till it is"----Dog-Hauler Cargo eTrike SB Cruiser----The HI-Lebowski: a Lebowski SMD brain running a zombified Honda IMA Inverter: a HOW-TO guide----Cargo eBike CrazyBike2----General Blog
"if it ain't broke, improve it till it is"----Dog-Hauler Cargo eTrike SB Cruiser----The HI-Lebowski: a Lebowski SMD brain running a zombified Honda IMA Inverter: a HOW-TO guide----Cargo eBike CrazyBike2----General Blog