simplefoc / Arduino-FOC

Arduino FOC for BLDC and Stepper motors - Arduino Based Field Oriented Control Algorithm Library
https://docs.simplefoc.com
MIT License
1.95k stars 511 forks source link

Unified init() method #335

Closed runger1101001 closed 6 months ago

runger1101001 commented 8 months ago

Unify the init method. Create a clear paradigm:

  1. user declares objects for use by the code, with their static initialisation data, like the BLDCDriver with its pins
  2. user initialises parameters in the setup method. Parameters can be initialised in any order. Note: part of the parameters that get set are the sensor, current-sense, driver and other objects "linked" to the motor. Why treat them differently?
  3. user calls motor.init(). The motor init method also initialises any uninitialised linked objects like driver, sensor, etc.
  4. the motor init method checks parametrisation and inits the system accordingly.
  5. the motor init method performs calibration if needed (e.g. if closed loop mode is selected and electric zero is not set)

This will simply the API for users, who can currently do a lot of things wrong.