📢 SimpleFOClibrary v2.4.0 is out

Hi guys,

The v2.4 is out and it’s a big one!

NEW RELEASE :loudspeaker:: SimpleFOClibrary v2.4.0 see release

  • STM32

    • Added support for ADC reads in addition to Lowside current sense #506 - see in docs
    • Added support for multiple motors low-side CS (one per ADC) with ADC current sensing #503
    • BG341 low-side current sense sync was lost in v2.3.5 - fixed #482
  • ESP32

    • Many ESP32 safety optimisations by @uLipe: #490,#491,#492,#493,#495
    • Better ADC-Timer alignement for more stable current sensing See this commit
    • Now compiles for all v3.x arduino-esp32 versions (v2.3.5 was compatible with v3.2.x)
    • adcRead small refactor - no more magic numbers
  • Others

  • Major New features

    • Add current and voltage feed forward terms to motor classes by @Copper280z in #454
    • Velocity Calculation rework by @Copper280z in #45
    • Motion control - docs
      • Added custom motion control mode - see in docs and in examples
      • Added angle_nocascade control mode for position control without velocity cascade - see in docs - #384
      • Now all the closed and open loop modes can be used with any torque control modes (voltage and current)
        • Ex. velocity_openloop with foc_current torque control
    • Torque control - docs
      • Added estimated_current torque control mode for model-based current estimation without current sensing - see in docs
      • Now we can easily switch between voltage and estimated current control
  • Docs updates - see docs

    • Write the code page updated - see docs
    • Better step-by-step setup guides - see docs
    • New motion control documentation - see docs
    • New torque/FOC control documentation - see docs
    • Theory corner updated and extended - see docs
    • Library source updated and extended - see docs
    • Practical guides updated and extended - see docs
      • Motor parameter measurement guide - see docs
      • PID tuning guides - see docs
  • Examples

    • align_current_sense.ino example added to the examples/utils/current_sense_test allowing to verify the alignment between the driver and the current sense phases
  • Changelog

Thanks everyone for your contributions in code, discussions and issues!
Antun

Excellent! Is there a default implementation of _readRegularADCVoltage that calls analogRead on other CPUs? That would eliminate a lot of hassle using it in classes like LinearHall.

Hey!
No I did not implement it as a unified hardware specific abstraction for the moment.

Honestly, I also wanted to see how people will use it and if it’s gonna be good enough.
We do not even use it for inline sensing on stm32.

But we might do it for the next release!

I’ve encountered another minor issue with _readRegularADCVoltage, which is that it takes a pin name rather than ADC channel, so it can’t be used to read STM32G431’s internal temperature sensor on ADC1_IN16. Perhaps we could add a secret bitfield in the upper bits or a second argument specifying which ADC to read, in which case the first argument is interpreted as channel number?

Ah!
Because the corresponding pin name is not declared?
Not even with the alternatives?

Yeah, it makes perfect sense to make an alternative function definition that takes the ADC index and the channel.

It’s an internally connected channel, so there is no pin for it. It’s possible there could be a dummy pin in the library code that maps to ADC1_IN16, but I don’t see anything in PeripheralPins.c for it. I also tried searching how to get the temperature with analogRead since that also takes pin names, but all results are HAL code.

The opamps also have internal channels that allow reading their output without occupying a physical pin.