cancel
Showing results for 
Search instead for 
Did you mean: 

Motor doesn't spin on a STM32F04ZE custom board passing from MC-MDK 4.0 to MC-MDK 5.4.0

Muscle Man
Associate III

Hi,

I'm working on a project trying to port an old FOC SDK 4.0 based application on

a new MC-SDK 5.4.0 one. The job is done on a STM32F407ZE board where previously

the use of FOC 4.0 allows to spin a brushless PMSM motor at various mechanical

speeds. At the moment the motor supplier is not able to tell us if the motor he

is selling us is a SM-PMSM or an I-PSMS motor...

From a MC SDK point of wiev, our motor application uses a 3-phase inverter based

on three STM L6395s (High voltage high and low-side drivers) and a 3-shunts current

sensing configuration.

No over current protection mechanism is at the moment employed and the current

sensing is based on external opamps whose configuration has been taken from

another HW application note (this was the job of an external HW engineer).

Speed and position feedback is obtained employing 3 120-degrees shifted phase 

Hall sensors; neither PFC or Brake components are used.

The motor voltage bus is 24 V, maximum speed is 40 Krpm, PWM frequency of the

3-phase inverter is 35000 Hz.

I opened the old FOC 4.0 motor configuration file with the new MC SDK 5.4.0;

it was able to convert with no problem the old settings and to produce a .ioc

file with which it generated a project based on IAR Workbench.

In main.c of the project I do the following things:

  uint16_t fault_occurred = MC_GetOccurredFaultsMotor1();
  uint16_t fault_current  = MC_GetCurrentFaultsMotor1();
  bool motor_rc = MC_AcknowledgeFaultMotor1();
  ASSERT(motor_rc == true);
  uint32_t motor_start = 1;
 
  /* Infinite loop */
  while (1)
  {
        switch (MC_GetSTMStateMotor1())
        {
            case IDLE:
                if (motor_start == 1)
                {
                    motor_start = 0;
                    MC_ProgramSpeedRampMotor1(1000, 500);
                    motor_rc = MC_StartMotor1();
                    ASSERT(motor_rc == true);
                }
            break;
 
            case RUN:
                motor_rc = false;
            break;
 
            case FAULT_NOW:
                fault_current = MC_GetCurrentFaultsMotor1();
                motor_rc      = MC_AcknowledgeFaultMotor1();
                MC_AcknowledgeFaultMotor1();
            break;
 
            case FAULT_OVER:
                fault_occurred = MC_GetOccurredFaultsMotor1();
                motor_rc       = MC_AcknowledgeFaultMotor1();
                MC_AcknowledgeFaultMotor1();
            break;
        }
  }

What I checked is that the motor state becomes IDLE and once triggered the

motor speed ramp and the motor start, the it never spins. I also checked that

no PWM signal are present on the input pins of the L6368 drivers..

Can someone address me where to find the possible cause(s) of this missing

motor spinning?

Thanks in advance to everyone that can help me.

1 ACCEPTED SOLUTION

Accepted Solutions
cedric H
ST Employee

Hello,

The conversion from a 4.0 project into a 5,4.0 project is something very hard to test, and indeed, it would be more secure to restart your project from scratch.

If you use a Hall sensor, you need - as you mentioned- to do the phase shift alignement. I would advise you to try your motor in sensorless mode first and check that the observer electrical angle and the Measured electrical angle are aligned (thanks to the DAC).

I confirm that For F4 series 3 shunts topology, we do NOT use the DMA.

Regards

Cedric

View solution in original post

4 REPLIES 4
Muscle Man
Associate III

Ok,

some news..

It seems that MC SDK 5.4.0 didn't correctly import/translate the old project based on the FOC 4.0 library.

Infact it seems that during that process, the tools missed:

  • to select the right ADC sampling time: I have to set it to the minimum value (3), otherwise the IRQ TIM 1 Handler remains stucked looping over a condition;
  • to generate the proper GPIO setting for the pin where TIM1 complementary channels are mapped (neither the code was generated, nor the proper GPIO defines);

Could be that the MC SDK works correctly and that the wrong/missing generated code was due to some errors made by myself..

By the way, to let the motor spins, I manually added the GPIO programming of those pins where the complememtary output channels are mapped.

With these fixs, the motor spins poorly, I think more adjustments must be made, first of all that one concerning the Hall phase shift.

Muscle Man
Associate III

Another little bit of investigation about the problem..

Now the motor spins, but often it starts to spin in a weird mode, jerky and at a speed that it's not that selected...

I'm reading the UM1292 - USer Manual of the STM32 motor control SDK.

At the page 19 there is the Table 4. "Three-shunt current reading, used resources (Dual drive, F103 HD, F2x, F4x)", where it is showed

the HW resources used in a 3-shunt current reading when using two motors or a F103 mcu or a F4 mcu (at least this is my interpretation).

In such table is shown that when the TIM1 is selected to generate the PWM signals, it also uses DMA1_CH1, TIM1 Update IRQ and ADC1

plus ADC2.

Of all these resources, the only one I cannot find evidence of in the code generated by MC SDK 5.4.0 is the DMA_CH1. There is only

one define, but no initialization code or the related DMA IRQ Handler...

Could be that the bad spinning is because of some missing initialization code not generated by MC SDK?

Or something else?

cedric H
ST Employee

Hello,

The conversion from a 4.0 project into a 5,4.0 project is something very hard to test, and indeed, it would be more secure to restart your project from scratch.

If you use a Hall sensor, you need - as you mentioned- to do the phase shift alignement. I would advise you to try your motor in sensorless mode first and check that the observer electrical angle and the Measured electrical angle are aligned (thanks to the DAC).

I confirm that For F4 series 3 shunts topology, we do NOT use the DMA.

Regards

Cedric

Laurent Ca...
Lead II

The question has been moved from the "Motor Control Hardware" section to the "STM32 Motor Control" section (the question is about the STM32 MC SDK). 

Best regards