cancel
Showing results for 
Search instead for 
Did you mean: 

how to start using PMSM to write FOC ?

itri532600
Associate II
Posted on October 21, 2015 at 07:32

I downloaded the PMSM Motor Example. I want to fix my own programs, but has no idea .

I just wanted to ask if the external input from ia, ib, via FOC algorithm, the output value of the three-phase voltage to the oscilloscope measurement,

The FOC algorithm as long as I call following below program paradigm can be ?

 PWMC_GetPhaseCurrents(oCurrSensor[bMotor], &Iab);

  Ialphabeta = MCM_Clarke(Iab);

  Iqd = MCM_Park(Ialphabeta, hElAngledpp);

  hElAngledpp = SPD_GetElAngle(oSPD[MC_NUM]);    

  Vqd.qV_Component1 = PI_Controller(oPIDIq[MC_NUM], 

             (int32_t)(FOCVars[MC_NUM].Iqdref.qI_Component1) - Iqd.qI_Component1);

  Vqd.qV_Component2 = PI_Controller(oPIDId[MC_NUM], 

             (int32_t)(FOCVars[MC_NUM].Iqdref.qI_Component2) - Iqd.qI_Component2); 

  Valphabeta = MCM_Rev_Park(Vqd, hElAngledpp);  

  hCodeError = PWMC_SetPhaseVoltage(oCurrSensor[MC_NUM], Valphabeta);

This function is the final output of the three-phase voltage values ?

Thanks!
3 REPLIES 3
Gigi
Senior
Posted on October 29, 2015 at 12:14

Ciao Sapphira

Yes, these are the steps present inside the High Frequency Task that performs the current regulation to achieve the FOC.

The final function

PWMC_SetPhaseVoltage(oCurrSensor[MC_NUM], Valphabeta);

Transform the Valpha and Vbeta into the three duty cycle values (voltage applied to the motor) and set it into the PWM timer to generate the output. Intermediate value Va, Vb and Vc is not reaqlly computed and stored and for this reason the Va, Vb and Vc variables can't directly sent to the DAC output in this way. You can go inside the code and find the variables computed for the three duty and send it to the DAC (but you require confidential or protected version of the lib.)

The return value hCodeError it is only a error code or null if the three duty cycle has been updated before the update event of the timer (the moment in which the three duty cycle computed become actual).

Ciao

Gigi

itri532600
Associate II
Posted on November 02, 2015 at 01:38

Dear Gigi,

     Thanks for your information.

     But I had some problems about function

     

PWMC_GetPhaseCurrents(oCurrSensor[bMotor], &Iab);

     When I call this function, this code into an infinite loop.

void HardFault_Handler(void)

{

  /* Go to infinite loop when Hard Fault exception occurs */

  while (1)

  {

  }

}

     I send 3.3v to Ia and Ib from function generator, but I couldn't 

     get Ia, Ib from this function.

     So maybe something wrong with my code.

     How could I use this function correctly?

     Thanks!

     

Gigi
Senior
Posted on November 02, 2015 at 11:00

Ciao Sapphira

This can occur if all the object are not correctly instantiated using the MC Boot function in MCTaks.c

This due to the fact that some pointer to data or functions can be NULL and this generate a jump in a not valid range of the memory.

Calling then

PWMC_GetPhaseCurrents

in normal operation (I mean with FW correctly configured and MC Boot executed) and done one time each PWM period inside the Hghfrequency taks, the hard fault normally doesn't occur.

Ciao

Gigi