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.

TMS320F28069M: Encoder feedback angle isn't right when running lab12b

Part Number: TMS320F28069M

Hi Champs,

My customer ran motion lab12b and found out that motor spun back and forth when they applied dyno. Customer found out that when they commented out  angle pu = electricalAngle;  // Update electrical angle from the sensor in ctrlQEP.h. They used EST_getAngle_pu() to get angle and motor spin smoothly. That means estimator angle is right and encoder angle is wrong,

After traced back code, ENC_getElecAngle(encHandle) output electricalAngle. And ENC_calcElecAngle() calculated electricalAngle. Could you please tell me which variable should I modify to get right eletricalAngle base on encoder feedback ? I checked ENC_calcElecAngle() and there is an enc_zero_offset variable. this offset is gotten from ENC_setZeroOffset() which is in below code. Does is mean user must to do Rs Recalculation to get encoder offset ? 

 // if we are forcing alignment, using the Rs Recalculation, align the eQEP angle with the rotor angle
  if((EST_getState(obj->estHandle) == EST_State_Rs) && (USER_MOTOR_TYPE == MOTOR_Type_Pm))
  {
	  ENC_setZeroOffset(encHandle, (uint32_t)(HAL_getQepPosnMaximum(halHandle) - HAL_getQepPosnCounts(halHandle)));
  }

There is a weird thing which is that customer increase USER_MOTOR_RES_EST_CURRENT and solve this problem. But customer don't know why this variable will effect result. And i have no idea either. Could anyone can help to check? thanks! 

  • Hi Lisa,

    You may refer to lab12a that setups the calibrated angle of the encoder by re-calibrating the Rs value of the motor if the motor is a PMSM. Please ensure that the encoder are connected correctly, and the number of lines is also setup in ENC_setup() and user.h correctly.
    You will look at the correct angle offset of encoder in "enc" object struct by adding enc.enc_zero_offset in expression window, and then set the calibrated offset in ENC_setup().
    Actually, the Rs-recalculate is enabled in default in all motion lab projects. Please increase the USER_MOTOR_RES_EST_CURRENT in user.h to make sure the rotor can be aligned to get the encoder offset correctly by rotating the rotor to Zero angle.
  • Hi Yanming,
    thanks for your feedback. If customer attached dyno first then start to do encoder angle calibration. Is that OK ? Because rotor shaft won't be moved and QEP suppose doesn't output any signal. Can i still get QEP offset ? thanks.
  • It's better to run the calibration without load or with light load, to ensure the rotor can be moved to ZERO position. If not, you can't get the correct offset. You just need to do this calibration once for a motor, and then set the offset value in project for running next time.
  • Hi Yanming,
    Thanks for feedback. Now customer tested electrical brake on their system. They add brake before motor alignment. Now they faced the problem which is motor rotor can't be align with D-axis. Therefore, they can't get correct QEP offset. Is there any other method to get correct QEP offset without alignment ? thanks!
  • They have to do this offset calibration each time the controller powers up, don't need to do this each running if the QEP and controller are powered up always. Or, they need additional signal to know the initial rotor position , like a encoder with A/B/I and U/V/W.
  • Yanming said:
    You just need to do this calibration once for a motor, and then set the offset value in project for running next time.

    [Lisa]: Could you please tell me why only to do calibration for one time ? Because motor shaft should be in different angle in each motor. QEP offset should be different in each motor. thanks.   

  • Do this offset calibration once for the motor with encoder each power up if the power of encoder and controller is always on. Otherwise, have to do it again when power up if the power is lost before.
  • Hi Yanming,
    Thanks. Customer has another question. We can use EST_getAngle_pu to get angle information from FAST. However, customer want to convert FAST angle information into Encoder angle reading. I know ENC_calcElecAngle is based on QEP-> QPOSCNT. However, i don't know how to convert FAST angle pu into QPOSCNT....Could you please tell me how to convert FAST angle pu into encoder angel ? thanks!
  • It's possible to change QPOSCNT with the angle from FAST estimator, but it's not right way to do this for offset calibration using this method. The angle (angle_est) of FAST estimator is a absolute angle from _IQ(0.0) to _IQ(1.0), so the output value of encoder (QPOSCNT) is angle_est*4*encoder_line/(2^24) if the offset of encoder is 0 and the value of global IQ is 24.
  • Hi Yanming,

    thanks for your reply, Now customer would like to use sensoreless solution at initial state and switch to sensored solution after motor strart-up. We want to use FAST angle subtract from ENC_calcElecAngle then we can get the encoder offset. Not sure this works or not. If you have any concern, please let me know! thanks. 

    Yanming said:
    The angle (angle_est) of FAST estimator is a absolute angle from _IQ(0.0) to _IQ(1.0), so the output value of encoder (QPOSCNT) is angle_est*4*encoder_line/(2^24) if the offset of encoder is 0 and the value of global IQ is 24.

     

    [Lisa]: Does "4" mean 4 pole pair ? thanks 

  • This assume the pole pairs is ONE, the full equation should be Counter = angle_est*4*encoder_line/(2^24)/Pole_Pairs.