Page 5 of 8
Re: Testing FOC for synchronous motor
Posted: Fri Nov 08, 2019 5:05 pm
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.
Re: Testing FOC for synchronous motor
Posted: Sat Nov 09, 2019 3:21 pm
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 !
Thanks for you hard work.
Re: Testing FOC for synchronous motor
Posted: Sat Nov 09, 2019 4:31 pm
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
Re: Testing FOC for synchronous motor
Posted: Sat Nov 09, 2019 9:33 pm
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?)
Re: Testing FOC for synchronous motor
Posted: Mon Nov 11, 2019 7:12 pm
by doobedoobedo
Just uplodaded the new code and coming off throttle is much better. Big thumbs up from me

.
Re: Testing FOC for synchronous motor
Posted: Mon Nov 11, 2019 7:30 pm
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.
Re: Testing FOC for synchronous motor
Posted: Mon Nov 11, 2019 7:45 pm
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.
Re: Testing FOC for synchronous motor
Posted: Mon Dec 02, 2019 12:12 pm
by PoloLbricolo
Hi all,
Any update on the bugs solution?
Re: Testing FOC for synchronous motor
Posted: Tue Dec 03, 2019 10:26 pm
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

Re: Testing FOC for synchronous motor
Posted: Sun Dec 15, 2019 11:14 am
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.
Re: Testing FOC for synchronous motor
Posted: Sun Jan 19, 2020 5:18 pm
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!
Re: Testing FOC for synchronous motor
Posted: Sun Jan 19, 2020 7:35 pm
by PoloLbricolo
Great news

Re: Testing FOC for synchronous motor
Posted: Mon Jan 20, 2020 10:55 pm
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
EDIT: Changed line 587 ...compiled OK.
Code: Select all
int measTm = timer_get_counter(REV_CNT_TIMER);
Re: Testing FOC for synchronous motor
Posted: Tue Jan 21, 2020 12:10 am
by doobedoobedo
Builds fine for me (linux)
did you run:
I wrote a little script:
Code: Select all
$ cat build.sh
#!/bin/bash
make get-deps
CONTROL=FOC make clean
CONTROL=FOC make
Re: Testing FOC for synchronous motor
Posted: Tue Jan 21, 2020 10:11 am
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.
Re: Testing FOC for synchronous motor
Posted: Thu Jan 30, 2020 5:11 pm
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
Re: Testing FOC for synchronous motor
Posted: Fri Jan 31, 2020 4:34 pm
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
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
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.
Re: Testing FOC for synchronous motor
Posted: Fri Jan 31, 2020 8:11 pm
by doobedoobedo
Awesome
Cocaine is overrated.
Re: Testing FOC for synchronous motor
Posted: Fri Jan 31, 2020 9:05 pm
by Alexstarex
All I ran to buy an engine from Nissan Liaf).
johu respect
Re: Testing FOC for synchronous motor
Posted: Fri Jan 31, 2020 9:31 pm
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

Re: Testing FOC for synchronous motor
Posted: Sat Feb 01, 2020 9:26 am
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

Re: Testing FOC for synchronous motor
Posted: Sat Feb 01, 2020 11:14 am
by omegon
Re: Testing FOC for synchronous motor
Posted: Sat Feb 01, 2020 1:01 pm
by johu
Thank you all

Now on to traction control -> see
Touran thread
Re: Testing FOC for synchronous motor
Posted: Thu Feb 06, 2020 11:10 am
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

Re: Testing FOC for synchronous motor
Posted: Thu Feb 06, 2020 11:17 am
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?