Hoverboard main board with simpleFOC

Select those option bytes maybe

The option bytes were OK.
I found a workaround for those stubborn MCUs:

  • let ArduinoIDE export the .bin file <sketch/export compiled binary>
  • use ST-Link utility to flash the file

…coincidently there was an simpleFOC update yesterday and I happily installed it without thinking of the consequences it has on my code.
I forgot to change “PWM_LOWSIDE_ACTIVE_HIGH” to false
and when I switched on the PSU after I was finally able to flash it, the left motor made some squeeky noises and then the overcurrent protection of my PSU tripped.
I couln’t start the controller anymore, but the ST-Link was still able to erase the chip.
I guess there is a short in the FETs from the shoot-through…

That’s why I hated auto-update ever since… :rage:

Where do you change PWM_LOWSIDE_ACTIVE_HIGH?

If you change it directly in simplefoc code, for sure you will be impacted by an update.

I changed it directly in drivers/hardware-api.h, since that was the only option I had, without learning Platformio…

We learn more from our mistakes than from success

…just a sidenote:
Although I duplicated the whole code I had on the splitboard controller for two motors,
the code for the F103 was ~10k smaller than the F030 code.
Because it has an FPU?

No F1 has no FPU neither.
Maybe differences between cortex M0 and M3.

I could rescue the dualboard controller by removing two dead FETs.
Now it runs on one leg only, but I could compare both controllers (splitboard and dual)
The dual has a loop time of around 5.2kHz, the splitboard 1.7kHz ( both with smoothingSensor)

Furthermore I tested both values for hubmotor inductivity.
With H= 0.00119 (@OiD-W value) the noLoad current at full throttle was ~1A
With H= 0.00036858 ( @Candas1 value) it dropped to 0.45A
I couldn’t compare shaft_velocity, because I don’t have a serial-port configured.

You really have some great progress going :smiley:
I think for how far in you are it would be worthwhile to try PIO, it can make experimenting with things on the build side considerably easier!

I was just lucky that both my MCUs are supported in arduino IDE. And I took some pragmatic shortcuts to get there.
What does PIO mean?

PIO is the short name for Platformio

1 Like

@o_lampe I’m really sorry to hear the recent library update has given you problems!

Directly modifying the downloaded library files is really problematic for this reason, but I’m sorry you discovered this the hard way!! :frowning:

I also recommend platformio as a way to “graduate” from ArduinoIDE to a more capable development environment, but of course it is not without its own problems and pitfalls :slight_smile: every system requires some learning curve.

Anyway, if you are happy with Arduino IDE, there is a better way to use and modify the library:

  • download your own copy of the library from the github repository. The best way really is to use a git client and git-clone the repository, Then you can track the changes, and also commit back your improvements. But it’s also ok to just download and extract the ZIP file.

  • put the library in some safe location in your home folder or on your drive

  • navigate to your Arduino15 folder, and delete the Simple FOC library from inside the libraries folder

  • then, using the shell (or CMD in Windows) create a symlink (or “Directory Junction”, mklink /J in Windows) from the Arduino libraries folder to your copy of the library

  • from now on, your modifications won’t be overwritten, but you also can’t change the version using the library manager. The library is present, but externally installed, so to speak.

A 5 minutes video where I:

  • open in github the dev branch of my SimpleFOC sketch for hoverboard in a code space
  • install platformio on the code space
  • choose the STM32F103RC variant (it installs stm32duino and the right toolchain)
  • change the SimpleFOC library in platformio.ini to my f1_no_adc_interrupt branch
  • change a parameter in a .h file in SimpleFOC
  • compile (it’s using my filtersrc.py script by the way)

I am not saying you should work like that but you see the potential.

1 Like

This looks like spam ?

At least it sounds like bull$hit.
You can’t have better dynamic response, because the control loop is much slower with FOC than it would be with a classic 6-step loop.
With FOC data aquisition always lags behind. Angle, speed and currents never seem to match the real deal. That’s why we have to add extra safety margins, which slows down dynamics.

But sFOC offers new use cases, so I like it!

1 Like