2020-08-04 11:07 PM
Hi there :)
I've recently got my hands on the IHM002 kit. I'm trying out MCSDK and the example project which comes with it, "P-NUCLEO-IHM001 kit, 3-Shunt, Sensorless". I can get MCSDK to generate the code successfully but after flashing, the motor refuses to run.
Using the MCSDK monitor, whenever I press the button to start the motor, I keep getting the errors, FOC Duration & Software Error.
I've configured the jumpers accordingly, as per the pamphlet & user manual instructions.
The initial firmware on the board and the binary from the X-CUBE-SPN7, which I believe is the 6-step algorithm implementation, works fine concluding that the board and motor are OK.
Please help in getting my IHM002 kit running using the MCSDK 5.4.4.
Solved! Go to Solution.
2020-08-06 08:09 AM
Hi @JJeth.1 ,
thank you for sharing your experience and how you solved the intermittent start-up issue you faced !
It is always helpful for other guys in the community: when you have something interesting to share fell free to share :D
About the debug build option: usually it does not use any optimization in the code.
In this way it is easy for the debugger to go through the code line by line, but the firmware of course has less performance.
This can lead to a timing error because the MCU cannot execute all the instructions of the not-optimized code.
As you already have done, use the release mode: it adds some optimization in the code building and fix timing issues.
Anyway, if you want to use the debug mode without optimization, there is something you can do on the FOC parameters.
The first suggestion is to reduce the PWM frequency of the power stage (look at the picture below).
The MCU has more time for the FOC calculations during each PWM cycle.
Try using 15kHz for example, but consider that reducing PWM frequency can lead to less performance at high motor speed.
The other thing you can try is not to change the PWM frequency but the execution rate.
Execution rate =1 means that the firmware does the calculations every PWM cycle.
Changing the execution rate = 2 will help: the calculation will be done once every 2 PWM cycles giving more time to the microcontroller.
Then, in my experience also reducing the baud rate of the UART interface (if used) can help.
Use 9600 as a baud rate, it is not so fast but in many applications is enough.
Then remember in the monitor to set the same baud rate when communicating with the board.
These are some suggestions you can try and see the results, but in any case consider to build the code in release mode, with optimizations.
The motor will run without any compromise on performance !
All the best :smiling_face_with_smiling_eyes:
2020-08-05 10:03 AM
Hi @JJeth.1 and welcome to the ST community !
sometimes FOC Duration & Software Error are related to some timing issues of the FOC algorithm.
As a first step, can you check which optimization is used in the compiler of your firmware development environment ?
It should be set on high optimization for speed.
By the way, which firmware development environment are you using ?
Have a good day =)
2020-08-05 07:20 PM
Hi Dario :) ,
Hope you are doing well.
I'm using STM32CubeIDE v1.4.1 by the way; MCSDK v5.4.4; STM32CubeMX v6.0.0.
The issues highlighted above only seem to happen when using the Debug build option.
The same code when built in Release mode is OK. It works as described in manuals, MOOC training and etc. No issues running it in conjunction with the MCSDK monitor.
I suppose from this, it can be concluded that you are correct to assume some sort of timing issue introduced by optimization or the lack of in the Debug build.
Can you propose a fix for the Debug build? Is it as simple as adding the speed optimization flag together with the debug flag?
Thank you so much for your kind support. Really appreciate it bro :D
Oh I did have intermittent start-up issues with the motor using the Release build. Meaning frequently when I pressed the start button the motor jerks( aligns I assume ) but then an over-current error is indicated in the monitor. At other times it starts spinning without any problems. After some trouble-wrangling, it was found out that one of the wires from the motor was loosely attached to the board connector.
Just including this for completeness i.e. for use by others in the future.
Regards.
2020-08-06 08:09 AM
Hi @JJeth.1 ,
thank you for sharing your experience and how you solved the intermittent start-up issue you faced !
It is always helpful for other guys in the community: when you have something interesting to share fell free to share :D
About the debug build option: usually it does not use any optimization in the code.
In this way it is easy for the debugger to go through the code line by line, but the firmware of course has less performance.
This can lead to a timing error because the MCU cannot execute all the instructions of the not-optimized code.
As you already have done, use the release mode: it adds some optimization in the code building and fix timing issues.
Anyway, if you want to use the debug mode without optimization, there is something you can do on the FOC parameters.
The first suggestion is to reduce the PWM frequency of the power stage (look at the picture below).
The MCU has more time for the FOC calculations during each PWM cycle.
Try using 15kHz for example, but consider that reducing PWM frequency can lead to less performance at high motor speed.
The other thing you can try is not to change the PWM frequency but the execution rate.
Execution rate =1 means that the firmware does the calculations every PWM cycle.
Changing the execution rate = 2 will help: the calculation will be done once every 2 PWM cycles giving more time to the microcontroller.
Then, in my experience also reducing the baud rate of the UART interface (if used) can help.
Use 9600 as a baud rate, it is not so fast but in many applications is enough.
Then remember in the monitor to set the same baud rate when communicating with the board.
These are some suggestions you can try and see the results, but in any case consider to build the code in release mode, with optimizations.
The motor will run without any compromise on performance !
All the best :smiling_face_with_smiling_eyes:
2020-08-06 07:24 PM
Hey Dario,
Firstly, thanks for your support. Awesome bro =)
Thanks for the suggestions I'll give them a try.
You've made it really clear, so thanks for the time and effort.
Appreciate it much.
Cheers,
Jugnu J.