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:
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
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.
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.
I have been using STMViewer for some time now, I must say I like it.
You can add a variable, type the name of any global variable like motor.LPF_current_q.Tf, update the variable address, and it just works.
You can download STMViewer from here. Here are the installation instruction.
I believe it needs at least version 13.2 of GDB (issue).
I am compiling with platformio using -g -ggdb build flags, this ensures proper information are available in the .elf file.
I made a short video showing basic usage of the tool.
If you change your program, the memory addresses might change, so you need use the Update variable addresses button.
This should support different model of stlinks and should work on STM32 only.
But it works for me with a Chinese STlink V2.1 clone and GD32F103/GD32F130 chips also.
Yeah but after downloading it, like what’s the process? You compile with arduino, how does it know the memory address? Doesn’t it need to have info from the compiler somehow to know the address of a variable and it’s name? I don’t see how it can get that info.
Oh ok a video is awesome, sorry. Will check it out thanks! Looking in there and seeing the system working is extremely important but in arduino it’s quite hard.
Edit:hm, how do you get this mysterious .elf file? It’s the binary I take it?
Anton wrote how to trigger the platformio debug toolchain from Arduino-code
first add a build_opt.h file in your arduino sketch and add inside the line -g -ggdb
Just to clarify: this “build_opt.h” file doesn’t already exist somewhere in my arduinoIDE libraries?
I don’t have to edit it and add the -g -ggdb line, but have to create a new file? Is that correct?
I never figured out build options with arduino very well, but there was a file specific to each family of boards that contained a section where the build options were located. There are some instructions I think I left on the forum for modifying some of them in some ways, the build options were needed to get current sensing working with the b-g431b-esc1 board.
Why would you use platformio’s debugger from inside ArduinoIDE? That doesn’t make that much sense for most people, I think.
At that point it would be easier to just use PlatformIO, for code and debugging, and not have to deal with the idiosyncrasies of both IDEs at the same time?