Skip to main content
Randy1
Associate II
February 18, 2019
Solved

My Motor don't spin with MCSDK_v5.3.3-Full on my custom board

  • February 18, 2019
  • 9 replies
  • 2334 views

Hello I made a custom board with a stm32f446ze and L6398 driver. To make it work I generated the source code thanks to STMCWB and I built it with atollic TRUE Studio.

And I added this code in the while loop in the main.c file:

/* USER CODE BEGIN 2 */

 /* USER CODE END 2 */

 /* Infinite loop */

 /* USER CODE BEGIN WHILE */

 while (1)

 {

 HAL_Delay(2000);

 MC_ProgramSpeedRampMotor1(83,0);

 HAL_Delay(100);

 MC_StartMotor1();

 HAL_Delay(3000);

 MC_StopMotor1();

 /* USER CODE END WHILE */

 /* USER CODE BEGIN 3 */

 }

 /* USER CODE END 3 */

} // End of int main(void)

The PWM outputs of my microcontroler are still at 3.3V for high side and 0V for low side. I don't understand why but the pwm signals are not generated.

Is something missing in my code ? or the problem is somewhere else?

Regards

This topic has been closed for replies.
Best answer by CPrin

Hi Randy, at this point I cannot say whether your code is OK or not. But, have you tried to get the Motor Control Work Bench monitor to get connected to your custom hardware? It's very useful for me, so I expect that it can be useful for you too. the MCWB monitor only needs correct setting of the UART and is very helpful for me. Kind regards from the Netherlands, Cojan

9 replies

CPrin
CPrinBest answer
Associate II
February 26, 2019

Hi Randy, at this point I cannot say whether your code is OK or not. But, have you tried to get the Motor Control Work Bench monitor to get connected to your custom hardware? It's very useful for me, so I expect that it can be useful for you too. the MCWB monitor only needs correct setting of the UART and is very helpful for me. Kind regards from the Netherlands, Cojan

CPrin
Associate II
February 26, 2019

In mc_api.c I found following remarks:

 * One of the following commands must be executed before calling MC_StartMotor1():

 *

 * - MC_ProgramSpeedRampMotor1()

 * - MC_ProgramTorqueRampMotor1()

 * - MC_SetCurrentReferenceMotor1()

 *

So in my opinion your code looks good ... please inform if you have solved the problem.

Randy1
Randy1Author
Associate II
February 26, 2019

Ok thanks

I discovered my oscillator is not powerd by the stm32 and my pwm outputs for low side reach only 2.64V instead of Vdd = 3.3V and it's constant I don't know why. I'm trying to fix this first.

Regards

Randy1
Randy1Author
Associate II
February 26, 2019

I fixed my oscillator circuit. In the STMCWB I choose the ceramic resonator but in the CubeMX project generated by STMCWB it was "BYPASS clock source" which was selected. Now my oscillator is powered and I can see the 8 MHz signal. But my PWM outputs are still constant. I keep investigating

Randy1
Randy1Author
Associate II
March 1, 2019

Hi

Do I need a LSE clock source to make this work ?

Randy1
Randy1Author
Associate II
March 12, 2019

It seems my microcontroller is still in idle state. It will be difficult to reach UART port on my custom board but I will try it.

Randy1
Randy1Author
Associate II
March 23, 2019

I used the UART port with a UART-USB cable in the STMCWB and there was a Under Voltage fault I cleared it and the motor ran.

Thank You very much Cojan

CPrin
Associate II
March 26, 2019

You're welcome Randy, great that you have a running motor yet!

Randy1
Randy1Author
Associate II
March 23, 2019

But now the question is why I have an under voltage fault at the beginning? I mesured the voltage and it's 39.5V and my max is 42 and my min is 32 in settings

Saurabh SONA
Visitor II
October 21, 2019

It is possible that the sense voltage rise time is slow and the MCU power ON and init for MC library is complete before a stable voltage (greater than 32V) is available at the VBUS sensing ADC input (RC filter delay, etc).

To verify this, you can use any free GPIO configured as Output Push Pull and set it to high in the  /* USER CODE BEGIN 2 */ area above the while(1) loop.

Now connect this GPIO and VBUS ADC input to two channels of a CRO and check if ADC scaled voltage corresponds to more than 32V before the GPIO state goes to high. So if your voltage divider ratio is 16, VBUS ADC voltage should be greater than 2V before GPIO goes high.

After power ON, it is always a good idea to check that the STM state machine is in IDLE. If it is in FAULT NOW, wait for it to go to FAULT OVER and acknowledge fault so that state machine is in IDLE state before any other operation is performed. Some kind of visual feedback (say a single LED blinking at different rates for different faults) can be quite useful for debugging.

Hope it helps.

Laurent Ca...
Senior III
June 28, 2021

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