4.2. ADC Calibration and Compensation¶
Certain aspects of the MCAF are sensitive to gain and offset variation. At this time of writing, only the motor phase current readings are compensated:
| Compensation topic | Calibration type | Comments |
|---|---|---|
| Phase current offset | Runtime, at startup | Phase currents are measured and filtered at startup, when PWM outputs are in a safe state, and currents are known to be zero. |
| Phase current gain | Not calibrated at present, reserved for future use by Self-Commissioning in motorBench™ Development Suite, or other runtime methods | Includes compensation for cross-phase coupling. |
4.2.1. Implementation Notes¶
MCAF v1.0 includes some ADC calibration and compensation functionality that is located in the foc module
(specifically portions of initStateParameters(), MCAF_FocCalibrateCurrentOffsets(), and MCAF_FocReadADC())
which more properly belongs in a separate module.
The currentCalibration field of MCAF_MOTOR_DATA contains four gain terms:
KaaKabKbaKbb
These represent a 2x2 gain matrix:
\[\begin{bmatrix}
I_a \cr
I_b
\end{bmatrix}
=
\begin{bmatrix}
K_{aa} & K_{ab} \cr
K_{ba} & K_{bb}
\end{bmatrix}
\begin{bmatrix}
I_{a0} - I_{a,\text{ofs}} \cr
I_{b0} - I_{b,\text{ofs}}
\end{bmatrix}\]
or (more concisely)
\[\mathbf{I}_{ab} \,=\, \mathbf{K}_\text{comp}(\mathbf{I}_{ab0} \,-\, \mathbf{I}_{ab,\text{ofs}})\]
This gain matrix is used to compensate for part-to-part variation and to correct for a board layout issue in the MCLV2 board, described in MCLV2 Sense Resistors.
4.2.1.1. Modules¶
| Module | Files | Description | Comments |
|---|---|---|---|
parameters/adc_params |
parameters/adc_params.h |
ADC compensation parameters | |
meas_curr |
meas_curr.hmeas_curr.incmeas_curr.s |
Gain/offset compensation for phase current measurements | Likely removal and conversion to C in a future MCAF version |