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

Register Now
 Remember

 10-07-2014, 01:53 PM #1171 (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,362 Thanked 1,202 Times in 765 Posts It just took a huge leap closer to working last night! Morgan LaMoore and Edward Cheeseman had some wonderful debugging ideas, and also this very helpful formula(s): Va = duty1 - (average of the 3 duties) Vb = duty2 - (average of the 3 duties) Vc = duty3 - (average of the 3 duties) That's what the motor sees. All this time, I thought setting the duty was setting the duty of the low side IGBT, and the high side igbt was just the complement of the low side. It turns out, the low side is actually the slave to the high side! Setting the duty sets the high side duty. So, my space vector modulation routine was flipped around. So, their formulas above let me know what the space vector modulation SHOULD HAVE BEEN doing, so I changed it to that, and then tried to make sense of it geometrically. Then finally I found out that the high side gets set when you set the duty! oh the humanity.. It's all to glorious for words. hahaha. Here's the video from last night. Running at 12v on a motor that should have a DC voltage of like 680v or something. haha: By the way, I could make it tick like the second hand on a clock just by setting the rotor flux angle manually instead of finding it, and then just putting in a delay. I did that last night on accident. The motor could actually double as a clock. Oh what time is it? Well, it only has a second hand, so I have no idea! haha __________________ kits and boards Last edited by MPaulHolmes; 10-07-2014 at 05:13 PM..
 The Following 6 Users Say Thank You to MPaulHolmes For This Useful Post: Astro (10-07-2014), e*clipse (10-07-2014), flores (10-07-2014), freebeard (10-07-2014), mpgmike (02-01-2022), thingstodo (10-07-2014)
 Today Popular topics Other popular topics in this forum...
 10-07-2014, 08:46 PM #1172 (permalink) Master EcoModder     Join Date: Aug 2012 Location: northwest of normal Posts: 28,318 Thanks: 8,000 Thanked 8,816 Times in 7,273 Posts I was going to let this go, and just let you get on with your work; but I'll say it once more: The more people that audit your code the better it will be. I figured I'd get my MGR mounted and the axles hooked up and wait (the easy part?); but maybe I'd better get on the stick.
 10-07-2014, 09:12 PM #1173 (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,362 Thanked 1,202 Times in 765 Posts You promise it's only once more? Haha. I'm happy to email it to anybody that wants it. But a lot of coding critique is style critique. Don't use globals. Break that up into separate files, etc... but my style is my style and is easiest for me to get it done. If you want to post it wherever you want, go ahead. now I have a path for tuning Id and Iq pi loops thanks to eV tech suggestions (but those aren't code specific suggestions), and then just need to find the right rotor time constant. I found a process in an ebook for that now that can be programmed into the controller so each person can identify their respective time constant, which unfortunately is unique to their motor. __________________ kits and boards
 The Following User Says Thank You to MPaulHolmes For This Useful Post: thingstodo (10-08-2014)
Dreamer

Join Date: Nov 2013
Location: Australia
Posts: 350
Thanks: 95
Thanked 214 Times in 151 Posts
Quote:
 Originally Posted by MPaulHolmes You promise it's only once more? Haha. I'm happy to email it to anybody that wants it. But a lot of coding critique is style critique. Don't use globals. Break that up into separate files, etc... but my style is my style and is easiest for me to get it done. If you want to post it wherever you want, go ahead. now I have a path for tuning Id and Iq pi loops thanks to eV tech suggestions (but those aren't code specific suggestions), and then just need to find the right rotor time constant. I found a process in an ebook for that now that can be programmed into the controller so each person can identify their respective time constant, which unfortunately is unique to their motor.
Paul, i hear what you are saying about coding style. One of my co-workers wrote a script that ran at random times and modified each of the other team members efforts to match their own way of working. She was not very popular that day (actually she never was popular). The script had some major oversights that meant a lot of lost work for the other members of the team.
Some programmers are crazy good, some are just plain crazy.

What parameters are required to work out the time constant? Is there a way of deriving it by trial and error? Maybe spinning the flywheel one way then attempting to reverse its spin and seeing which time constant results in the least time to achieve the full reversal of rotation?

 The Following User Says Thank You to Astro For This Useful Post: MPaulHolmes (10-08-2014)
 10-07-2014, 11:39 PM #1175 (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,362 Thanked 1,202 Times in 765 Posts The books way of doing it was to run the motor unloaded for one test, and then locked rotor for another test. From those two tests, you deduce like 15 different things. One of those is the rotor resistance (like number 15 in that train wreck process.). We still need the rotor inductance. Then the time constant is L/R. __________________ kits and boards
 10-08-2014, 12:39 AM #1176 (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,362 Thanked 1,202 Times in 765 Posts I think your way sounds good. There aren't that many possibilities. The Tumanako devel motor worked well for 0.04 to 0.047. So, it may only be 100 things to check. 0.001 to 0.100 or so. __________________ kits and boards
Dreamer

Join Date: Nov 2013
Location: Australia
Posts: 350
Thanks: 95
Thanked 214 Times in 151 Posts
Quote:
 Originally Posted by MPaulHolmes I think your way sounds good. There aren't that many possibilities. The Tumanako devel motor worked well for 0.04 to 0.047. So, it may only be 100 things to check. 0.001 to 0.100 or so.
As long as none of the 0.001 to 0.1 values will cause damage to either the motor or the controller then trial and error may be ok. I am assuming that an incorrect time constant will cause the motor to take longer to slow down the rotating flywheel and then accelerate it back up in the opposite direction.
Depending on how quickly the performance degrades as you move away from the ideal value then maybe we could sample at 0.01, 0.02, 0.03 etc. Then test the 10 values between the two best out of the first set of ten tests. That would save having to run the test 100 times.
If the test required a bigger load or if the car had no flywheel then maybe a wheels up test using the momentum of two spinning wheels as the load to test against?

 10-08-2014, 02:51 AM #1178 (permalink) Master EcoModder     Join Date: Aug 2012 Location: northwest of normal Posts: 28,318 Thanks: 8,000 Thanked 8,816 Times in 7,273 Posts I watched your video and Youtube concluded the closest match was this The speaker is Dave Wilson, the Motor Control Systems Manager for Texas Instruments. It's 53 minutes, but the 2nd half is TI-specific. Through the introductory first half he keeps saying "But wait, there's a better way" and moves on from encoders and resolvers to observers. A lot of it sounded familiar from reading this thread. Something about a predictive, single-phase controller.... ? Also I said audit, not critique. That sounds like something art students would do.
 The Following User Says Thank You to freebeard For This Useful Post: mpgmike (02-02-2022)
 10-08-2014, 05:56 AM #1179 (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,362 Thanked 1,202 Times in 765 Posts Maybe the test could be done at low current. I know you can have absolutely no idea as to the right rotor time constant, and still control "Id" and "Iq". They will even be 90 degrees apart, but they just won't be the ideal field and torque component. The more I think of your idea, the better it sounds. Freebeard, you can submit the code anywhere you want. I will even be happy to allow the irs to email me and download it. One concern I have is, are you depending on a boost section being done by me any time soon? This would be a major undertaking, and a new board would need to be made, using a different microcontroller that has 4 pwm channels. __________________ kits and boards
 The Following User Says Thank You to MPaulHolmes For This Useful Post: Astro (10-08-2014)
Dreamer

Join Date: Nov 2013
Location: Australia
Posts: 350
Thanks: 95
Thanked 214 Times in 151 Posts
Quote:
 Originally Posted by MPaulHolmes ....The more I think of your idea, the better it sounds.
Now i know we are entering the land of crazy when one of my ideas sounds good.

I watched the video freebeard linked. Well i got as far as the part where the presenter started talking about filters and using pictures of cars at which point my head decided to invert itself at high velocity. Up to that point it was all making a crazy sort of sense.
Paul, you must have a skull of steel to keep all this in there.

But back to the time constant thingy. It sort of seems like cheating to use the trial and error method but if it is just that single value we need and we know the range that it exists in then why not. It should allow the controller to be matched to any motor even if the motor specifications are totally unknown.
Which would be handy for people who had rewound their motor and may not know all of the modified motors parameters. Or where the motor is a junk yard rescue with a missing or unreadable specification plate. Or the motor comes out of a hybrid vehicle and the manufacturer isn't forthcoming with specifications.