View Single Post
Old 09-10-2017, 01:48 PM   #7203 (permalink)
fasset
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..
  Reply With Quote