EcoModder Forum Paul and Sabrina's Cheap 3 Phase Inverter (AC Controller) with Field Oriented Control

Register Now
 Remember

 09-07-2015, 11:57 AM #1941 (permalink) PaulH     Join Date: Feb 2008 Location: Maricopa, AZ (sort of. Actually outside of town) Posts: 3,832 Michael's Electric Beetle - '71 Volkswagen Superbeetle 500000 Thanks: 1,368 Thanked 1,202 Times in 765 Posts OK we need a new rule for how to tune the motor. I thought I understood when to go up or down, but when I started with numbers that work well for me, set Ki to 0, and then gradually reduced Kp, the error started to oscillate around zero. It didn't matter how small I made Kp. So, "does it oscillate around zero" seems to be a terrible test for Kp being "too big". To give an example, Kp = 15000, Ki = 240 works very very well for my motor. Even Kp = 15000 by itself converges pretty fast to zero. And yet Kp = 500 gave oscillations around 0. We need Ki to be nonzero, so I wonder what would happen if we just insisted on Ki being some fixed fraction of Kp, and then ramping Kp up until you get good convergence? For example: Kp = 500 Ki = 500/fixedNumber kp = 1000 ki = 1000/fixedNumber ... We need Ki to be nonzero, because the field weakening automatically comes in through that. I'm starting to wonder if there are a variety of pairs of Kp and Ki that would work equally well. I'll read up on this and let you know what I come up with. By the way, I've tested the auto-find for the rotor time constant. You just have to let the motor run for a couple minutes. It's a new test called run-rotor-test Then it outputs the steady state speed of the motor at each candidate rotor time constant. I guess you then just pick the biggest number. at least that works. I'm going to also do acceleration tests to see if one time constant has better acceleration, but lower top speed. __________________ kits and boards Last edited by MPaulHolmes; 09-07-2015 at 12:40 PM..
 The Following User Says Thank You to MPaulHolmes For This Useful Post: thingstodo (09-07-2015)
 Today Popular topics Other popular topics in this forum...
 09-07-2015, 01:48 PM #1942 (permalink) PaulH     Join Date: Feb 2008 Location: Maricopa, AZ (sort of. Actually outside of town) Posts: 3,832 Michael's Electric Beetle - '71 Volkswagen Superbeetle 500000 Thanks: 1,368 Thanked 1,202 Times in 765 Posts I'm coming up with a set of test conditions that will let us know automatically if a particular P and I are no good. Here's the checklist so far: 1. If an error goes below -80, move to next Kp and Ki. Too much negative overshoot. 2. after going below 0, if anything goes ABOVE 100, move to next Kp and Ki. Too much oscillation. 3. If it doesn't go below 0 before 30 iterations, move on! Convergence too slow. 4. The error starts out as about 512. If the error gets much bigger than 512, move on. The good news is this can all be checked on the PI error array without us doing anything. So, maybe we can use this test to get a much smaller list of curves that we can examine. Then we can pick the best of the bunch. Or if all candidates fail the test, we can modify the x, y, and z above, to make it easier to pass the test. Or we can get a different ratio for Kp to Ki. Or we could make the x,y,z above more restrictive if there are too many candidates that pass. The more restrictive, the better the convergence. The code is done, and now just needs to be tested. This is going to be much faster! __________________ kits and boards Last edited by MPaulHolmes; 09-07-2015 at 06:59 PM..
 The Following 2 Users Say Thank You to MPaulHolmes For This Useful Post: mpgmike (02-11-2022), thingstodo (09-07-2015)
 09-07-2015, 09:09 PM #1943 (permalink) PaulH     Join Date: Feb 2008 Location: Maricopa, AZ (sort of. Actually outside of town) Posts: 3,832 Michael's Electric Beetle - '71 Volkswagen Superbeetle 500000 Thanks: 1,368 Thanked 1,202 Times in 765 Posts autotuning tested and working! It took maybe 5 or 10 seconds to run through several hundred possible values, testing each one. Then it listed the ones that worked. Anything on the list should be fine. My number one choice was right in the middle of the list, so that made me feel better. __________________ kits and boards
 The Following 2 Users Say Thank You to MPaulHolmes For This Useful Post: mpgmike (02-11-2022), thingstodo (09-07-2015)
Master EcoModder

Join Date: Sep 2010
Posts: 1,488

Ford Prefect - '18 Ford F150 XLT XTR

Tess - '22 Tesla Y LR
Thanks: 747
Thanked 565 Times in 447 Posts
Quote:
 Originally Posted by MPaulHolmes autotuning tested and working! It took maybe 5 or 10 seconds to run through several hundred possible values, testing each one. Then it listed the ones that worked. Anything on the list should be fine. My number one choice was right in the middle of the list, so that made me feel better.
So Paul, do I need an updated hex file? I'll be testing tomorrow morning.

Got home too late to start testing tonight.

By the way - what signal is expected from the throttle when the system starts up? I need to get past the 'high throttle lockout', and I'm still using a potentiometer with a couple of bias resistors instead of a hall effect wig-wag setup.

Master EcoModder

Join Date: Sep 2010
Posts: 1,488

Ford Prefect - '18 Ford F150 XLT XTR

Tess - '22 Tesla Y LR
Thanks: 747
Thanked 565 Times in 447 Posts
Quote:
 Originally Posted by MPaulHolmes autotuning tested and working!
Great news! Congratulation!! WOO-HOO!

Autotune is an advanced feature ... that can sell controllers!

If someone were to blow up their matched AC controller - like a DMOC AC controller on a Ford transit E-connect - your controller could be installed, the motor autotuned, and the vehicle is back up and running! (DMOC was produced by Azure Dynamics, and they went bankrupt - no parts, no spares)

So far, HPEVS motors are supplied with Curtis Controllers. With Autotune, your controller will work with them too!

The list of motors that could use a good controller is not *REALLY* long, but it's long enough.

 The Following User Says Thank You to thingstodo For This Useful Post: MPaulHolmes (09-07-2015)
 09-08-2015, 12:00 AM #1946 (permalink) PaulH     Join Date: Feb 2008 Location: Maricopa, AZ (sort of. Actually outside of town) Posts: 3,832 Michael's Electric Beetle - '71 Volkswagen Superbeetle 500000 Thanks: 1,368 Thanked 1,202 Times in 765 Posts I'll take out the high pedal lockout thing. I'll also send a new hex file either late tonight or early early in the morning (like 3 or 4am. I've been waking up at 3am lately. haha) __________________ kits and boards
Master EcoModder

Join Date: Sep 2010
Posts: 1,488

Ford Prefect - '18 Ford F150 XLT XTR

Tess - '22 Tesla Y LR
Thanks: 747
Thanked 565 Times in 447 Posts
Quote:
 Originally Posted by MPaulHolmes I've been waking up at 3am lately. haha)
So do I .. and at 5 am as well .. but that's only to go to the bathroom! I HATE getting OLD.

 The Following User Says Thank You to thingstodo For This Useful Post: MPaulHolmes (09-08-2015)
 09-08-2015, 10:33 AM #1948 (permalink) EcoModding Lurker   Join Date: Sep 2015 Location: Australia Posts: 3 Thanks: 2 Thanked 2 Times in 2 Posts Paul, would you be so kind as to send me the bill of materials for your controller board? The link on the instructables page is dead. Can you also recommend a good PCB printing place? The ones I've found online run with minimum quantities of 3 (not a bad thing in itself), or have outrageous pricing (becomes bad when combined with minimum quantities).
 The Following User Says Thank You to G-Max For This Useful Post: MPaulHolmes (09-08-2015)
Master EcoModder

Join Date: Sep 2010
Posts: 1,488

Ford Prefect - '18 Ford F150 XLT XTR

Tess - '22 Tesla Y LR
Thanks: 747
Thanked 565 Times in 447 Posts
Some progress to report for Sep 8

Load new firmware into AC controller
- power is off to controller and PICkit 3
- plug PICKit 3 into controller
- plug USB into laptop
- turn on 12V to controller
- connect to controller
- load hex file ACControllerproject150908 autotune.hex
- program controller
- turn off 12V
- eject USB and remove
- disconnect PICKit 3 from ACController board

Connect serial from laptop to controller
load accontroller settings 115200,n,8,1 no flow control
power up controll 12V
After pre-charge, welcome message AC controller firmware, ver. 1.0

following Paul's instructions - I will be typing in run-pi-test

Before I do that, set up:
- whole scene video on my gopro
- audio on my old phone with a headset
- my phone recording a closeup of the DC motor since you can't really see the AC motor

The first run, nothing appeared to happen when I did run-pi-test. So I shut
things down and did it again. This time when nothing appeared to happen, I started to mess around with the throttle pot. The program (after a couple of minutes, and when I wasn't watching) put out ALL of the numbers from 62 up to the maximum in multiples of 62. That seems strange. This is after autotune 2 stopped recording.

I stopped the video and audio capture, turned everything off, then started up the video and audio, then started the text capture (autotune 3), powered up the high voltage, then the low voltage.

The motor started running! So I messed with the throttle until it stopped.
Then I ran run-pi-test
I got 2 numbers, 03844 and 04774
I stopped the video and audio capture, text capture and read through Paul's instructions

Armed with a value for kP, I don't know what to do to get Ki. I read through the ecomodder forum again.

Ahh - i is k / 62 (that's why the steps are set to 62). So 3844/62= 62, 4774/62=77

run-rotor-test
the controller and motor buzzed for several seconds and stopped.

Turn it all off and try again with 4774 and 77
the controller did not buzz this time
and the contactors appeared to cycle for no reason
and then I received the startup message from the controller again

The 12V battery is down to 8V. That's a problem. Connect it to a charger and go back to testing. The controller does not respond well. The contactors cycle again. Perhaps the dead contactor that I left connected to hear when the output cycles is taking a bunch of current? Disconnect it and cap off the wires.

12V battery is up to 10.2V with the charger on it ... so it is *WAY* down on the discharge curve (small lithium pack). The charger outputs 3A so I will wait until the 12V reaches 12V as a minimum.

Up the capture to autotune 5

k 4774
i 77
run-rotor-test

The controller buzzed for a while, finally starting the motor shaft turning .. at maybe 40 or 50 rpm. The motor slows down over time and when the test is complete, the values printed out are .. 0s?

The output from autotune 5 is 0, a bunch of 0's

Shut off the video and audio, shut off the system, start it all back up

autotune 6

k 3844
i 62
run-rotor-test

The controller buzzes for a while, just like last time. The motor shaft starts to turn at 40 or 50 rpm, just like last time. The motor slows down over time and when the test is complete, the values are printed out ..

The output is 0's again.

Maybe I need to remove the coupler for the DC motor and let the motor spin more freely during the test?

I have some video to edit, and see if I can get the voice-over to work. I have not done video with multiple sources before so it will be a bit of an experiment.

I did a motor spin test in there somewhere as well. The controller makes a loud buzzing until the motor begins to turn, then if I back off the throttle the noise sort of goes away. More throttle buzzes more but does not turn the motor faster.

EDIT BELOW ---

There are 9 videos, 2 - 8 minutes each. Be warned - the video work is not done well (the separate audio experiment did not go well, the editing software did not digest the Gopro footage and allow for windowed zoom) and the audio is a bit hard to hear (refer to audio experiment comment). Lots of stuff happens off-camera (refer to gopro footage comments).

Video 1 https://youtu.be/J15KnjW2CbI

Video 2 https://youtu.be/4XcoedWKTPk

But if you suffer through the videos and follow along with the problems, it's sorta like getting the experience of troubleshooting without having to do it yourself ... so I've been told by at least one person .. your mileage may vary!

Video 3 https://youtu.be/8ZFoPcTN2As

Video 4 https://youtu.be/lcaJat9hp9Y

Video 5 https://youtu.be/x1Umb_ckRpU

Video 6 https://youtu.be/TgTP6M2FwLc

Video 8 https://youtu.be/pxDl0BxKrLw

Video 9 https://youtu.be/KicuUhKoibU
Attached Files
 autotune.txt (63 Bytes, 11 views) autotune 1.txt (86 Bytes, 12 views) autotune 2.txt (94 Bytes, 16 views) autotune 3.txt (64 Bytes, 15 views) autotune 4.txt (98 Bytes, 11 views) autotune 5.txt (464 Bytes, 19 views) autotune 6.txt (464 Bytes, 11 views)

Last edited by thingstodo; 09-14-2015 at 12:45 PM.. Reason: Add first 2 links for videos (boring, but they give you a flavor for the testing process) ... then added rest of the links

 The Following User Says Thank You to thingstodo For This Useful Post: MPaulHolmes (09-08-2015)
 09-08-2015, 10:45 PM #1950 (permalink) PaulH     Join Date: Feb 2008 Location: Maricopa, AZ (sort of. Actually outside of town) Posts: 3,832 Michael's Electric Beetle - '71 Volkswagen Superbeetle 500000 Thanks: 1,368 Thanked 1,202 Times in 765 Posts Wow! awesome progress. I forgot, you definitely need to make sure that the throttle is stuck at about 2.5v. Otherwise, when the PI test isn't being run, the controller will try to command current, with saved PI values that are horribly inappropriate for your motor. I noticed you did: k 3476 (or whatever) i 62 but it should actually be: p 3476 (or whatever) i 62 Probably any P between the 3400 (or whatever) and the 4400 (or whatever it was) should be fine. __________________ kits and boards
 The Following User Says Thank You to MPaulHolmes For This Useful Post: thingstodo (09-09-2015)