This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

F28035 中的QEP正交编码电路的工作原理是什么?

Other Parts Discussed in Thread: AM4379

如题。 谢谢

  • 百度一下正交编码器的原理即可

  • 个人的理解

    编码器的A B Z三相输出三路信号   A B相相位差为90度     Z每旋转一周来一个脉冲信号

    正交编码电路通过A B相信号的90度相位差  逻辑关系    判断电机旋转的方向

    A B相的方波信号  可以触发捕获单元  去捕获通用定时器的当前值    通过两次捕获值做差值

    加上编码器的线数  计算电机旋转的速度

  • 百度上的太杂乱了,而且不专业,并且没有针对性。所以我才来了这里。

  • 请问下面两个if判断语句里面是什么意思 啊?

    解释里面说一个位置到达事件,还有一个是时间到达事件。 但是还是不太理解。


    if(EQep1Regs.QFLG.bit.UTO==1) // If unit timeout (one 100Hz period)
    {
    /** Differentiator **/
    // The following lines calculate position = (x2-x1)/4000 (position in 1 revolution)
    pos16bval=(unsigned int)EQep1Regs.QPOSLAT; // Latched POSCNT value
    tmp = (long)((long)pos16bval*(long)p->mech_scaler); // Q0*Q26 = Q26
    tmp &= 0x03FFF000;
    tmp = (int)(tmp>>11); // Q26 -> Q15
    tmp &= 0x7FFF;
    newp=_IQ15toIQ(tmp);
    oldp=p->oldpos;

    if (p->DirectionQep==0) // POSCNT is counting down
    {
    if (newp>oldp)
    Tmp1 = - (_IQ(1) - newp + oldp); // x2-x1 should be negative
    else
    Tmp1 = newp -oldp;
    }
    else if (p->DirectionQep==1) // POSCNT is counting up
    {
    if (newp<oldp)
    Tmp1 = _IQ(1) + newp - oldp;
    else
    Tmp1 = newp - oldp; // x2-x1 should be positive
    }

    if (Tmp1>_IQ(1))
    p->Speed_fr = _IQ(1);
    else if (Tmp1<_IQ(-1))
    p->Speed_fr = _IQ(-1);
    else
    p->Speed_fr = Tmp1;

    // Update the electrical angle
    p->oldpos = newp;

    // Change motor speed from pu value to rpm value (Q15 -> Q0)
    // Q0 = Q0*GLOBAL_Q => _IQXmpy(), X = GLOBAL_Q
    p->SpeedRpm_fr = _IQmpy(p->BaseRpm,p->Speed_fr);
    //=======================================

    EQep1Regs.QCLR.bit.UTO=1; // Clear interrupt flag
    }

    //**** Low-speed computation using QEP capture counter ****//
    if(EQep1Regs.QEPSTS.bit.UPEVNT==1) // Unit position event
    {
    if(EQep1Regs.QEPSTS.bit.COEF==0) // No Capture overflow
    temp1=(unsigned long)EQep1Regs.QCPRDLAT; // temp1 = t2-t1
    else // Capture overflow, saturate the result
    temp1=0xFFFF;

    p->Speed_pr = _IQdiv(p->SpeedScaler,temp1); // p->Speed_pr = p->SpeedScaler/temp1
    Tmp1=p->Speed_pr;

    if (Tmp1>_IQ(1))
    p->Speed_pr = _IQ(1);
    else
    p->Speed_pr = Tmp1;

    // Convert p->Speed_pr to RPM
    if (p->DirectionQep==0) // Reverse direction = negative
    p->SpeedRpm_pr = -_IQmpy(p->BaseRpm,p->Speed_pr); // Q0 = Q0*GLOBAL_Q => _IQXmpy(), X = GLOBAL_Q
    else // Forward direction = positive
    p->SpeedRpm_pr = _IQmpy(p->BaseRpm,p->Speed_pr); // Q0 = Q0*GLOBAL_Q => _IQXmpy(), X = GLOBAL_Q


    EQep1Regs.QEPSTS.all=0x88; // Clear Unit position event flag
    // Clear overflow error flag
    }

  • 这两段代码都是用来计算速度的,上面的是应用于高速,利用计算每10ms时间段里面QEP接收到几个脉冲信号的原理,因此利用了UT单位时间事件;下面部分是用在低速时的,利用计算QEP接收到的两个相邻信号之间的时间间隔来计算速度,因此用了UP单位位置事件。具体的原理解释可以在SPRUFK8文档上第25~26页找到。

  • 请问何时判为高速,何时算做低速呢?

  • 这个根据具体情况设定,如上10ms内至少一次脉冲以上的速度为高速,否则即为低速

  • 如果我只想测量编码器的旋转角度,但是在配置的时候出了点问题。这个寄存器怎么配置呢?AM4379