True FOC: definition and examples

john61ct said:
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?

Technically FOC can be run with single current sense, e.g. the st libraries support it, but no one does that because the result is fairly poor at low and high and middle duty cycles... It relies on one phase being powered and the other 2 free Wheeling which can have very limited sampling time.

Sinusoidal control, yes it can be done by just drawing a sin wave with pwm in phase with the Hall sensors. Is it a good idea? Well it only seems to be done by very low end controllers.
 
Comments on why Kunteng and TSDZ2 projects are not true FOC

https://endless-sphere.com/forums/viewtopic.php?p=1610791#p1610791
 
With FOC it's more helpful to consider that the phases are working together to create a rotating magnetic field, which pulls the rotor magnetic field along with it. A single phase will not generate continuous torque, but when combined they generate torque. You can think of the phases taking turns to pull the rotor magnet.
 
The 3 phases/power rangers combine their forces to control the megazoid/ motor.
Its thier combined power that gives the strength if one is weakened then it acts on the whole.

Then there is a hint of honda vtecs timing fettling at low and high rpm but the cam profile is adjustable.

Sorry to bomb the thread but thats how i would describe the sunwin controllers high speed mode it would pause then boom back wheel would spin up my 6.5inch scooter wheel while i was doing 30mph.
 
are all three phases and their teeth producing usable torque when running foc or like trapazoidal waves is one phase being used to figure positioning?
 
Sensorless control methods can vary, but in general all three phases are producing some level of pulsating power, but once again it's more useful to think of the sum effect of the three phases as producing one rotating magnetic field vector that pulls the rotor magnet along.
 
everythingisawave said:
Sensorless control methods can vary, but in general all three phases are producing some level of pulsating power, but once again it's more useful to think of the sum effect of the three phases as producing one rotating magnetic field vector that pulls the rotor magnet along.

is that an fzr bike?

was wondering if with foc could possibly have a higher max torque output before saturating if more teeth are producing torque at once instead of 2/3rd the teeth.
 
Hummina Shadeeba said:
is that an fzr bike?

was wondering if with foc could possibly have a higher max torque output before saturating if more teeth are producing torque at once instead of 2/3rd the teeth.

A CBR400RR.. similar to what I used to have.

This is a huge generalization, especially since BLDC vs FOC, etc, are very loose terms that are often misused, but in general FOC will provide smoother, more efficient control of motor current and torque, therefore providing more power density. Because relative phase angle between the inverter and motor can be better controlled, torque is generally higher too. This has less to do with the number of phases in operation rather it has to do with the accuracy and precision, and smoothness.
 
FOC can deliver higher torque since it can orient the field at any arbitrary angle whereas BLDC is fixed to 6 discrete angles. Since the torque is the sin of the angle between the two fields, and over 60 degrees there is a significant change in the sin value (sin90=1…sin60 and sin120=√3/2) there's something like a15% difference from just the angle. In BLDC mode, although only 2 phases are powered, when wired in delta (most common) actually all 3 phases are conducting so the saturation situation is less clear and dependent on the winding pattern.

I don't see why anyone developing a controller now would not use FOC. It's literally only about 50 lines of code and requires oooooooo 3 resistors and opamps instead of 1... The angle generator/observer and edge case and power calculation and... Are far more work and need doing whether you use foc or bldc or plain sin wave.

The valid alternative to FOC is DTC, but the hardware and logic for that is more complex.
 
Foc would of helped my motor not be in the scrap pile.

Holding top speed for long durations seen my motor get got enough to chuck a magnet, those demon eddys in the core could have been limited if the motor was phases wernt playing a game of push and pull between eachother with minor errors building up as lost current that in turn makes heat as it turns higher the effect gets worse.

Thing is this forum has from top level engineers as shown explaining FOC and its needed process to make it work rite down to me that may understand it a little but not exactly writing the code or pushing its boundarys.

Vesc is the best way to view its code for a beginner and from there a basic understanding of electrical principles and formula to read whats going on.

Electronics is like a language if you have a wrong understanding of the words the sentence makes no sence.
 
Ianhill said:
Vesc is the best way to view its code for a beginner and from there a basic understanding of electrical principles and formula to read whats going on.

Just no.

If you want to understand FOC, stay away from VESC. Far far away. I've written FOC from scratch, using wikipedia as my only reference. I was not able to make sense of or use a single line from the VESC project.

By contrast, stancecoke lishui foc is easy to follow but less complete, the o-drive code is trickier since it's all c++ not c but way easier to follow than VESC.

You can also flip through the ST and Infineon libraries. They're enormous, but at some point you realise that actually the FOC part is truly tiny and the bits that sit between ADCs reading current and writing the pwm values is only a small handful of simple math functions, with a million different headers piling in to deal with edge cases.

The messiness of the VESC code seems to have lead lots of people to think FOC is impenetrable. It's not. It's 50 not very complicated lines of code.
 
mxlemming said:
Ianhill said:
Vesc is the best way to view its code for a beginner and from there a basic understanding of electrical principles and formula to read whats going on.

Just no.

If you want to understand FOC, stay away from VESC. Far far away. I've written FOC from scratch, using wikipedia as my only reference. I was not able to make sense of or use a single line from the VESC project.

By contrast, stancecoke lishui foc is easy to follow but less complete, the o-drive code is trickier since it's all c++ not c but way easier to follow than VESC.

You can also flip through the ST and Infineon libraries. They're enormous, but at some point you realise that actually the FOC part is truly tiny and the bits that sit between ADCs reading current and writing the pwm values is only a small handful of simple math functions, with a million different headers piling in to deal with edge cases.

The messiness of the VESC code seems to have lead lots of people to think FOC is impenetrable. It's not. It's 50 not very complicated lines of code.

Your coming at it from the programing perspective where u need to understand it inside out like you say every line of code.

Im coming from an engineers point of view understanding the method as a whole enough to make use of the programs you help write, how that code assembles goes straight over my head I've never spent time learning as I've always been on the tools side of it.

I get your talking programming languages and the tool of choice is the laptop and i see compared to just knowing enough to get a install spinning.

I must say ive had inductance issues with vesc myself so can not recommend but its the only way till know ive used FOC but if ones making 3d printers etc with odrive then i can see how they could get quite competent understanding of it all like yourself for example but your not the average skateboard builder by the sounds of it.
 
Hummina Shadeeba said:
Ianhill said:
Im coming from an engineers point of view understanding the method as a whole enough to make use of the programs you help write,

you plug it in

If you put it that simple then yes i plug it in.

But part of my work is service replacement of industrial motors for a living and done many years in college etc so i understand a little more than plug it in but your average skateboard builder not so much 😅 but u got me fp lol
Shit he caught me out lmao i know nothing hahaha.
 
mxlemming said:
By contrast, stancecoke lishui foc is easy to follow but less complete
Hm, it's fully working :). But of course some features like field weakening or detection of motor inductance and resistance are not implemented. I don't need this features :lol:

It has a user friendly GUI with an up to date wiki to set up your system. It should be usable even for people with no computer skills :wink:
And it works with cheap and widely available China hardware, that is used by many european Ebike OEMs like Prophete, Fischer, NCM...

regards
stancecoke

68747470733a2f2f7777772e706564656c6563666f72756d2e64652f77696b692f6c69622f6578652f66657463682e7068703f63616368653d266d656469613d656c656b74726f746563686e696b3a677569626173696373657474696e67732e706e67
 
stancecoke said:
mxlemming said:
By contrast, stancecoke lishui foc is easy to follow but less complete
Hm, it's fully working :). But of course some features like field weakening or detection of motor inductance and resistance are not implemented. I don't need this features :lol:

It has a user friendly GUI with an up to date wiki to set up your system. It should be usable even for people with no computer skills :wink:
And it works with cheap and widely available China hardware, that is used by many european Ebike OEMs like Prophete, Fischer, NCM...

regards
stancecoke

I was meaning inductances, resistance etc and the gui for current/wave form sampling and... Also no CAN, and the sensorless is on another branch.

Your code is absolutely fit for purpose! It's main fault is it's not so well known. Had I known about it when I started designing my controller I might have made it cross compatible. I think the lack of interest on this forum probably comes from the fact that most people here are interested in pushing hundreds of amps at 80V+ on various loony devices and the China hardware doesn't really cut it. The Casainho code (8 bit?) seems remarkably popular though, got the most active threads on the motor technology forum.

Regarding the hardware, I tried to buy a china hardware to run this code but when it arrived I opened it up and... No stm32. Some GPM8F thing with 15 FETs and a single shunt and the kind of layout that would make me Marcos Peters et al cry. :(.
 
Stepping back from all the fancy maths, I have a question or maybe proposal: If I had a motor mounted in a test stand dyno and drive it with a china KT sine wave controller could I see some FOC based results if I changed the timing of the hal sensor by a few degrees ? Maybe in other words: Does a 'proper' FOC type control actually modify the *shape* of the waveform being generated by the controller? Would a first approximation with some worthwhile benefits be to just tune the timing of the hal position sensors ( in real time ) to the controller?
Taking this exercise further, if I added a current sensor to a phase wire would this help in determining how much to change the timing by? My suspicion is yes.
You can see where I am going with these questions: Can a 'dumb' sine wave controller be improved by some external timing modifier device. I am not interested in the open source controller project as I see the constant dribble of tech issue posts on that thread as an indication that it's not mature yet. Maybe after another 50 pages of posts.
 
marka-ee said:
I see the constant dribble of tech issue posts on that thread as an indication that it's not mature yet.

These questions and this complaining is mainly from people, who doesn't read the wiki carefully and I'm tired of explaining the same things over and over again.... :(

I can't get the meaning of your post... You want to do the same as the open Kunteng firmware does (correcting the timing by one phase current sensor), but you don't want to use the open Kunteng firmware ... :shock: :?

The Kunteng hardware is really poor, but it's popular and available up to 18FET with 5kW....

regards
stancecoke
 
Yes, I guess. So is that really what the FOC is doing, just moving the hal timing a little to compensate for the current lag? Boiling it down to the simple here. Does the ultimate FOC implementation modify the shape of the sine wave being generated?
The 'field weakening' still eludes me. Maybe field weakening involves more than a timing change ( read: phase change ) and actually changes the shape of the output to the motor phase wire.
So in summary: FOC at first approximation is nothing more that optimized hal timing. That I can code and to hell with the vector theory. None of this interests me if it does not increase range or speed measurably.
 
marka-ee said:
Does the ultimate FOC implementation modify the shape of the sine wave being generated?
No, it uses exactly the same third harmonic injection waveform normally, that is implemented in the open Kunteng firmware also.
It is only a matter of determining the "correct" advance angle for the voltage vector with respect to the current vector.
"correct" can mean having best torque and minimum losses, but also it can mean weakenig the magnetic field of the rotor for achieving higher speeds at a given voltage....

But of course it is much easier to control torque and field weakening with "real" FOC where id and iq are known

regards
stancecoke
 
mxlemming said:
Ianhill said:
Vesc is the best way to view its code for a beginner and from there a basic understanding of electrical principles and formula to read whats going on.

Just no.

If you want to understand FOC, stay away from VESC. Far far away. I've written FOC from scratch, using wikipedia as my only reference. I was not able to make sense of or use a single line from the VESC project.

By contrast, stancecoke lishui foc is easy to follow but less complete, the o-drive code is trickier since it's all c++ not c but way easier to follow than VESC.

You can also flip through the ST and Infineon libraries. They're enormous, but at some point you realise that actually the FOC part is truly tiny and the bits that sit between ADCs reading current and writing the pwm values is only a small handful of simple math functions, with a million different headers piling in to deal with edge cases.

The messiness of the VESC code seems to have lead lots of people to think FOC is impenetrable. It's not. It's 50 not very complicated lines of code.

I've not looked at VESC but for various reasons I prefer to write my own code. I do understand it will be harder to understand for some people though, it does take some degree of mental contortions and lying in bed thinking about it to truly understand vector control. The whole concept of a rotating reference frame, and matrix transformations can be intimidating, and then there is the issue of discretization, sampling rates, delays, etc.

Mathworks reference pages are great. For a more formal approach, I have found that Krishnan's books on Permanent Magnet Synchronous Machines were the most practical and easiest to understand (which is not saying much). Application notes from TI and Freescale are also very good.
 
marka-ee said:
Yes, I guess. So is that really what the FOC is doing, just moving the hal timing a little to compensate for the current lag? Boiling it down to the simple here. Does the ultimate FOC implementation modify the shape of the sine wave being generated?
The 'field weakening' still eludes me. Maybe field weakening involves more than a timing change ( read: phase change ) and actually changes the shape of the output to the motor phase wire.
So in summary: FOC at first approximation is nothing more that optimized hal timing. That I can code and to hell with the vector theory. None of this interests me if it does not increase range or speed measurably.

The modification is done during the PWM generation, in a separate process. The decision on suitable reference currents and voltages is unaffected.

I guess you can consider it as a being able to control timing and magnitude in a very smooth way, although IMHO it's not really possible to fullly understand FOC without vector theory (yes, mental gymnastics needed :( ). It does increase maximum speed and range, which is why it is defacto standard for higher power machines and servomotors. Cost and development effort is higher for software, sensors etc. although that cost is coming down as an industry trend.
 
Back
Top