Hi~ ,
I am trying to control my 3-phase PMSM motor with lab12b and I use EST_getAngle_pu(obj->estHandle) to estimation elctric angle for controling motor speed. The PMSM set @1k rpm (SpeedRef_krpm),but I got 2k rpm (Speed_krpm) in watch window as below.
Below is speed relation between SpeedRef_krpm and Speed_krpm.
2* SpeedRef_krpm= Speed_krpm
-------------------------------------------------------
SpeedRef_krpm Speed_krpm
0.5k rpm 1k rpm
1k rpm 2k rpm
2k rpm 4k rpm
-----------------------------------------------------------
I don't know the reason for speed mismatch.
Best Regards,
ShengHua
interrupt void mainISR(void)
{
static uint16_t stCnt = 0;
CTRL_Obj *obj = (CTRL_Obj *)ctrlHandle;
// toggle status LED
if(gLEDcnt++ > (uint_least32_t)(USER_ISR_FREQ_Hz / LED_BLINK_FREQ_Hz))
{
HAL_toggleLed(halHandle,(GPIO_Number_e)HAL_Gpio_LED2);
gLEDcnt = 0;
}
---------------------------------------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
----------------------------------------------------------
// compute the electrical angle
//ENC_calcElecAngle(encHandle, HAL_getQepPosnCounts(halHandle));
---------------------------------------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
----------------------------------------------------------
void ST_runPosConv(ST_Handle handle, ENC_Handle encHandle, CTRL_Handle ctrlHandle)
{
ST_Obj *stObj = (ST_Obj *)handle;
// get the electrical angle from the ENC module
// STPOSCONV_setElecAngle_erev(stObj->posConvHandle, ENC_getElecAngle(encHandle));
// 2015.0706 by ysh .....
STPOSCONV_setElecAngle_erev(stObj->posConvHandle, rvl_ang_pu /*ENC_getElecAngle(encHandle)*/);
if(USER_MOTOR_TYPE == MOTOR_Type_Induction) {
// The CurrentVector feedback is only needed for ACIM
// get the vector of the direct/quadrature current input vector values from CTRL
STPOSCONV_setCurrentVector(stObj->posConvHandle, CTRL_getIdq_in_addr(ctrlHandle));
}
// run the SpinTAC Position Converter
STPOSCONV_run(stObj->posConvHandle);
if(USER_MOTOR_TYPE == MOTOR_Type_Induction) {
// The Slip Velocity is only needed for ACIM
// update the slip velocity in electrical angle per second, Q24
SLIP_setSlipVelocity(slipHandle, STPOSCONV_getSlipVelocity(stObj->posConvHandle));
}
}
void ST_runVelCtl(ST_Handle handle, CTRL_Handle ctrlHandle)
{
_iq speedFeedback, iqReference;
ST_Obj *stObj = (ST_Obj *)handle;
CTRL_Obj *ctrlObj = (CTRL_Obj *)ctrlHandle;
// Get the mechanical speed in pu
speedFeedback = STPOSCONV_getVelocityFiltered(stObj->posConvHandle);
// Run the SpinTAC Controller
// Note that the library internal ramp generator is used to set the speed reference
STVELCTL_setVelocityReference(stObj->velCtlHandle, TRAJ_getIntValue(ctrlObj->trajHandle_spd));
STVELCTL_setAccelerationReference(stObj->velCtlHandle, _IQ(0.0));// Internal ramp generator does not provide Acceleration Reference
STVELCTL_setVelocityFeedback(stObj->velCtlHandle, speedFeedback);
STVELCTL_run(stObj->velCtlHandle);
// select SpinTAC Velocity Controller
iqReference = STVELCTL_getTorqueReference(stObj->velCtlHandle);
// Set the Iq reference that came out of SpinTAC Velocity Control
CTRL_setIq_ref_pu(ctrlHandle, iqReference);
}