cancel
Showing results for 
Search instead for 
Did you mean: 

Hall Speed back fault error

SRedd.5
Senior III

I am getting the hall fault in the below code which i have highlighted in red. When i run in open load the below error does not come but only in vehicle condition the fault happens. 

__weak void *HALL_TIMx_CC_IRQHandler(void *pHandleVoid)
{
  uint32_t wCaptBuf;
  uint16_t hPrscBuf;
  uint16_t hHighSpeedCapture;
  HALL_Handle_t *pHandle = (HALL_Handle_t *)pHandleVoid; //cstat !MISRAC2012-Rule-11.5
  TIM_TypeDef *TIMx = pHandle->TIMx;
  uint8_t bPrevHallState;
  int8_t PrevDirection;
 
  if (pHandle->SensorIsReliable)
  {
    /* A capture event generated this interrupt */
    bPrevHallState = pHandle->HallState;
    PrevDirection = pHandle->Direction;
 
    if (DEGREES_120 == pHandle->SensorPlacement)
    {
      pHandle->HallState  = (uint8_t)((LL_GPIO_IsInputPinSet(pHandle->H3Port, pHandle->H3Pin) << 2U)
                                      | (LL_GPIO_IsInputPinSet(pHandle->H2Port, pHandle->H2Pin) << 1U)
                                      | LL_GPIO_IsInputPinSet(pHandle->H1Port, pHandle->H1Pin));
    }
    else
    {
      pHandle->HallState  = (uint8_t)(((LL_GPIO_IsInputPinSet(pHandle->H2Port, pHandle->H2Pin) ^ 1U) << 2U)
                                      | (LL_GPIO_IsInputPinSet(pHandle->H3Port, pHandle->H3Pin) << 1U)
                                      | LL_GPIO_IsInputPinSet(pHandle->H1Port, pHandle->H1Pin));
    }
 
    switch (pHandle->HallState)
    {
      case STATE_5:
      {
        if (STATE_4 == bPrevHallState)
        {
          pHandle->Direction = POSITIVE;
          pHandle->MeasuredElAngle = pHandle->PhaseShift;
        }
        else if (STATE_1 == bPrevHallState)
        {
          pHandle->Direction = NEGATIVE;
          pHandle->MeasuredElAngle = (int16_t)(pHandle->PhaseShift + S16_60_PHASE_SHIFT);
}
        else
        {
          /* Nothing to do */
        }
        break;
      }
      case STATE_1:
      {
        if (STATE_5 == bPrevHallState)
        {
          pHandle->Direction = POSITIVE;
          pHandle->MeasuredElAngle = pHandle->PhaseShift + S16_60_PHASE_SHIFT;
 
}
        else if (STATE_3 == bPrevHallState)
        {
          pHandle->Direction = NEGATIVE;
          pHandle->MeasuredElAngle = (int16_t)(pHandle->PhaseShift + S16_120_PHASE_SHIFT);
}
        else
        {
          /* Nothing to do */
        }
        break;
      }
 
      case STATE_3:
      {
        if (STATE_1 == bPrevHallState)
        {
          pHandle->Direction = POSITIVE;
          pHandle->MeasuredElAngle = (int16_t)(pHandle->PhaseShift + S16_120_PHASE_SHIFT);
}
        else if (STATE_2 == bPrevHallState)
        {
          pHandle->Direction = NEGATIVE;
          pHandle->MeasuredElAngle = (int16_t)(pHandle->PhaseShift + S16_120_PHASE_SHIFT + S16_60_PHASE_SHIFT);
        }
        else
        {
          /* Nothing to do */
        }
        break;
      }
 
      case STATE_2:
      {
        if (STATE_3 == bPrevHallState)
        {
          pHandle->Direction = POSITIVE;
          pHandle->MeasuredElAngle = (int16_t)(pHandle->PhaseShift + S16_120_PHASE_SHIFT + S16_60_PHASE_SHIFT);
 
}
        else if (STATE_6 == bPrevHallState)
        {
          pHandle->Direction = NEGATIVE;
          pHandle->MeasuredElAngle = (int16_t)(pHandle->PhaseShift - S16_120_PHASE_SHIFT);
}
        else
        {
          /* Nothing to do */
        }
        break;
      }
 
      case STATE_6:
      {
        if (STATE_2 == bPrevHallState)
        {
          pHandle->Direction = POSITIVE;
          pHandle->MeasuredElAngle = (int16_t)(pHandle->PhaseShift - S16_120_PHASE_SHIFT);
 
}
        else if (STATE_4 == bPrevHallState)
        {
          pHandle->Direction = NEGATIVE;
          pHandle->MeasuredElAngle = (int16_t)(pHandle->PhaseShift - S16_60_PHASE_SHIFT);
 
}
        else
        {
          /* Nothing to do */
        }
        break;
      }
 
      case STATE_4:
      {
        if (STATE_6 == bPrevHallState)
        {
          pHandle->Direction = POSITIVE;
          pHandle->MeasuredElAngle = (int16_t)(pHandle->PhaseShift - S16_60_PHASE_SHIFT);
}
        else if (STATE_5 == bPrevHallState)
        {
          pHandle->Direction = NEGATIVE;
          pHandle->MeasuredElAngle = (int16_t)(pHandle->PhaseShift);
        }
        else
        {
          /* Nothing to do */
        }
        break;
      }
 
      default:
{
        /* Bad hall sensor configutarion so update the speed reliability */
        pHandle->SensorIsReliable = false;
        break;
      }
    }
 
Fault 2:
Sometimes i get the fault in 
__weak bool SPD_IsMecSpeedReliable(SpeednPosFdbk_Handle_t *pHandle, const int16_t *pMecSpeedUnit)
but both faults does not come when in open load and happens only in vehicle condition. Why?
 
1 ACCEPTED SOLUTION

Accepted Solutions
Gael A
ST Employee

Hello SRedd.5,

At first glance, it looks like an issue that has been fixed in MCSDK 6.2, which was released last week. I advise you to upgrade your firmware.
However, if you can't / don't want to upgrade to MCSDK 6.2, you can take a look at this post : you will find the fix for the issue I am talking about.

If you agree with my answer, please consider accepting it by clicking on 'Accept as solution'.

Hope this will help,
Gaël A.

View solution in original post

7 REPLIES 7
Gael A
ST Employee

Hello SRedd.5,

At first glance, it looks like an issue that has been fixed in MCSDK 6.2, which was released last week. I advise you to upgrade your firmware.
However, if you can't / don't want to upgrade to MCSDK 6.2, you can take a look at this post : you will find the fix for the issue I am talking about.

If you agree with my answer, please consider accepting it by clicking on 'Accept as solution'.

Hope this will help,
Gaël A.

That is a big relief for me, i have not yet tested but hopefully there are no other serious bugs in the code and it will work fine. I have generated code from 6.2.0 and made modifications only to hall speed feedback code.

With the update of this code i do not get the Hall error but the start up is not smooth, it takes time before it starts and goes to normal speed in the vehicle in the loading conditions.

SRedd5_0-1696931714846.pngSRedd5_1-1696931777591.png

I really need some solution for this. The vehicle goes in kinds of steps before it picks up.

SRedd.5
Senior III

After flashing this software i am also seeing some kind of distortion in waveform in between or small kind of jerks

SRedd5_0-1696941522540.png

 

SRedd.5
Senior III

The hall fault still happens once in a while when using the work bench 6.20 but not as frequently as before from the previous work bench software's. This is observed in vehicle trails. Any other code updates to be done?

SRedd.5
Senior III

I think the mistake is from my end where the hall signals are going to hall state7 which is invalid, something to do with hardware. Regarding the initial slow ramp i increased the Kp and it starts little bit smooth. Thank you very much support. 

This issue keeps happening where the vehicle goes in steps and jerks observed before it smoothens. Any support on this please.

SRedd5_0-1697803388632.png