4.2. ADC Calibration and Compensation¶
Gain and offset errors in analog measurements (such as phase current) can cause several undesirable effects, notably torque ripple, increase in quiescent power, and derating of power semiconductor capability. As a result, MCAF includes support for ADC calibration and compensation of the following values.
Compensation target |
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. |
ADC gain error (dsPIC33AK only) |
Runtime, in RESET state while PWMs are disabled |
MCAF measures the resistor divider voltage on each ADC core and computes a gain correction factor. |
4.2.1. Phase Current Offset Compensation¶
The currentCalibration field of MCAF_MOTOR_DATA contains six gain terms:
KaaKabKbaKbbKccKidc
The Kaa, Kab, Kba, and Kbb terms represent a 2x2 gain matrix:
or (more concisely)
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
or (more concisely)
If single-channel current measurement is used, the following equation is used for DC link current measurement compensation:
4.2.2. ADC Gain Error Compensation¶
The high-speed ADC on dsPIC33A devices requires manual gain calibration for best performance. (For more information, see AN5971: Enhancing ADC Performance on dsPIC33AK Devices) For ADC gain error calibration with dsPIC33AK devices, \(V_{\text{nominal}}\), defined below, is the internal \(\frac{15}{16}V_\text{dd}\) voltage reference. This is a resistor divider for measuring ratiometric voltages that are close to the supply rails but within the ADC input range.
ADC gain error, which is applied to each ADC core used by MCAF, is assumed to be a linear error that can be corrected by applying a gain \(G\) to the raw ADC voltage reading, \(V_{\text{adc}}\), to obtain the true, corrected value, \(V_{\text{true}}\), resulting in the equation
where \(G\) is determined by evaluating a known voltage, \(V_{\text{nominal}}\), and taking the corresponding ADC reading of this known value, \(V_{\text{adc}}\), such that
Each ADC core used in an MCAF configuration is independently measured during the RESTART motor state, which happens during the RESTART state as described in the state machine. These ADC core gain factors, \(G_{\text{channel,core}}\), are then assigned to gain factors, which are used to scale the gain terms used in current compensation — \(K_{\text{aa}}\), \(K_{\text{bb}}\), \(K_{\text{cc}}\), \(K_{\text{idc}}\) — dependent on which channels are configured for current measurement in MCAF, and which ADC core is used for each
These \(K'_{\text{aa}}\), \(K'_{\text{bb}}\), \(K'_{\text{cc}}\), and \(K'_{\text{idc}}\) terms are used in place of the existing phase current compensation terms — \(K_{\text{aa}}\), \(K_{\text{bb}}\), \(K_{\text{cc}}\), and \(K_{\text{idc}}\), respectively.
4.2.3. Implementation Notes¶
4.2.3.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.3.2. MCAF R7¶
As of MCAF R7, calibration and compensation functionality is located in the adc_compensation and current_measure
modules.
4.2.3.3. MCAF R9¶
In MCAF R9, the ADC gain error compensation functionality was added to the adc_compensation and
current_measure modules.
4.2.3.4. Modules¶
Module |
Files |
Description |
Comments |
|---|---|---|---|
adc_compensation |
adc_compensation.cadc_compensation.hadc_compensation_types.hparameters/adc_params.h |
ADC compensation |
Prior to R7, included current offset calibration,
which has been moved to the |
current_measure |
current_measure.ccurrent_measure.hcurrent_measure_types.hparameters/current_measure_params.h |
Introduced in R7. Includes logic to handle single-channel (single-shunt), dual-channel, and triple-channel current measurement, as appropriate. |
