cancel
Showing results for 
Search instead for 
Did you mean: 

STSPIN32F0 with STEVAL-SPIN3201 how to adjust HALL angle duration?

GeorgesLab
Associate

Hello, I have STEVAL-SPIN3201 with sinopro motor. One direction works smoothly and reverse direction is jitter, noisy and with above 2000rpm diver starts to trigger overcurrent condition. According to symptoms it is caused by bad Hall alignment. Hall sensor signal is clean so no filtering issue I suppose.

I'm using example code from workbench 5.Y.4 with HAL driver based on FW package 1.11.3 and cubeMX 6.6.1 . Generated code have setting for commutation delay in HALL timer setup:

sConfig.IC1Polarity = TIM_ICPOLARITY_RISING;
  sConfig.IC1Prescaler = TIM_ICPSC_DIV1;
  sConfig.IC1Filter = 8;
  sConfig.Commutation_Delay = 0;

but when I modify 0 to any other value, it is load to TIM2 CCR2 on startup but is changed to 10 after motor is started. I'm unable to find where is this changed.

Any hint how to adjust Hall alignment will be welcome.

Other question, is possible to use active motor brake when engine stops (just for few seconds) with this code or I have to implement it myself?

Thank you.

1 REPLY 1
GeorgesLab
Associate

Looks like I solve it. There was mistake in one table function. There was identical steps for both direction, but for reverse should be backward as follows.

MC_FuncStatus_t MC_Core_HallStatusToStep(MC_Handle_t *pMc)
{
  if (pMc->direction == 0)    
  {
    switch (pMc->hall.status)
    {
      case VALIDATION_HALL_STATUS_DIRECT0_STEP1:
      {
        pMc->step_pos_next = 1;
      }
      break;
      case VALIDATION_HALL_STATUS_DIRECT0_STEP2:
      {
        pMc->step_pos_next = 2;
      }
      break;
      case VALIDATION_HALL_STATUS_DIRECT0_STEP3:
      {
        pMc->step_pos_next = 3;
      }
      break;
      case VALIDATION_HALL_STATUS_DIRECT0_STEP4:
      {
        pMc->step_pos_next = 4;
      }
      break;
      case VALIDATION_HALL_STATUS_DIRECT0_STEP5:
      {
        pMc->step_pos_next = 5;
      }
      break;
      case VALIDATION_HALL_STATUS_DIRECT0_STEP6:
      {
        pMc->step_pos_next = 6;
      }
      break;
      default:
      {
        return MC_FUNC_FAIL;
      }
      break;
    }
  }
  else
  {
    switch (pMc->hall.status)
    {
      case VALIDATION_HALL_STATUS_DIRECT1_STEP1:
      {
        pMc->step_pos_next = 6;
      }
      break;
      case VALIDATION_HALL_STATUS_DIRECT1_STEP2:
      {
        pMc->step_pos_next = 1;
      }
      break;
      case VALIDATION_HALL_STATUS_DIRECT1_STEP3:
      {
        pMc->step_pos_next = 2;
      }
      break;
      case VALIDATION_HALL_STATUS_DIRECT1_STEP4:
      {
        pMc->step_pos_next = 3;
      }
      break;
      case VALIDATION_HALL_STATUS_DIRECT1_STEP5:
      {
        pMc->step_pos_next = 4;
      }
      break;
      case VALIDATION_HALL_STATUS_DIRECT1_STEP6:
      {
        pMc->step_pos_next = 5;
      }
      break;
      default:
      {
        return MC_FUNC_FAIL;
      }
      break;
    }
  }
  return MC_FUNC_OK;