cancel
Showing results for 
Search instead for 
Did you mean: 

How to successfully debug a ST FOC motor control project ?

c1ron
Associate III

I'm working on a project where the STMC FOC v4.3 SDK has been used.

Developers of the project are not available for support, and I need to learn the details to implement new features as well as debugging/fixing existing code.

To facilitate my learning, I've bought a P-NUCLEO-IHM001 and generate code using the new version of the SDK. I'm using Keil and the onboard ST-Link to go into debugging, to look at how the code is being executed and trying to get access to some project variables. Of course, I cannot run the motor and simultaneously have breakpoints in the code. So I'm trying to look at some register values, i.e. the DAC and ADC1 registers. When doing this, the motor is spinning, and the Motor Workbench Monitor says that the UI has connection to the MCU, but pressing the "Stop Motor" or "Execute ramp" no longer works. Also, pressing the blue user button and turning the potmeter also has no impact on the motor.

I hope to come across some "How to debug STMC FOC projects", but cannot find any.

Any tips ?

4 REPLIES 4
Laurent Ca...
Lead II

Dear @Community member​ 

Sorry for the late answer.

Do you have still this problem to solve?

And just in case, if not, do not hesitate to share the final solution you found. Thanks by advance.

Best regards

c1ron
Associate III

Hi @Laurent Ca...​ . Well, my question was not very specific. I was aiming for someone to point me to a "hands-on tutorial" or "getting started" on debugging STMC projects. I've sadly found out that the project I'm working on uses the MC-SDK-4.3, and it seems like the latest version, e.g. SDK-5.4.7 - has changed a lot since then.

I'm struggling with finding essential program variables under debugging, such as measured current etc.

In the SDK-5.4.7 version, as I understand, structures (components) - e.g. of type MCI_Handle_t, contain all structures/variables for one motor and is central in execution.

You can add the handle to watch under debugging, (IAR) and see live how variables are updated.

However, in the SDK-4.3 version, I find the CMCI_t "class", but when adding it to watch (IAR) under debugging, I can't see any variables - i.e. FOC-variables, measured currents ect. How can I find the various FOC-related variables in the SDK-4.3 version ?

cedric H
ST Employee

Hello @Community member​ ,

The SDK 4.3 was indeed very tough to understand and debug. It is the main reason why we re-write it with a component architecture. Now, the heart of the algorithm did not change between 4.3 and 5.4.x series. the 5.Y series brings a new breakthrough feature with the help of the new communication protocol that we developed, allowing you to see with the motor Pilot a lot of live data without any loss. In few words, it allows you to do the same than with the DAC, but with around 10 signals (depending on you PWM frequency) and without the need of an oscilloscope.

So, I do not know what your mission is, but I would suggest you to start to learn the ST solution with a 5.Y version or a 5.4.8. the internal is the same than in the 4.3.

If you are force to stay with a 4.3 version (do not hesitate to explain why ), you can have a look at variable MCTpool, If I remember correctly, it contains MC tuning internal objects structure type.

Hope it helps

Regards

Cedric

c1ron
Associate III

Thanks Cedric.

We will probably upgrade our firmware to a newer SDK sometime in the future, but due to deadlines we need to focus on specific tasks for now.

I am not the one that wrote the original software, but It's probably me who will do the upgrading, which seems somewhat time consuming due to tinkering with the original 4.3 SDK workspace and inclusion of several user classes.