Page 1 of 2

Need help with FOC tuning (prius gen2 inv+ gen2 MG2)

Posted: Sat Jan 22, 2022 1:43 pm
by geduxaz
Hi.
Setup: Prius Gen2 inverter, Prius Gen2 MG2.
When tuning FOC i find two spots where i can get motor spinning.
Only one of those spots gets me moving forward and backwards.
But that spot gives me forward on reverse and reverse on forward.
How do i get directions swapped?

Re: Need help with FOC tuning

Posted: Sat Jan 22, 2022 4:32 pm
by m.art.y
Change any two of the phase wires over. You'll have to find syncoffs value once again though

Re: Need help with FOC tuning

Posted: Sat Jan 22, 2022 5:20 pm
by geduxaz
Cant change because it is original inverter<>mg2 wiring...

Re: Need help with FOC tuning

Posted: Sat Jan 22, 2022 5:21 pm
by geduxaz
Is forward/reverse algorithms the same? Can i drive car forward when reverse is selected?

Re: Need help with FOC tuning

Posted: Sat Jan 22, 2022 5:48 pm
by m.art.y
I had the same problem and as far as I have tested they are not the same and driving forward when reverse is selected is not a good idea. Another option would be to invert resolver/encoder wiring with a special command can't remember what it is though

Re: Need help with FOC tuning

Posted: Sun Jan 23, 2022 7:22 pm
by johu
It's normal to find two offset. Just use the one that gives you the correct direction

Re: Need help with FOC tuning

Posted: Sun Jan 23, 2022 9:06 pm
by geduxaz
johu wrote: Sun Jan 23, 2022 7:22 pm It's normal to find two offset. Just use the one that gives you the correct direction
Thanks! I will try again if those offsets are identical, but directions swiched.
It looked that second one could not get me going well forward or backwards...

Re: Need help with FOC tuning

Posted: Mon Jan 24, 2022 8:37 am
by RetroZero
I posted my parameters in the Adapter board thread if that helps.

Re: Need help with FOC tuning

Posted: Sat Jan 29, 2022 9:07 pm
by geduxaz
m.art.y wrote: Sat Jan 22, 2022 5:48 pm I had the same problem and as far as I have tested they are not the same and driving forward when reverse is selected is not a good idea. Another option would be to invert resolver/encoder wiring with a special command can't remember what it is though
i dont think you can change direction by doing anything to resolver. its job is to provide rotor position.
i tried to change phase wires of the motor, i didnt get any spin if i change phase wires. i think it is not possible as it is 8 pole motor.

Re: Need help with FOC tuning

Posted: Sat Jan 29, 2022 9:22 pm
by m.art.y
I'm pretty sure mine was also 8 pole motor. If you change phase wires you also have to find new syncoffs as the old one will no longer work. Mine wasn't a resolver but an ecoder and there is a command to invert the encoder wiring without physically unsoldering the wires, not sure if that would aslo work with a resolver. Also are you sure you got your resolver wiring right? Only one in 4 chance to get it right.

Re: Need help with FOC tuning

Posted: Sun Jan 30, 2022 7:47 am
by geduxaz
m.art.y wrote: Sat Jan 29, 2022 9:22 pm I'm pretty sure mine was also 8 pole motor. If you change phase wires you also have to find new syncoffs as the old one will no longer work. Mine wasn't a resolver but an ecoder and there is a command to invert the encoder wiring without physically unsoldering the wires, not sure if that would aslo work with a resolver. Also are you sure you got your resolver wiring right? Only one in 4 chance to get it right.
My resolver is connected by pinout diagrams.

Also one more strange thing. Do i need to feel resistance in manual run and turning motor by hand?

Re: Need help with FOC tuning

Posted: Sun Jan 30, 2022 8:29 am
by johu
geduxaz wrote: Sun Jan 30, 2022 7:47 am My resolver is connected by pinout diagrams.

Also one more strange thing. Do i need to feel resistance in manual run and turning motor by hand?
When commanding no current? Then no, no resistance beyond the usual cogging.

Re: Need help with FOC tuning

Posted: Sun Jan 30, 2022 8:47 am
by geduxaz
When manual run and no manualid/manualiq i get resistance when turning motor example to plot angle. If i turn the inverter off- no resistance.

Found a way to reproduce this resistance.
1. Everything is off- no Resistance
2. Start Inverter Manual mode, HV ON- no Resistance
3. make manualid - 10a and later make it back to 0. Resistance is present.
4. Halt inverter- resistance present.
5. Turn HV off- resistance present.
6. Turn 12V off to inverter- no resistance.

Resolver is disconnected when tried this sequence.
But maybe it is normal behaviour?
Also i tried different resolver combinations. Next weekend will try to solve the puzzle again :)

Re: Need help with FOC tuning

Posted: Sun Jan 30, 2022 9:00 pm
by johu
Hmm, Gen2 has bottom IGBTs closed as soon as MSDN signal is pulled to 12V. So shorting out motor leads. Just makes me wonder why it doesn't resist in phase 2 of your sequence?

Re: Need help with FOC tuning

Posted: Mon Jan 31, 2022 8:43 pm
by RetroZero
Do you have Mg1 wired up as well by any chance to your inverter? If so remove it (and isolate the hv wires) whilst testing.

Re: Need help with FOC tuning

Posted: Mon Jan 31, 2022 10:23 pm
by geduxaz
RetroZero wrote: Mon Jan 31, 2022 8:43 pm Do you have Mg1 wired up as well by any chance to your inverter? If so remove it (and isolate the hv wires) whilst testing.
Hi. No, MG1 is not connected. next weekend i will make more photos. it might be also the inverters or motors fault. They were from different cars and from junkyard...

Re: Need help with FOC tuning (prius gen2 inv+ gen2 MG2)

Posted: Thu Feb 03, 2022 7:56 pm
by geduxaz
So does anyone have working (ridable) example of gen2 inverter + gen2 mg2? In air i can go and setup the syncofs (during the tests i go to up to 130A in manualid), but when trying to move i get almost no power. If i choose other syncofs i can drive the car but then i have directions swapped. It is much easier to test it with wheels in air and it looks it is working great, but on the ground (with load) it is different case.

Re: Need help with FOC tuning (prius gen2 inv+ gen2 MG2)

Posted: Thu Feb 03, 2022 11:11 pm
by ZooKeeper
The video Damien published with Johannes needs to be followed exactly if one hopes to get the FOC settings correct, starting with the resolver wiring checks. I had similar problems, all of my own doing from a lack of understanding and the video confirmed just how far off my thinking was :O

The Gen2 Prius inverter and "motors" are engineered to work together, the VCU is only assuming the role of the Toyota ECM by processing inputs to the desired inverter outputs.


Re: Need help with FOC tuning (prius gen2 inv+ gen2 MG2)

Posted: Fri Feb 04, 2022 8:08 am
by geduxaz
I watched the video many times. Maybe i am too dumb to understand, but there is no clear explanation how does angle look on wrong resolver pinout and how the correct angle plot looks.
I trust prius manual for resolver pinout. Is that a wrong way to connect it?

Re: Need help with FOC tuning (prius gen2 inv+ gen2 MG2)

Posted: Fri Feb 04, 2022 9:38 am
by johu
That does not seem to be the problem then. I used the same pinout as you posted.

Re: Need help with FOC tuning (prius gen2 inv+ gen2 MG2)

Posted: Fri Feb 04, 2022 10:48 am
by geduxaz
johu wrote: Fri Feb 04, 2022 9:38 am That does not seem to be the problem then. I used the same pinout as you posted.
during the manual wheel turn by hand there is very short moment when angle starts jumping from 0 to 360 and back to 0. maybe it is a resolver fault?
In picture it is thick line. If i stop motor there the angle is changing 0-360-0 indefinitaly.

Also... Shouldnt the angle be rising not falling when wheels are spinning in forward direction?

I am going to the car (100km) this evening and will have there 1 day. It is still too cold to work long with it. Need to do as many test as possible to get it working or else it is gonna burn :) !

Re: Need help with FOC tuning (prius gen2 inv+ gen2 MG2)

Posted: Fri Feb 04, 2022 1:50 pm
by johu
geduxaz wrote: Fri Feb 04, 2022 10:48 am during the manual wheel turn by hand there is very short moment when angle starts jumping from 0 to 360 and back to 0. maybe it is a resolver fault?
In picture it is thick line. If i stop motor there the angle is changing 0-360-0 indefinitaly.

Also... Shouldnt the angle be rising not falling when wheels are spinning in forward direction?

I am going to the car (100km) this evening and will have there 1 day. It is still too cold to work long with it. Need to do as many test as possivble to get it working or else it is gonna burn :) !
That explains why it wants to go backwards. You can now indeed try setting pinswap to 7 (this time I mean it). It swaps resolver sin/cos. See if that makes it go 0-360 instead. But then it might not move at all. Maybe just accept that you need to select reverse to go forward. Will check this once I get this far.

hovering 0-360-0 is normal. There is like 0.5-1° jitter typically and if that happens to be at the turnaround point, that's what happens

Re: Need help with FOC tuning (prius gen2 inv+ gen2 MG2)

Posted: Fri Feb 04, 2022 2:40 pm
by m.art.y
I had exact same problem and this is what I was suggesting in the other thread too just couldn't remember the exact comand 'pinswap'. From my experience when I chose reverse but drove forward the performance was not the same - it was obvious that in reverse (actual forward) the car drove better but maybe that could have been adjusted somehow I don't know. And mine was a gen3 prius inverter with a different motor with a sin/cos chip. I changed the phase wires over and fixed the problem (had to find new syncoffs).

Re: Need help with FOC tuning (prius gen2 inv+ gen2 MG2)

Posted: Fri Feb 04, 2022 4:59 pm
by geduxaz
I tried pinswap 7 and motor did not spin.
Tried to swap two phases and motor did not spin. Maybe it is because there is many phase pairs. Swapping phase would help if motor had only 3 windings. Maybe i need to swap some exact phase wires?

Re: Need help with FOC tuning (prius gen2 inv+ gen2 MG2)

Posted: Fri Feb 04, 2022 5:10 pm
by m.art.y
When you changed phase wires did you also go through the procedure again to find a new syncoffs value? When you change phase wires motor will not spin until you find new syncoffs.