6.6.8. Verification and board bring-up

6.6.8.1. Overview

This section provides guidance on bringing up a custom board for the first time with MCAF, after creating and importing a new board definition.

Warning

Use a current-limited power supply to power the custom board until you gain sufficient confidence in the board definition in motorBench and the board design/build.

Caution

Do not try to connect or start the motor after programming the code generated from MCC for the first time. Follow the procedure described below to reduce the risk of hardware damage.

6.6.8.1.2. General procedure

At a high level, we recommend the following steps when working with a new board:

  1. Firmware execution: is the board executing properly? (heartbeat LEDs, PWM channels, real-time diagnostic connection)

  2. Verify open-loop voltage operation

  1. Configure system for open-loop voltage operation

  2. Verify PWM operation: ensure PWM outputs are switching.

  3. Verify DC link voltage measurement within expected range.

  4. Test overcurrent fault functionality.

  5. Verify current measurement.

  1. Verify closed-loop current control.

6.6.8.2. General firmware execution

Look for signs of correct CPU execution and timing:

  • “Heartbeat LEDs” — if present on the board, these will either be flashing at a 1Hz rate under normal operation, or flashing an error code if there is a fault condition (see External Interface)

  • PWM Channels — if the board is not in a fault condition, the PWM low-side channels (PWMxL) will be switching in a “minimal impact” state at the specified PWM frequency.

  • Test point MCAF_TESTPOINT1, if available — should have a pulse at PWM switching frequency, representing the time interval when the MCAF ADC ISR is executing.

  • Real-time diagnostic connection (X2Cscope) — the board should be able to communicate with the real-time diagnostic software.

If these are not working properly, there may be an issue with the CPU running at the correct frequency.

6.6.8.3. Open-loop voltage operation

The test harness can be used to run the controller in an open-loop voltage mode where PWM outputs are driven at a forced commutation frequency and the outputs drive the PWM with a sinusoidally-varying line-to-line duty cycle. Each phase has an individual duty cycle that follows the characteristic double-humped waveforms of space-vector PWM / zero-sequence modulation.

  • Make sure that the motor terminals of the board are open-circuited (not connected to any motor or load)

  • Follow the steps in Table 6.2 to prepare the controller for verification using open-loop voltage control.

Table 6.2 Enabling open-loop voltage control

Step

Program variable

Value

Comments

1

Define the macro MCAF_TEST_HARNESS in options.h.

2

Build and program the project to the test hardware.

3

systemData.testing.guardKey

0xD1A6 (53670)

Needed to enable automatic shutdown of test modes — see Implementation of Test Guarding

4

motor.testing.operatingMode

0

Set the test harness mode to normal operation prior to configuring the desired test cases. — see Test harness modes

5

motor.vdqCmd.d

motor.vdqCmd.q

0

Set both d- and q-axis components of vdqCmd to 0.

6

motor.testing.overrides

2

Override commutation angle — see Commutation Override

7

motor.testing.overrideOmegaElectrical

as needed

Small values allow for slow changes in electrical angle; for example, overrideOmegaElectrical set to 1 count causes motor.thetaElectrical to completes a full electrical cycle in 65536 current loop updates, or 3.2768 seconds for a 20 kHz control ISR. Values from 0 to 50 counts (15.25 Hz electrical for a 20 kHz control ISR) are typical during these kinds of tests.

8

motor.testing.operatingMode

1

Set the test harness mode to force dq-axis voltage — see Test harness modes

6.6.8.3.1. Verify PWM operation

  • Look at PWM outputs to ensure they are all switching.

  • Verify dead time of the digital gate drive signals is occurring as expected.

  • Make sure transistor turn-on transients look ok.

  • Look at the output of each half-bridge to verify it is reaching proper voltage levels.

6.6.8.3.3. Verify hardware overcurrent fault

  1. Trigger the overcurrent input manually by connecting the overcurrent sense input to the appropriate power rail, depending on the value of peripherals.pwm.fault.polarity (see custom board schema):

    • to Vss (polarity = active-low)

    • to Vdd (polarity = active-high)

  2. Verify that the PWM outputs stop switching.

  3. Reset the overcurrent input (if using the Sample Application, press the primary pushbutton).

  4. Verify that the PWM outputs start switching again.

6.6.8.3.4. Verify scaling and polarity of current measurement

  1. Ensure the test harness is configured in open-loop voltage mode as described in Table 6.2

  2. Connect a three-phase inductive load (alternator stator or test motor).

    Note

    If using a motor, to prevent back-emf from affecting measurements, take either of the following approaches:

    • Lock the rotor so it does not move

    • Set the electrical frequency motor.testing.overrideOmegaElectrical to zero

  3. Increase d-axis voltage motor.vdqCmd.d in small steps until a modest amount of current (10-20% of maximum continuous current) flows through the motor phases. The required voltage should be approximately \(\delta_1V_{dc}+IR\) where \(\delta_1\) is the dead time, expressed as a duty cycle, and IR is the line-to-neutral voltage drop across the motor winding. Small increases of 5 – 20 counts at a time should be sufficient.

    Warning

    Depending on the electrical angle motor.thetaElectrical, the current in one motor phase may be near zero even though current flows in the other two phases. Make sure to measure current on at least two of the motor phases, to ensure that the motor phase current is not excessive. Alternatively, use a value of motor.testing.overrideOmegaElectrical that is large enough to ensure at least 5 Hz electrical, while adjusting d-axis voltage, so that the electrical angle is changing smoothly and current is visible on all phases.

  4. Set motor.testing.overrideOmegaElectrical to zero, so that the voltages and currents are at DC.

  5. Measure actual phase currents with a current probe, and compare with digitized current in firmware located in the motor.iabc structure; the measured and digitized currents should be within a reasonable range of each other.

  6. Verify that positive digitized current corresponds with the expected direction of current.

6.6.8.4. Closed-loop current control

In this step, the inductive load (motor or stator) will be used to operate MCAF in closed-loop current control, with commanded current set to a small desired value and a superimposed square wave perturbation.

As shown in the data flow diagram, there are three important sets of dq-axis currents:

Program variable

Description

motor.idqCmdRaw.d
motor.idqCmdRaw.q

Desired dq-axis currents, prior to perturbation

motor.idqCmd.d
motor.idqCmd.q

Desired dq-axis currents, including perturbation
(commanded input to current controller)

motor.idq.d
motor.idq.q

Measured dq-axis currents

The goal of this step is to ensure that the measured currents motor.idq follow the commanded currents motor.idqCmd; both d- and q-axis components of these currents should be examined using real-time diagnostics software.

Using the test harness:

  1. Make sure MCAF is initialized for forced commutation:

    1. Set systemData.testing.guardKey = 0xD1A6 (53670)

    2. Set motor.testing.operatingMode = 0
      (OM_DISABLED to keep output transistors in a minimal impact state)

    3. Set motor.testing.overrides = 2
      (Commutation Override to force commutation)

  2. Set motor.testing.overrideOmegaElectrical = 0 to force a fixed commutation angle

  3. Set motor.idqCmdRaw.d and motor.idqCmdRaw.q to zero

  4. Set motor.testing.operatingMode = 2
    (OM_FORCE_CURRENT to run the controller in closed-loop current control, but disable the outer loop)

  5. Set motor.idqCmdRaw.d to a modest value (for example 10-25% of rated continuous current; see CURRENT_MAXIMUM_COMMAND in sat_PI_params.h)

Verify that the measured currents motor.idq follow the commanded currents motor.idqCmd.

Add a perturbation square wave signal, as described in the test harness, to the d-axis current command:

  1. Set motor.testing.sqwave.idq.q to zero

  2. Set motor.testing.sqwave.idq.d to a small value (half of the value used in motor.idqCmdRaw.d is suggested)

  3. Set motor.testing.sqwave.halfPeriod to a mid-range frequency (10Hz – 100Hz suggested)

  4. Set motor.testing.sqwave.value to 1, to enable perturbation

Verify that the measured currents motor.idq follow the commanded currents motor.idqCmd.