EcoModder Forum Paul & Sabrina's cheap DIY 144v motor controller

Register Now
 Remember

 08-15-2017, 08:46 AM #7201 (permalink) EcoModding Lurker   Join Date: Jul 2017 Location: Croatia Posts: 23 Thanks: 0 Thanked 2 Times in 1 Post tnx will those work with your logic ? FUJI 1MBI600U4B-120 Last edited by mfox; 08-15-2017 at 04:51 PM..
 Today Popular topics Other popular topics in this forum... View the most popular topics in this subforum by views or by posts
 09-10-2017, 01:48 PM #7202 (permalink) EcoModding Lurker   Join Date: Sep 2017 Location: Cracow Posts: 1 Thanks: 0 Thanked 0 Times in 0 Posts Hello. I'm trying to write soft for Field Oriented Control of induction motor. I have finished 3ph 3kW inverter, controled by STM32F4, and V/F open loop algorithm to control ACIM - it works. Now I'm trying to implement FOC algorithm rewriting code from this project using float variables. CortexM4 have FPU so operations on floating points numbers take same time (cycles) as operating on integers. Here is part of code: Code: ```void ClarkPark(float L1_curr, float L2_curr) { vector.Ialpha = L1_curr; vector.Ibeta = (L1_curr + 2.0*L2_curr) / 1.732; //Id = Ialpha*cos(Angle) + Ibeta*sin(Angle) vector.Id = vector.Ialpha*cos(vector.AngleFluxDeg) + vector.Ibeta*sin(vector.AngleFluxDeg); // Iq = -Ialpha*sin(Angle) + Ibeta*cos(Angle) vector.Iq = (-1.0)*vector.Ialpha*sin(vector.AngleFluxDeg) + vector.Ibeta*cos(vector.AngleFluxDeg); } //qdImag = qdImag + qKcur * (qId - qdImag) ;; magnetizing current void curModel(void) { //qdImag = qdImag + qKcur * (qId - qdImag) ;; magnetizing current vector.Imag = vector.Imag + (LOOP_PERIOD / ROTOR_TIME_CONST) * (vector.Id - vector.Imag); if(vector.Imag == 0) { return; } // VelSlipRPS = (1/fRotorTmConst) * Iq/Imag / (2.0*pi) vector.VelSlipsRPS = (1 / ROTOR_TIME_CONST ) * (vector.Iq / vector.Imag) / (2.0*PI); //VelFluxRPS = iPoles * VelMechRPS + VelSlipRPS vector.VelFluxRPS = 2.0 * speed.perSec + vector.VelSlipsRPS; //AngFlux = AngFlux + fLoopPeriod * 2.0 * pi * VelFluxRPS vector.AngleFluxRad = vector.AngleFluxRad + LOOP_PERIOD * 2.0 * PI * vector.VelFluxRPS; vector.AngleFluxDeg = vector.AngleFluxRad * (180.0 / PI); }``` Please tell me If I'm wrong: I have to keep an eye on vector.AngleFluxDeg variable to be value between 0 - 360 degree? (back to 0 if 360 overflowed). It will be correct? Thanks for any reply. Last edited by fasset; 09-10-2017 at 02:15 PM..
Master EcoModder

Join Date: Sep 2010
Posts: 1,481

ChargE (not yet running) - '92 Mazda MX6 LX
90 day: 33.89 mpg (US)

Ford Prefect - '18 Ford F150 XLT XTR
Thanks: 747
Thanked 560 Times in 443 Posts
??

Quote:
 Originally Posted by fasset I'm trying to write soft for Field Oriented Control of induction motor. I have finished 3ph 3kW inverter, controled by STM32F4, and V/F open loop algorithm to control ACIM - it works. Now I'm trying to implement FOC algorithm rewriting code from this project using float variables.
I think that maybe this should be moved to the AC controller thread? Do you need to be a moderator to do that?

As for the translation of the code, you should be able to run the code as Paul wrote it. The floating point variables should work as written. It appears to be ansi standard C with no goofy library calls.

If you want to optimize the math to make better use of your floating point math library, I'd suggest doing that after you have Paul's math running. Just my opinion. That way you can run through a test set for your math before your changes and after your changes to make sure it still works!

As for the range on degrees, you should be able to use the modulo or mod() function on your angle to bring it back to the range 0 - 360. It won't matter for the intermediate calculations. Sin(0) = sin(360) = sin(720). It is only convention that shows the angle between 0 and 360 degrees.

Hope this helps
__________________
In THEORY there is no difference between Theory and Practice
In PRACTICE there IS!

 The Following User Says Thank You to thingstodo For This Useful Post: MPaulHolmes (11-21-2017)
 11-21-2017, 01:00 PM #7204 (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,201 Times in 765 Posts Yes, thingstodo, and I actually use 0-65535 for the "degrees" so that when it rolls over, it automatically goes back to zero, so you don't have to worry about it. mfox: I would use either a high side IGBT with a diode on the low side (I think they call those choppers), or an IGBT half bridge, since you need a freewheel diode too, and just just the IGBT. So, the part you listed wouldn't work for that. __________________ kits and boards
 The Following User Says Thank You to MPaulHolmes For This Useful Post: mpgmike (01-25-2022)
 02-07-2018, 06:30 PM #7205 (permalink) EcoModding Lurker   Join Date: Feb 2018 Location: Colorado Springs Posts: 9 Thanks: 0 Thanked 2 Times in 2 Posts Hey, folks - Paul supplied me with a DC board for IGBTs and has been helping me with my controller. Seeing as he's pretty busy right now, does anyone have a current copy of the DC control software? I've read through a ton of posts, and I keep seeing messages about the software being sent back and forth, so hopefully someone can lend a hand Thanks!
 02-07-2018, 09:52 PM #7206 (permalink) Master EcoModder   Join Date: Apr 2009 Location: Charlton MA, USA Posts: 463 EVVette - '71 Chevy Corvette Coupe Thanks: 31 Thanked 183 Times in 94 Posts Index of /firmware __________________ www.EVVette.com - 1971 Corvette Coupe Conversion to all Electric! www.AdamBrunette.com - Machining, CNC, Robotics and Electronics. You can download RTD Explorer for the Cougar controllers at www.EVVette.com
Master EcoModder

Join Date: Sep 2010
Posts: 1,481

ChargE (not yet running) - '92 Mazda MX6 LX
90 day: 33.89 mpg (US)

Ford Prefect - '18 Ford F150 XLT XTR
Thanks: 747
Thanked 560 Times in 443 Posts
Quote:
 Originally Posted by jbman Hey, folks - Paul supplied me with a DC board for IGBTs and has been helping me with my controller. Seeing as he's pretty busy right now, does anyone have a current copy of the DC control software? I've read through a ton of posts, and I keep seeing messages about the software being sent back and forth, so hopefully someone can lend a hand Thanks!
The code I have for the IGBT DC version (Paul doesn't call it the cougar) does not compile for me on MPLAB X. This zip file does include the .hex file for .. I think it's version 7 that Paul uses?

Dated April 4, 2017 ... even though the zip file shows it is today's date.

This is the version I was running when I posted the test videos
Attached Files
 DC_Controller_2017_April_04.zip (48.4 KB, 43 views)
__________________
In THEORY there is no difference between Theory and Practice
In PRACTICE there IS!

Master EcoModder

Join Date: Sep 2010
Posts: 1,481

ChargE (not yet running) - '92 Mazda MX6 LX
90 day: 33.89 mpg (US)

Ford Prefect - '18 Ford F150 XLT XTR
Thanks: 747
Thanked 560 Times in 443 Posts
Quote:
 Originally Posted by jbman Hey, folks - Paul supplied me with a DC board for IGBTs and has been helping me with my controller.
Hmmm .. if Paul sent you the board, it should already have the latest firmware loaded ... but it never hurts to have the source files!
__________________
In THEORY there is no difference between Theory and Practice
In PRACTICE there IS!

EcoModding Lurker

Join Date: Feb 2018
Posts: 9
Thanks: 0
Thanked 2 Times in 2 Posts
Quote:
 Originally Posted by thingstodo Hmmm .. if Paul sent you the board, it should already have the latest firmware loaded ... but it never hurts to have the source files!
You are correct, I believe that it was loaded already. I was having a lot of trouble getting it to respond, however, so I made a mess of it XD I figured it would be easier to find a current copy of the software, but I was mistaken.

I am having a ton of trouble connecting to the controller via realterm.

I appreciate everyone's help!

Last edited by jbman; 02-10-2018 at 01:57 AM..

 02-11-2018, 09:05 AM #7210 (permalink) EcoModding Lurker   Join Date: Feb 2018 Location: Colorado Springs Posts: 9 Thanks: 0 Thanked 2 Times in 2 Posts Well, I'm getting no response over serial no matter what software I load on the chip, what terminal application I use, what cable I use, or what computer I use. It doesn't respond to throttle and never switches the IGBTs. The board is very different from the rest of these - I've attached some pictures. I think I'm stuck waiting for Paul to send the software. Attached Thumbnails