True FOC: definition and examples

Electric Motors and Controllers
john61ct   100 GW

100 GW
Posts: 6289
Joined: Dec 18 2018 2:06pm

True FOC: definition and examples

Post by john61ct » Mar 16 2020 2:01pm

I am not just interested in the smoothest possible torque-based control in challenging high-load low-rpm contexts, but also

maximum energy efficiency at all speeds, and

coordinating multiple unlike motors to work together as one.

I have been trying to nail down a set of criteria that define a "true FOC" controller.

Some features / phrases:
direct controller sensing of phase current / motor amps,

with current sensors on each phase connection in the motor providing a high bandwidth data stream,

controller performing CPU-intensive calculations and analysis of that data, to instantaneously predict the rotor angle / position in real time.

Do you think that captures the essentials? (anyone can answer of course)

If so, does for example the Lebowski design meet that criteria?
Last edited by john61ct on Mar 16 2020 2:01pm, edited 1 time in total.

kiwifiat   100 W

100 W
Posts: 220
Joined: Mar 16 2013 5:49pm
Location: Vancouver, Canada

Re: True FOC: definition and examples

Post by kiwifiat » Mar 16 2020 2:59pm

If you are familiar with FOC nomenclature then in my opinion any controller that is capable of controlling Iq and Id is a true FOC controller. On that basis the Lebowski controller qualifies. The fact that it is also capable of field weakening, acceleration limiting, angular velocity control, temperature and battery voltage scaleback, Hall sensor angle correction, CAN control, and constantly provides MTPA makes it the best motor controller on the planet. Compared to working with Sevcon controllers it is a dream come true.

If I have missed any important features hopeully Lebowski will chime in.
“You never know if quotes on the internet are genuine.” - Abraham Lincoln

JackFlorey   10 kW

10 kW
Posts: 777
Joined: Feb 19 2020 7:22pm

Re: True FOC: definition and examples

Post by JackFlorey » Mar 16 2020 3:07pm

john61ct wrote:
Mar 16 2020 2:01pm
Do you think that captures the essentials? (anyone can answer of course)
I think any controller that controls phase current angle based on an internal estimate of actual fields qualifies. To do that you also need the ability to create a specific phase current angle, of course, which means that straight PWM controllers don't qualify.

john61ct   100 GW

100 GW
Posts: 6289
Joined: Dec 18 2018 2:06pm

Re: True FOC: definition and examples

Post by john61ct » Mar 16 2020 4:42pm

kiwifiat wrote:If you are familiar with FOC nomenclature then in my opinion any controller that is capable of controlling Iq and Id is a true FOC controller.
I am not familiar with Iq nor Id.

I'm reading and googling for more, but if anyone's willing to ELI5 or link to a noob-friendly intro to this stuff I would appreciate the help.

Can only get so far with stuff like this:
https://www.motioncontroltips.com/faq-w ... ommutation


john61ct   100 GW

100 GW
Posts: 6289
Joined: Dec 18 2018 2:06pm

Re: True FOC: definition and examples

Post by john61ct » Mar 16 2020 4:54pm

Sabvoton

and the Grin PhaseRunner - apparently derived from a Sabvoton model?

are apparently true FOC, not controversial, correct?

Same with whatever is used on Zero electric motorcycles?

Are those proprietary, developed in-house?

User avatar
spinningmagnets   100 GW

100 GW
Posts: 11752
Joined: Dec 21 2007 10:27pm
Location: Ft Riley, NE Kansas

Re: True FOC: definition and examples

Post by spinningmagnets » Mar 16 2020 7:03pm

FOC = Field Oriented Control.

That's all I know so far. Edit, people that I highly respect say FOC is the best way to control a motor, and the controller should have a shunt for each of the motor phase wires. Three wires, three shunts (or more)

User avatar
serious_sam   1 kW

1 kW
Posts: 428
Joined: Mar 05 2017 8:07am
Location: Australia

Re: True FOC: definition and examples

Post by serious_sam » Mar 16 2020 8:03pm

In my very basic understanding:

Maximum torque/efficiency is achieved when the magnetic forces are tangential to the rotor, with no radial component. The radial component applies no useable force, and is wasted energy = heat.

Since the motor coils are inductors, there is a phase lag between voltage and current. And the magnetic field is created by current, not voltage.

Pure sinusoidal control doesn't take this into account, and applies voltage to the coils according to rotor position only. So the magnetic field (current) is slightly lagging and not optimised for maximum efficiency. Some energy is wasted as that non-usable radial force.

FOC measures/calculates that phase lag, and uses that information to adjust the applied voltage so the current (magnetic field) is optimised, in order to maximise the tangential forces and minimise the radial forces.

Please correct me if I'm wrong.

john61ct   100 GW

100 GW
Posts: 6289
Joined: Dec 18 2018 2:06pm

Re: True FOC: definition and examples

Post by john61ct » Mar 16 2020 8:27pm

That is in line with pages I'm finding.

However very much over my head, given my lack of the most basic magnetic fields / motor fundamentals pre-requisite knowledge.

What I'm really after here, is clarification as to how to determine whether a given controller is true FOC or not.


john61ct   100 GW

100 GW
Posts: 6289
Joined: Dec 18 2018 2:06pm

Re: True FOC: definition and examples

Post by john61ct » Mar 16 2020 8:30pm

One "controversial" example

The Powervelocity guy says

"FOC implementation in VESC is likely the best in its class. It is in fact FOC done the right way."

While others state they just use sinusoidal commutation - while better than trap type controllers (less ripple) - Powervelocity controllers are in fact not FOC at all.


markz   100 GW

100 GW
Posts: 10873
Joined: Jan 09 2014 11:38pm
Location: Alberta Canada

Re: True FOC: definition and examples

Post by markz » Mar 16 2020 8:49pm

spinningmagnets wrote:
Mar 16 2020 7:03pm
FOC = Field Oriented Control.

That's all I know so far.
You and me both!

j bjork   10 kW

10 kW
Posts: 702
Joined: Aug 31 2018 3:01pm
Location: Linköping, Sweden

Re: True FOC: definition and examples

Post by j bjork » Mar 17 2020 8:01am

john61ct wrote:
Mar 16 2020 8:30pm
One "controversial" example

The Powervelocity guy says

"FOC implementation in VESC is likely the best in its class. It is in fact FOC done the right way."

While others state they just use sinusoidal commutation - while better than trap type controllers (less ripple) - Powervelocity controllers are in fact not FOC at all.
They are talking about different controllers. The vesc based are their new, not really released yet controller.
Their old controllers are modified chinese, not foc controllers

john61ct   100 GW

100 GW
Posts: 6289
Joined: Dec 18 2018 2:06pm

Re: True FOC: definition and examples

Post by john61ct » Mar 17 2020 9:05am

Ah great, thanks for clearing that up!

marcos   1 kW

1 kW
Posts: 336
Joined: Nov 19 2016 11:38pm

Re: True FOC: definition and examples

Post by marcos » Mar 17 2020 9:24am

In my mind, field oriented control does the motor control in the rotor frame. So if the torque control is based on setting an iq and id current, that's FOC.

iq/id are the currents in the rotor reference frame. So if you are standing in the rotating rotor, you see DC currents instead of sinewaves.
Image

This way the higher level control system just uses a single DC parameter and you can forget about time varying stuff of the sinewaves. Granted, sinewaves are happening, but that's unfolded from clarke/park transformations within the controller math.

If you are standing in the stator frame, you will see 3 sine waveforms. Mathematically you can reduce those 3 sines to 2 sines (alpha-beta) without losing information (clarke transform). Then if you know the field angle (in a PMSM equals to the rotor angle) you can do park transform to jump into the rotor frame and do the control there. Then inverse park and SVM will drive the PWM required to drive current into the motor

That's the basic stuff, you can see many variations like 5, 6 or 9 phase control, different angle observers, harmonic injection, mtpa, FW, non-SVM, etc, but they all can be reduced to a mechanism to transform the signals to the rotor frame (dc) to make control easier.
Does your project need a high performance motor drive? Let's talk!
www.powerdesigns.ca
Do you like our work? Follow Axiom!

casainho   10 GW

10 GW
Posts: 4625
Joined: Feb 14 2011 2:43pm

Re: True FOC: definition and examples

Post by casainho » Mar 17 2020 9:39am

john61ct wrote:
Mar 16 2020 8:30pm
One "controversial" example

The Powervelocity guy says

"FOC implementation in VESC is likely the best in its class. It is in fact FOC done the right way."

While others state they just use sinusoidal commutation - while better than trap type controllers (less ripple) - Powervelocity controllers are in fact not FOC at all.
Yes, probably best FOC is on VESC and because it is OpenSource and in C code, which makes much easier to learn from and adapt (just compare the many projects and available knowledge based on VESC).

Lebowski controller it is not OpenSource and it is written in assembly which makes it hard to learn from and adapt.

There are also the OpenSource firmware I wrote for 2 different cheap slow popular STM8 motor controllers and that do FOC but at "low resolution", still, users are very happy with the results (increase of motor torque and battery range)!!
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless Ebike boar ANT+ and Bluetooth, Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation to help my developments: paypal.me/jorgecasa

john61ct   100 GW

100 GW
Posts: 6289
Joined: Dec 18 2018 2:06pm

Re: True FOC: definition and examples

Post by john61ct » Mar 17 2020 10:04am

marcos wrote: if the torque control is based on setting an iq and id current, that's FOC.
Thanks! Yes, I've read about that stuff, but the complex maths involved in "how it works", phrases like ‘representing the total stator field as current space vectors’ is a bit abstract at my level.

As I search and read more I'll eventually start grokking that arena I'm sure, but I'm not asking for more of that to be posted here.

Let's try this approach: I'll post some "more basic" syllogisms like:
FOC works only with three-phase brushless DC (BLDC) motors that operate in sinusoidal mode.
for feedback.

Is that accurate? Are there exceptions?

I don't think (?) that is actually contradicted by:

BLDC aka trapezoidal motors, are **said** to typically have a trapezoidal back EMF waveform.

AKA "square-wave drives", but actually quasi-square waveform, aka modified square
However, the back EMF waveform is not truly trapezoidal in shape but more sinusoidal. Thus BLDC motors can use trapezoidal (aka direct current) or sinusoidal commutation.
Anything in all that, that is **not** accurate?



Last edited by john61ct on Mar 17 2020 10:04am, edited 2 times in total.

john61ct   100 GW

100 GW
Posts: 6289
Joined: Dec 18 2018 2:06pm

Re: True FOC: definition and examples

Post by john61ct » Mar 17 2020 10:32am

casainho wrote:Yes, probably best FOC is on VESC and because it is OpenSource
Hi welcome and thanks for joining! Yes I'm a fan of FOSS, but do not want that aspect to be a derail here. Same with your project, but my current use case involves pushing 4-500lbs up long steep hills. . .

I want to also learn more about what VESC means (as opposed to what?) but again, not in this thread, later. . .

Finally, I would prefer to not get into comparisons between projects / controllers, except as pertinent to their implementation (or not) of "true FOC"

______
> firmware I wrote for 2 different cheap slow popular STM8 motor controllers and that do FOC but at "low resolution"

When you say "do FOC", does that involve:

a powerful processor doing Clarke & Park transform calculations

so that Quadrature/Torque (Iq) current vs Flux/Direct (Id) current are controlled directly, in order to as perfectly as possible

keep the stator current vector in orthogonal alignment (at 90 degrees) to the rotor flux?

If not exactly, then could you please explain as simply as possible what you mean by
FOC but at "low resolution"
?
Also, I assume your controller gets the rotor position information from an encoder rather than just Hall sensors?


Last edited by john61ct on Mar 17 2020 10:32am, edited 1 time in total.

User avatar
stancecoke   100 kW

100 kW
Posts: 1280
Joined: Aug 02 2017 2:56pm

Re: True FOC: definition and examples

Post by stancecoke » Mar 17 2020 10:45am

john61ct wrote:
Mar 16 2020 2:01pm
I have been trying to nail down a set of criteria that define a "true FOC" controller.
There are tons of literature about FOC.
I've developed an open source FOC firmware for the STM32-Lishui Controllers from scratch.

https://github.com/stancecoke/LishuiFOC

The links in the readme were very helpful for me. I followed the UM1052 - STM32F PMSM single/dual FOC SDK v4.3 step by step and got it working finally 8).

In the sensorless branch I implemented the observer that is used in the VESC project.

The "heart" of FOC, the Park- and Clark- (and inverse-) transformations are available in the arm_math libraries, so you don't have to care about the math itself.

regards
stancecoke
Last edited by stancecoke on Mar 17 2020 11:24am, edited 1 time in total.

casainho   10 GW

10 GW
Posts: 4625
Joined: Feb 14 2011 2:43pm

Re: True FOC: definition and examples

Post by casainho » Mar 17 2020 10:46am

john61ct wrote:
Mar 17 2020 10:32am
casainho wrote:Yes, probably best FOC is on VESC and because it is OpenSource
Hi welcome and thanks for joining! Yes I'm a fan of FOSS, but do not want that aspect to be a derail here. Same with your project, but my current use case involves pushing 4-500lbs up long steep hills. . .

I want to also learn more about what VESC means (as opposed to what?) but again, not in this thread, later. . .

Finally, I would prefer to not get into comparisons between projects / controllers, except as pertinent to their implementation (or not) of "true FOC"

______
> firmware I wrote for 2 different cheap slow popular STM8 motor controllers and that do FOC but at "low resolution"

When you say "do FOC", does that involve:

a powerful processor doing Clarke & Park transform calculations

so that Quadrature/Torque (Iq) current vs Flux/Direct (Id) current are controlled directly, in order to as perfectly as possible

keep the stator current vector in orthogonal alignment (at 90 degrees) to the rotor flux?

If not exactly, then could you please explain as simply as possible what you mean by
FOC but at "low resolution"
?

Also, I assume your controller gets the rotor position information from an encoder rather than just Hall sensors?
Go and see the source code, I put there the notes and reference resources, there is a function with FOC in the name.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless Ebike boar ANT+ and Bluetooth, Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation to help my developments: paypal.me/jorgecasa

john61ct   100 GW

100 GW
Posts: 6289
Joined: Dec 18 2018 2:06pm

Re: True FOC: definition and examples

Post by john61ct » Mar 17 2020 11:20am

Are there implementations of "true FOC but sensorless" out there in eBike use cases?

john61ct   100 GW

100 GW
Posts: 6289
Joined: Dec 18 2018 2:06pm

Re: True FOC: definition and examples

Post by john61ct » Mar 17 2020 11:25am

stancecoke wrote:There are tons of literature about FOC
Yes, but mostly incomprehensible for noobs like me. But my comprehension is growing.

Thank you for linking to your references.
casainho wrote:Go and see the source code, I put there the notes and reference resources, there is a function with FOC in the name.
Maybe I'll figure out how to do that, but my list of reading/research projects is fast exceeding time available.

If someone else is able to briefly answer those specific questions about casainho's implementation I'd appreciate it.



User avatar
stancecoke   100 kW

100 kW
Posts: 1280
Joined: Aug 02 2017 2:56pm

Re: True FOC: definition and examples

Post by stancecoke » Mar 17 2020 11:29am

john61ct wrote:
Mar 17 2020 11:20am
Are there implementations of "true FOC but sensorless" out there in eBike use cases?
Yes of course, many e-bike manufacturers use sensorless motors (with Lishui controllers).
e.g. Fischer:
Image
john61ct wrote:
Mar 17 2020 11:25am
If someone else is able to briefly answer those specific questions about casainho's implementation I'd appreciate it.
casainho is not using "typical FOC" with Clark/Park-transformations, the STM8 processors are too weak for that calculations. In the Kunteng-Project we are using the single phase current sensor to adjust the advance angle by the zero-crossing of the phase current and in the TSDZ2-project he uses a theoretical motor model (see Shane Colton's paper) to calculate the advance angle from the motor speed and the current.
There are only simple hall-sensors for the rotorposition detection in both approaches. The rotor angle is extrapolated from the hall signals.
shane_colton.PNG
shane_colton.PNG (126.07 KiB) Viewed 1489 times
regards
stancecoke

john61ct   100 GW

100 GW
Posts: 6289
Joined: Dec 18 2018 2:06pm

Re: True FOC: definition and examples

Post by john61ct » Mar 17 2020 12:13pm

Thanks for the links again. OK, so different kinds of FOC, that's what's causing my discombobulation.

I'll use the phrase "true FOC" for now to represent
Using powerful processors to calculate Clark/Park-transformations, so that

Quadrature/Torque (Iq) current vs Flux/Direct (Id) current are controlled directly,

in order to as perfectly as possible

keep the stator current vector in orthogonal alignment (at 90 degrees) to the rotor flux
Unless there is a better short term out there, suggestions welcome.

Also feedback on that definition please.

______
So, **other** categories of FOC.

From your text, I infer three categories.

Are these mutually exclusive, or is there any overlap between them?

sensorless FOC
single sensor FOC
3-sensors FOC

Are there additional categories, or is four the right number?

Does the word "sensor" in all three of those category names refer to a Hall effect sensor specifically?

IOW does using a **different** sensor type instead (e.g. shunts) for measuring current, change **what kind** of FOC is being done?

Finally is it only "true FOC" (as I define that above) that uses both current sensors **and** an additional encoder?

Last edited by john61ct on Mar 17 2020 12:13pm, edited 4 times in total.

JackFlorey   10 kW

10 kW
Posts: 777
Joined: Feb 19 2020 7:22pm

Re: True FOC: definition and examples

Post by JackFlorey » Mar 17 2020 12:15pm

spinningmagnets wrote:
Mar 16 2020 7:03pm
That's all I know so far. Edit, people that I highly respect say FOC is the best way to control a motor, and the controller should have a shunt for each of the motor phase wires. Three wires, three shunts (or more)
Note that if you have three wires going to motor windings, due to Kirchoff's Current Law, once you know the current in two of the phases, you automatically know the current in the third. My first hybrid (Honda Civic Hybrid) had only two current sensors for the three phase traction motor for that reason.

JackFlorey   10 kW

10 kW
Posts: 777
Joined: Feb 19 2020 7:22pm

Re: True FOC: definition and examples

Post by JackFlorey » Mar 17 2020 12:17pm

john61ct wrote:
Mar 17 2020 10:32am
When you say "do FOC", does that involve:

a powerful processor doing Clarke & Park transform calculations

so that Quadrature/Torque (Iq) current vs Flux/Direct (Id) current are controlled directly, in order to as perfectly as possible

keep the stator current vector in orthogonal alignment (at 90 degrees) to the rotor flux?
That's one way to look at it, but I would note that many FOC's don't do much with the Id (since the magnets provide that field, and it can be assumed.) Better ones will oppose it to do field weakening for higher speeds.

User avatar
stancecoke   100 kW

100 kW
Posts: 1280
Joined: Aug 02 2017 2:56pm

Re: True FOC: definition and examples

Post by stancecoke » Mar 17 2020 12:26pm

JackFlorey wrote:
Mar 17 2020 12:17pm
keep the stator current vector in orthogonal alignment (at 90 degrees) to the rotor flux
that's the gist of the matter (except situations, where you want to do field weakening by applying "too high" advance angles, or other specialities)

If the rotor position is detected by hall sensors or by a sensorless observer is irrelevant for FOC.

You have to find the right advance angle (like the pre-ignition in an internal combustion engine) for the voltage vector.
john61ct wrote:
Mar 17 2020 12:13pm
Does the word "sensor" in all three of those category names refer to a Hall effect sensor specifically?
"sensorless" means no hall-sensors in the motor for the rotor angle detection.

phase current sensors can be simple shunts + opamps (e.g. in the lishui controllers) or hall-effect-based current sensors (like the acs711 in the Kunteng controllers). You can do FOC with one, two or three current phase sensors, see chapter 5 of the STM-Paper linked above.

regards
stancecoke
Last edited by stancecoke on Mar 17 2020 12:49pm, edited 3 times in total.

Post Reply