I am in the middle of implementing the SimpleFOClibrary for Stm32 boards. Even before I am finished with it I wanted to release you give you some updates about what can you expect form it and it would be very cool to have some feedback from you guys!
I am primarily testing the code on Bluepill board and Nucleo64 stm32f401re, but most of the nucleo and bluepill boards are the same and you should have no problems running the library with them.
You will be able to use the the same Arduino IDE to upload the code. The sketch code and all the library features will stay the same, basically you will be able to upload your Arduino UNO, change the board type in the Arudino IDE, change the serial port and upload your Nucleo board directly.
The benefits of using stm32 boards are numerous, for example:
- The PWM frequency is much higher - less noise
- The clock is much higher - much faster execution (Arduino UNO 1ms/loop - Nucleo 100us/loop)
- No performance problems reading encoders
- You can attach encoder to any pin
- Much more internal memory
To enable using the Arudino IDE I am using stm32duino project. I found it very very simple and with almost no changes I was able to run SimpleFOClibrary on Nucleo64 and Bluepill.
Here are some photos of my setups:
Arduino IDE configuration
And the difference in configuration:
To run the same motor with Arduino SimpleFOCShiled using an Arduino UNO or Nucleo board you will run exactly the same sketch. You will initialize the
Ecnoder class using the hardware pins and configure them exactly the same in
setup() and run the exaclty the same
// BLDCMotor( int phA, int phB, int phC, int pp, int en) BLDCMotor motor = BLDCMotor(5, 6, 9, 11, 7); //Encoder(int encA, int encB , int cpr, int index) Encoder encoder = Encoder(2, 3, 8192);
The only difference in comparison to a Bluepill board is the pinout. Since it ddoesnt have arduino headers you will need to specify the pins you wish to use with the
BLDCMotor class and
Encoder class. For example:
// BLDCMotor( int phA, int phB, int phC, int pp, int en) BLDCMotor motor = BLDCMotor(PB7, PB8, PB9, 11, PB6); //Encoder(int encA, int encB , int cpr, int index) Encoder encoder = Encoder(PB3, PB4, 8192);
As simple as that
I am still in a process of implementing properly the magnetic sensors as504x and as soon as I have stable behavior the new library version will be released. I hope it will be in this week .
I am very excited to be enable using the stm32 chips so elegantly using the stm32duino.
Let me know what you think!