Testing FOC for synchronous motor

User avatar
johu
Site Admin
Posts: 5684
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 154 times
Been thanked: 960 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

Great to hear, thanks for testing!
Yes fixing regen is my next and hopefully last homework :)
PoloLbricolo wrote: Fri Nov 08, 2019 2:14 pm attached are the parameters i used
Erm, this exhibits a catch of the web interface: you have to hit "Refresh" to download a recent parameter set (frqfac=0 in yours). Maybe something I should fix.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
PoloLbricolo
Posts: 78
Joined: Wed Apr 10, 2019 2:32 pm
Location: France
Been thanked: 1 time

Re: Testing FOC for synchronous motor

Post by PoloLbricolo »

Did some more testing today, drove about 30km, and the car feels really good.
Exept when i stay at about the same speed for long periods of time, typically above 4000rpm (60kph) and for more than a few minutes, the "cruise control" effect comes back, but this time it doesn't comme off, (i stayed a 65kph for a minute on flat road with my foot off the throtle)
It may be because my syncadv parameter is set to 11, and/ or the frqfac is set to 50, i run a 250v DC.

Also at maximum speed (8000rpm or 120kph) the behaviour is quite strange, i have to stay full throtle to maintain speed and if i comme off just a little, my speed comes down to 100. Mybe it's normal, but it feels stange.

Anyways, i'm leaving the car for a moment (the car is in Romania, and i work in France now) so no more testing for me for a while, hope you get the last bug corrected so we can start to chase more power ! :D
Thanks for you hard work.
User avatar
johu
Site Admin
Posts: 5684
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 154 times
Been thanked: 960 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

Yes I think I know what that is.

Code: Select all

if (y < maxY && y > minY)
{
   esum += err;
}
So it will stop accumulating when the output saturates but it will never de-accumulate either! I've changed that, will test myself.

Strange behavior at 8000rpm might be solvable with higher fwkp and other value for syncadv
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
doobedoobedo
Posts: 260
Joined: Sat Jan 12, 2019 12:39 am
Location: UK

Re: Testing FOC for synchronous motor

Post by doobedoobedo »

Did some bench testing today, seems a lot better.

I don't have any regen. When I come off the throttle at max rpm (1200rpm running at 60V) there is a sudden drop in rpm followed by a long slowdown. I need to play with parameters maybe?

Could we have a brief explanation of the new params and their expected function?

eg. throtcur seems to be higher = faster acceleration (and stronger regen?)
doobedoobedo
Posts: 260
Joined: Sat Jan 12, 2019 12:39 am
Location: UK

Re: Testing FOC for synchronous motor

Post by doobedoobedo »

Just uplodaded the new code and coming off throttle is much better. Big thumbs up from me :).
User avatar
johu
Site Admin
Posts: 5684
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 154 times
Been thanked: 960 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

Thanks :)
No parameter description yet, as they are not matured yet. Don't want to describe parameters that vanish in the next version.
throtcur might stay. It is A/% throttle. So throtcur=4 means 400A at 100% throttle.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
doobedoobedo
Posts: 260
Joined: Sat Jan 12, 2019 12:39 am
Location: UK

Re: Testing FOC for synchronous motor

Post by doobedoobedo »

Ah OK, I'm drawing pretty low currents with my low voltage and no load on the bench, I did notice faster ramp up with throtcur = 3 over throtcur =1. Variable max power/torque is something I want to implement in my car anyway, so a max amperage is perfect for that I think.

I appreciate that things are in a fairly rapid dev cycle at the moment, so no worries about the changing parameters for now.
PoloLbricolo
Posts: 78
Joined: Wed Apr 10, 2019 2:32 pm
Location: France
Been thanked: 1 time

Re: Testing FOC for synchronous motor

Post by PoloLbricolo »

Hi all,
Any update on the bugs solution?
User avatar
johu
Site Admin
Posts: 5684
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 154 times
Been thanked: 960 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

Unfortunately no, winter and contracting is keeping me away from more coding/testing.
Ideas to test next: when transitioning between acceleration and regen (at speed) first ramp up/down to 0 torque request until the PI loop has settled, then go on ramping to the desired direction. Hopefully thats fixes the roughness.
In terms of high speed operation: check what q-current is being calculated on unwanted regen, i.e. raw back-emf pushing current into the battery through the inverters diodes. If this shows up as q-current I can add an other P or PI-regulator that counteracts unwanted q-current by outputting a field-weakening d-current. Hope that makes sense ;)
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
johu
Site Admin
Posts: 5684
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 154 times
Been thanked: 960 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

So I plotted iq at high speed regen yesterday and indeed it exceeds the -50A setpoint grossly (down to -220A). I have added a P-regulator to increase field weakening current if iq cannot be maintained. It does do that as expected but still fails to decrease iq. Not sure what the deal is.
When dialing down regen to -5% surprisingly I got less undesired regen. Will keep investigating.

Apart from that driving works really well.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
johu
Site Admin
Posts: 5684
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 154 times
Been thanked: 960 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

I corrected one bug in FOC code: the frequency dependent offset was not limited to the controllers maximum output, typically [-37813, 37813]. So once the offset surpassed that limit the integrator would wind up to counteract. Offset is now limited. Haven't drafted a new release yet.
There is also a new test mode for FOC that allows you to manually specify and id and iq set point, e.g. for finding syncofs. It's still a bit dangerous as the speed limiting code is not in effect. Given enough field weakening current I'm not sure where the physical limit for the motor speed will be, so careful, keep your hand on the ignition key!
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
PoloLbricolo
Posts: 78
Joined: Wed Apr 10, 2019 2:32 pm
Location: France
Been thanked: 1 time

Re: Testing FOC for synchronous motor

Post by PoloLbricolo »

Great news :)
User avatar
dima
Posts: 157
Joined: Sun Dec 09, 2018 9:35 pm
Location: Canada

Re: Testing FOC for synchronous motor

Post by dima »

Attempted to build (under Windows) Can't seem to find timer_get_ic_value from inc_encoder.cpp (searched all files)

Used your copy of custom libopencm3 and libopeninv
source-error.png
EDIT: Changed line 587 ...compiled OK.

Code: Select all

 int measTm = timer_get_counter(REV_CNT_TIMER);
doobedoobedo
Posts: 260
Joined: Sat Jan 12, 2019 12:39 am
Location: UK

Re: Testing FOC for synchronous motor

Post by doobedoobedo »

Builds fine for me (linux)

did you run:

Code: Select all

make get-deps
I wrote a little script:

Code: Select all

$ cat build.sh 
#!/bin/bash

make get-deps
CONTROL=FOC make clean
CONTROL=FOC make
User avatar
johu
Site Admin
Posts: 5684
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 154 times
Been thanked: 960 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

dima wrote: Mon Jan 20, 2020 10:55 pm EDIT: Changed line 587 ...compiled OK.

Code: Select all

 int measTm = timer_get_counter(REV_CNT_TIMER);
Of course thats not the same but then this code won't be used in FOC mode most likely.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
johu
Site Admin
Posts: 5684
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 154 times
Been thanked: 960 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

Just studied another paper on anti-windup and came across a chapter where he calculates some ideal Kp and Ki values for the id and iq controllers. Surprisingly he ends up at K p = 16.06, K i = 20200. So really high Ki. Hmm, maybe I should try that too.
Paper here: http://www.jcee.upc.edu/JCEE2008/pdf_po ... windup.pdf
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
johu
Site Admin
Posts: 5684
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 154 times
Been thanked: 960 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

Alright everyone, this is crazy! I just drove with curki cranked up to 20000 and all the various kludges that I added in the last months disabled. Result: awesome!
No unwanted regen, smooth acceleration to 9000rpm (didn't dare spin faster with my vibrato coupler), no over current trips on wheel spin. It just drives.
All that pain because I didn't have da ballz to crank up the integral controller gain :D
Did a quick measurement and reported a power peak at 110kW, 20 kW regen. I never sniffed cocain, but I'm sure this is better 8-)

By disabled kludge I mean the frqfac parameter, the separate regen controller and the ramp between the two. All unnecessary.

Parameter attached, will release the cleaned up firmware in a minute.
Attachments
throtcur-4.5-v2.png
Leaf 2020-01-31.json
(1.15 KiB) Downloaded 82 times
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
doobedoobedo
Posts: 260
Joined: Sat Jan 12, 2019 12:39 am
Location: UK

Re: Testing FOC for synchronous motor

Post by doobedoobedo »

Awesome :D

Cocaine is overrated.
Alexstarex
Posts: 28
Joined: Mon Jan 13, 2020 1:53 pm
Location: Russia

Re: Testing FOC for synchronous motor

Post by Alexstarex »

All I ran to buy an engine from Nissan Liaf).
johu respect
kiwifiat
Posts: 99
Joined: Sat Dec 22, 2018 9:39 pm
Location: Vancouver, Canada
Been thanked: 10 times

Re: Testing FOC for synchronous motor

Post by kiwifiat »

johu wrote: Fri Jan 31, 2020 4:34 pm Alright everyone, this is crazy! I just drove with curki cranked up to 20000 and all the various kludges that I added in the last months disabled. Result: awesome!
No unwanted regen, smooth acceleration to 9000rpm (didn't dare spin faster with my vibrato coupler), no over current trips on wheel spin. It just drives.
That is really great news, persistance and research pays dividends. Thank you :)
User avatar
Kevin Sharpe
Posts: 1345
Joined: Fri Dec 14, 2018 9:24 pm
Location: Ireland and US
Been thanked: 4 times

Re: Testing FOC for synchronous motor

Post by Kevin Sharpe »

johu wrote: Fri Jan 31, 2020 4:34 pm Alright everyone, this is crazy! I just drove with curki cranked up to 20000 and all the various kludges that I added in the last months disabled. Result: awesome!
Congratulations Johannes :D
This is a personal post and I disclaim all responsibility for any loss or damage which any person may suffer from reliance on the information and material in this post or any opinion, conclusion or recommendation in the information and material.
omegon
Posts: 13
Joined: Mon Nov 04, 2019 1:36 pm

Re: Testing FOC for synchronous motor

Post by omegon »

:D :lol: :twisted: ;) Party on!!
User avatar
johu
Site Admin
Posts: 5684
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 154 times
Been thanked: 960 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

Thank you all :)
Now on to traction control -> see Touran thread
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
johu
Site Admin
Posts: 5684
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 154 times
Been thanked: 960 times
Contact:

Re: Testing FOC for synchronous motor

Post by johu »

More testing today. There are still some occasional trips in the high rev range when changing from full throttle to full regen.
I have removed the bus voltage based field weakening controller and only left the "crossover-controller" in. That is if iq can't be reached, id will be increased (well, decreased, as it's negative).
I also added a frequency dependent factor to curki. So with increasing motor speed it will increase integral controller gain for better response in that region while maintaining the car calm in the lower rev range.

I tried a filmed test drive but acceleration is so hard now that the camera topples over. Plus two cop cars came the other way which, well, is a bit problematic right now. So maybe not a good idea to publish the video ;)
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Testing FOC for synchronous motor

Post by arber333 »

johu wrote: Thu Feb 06, 2020 11:10 am More testing today. There are still some occasional trips in the high rev range when changing from full throttle to full regen.
I have removed the bus voltage based field weakening controller and only left the "crossover-controller" in. That is if iq can't be reached, id will be increased (well, decreased, as it's negative).
I also added a frequency dependent factor to curki. So with increasing motor speed it will increase integral controller gain for better response in that region while maintaining the car calm in the lower rev range.

I tried a filmed test drive but acceleration is so hard now that the camera topples over. Plus two cop cars came the other way which, well, is a bit problematic right now. So maybe not a good idea to publish the video ;)
Nice! Maybe you could go to some abandoned airfield and try there...

So do you think i can use FOC brain with TWO power sections now? I would be driving IGBTs from the same pwm channels but i would parallel current sensors up to 3K3 pulldown resistor. My theory is any difference in IGBT output would be shown in sensor readout leaving centerline. Would be interesting to try. Is the current reading fast enough to sense this?
Post Reply