5.4.3.3.1. Implementation issues common to all methods¶
5.4.3.3.1.1. API of qei_sync¶
Each of the back-emf synchronization methods has been designed to meet the following API for all methods:
The generated code is located in the
qei_syncmoduleDependencies of the
qei_syncmoduleIt may depend on the
startupandqeimodulesThere are no dependencies on the
system_stateorcommutationmodulesIt does not access any HAL functions directly
State data of the
qei_syncmoduleis located in
motor.estimator.qei.synchas type
MCAF_QEI_SYNC_Tmotor.estimator.qei.sync.completeis a flag that denotes whether back-emf synchronization is complete. To re-run the synchronization, set this flag tofalseusing the real-time diagnostic software.
Methods
MCAF_EstimatorQeiSyncInit()— initialization function, runs onceMCAF_EstimatorQeiSyncStep()— update function, runs in control ISR, returns action flags to influence startup behavior in certain states. These action flags are only valid in startup states with a status code ofMSST_ALIGNorMSST_SPIN. The return value can contain any of the following bit flags:MESACT_DELAY— startup state machine will be delayed, and remain in its current stateMESACT_SET_CURRENT `` --- ``MCAF_EstimatorQeiSyncOverrideCurrent()will be calledMESACT_SET_ANGLE—MCAF_EstimatorQeiSyncOverrideAngle()will be calledMESACT_SET_FREQUENCY—MCAF_EstimatorQeiSyncOverrideFrequency()will be called
MCAF_EstimatorQeiSyncIsComplete()— returns whether synchronization is completeMCAF_EstimatorQeiSyncGetCommutationOffset()— returns commutation offset computed by theqei_syncmodule. This result is only required to be valid if synchronization is complete (otherwise this function’s return value should be considered invalid)
Override handlers
The handler functions listed below are special methods that get called during appropriate stages of the startup sequence. A pointer to specific data is provided by the caller. This facilitates modularity by eliminating coupling between the
startupandqei_syncmodules; intercommunication is performed in thecommutationmodule.Each handler has the option to change data or not, and is generally declared
inline staticso that an empty handler function would be optimized out.Method
Applicable state
Behavior
MCAF_EstimatorQeiSyncOverrideCurrent()MSST_SPINCan set current
MCAF_EstimatorQeiSyncOverrideAngle()MSST_ALIGNCan set the applied electrical angle
MCAF_EstimatorQeiSyncOverrideFrequency()MSST_ALIGNCan set the applied electrical frequency
5.4.3.3.1.2. Important data elements¶
The following data members are available, regardless of which qei_sync method is used:
motor.estimator.qei.position.commutationOffset— controls commutation offset, which is the angle added to the raw electrical angle from the encoder before it is used for commutation. This can be modified using a real-time diagnostic tool to adjust the commutation offset while the motor is running. Any such changes should be slow: maximum recommended step size is 11 electrical degrees (2000 counts). Step changes larger than this may cause the control loops in FOC to lose synchronism.motor.estimator.qei.position.commutationOffsetFromIndex— this is a convenience calculation provided at the end of back-emf synchronization, and it measures the commutation offset relative to the index position within one electrical cycle. When using a motor with an encoder that has an index pulse, the values ofcommutationOffsetFromIndexwill be fairly consistent, independent of the starting position of the motor when the QEI peripheral is enabled.
