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

4.2.1.1. MCAF R1 – R6

In MCAF R1 and R2, some portions of calibration and compensation functionality were located in the meas_curr module and others in the foc module. In MCAF R3 – R6, all ADC calibration and compensation functionality was located in the adc_compensation module.

4.2.1.2. MCAF R7

In MCAF R7, calibration and compensation functionality is located in the adc_compensation and current_measure modules.

The currentCalibration field of MCAF_MOTOR_DATA contains six gain terms:

  • Kaa

  • Kab

  • Kba

  • Kbb

  • Kcc

  • Kidc

The Kaa, Kab, Kba, and Kbb terms represent a 2x2 gain matrix:

(4.1)\[\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)

(4.2)\[\mathbf{I}_{ab} \,=\, \mathbf{K}_\text{comp}(\mathbf{I}_{ab0} \,-\, \mathbf{I}_{ab,\text{ofs}})\]

These gains and offset are used to compensate for part-to-part variation and to correct for any board layout issues, such as those described in MCLV-2 Sense Resistors.

If triple-channel current measurement is used, the 2x2 gain matrix is augmented with the Kcc term to become a 3x3 gain matrix. The 3x3 equations become

(4.3)\[\begin{bmatrix} I_a \cr I_b \cr I_c \end{bmatrix} = \begin{bmatrix} K_{aa} & K_{ab} & 0 \cr K_{ba} & K_{bb} & 0 \cr 0 & 0 & K_{cc} \end{bmatrix} \begin{bmatrix} I_{a0} - I_{a,\text{ofs}} \cr I_{b0} - I_{b,\text{ofs}} \cr I_{c0} - I_{c,\text{ofs}} \end{bmatrix}\]

or (more concisely)

(4.4)\[\mathbf{I}_{abc} \,=\, \mathbf{K}_\text{comp}(\mathbf{I}_{abc0} \,-\, \mathbf{I}_{abc,\text{ofs}})\]

If single-channel current measurement is used, the following equation is used for DC link current measurement compensation:

(4.5)\[I_{\text{dc}} = K_{\text{idc}}(I_{\text{dc}0} - I_{\text{dc,ofs}})\]

4.2.1.3. Modules

Module

Files

Description

Comments

adc_compensation
adc_compensation.c
adc_compensation.h
adc_compensation_types.h
parameters/adc_params.h

ADC compensation

Prior to R7, included current offset calibration, which has been moved to the current_measure module.

current_measure
current_measure.c
current_measure.h
current_measure_types.h
parameters/current_measure_params.h

Current measurement

Introduced in R7. Includes logic to handle single-channel (single-shunt), dual-channel, and triple-channel current measurement, as appropriate.