Page 5 of 8

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
source-error.png
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:

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

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 :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.

Re: Testing FOC for synchronous motor

Posted: Fri Jan 31, 2020 8:11 pm
by doobedoobedo
Awesome :D

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 :D

Re: Testing FOC for synchronous motor

Posted: Sat Feb 01, 2020 11:14 am
by omegon
:D :lol: :twisted: ;) Party on!!

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?

Re: Testing FOC for synchronous motor

Posted: Thu Feb 06, 2020 11:33 am
by johu
Hmm, can you spawn an abandoned airfield in my neighborhood, please :)
Paralleling the PWM channels shouldn't be much of a problem. Your current sensor paralleling strategy sounds interesting. Not sure what exactly is going to happen. It won't be able to detect imbalance so you have to make sure there is none. Otherwise you can just connect one pair of current sensors and double (half) the gain factor.
Current reading happens at control frequency - independent of PWM frequency fixed to 8.8kHz nowadays

Re: Testing FOC for synchronous motor

Posted: Thu Feb 06, 2020 1:09 pm
by arber333
johu wrote: Thu Feb 06, 2020 11:33 am Hmm, can you spawn an abandoned airfield in my neighborhood, please :)
Paralleling the PWM channels shouldn't be much of a problem. Your current sensor paralleling strategy sounds interesting. Not sure what exactly is going to happen. It won't be able to detect imbalance so you have to make sure there is none. Otherwise you can just connect one pair of current sensors and double (half) the gain factor.
Current reading happens at control frequency - independent of PWM frequency fixed to 8.8kHz nowadays
Hmm... I am thinking of using longer phase wires and parallel connect them much closer to motor. I expect this will dampen induction surges and flyback diodes will not be too stressed inside IGBTs.

You can try to find an empty parking lot in a mall on Sunday? But idea is somewhere that you may not expect any traffic... or cops...

Re: Testing FOC for synchronous motor

Posted: Thu Feb 06, 2020 7:23 pm
by arber333
One more question J.
Can we use latest FOC code for Leaf motor with encoder ABZ interface? I have installed one ABZ encoder onto motor rear shaft since my resolver is damaged. If its possible to run motor without mechanical changes i would be very happy.

tnx

Re: Testing FOC for synchronous motor

Posted: Thu Feb 06, 2020 7:59 pm
by johu
The first startup could be rough, but theoretically it should work.

Re: Testing FOC for synchronous motor

Posted: Fri Feb 07, 2020 11:28 pm
by arber333
johu wrote: Thu Feb 06, 2020 7:59 pm The first startup could be rough, but theoretically it should work.
What do you mean for first setup rough? Why? Isnt ABZ signal pretty much the same as resolver only digital?
Do yopu mean every first start will be rough or just at setup?
Hm... should i then rather try to reinstall resolver?

A

Re: Testing FOC for synchronous motor

Posted: Sat Feb 08, 2020 10:14 am
by johu
Resolver instantly returns the current, absolute rotor angle. ABZ only returns incremental angle increase and once per rotation the index pulse. Only then do you have an absolute angle. So you're blind on the first turn and can just dump some random sine wave until you see the index pulse. Most of all I haven't tested ABZ mode for ages.
So I'd recommend you try to get the resolver running or use a sin/cos like this: https://www.melexis.com/-/media/files/d ... elexis.pdf with a small magnet as you already know. Of course I don't know if there will be any disturbance by motor stray field.

Re: Testing FOC for synchronous motor

Posted: Sat Feb 08, 2020 12:38 pm
by arber333
johu wrote: Sat Feb 08, 2020 10:14 am So I'd recommend you try to get the resolver running or use a sin/cos like this: https://www.melexis.com/-/media/files/d ... elexis.pdf with a small magnet as you already know. Of course I don't know if there will be any disturbance by motor stray field.
What a good idea. I will try to implement it ASAP. I think RLS has just the chip for my form factor.
https://www.rls.si/en/products/rotary-m ... tal-flange

EDIT: So if i would do this with your rev. 2 board i would need the resolver circuit too yes?
I would connect it by Sin and Cos lines and i would leave Ex lines unconnected yes? Also Sin/Cos lines are single ended. That means probably that other side is connected to GNDfor reference. How does that apply to your circuit?
BUT this chip sends ONE sine/cos weave only at single FULL shaft revolution. What does that mean for 8 pole motor like Leaf? Would that be enough?

Re: Testing FOC for synchronous motor

Posted: Sat Feb 08, 2020 1:16 pm
by johu
Yes, no excitation needed, so rev2 board will work. Remove encoder pull-up resistors!
You mean model RMF44AC? That is centered at Vcc/2. Would be perfect if it runs on 3V3. Otherwise you have to divide 2.5->1.65 accurately because there is no offset-calibration in that mode.
One sin/cos per turn is ok, just set respolepairs=1

Re: Testing FOC for synchronous motor

Posted: Sat Feb 08, 2020 3:41 pm
by arber333
It says signal is 1.1V each across reference so 2.2V in all. Can you tell me how to connect Sin and Cos signal wires? Do i just connect Sin to encA and Cos to encB? Minus pullups of course...

tnx

Re: Testing FOC for synchronous motor

Posted: Sat Feb 15, 2020 4:45 pm
by PoloLbricolo
Hi,
I'm back with the smart for the week-end, i did the firmware upgrade 4.73,i have a lot more power now :D but it's too much for the liking of my battery (limited to 350 DC Amps).
Also i now have a HICUROFS2 wich occurs either a high speeds and high load. freezed data shows 294A on il1 an ~195A on il2.
As well as going from positive torque to regen.

I have basically the parameters from the release adapted to my car.

I'm thinking of switching back to 4.54FOC


Paul