Page 7 of 7

Re: IPM Motor - Auto-setup

Posted: Sun Jul 16, 2023 8:56 am
by Ev8
Hi Pete did you update the bin for this on your GitHub? Just realised I can test it on mg1 if I put mg2 in run mode (only mg2 control board controls the contactors)

Re: IPM Motor - Auto-setup

Posted: Sun Jul 16, 2023 8:58 am
by Pete9008
Ev8 wrote: Sun Jul 16, 2023 8:56 am Hi Pete did you update the bin for this on your GitHub? Just realised I can test it on mg1 if I put mg2 in run mode (only mg2 control board controls the contactors)
Good point!

Didn't check but it should have pulled the new one across.

Edit - just checked and latest files are on there.

Re: IPM Motor - Auto-setup

Posted: Sun Jul 16, 2023 4:25 pm
by Pete9008
Been thinking about how to setup the controller gains when first setting up a new motor and have come up with this:
StartingGains.png
The idea is that you use the inductance value that the phase check test gives and the voltage you are running at to look up the values to use for kp and ki. For example in Bigpie's case of 0.2mH and 44V above you would set kp to around 508 and ki to around 9632 for the initial spin tests (and then drop down to 73 and 1376 when running at normal 96s pack voltage).

These are not intended to be final values, just a way of getting something sensible in there for initial tests. Might also be worth starting a bit lower initially, say half the value, until confidence is built up (to reduces the chance of control loop oscillation from setting them too high).

The values in there are just based on parameters published for the Outlander front generator, rx450h and mgr. Including others would probably improve accuracy but the values for these seemed to fit well with theory and I could find them and so will do for now!

The spreadsheet used to generate is attached if anyone wants to have a look at it or add more data.

Re: IPM Motor - Auto-setup

Posted: Sun Jul 16, 2023 5:02 pm
by Bigpie
Just posting latest findings. I don't seem to get getting an average error. Maybe I misread last night?
Screenshot 2023-07-16 at 5.57.49 pm.png

This is Bi Directional the the ki kp increased by a factor of 8

Running in forward mode but with no manual id, looks to give decent resolver feedback.
Screenshot 2023-07-16 at 5.30.38 pm.png

Re: IPM Motor - Auto-setup

Posted: Sun Jul 16, 2023 5:09 pm
by Pete9008
It still doesn't seem to be following the field correctly :(

What does it do on a forward spin now? (until that spins reliably there's not much point in trying to find syncofs)

Have you checked the phase resistances, is it possible that there is a problem with the motor?

Edit - not sure why the average error would have disappeared :?

Edit2 - Assume the missing bits in testangle in the first pic are due to wifi dropouts?

Re: IPM Motor - Auto-setup

Posted: Sun Jul 16, 2023 5:48 pm
by Bigpie
Forward seems to work with more id current


I gave it more id current.

Screenshot 2023-07-16 at 6.32.27 pm.png

Re: IPM Motor - Auto-setup

Posted: Sun Jul 16, 2023 5:58 pm
by Pete9008
Something just doesn't look right there, it's never going to be perfectly smooth but it should be a lot better than that (it appears to be going in the wrong direction sometimes!). It's almost like it's missing a phase (or half a phase maybe, just 1 IGBT)?

Is it worth checking the winding resistance of each phase on that motor? Do you have any way of checking that the PWM looks right on all three phases?

Other option is to log angle, pwm1, pwm2, pwm3, il1 and il2, stick it though a spreadsheet to calculate il3 and see what the current waveforms look like (I'm happy to do the spreadsheet bit if you post the log)?

Re: IPM Motor - Auto-setup

Posted: Sun Jul 16, 2023 6:20 pm
by Bigpie
Only had 1 probe to hand tonight. Each output phase with respect to HV gnd. This is fwd dir and 35 amps id
Screenshot 2023-07-16 at 7.14.52 pm.png
Screenshot 2023-07-16 at 7.15.31 pm.png
Screenshot 2023-07-16 at 7.15.44 pm.png
All looks good.

I span this motor with sine firmware the other week

Re: IPM Motor - Auto-setup

Posted: Sun Jul 16, 2023 6:37 pm
by Pete9008
Can't fault those waveforms (why are they negative though if measured relative to HV gnd?), all the IGBT's appear to be working fine.

I'm out of ideas again.

Can't quite tell in the video, was the spin with the sin software much smoother? They should be virtually equivalent, both should apply the same rotating field to the motor.

Re: IPM Motor - Auto-setup

Posted: Sun Jul 16, 2023 6:55 pm
by Bigpie
I clipped the ground to the phases and poke the probe to the negative:D I think it span smoothly with sine and also old manual mode

Re: IPM Motor - Auto-setup

Posted: Sun Jul 16, 2023 7:17 pm
by Pete9008
Bigpie wrote: Sun Jul 16, 2023 6:55 pm I clipped the ground to the phases and poke the probe to the negative :D
Makes sense :)

There is definitely something not right there. On the bidir plot you posted the motor is just oscillating between around -10 and +50degrees rather than doing a full rotation and in the video it's so uneven in places that is shakes the whole motor! I've had another look through the code but can't see anything and what should be equivalent code works fine here.

If you could do the log mentioned above I'll have a look at it but apart from that I'm out of ideas :(

Re: IPM Motor - Auto-setup

Posted: Sun Jul 16, 2023 7:53 pm
by Pete9008
One final thought for today. There is one difference between the normal run mode code and mine, because mine is running in manual mode the ADC offset routine may not have run so I run it at the start of the first test. This shouldn't make any difference but if it isn't working right it could cause the kind of issues you are seeing. Do you get any ERR_HICUROFS errors logged?

Are you able to get a scope plot of the CT outputs while starting a forward test, any problem with the offset routine would clearly show up.

Re: IPM Motor - Auto-setup

Posted: Sun Jul 16, 2023 8:23 pm
by Bigpie
Yes, Ive seen hicurofs errors, can't remember what they are at moment, but seem to think I get them on my Prius inverter in the car too.

Not sure how to log the PWM values. Does the binary logging work in manual mode? Not sure I'll get chance tomorrow, but will try probe the current sensors output when I get chance. Also flip back to sine and see if it spins smoothly.

Re: IPM Motor - Auto-setup

Posted: Sun Jul 16, 2023 8:39 pm
by Pete9008
Ignore me re the pwm values, forgot that they are not available as params. Haven't added logging to manual mode yet (seemed to be asking for trouble adding the extra complexity at the same time), probably ought to though! Do you have a working logging setup now?

A problem with the offset calibration could well cause this type of problem on the test spin modes. Might not affect the phase check as that uses rate of change rather than absolute current.

If you could get a scope capture the ideal would be of the first test run following a power up, idealy a test spin and ideally on a fairly slow timebase with a bit of the capture before the start and the rest while it's spinning.

Sorry for all the hassle getting it working and thanks for your persistence!

Edit - Just run the code up on a bluepill board and it all looks ok, pwm turns on and off in the right places and the current offset routine appears to run correctly (not possible to test it fully though as it isn't connected to anything). Still interested in the log and the scope capture if you have a chance though as an offset on the current sensors would explain all the effects seen.

Edit2 - One other thought - am I right in thinking that the sin code doesn't use the current sensors at all, it just applies a voltage waveform? If so that would also point to a current sensor issue.