Using stm studio for variable monitoring

We discussed about Deadtime compensation in the other thread.
I received the boards and tried running in openloop with a hoverboard motor but I wasn’t successful yet, bear with me it’s the first time I use simplefoc.

As I wasn’t sure the serial monitoring is fast enough to visualize the phase current, I used another approach that worked well for me in the past with STM chips.
In platformio.ini, I added -g -ggdb in the build flags.

I declared a variable outside the loop

PhaseCurrent_s current;

I populated this variable in the loop

current = currentSense.getPhaseCurrents();

I am then able to visualize the phase current in STM STUDIO:

(You will have to click OK many times because of some address errors when opening the elf file)
And I used those settings for faster acquisitions:

I am just sharing this method because I haven’t seen any mention about this in the forum


I had no idea that we can use stm studio with arduino ide. This is very cool!

What it does is parsing the elf file to find where the variables are stored in memory.
Then it reads or writes the memory with SWIM protocol (STLINK protocol) I think.

I was even thinking about rebuilding this tool in web in a more user friendly way after seing this

But sorry that’s off topic

That uses webUSB as should the web_SimpleFOC_Studio. Maybe a chance to see that happening.

I also tried the STM32CubeMonitor in the past, I think it’s the replacement for STM Studio, it has more features but I couldn’t get it to acquire data as fast as STM Studio.

1 Like

Hey Candas1, I want to try this, but I don’t know how to set up current sense, not quite. I have some idea but am painfully aware of how things can get complicated.

Can you post the exact code you used? I can extract the critical elements and make some elemental code to monitor current with this board.

I want to monitor current to do stall detection. The best thing for me is to watch the combined current of all three phases. That way I can take a single measurement and see what the current draw is, no need to average out a bunch of measurements on a single phase.

Unfortunately I am away from home.
But I picked code from this example

1 Like

Here is how I was able to reproduce it.

first add a build_opt.h file in your arduino sketch and add inside the line -g -ggdb

Then add a variable in your Arduino loop that you wanna log.

For example the current measurements as suggested by @Candas1

PhaseCurrent_s current;
void loop(){
    current = current_sense.getPhaseCurrents();

And then compile the code.
Onece when your code is uploaded and complied it will output:

Open your stmstudio and import the variables form the elf file indicated by the arudino ide compilation

And then add the variables to the viewer

For more precision of the visualization you might need to adjust the acquisition settings. In y case I’ve used these settings: