Code adaptation for storm32 BGC v1.31 - 3 x BLDC motors with SimpleFOClibrary

Hi Richard :slight_smile:

So first a few general points:

  1. it is possible to get this board working with SPI, I’ve done it myself
  2. However, its MCU is not really powerful enough to run 3 motors with SimpleFOC, and so the performance you will get won’t be great.

Regarding the SPI soldering:

  • I think I even left the LED and resistor on there. As long as you solder to the side of the resistor that is connected to the MCU it should work ok.
  • check for connectivity using your multimeter - the end of the SPI SCLK cable and the MCU pin PB13 should be nicely connected, with almost no resistance.
  • once you are happy the connection is good, secure it. I used “Sugru” which is like a non-conductive mouldable glue compound. A dab of this dries in a few hours, but can still be removed without too much hassle. It will prevent you damaging the solder connection by accidentally pulling on the wire.
  • after securing, recheck the connection with the multimeter

Testing the sensor:

  • run our sensor test program, or write a small one yourself to test the SPI sensor. Leave out all the motor code and other stuff.

  • you can use the dedicated AS5048A driver from our drivers library. It will allow you to read/write the other sensor registers, in particular you can use it to check the magnitude of the magnetic field and read the sensor status for errors.

  • you can adjust the SPI clock speed to find a speed that gives reliable readings.

  • if you can’t get the sensor to work like this, then there are issues - either with the connection, the sensor or the power supply to the sensor (3.3V and 5V require different configurations of the sensor power circuit - is your sensor suitable for the voltage you’re using?)

  • the nCS line normally needs a pull-up, so you could re-initialize it with internal pull-up:
    sensor.init(); pinMode(PA15, INPUT_PULLUP); or modify the library code to do so. At the moment the library code (both MagneticSensorSPI and the MagneticSensorAS5048A) initialize this pin in OUTPUT mode (no pull-up). Or you can add an external pull-up resistor. Not sure this will solve your problem though

  • you can use a logic analyser to look at the SPI signals between sensor and MCU to see the problems.

In parallel to this you can also test the motors in open-loop mode. Be careful to set appropriate voltage limits, and if possible use a power supply with current limiting for first tests.
Testing this will ensure the drivers and PWM generation is working as expected, and the motors can work in principle.

Then, when both motors and sensor are working independently, put them together to get closed loop control :slight_smile:

Regards,
Richard