打印
[LKS32 软件]

SVPWM_2ShuntGetPhaseCurrent函数怎么理解

[复制链接]
1503|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
guoxum|  楼主 | 2024-2-5 19:24 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
请问哪位大佬能不能解释一下这个函数,我硬件双电阻采集的B、C相电流,这个函数要改吗
stru_CurrPhaseUV SVPWM_2ShuntGetPhaseCurrent(stru_FOC_CurrLoopDef *this)
{
    stru_Array_Def mADC_Result;
    stru_CurrPhaseUV Local_Stator_Currents;
    s32 wAux;
    s16 hCurrA = 0, hCurrB = 0, hCurrC = 0;

    u8 bCurrASamp = 0, bCurrBSamp = 0;
    GET_ADC0_DATA(mADC_Result);//这读的不只是某一项电流吗?
    /* First sampling point */
    switch (this->bSampCur1)
    {
    case SAMP_IA://这是静止坐标下的扇区吗?

        wAux = (s32)(this->nPhaseAOffset) - mADC_Result.nData0;
        hCurrA = sat(wAux, S16_MIN, S16_MAX);

        bCurrASamp = 1;
        break;

    case SAMP_IB:

        wAux = (s32)(this->nPhaseBOffset) - mADC_Result.nData0;
        hCurrB = sat(wAux, S16_MIN, S16_MAX);

        bCurrBSamp = 1;
        break;

    case SAMP_IC:

        wAux = (s32)(this->nPhaseCOffset) - mADC_Result.nData0;
        hCurrC = sat(wAux, S16_MIN, S16_MAX);

        bCurrBSamp = 1;
        break;
    case SAMP_NIA:
        hCurrA = this->mStatCurrUVW.nPhaseU;
        bCurrASamp = 1;

        break;
    case SAMP_NIB:
        hCurrB = this->mStatCurrUVW.nPhaseV;
        bCurrBSamp = 1;

        break;
    case SAMP_NIC:
        hCurrC = 0 - this->mStatCurrUVW.nPhaseU - this->mStatCurrUVW.nPhaseV;

        break;
    default:
        wAux = 0;
        break;
    }

    GET_ADC1_DATA(mADC_Result);
    /* Second sampling point */
    switch (this->bSampCur2)
    {
    case SAMP_IA:
        wAux = (s32)(this->nPhaseAOffset) - mADC_Result.nData0;
        hCurrA = sat(wAux, S16_MIN, S16_MAX);

        bCurrASamp = 1;
        break;

    case SAMP_IB:

        wAux = (s32)(this->nPhaseBOffset) - mADC_Result.nData0;
        hCurrB = sat(wAux, S16_MIN, S16_MAX);

        bCurrBSamp = 1;
        break;

    case SAMP_IC:

        wAux = (s32)(this->nPhaseCOffset) - mADC_Result.nData0;
        hCurrC = sat(wAux, S16_MIN, S16_MAX);

        break;
    case SAMP_NIA:
        hCurrA = this->mStatCurrUVW.nPhaseU;
        bCurrASamp = 1;

        break;
    case SAMP_NIB:
        hCurrB = this->mStatCurrUVW.nPhaseV;
        bCurrBSamp = 1;

        break;
    case SAMP_NIC:
        hCurrC = 0 - this->mStatCurrUVW.nPhaseU - this->mStatCurrUVW.nPhaseV;

        break;
    default:
        wAux = 0;
        break;
    }
    if (bCurrASamp == 0)
    {   /* 饱和处理 hd */
        wAux = -hCurrB - hCurrC;
        hCurrA = sat(wAux, S16_MIN, S16_MAX);
    }
    if (bCurrBSamp == 0)
    {
        wAux = -hCurrA - hCurrC;
        hCurrB = sat(wAux, S16_MIN, S16_MAX);
    }

#if (CHIP_PART_NUMBER == LKS32MC057D_V0)
    Local_Stator_Currents.nPhaseU = -hCurrA;
#else
    Local_Stator_Currents.nPhaseU = hCurrA;
#endif   
    Local_Stator_Currents.nPhaseV = hCurrB;

    return (Local_Stator_Currents);
}

使用特权

评论回复
沙发
stormwind123| | 2024-2-20 11:56 | 只看该作者
SVPWM_2ShuntGetPhaseCurrent 这个函数名没有直接对应的标准函数或库函数,它可能是一个特定于某个应用或库的自定义函数。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

1

帖子

0

粉丝