First of all thank you to all the developers of SimpleFOC for their work.
I’ve been working on a project with the STSPIN32G4, and custom PCB, based off the EVSPIN32G4. The EV board has a lot of potential, high amperage, wide voltage range and hall sensor input.
Also looked through the simplefoc_funqi_example on github (GitHub - runger1101001/simplefoc_funqi_example: Sample firmware for STSPIN32G4 based BLDC driver), nice to see that CORDIC is implemented. Is there a way to enable build flags with the Arduino IDE to use the library?
Tried compiling and got ‘SimpleFOC_CORDIC_Config’ was not declared in this scope. Looked into the lib and there was: To use it, set the build-flag -DHAL_CORDIC_MODULE_ENABLED for the CORDIC to be enabled in the framework.
What else would I have to do to configure SimpleFOC to work with the board?
Firstly, I would strongly recommend using platformio over ArduinoIDE for working with new boards. It will be much easier to configure and change things on the fly than with ArduinoIDE’s system of board files.
You could then use the funqi example as a direct starting point.
Things you’ll have to change:
USB setup and serial setup - may be different on your board
clock - although it looks like you’re both using 24MHz external clocks, so the funqi clock config may work for you
other functions, LEDs, inputs/outputs which will obviously be different on these two boards.
That should get you up and running for open loop and closed loop voltage modes (if you add a sensor).
For the current sensing, this will be more complicated:
current sensing - the EV module has a totally different setup, using the op-amps. This will need custom code specific to the STM32G4 and the op-amp configuration used, you won’t be able to use the default SimpleFOC current sensing
the board has voltage sensing, which we currently don’t support but you may want to add since you’re writing custom ADC code anyways
Let us know how it goes! If you feel like sharing code it might help others trying to use this board…
Thank you for your guidance. I’ll switch to platformIO and begin with the funqi example. @VIPQualityPost - I havent got anything to present myself. I’ve only experimented with the example code in the FOC drivers rep: