Main Content

Adding ADC Driver Library Block

In the example modelmcb_pmsm_foc_sim, the subsystem for current controller receives the motor phase current in ADC counts from the plant model that converts the motor phase current from Amperes to ADC counts. In the target hardware, the current controller reads the motor phase current from the ADC driver block. Follow this workflow to add and configure the ADC driver block.

These steps explain addition and configuration of the ADC driver blocks in detail. In the Simulink®library browser, select and add the ADC block from the F2837xD library inEmbedded Coder®Support Package for Texas Instruments®C2000™ Processors. Use the following steps to configure the ADC blocks to read the phase-A and phase-B currents of the motor.

In the Texas Instruments BOOSTXL-DRV8305 inverter hardware, the phase-A current of the motor is read from ADC C2 channel and phase-B current is read from ADC B2 channel. In the ADC driver block for phase-A current (see the following figure), selectADC moduleC and conversion channel 2 to obtain the phase-A current of the motor. In the ADC driver block for phase-B current, selectADC moduleB and conversion channel 2 to obtain the phase-B current of the motor. For other target hardware, select theADC moduleand channel where the motor phase currents are interfaced.

SelectePWM1_ADCSOCAas the SOC trigger source in the ADC driver blocks for phase-A and phase-B currents because the PWM library block triggers the start-of-conversion event SOC0 when the PWM counter equals the PWM period register.

In the ADC driver block for phase-B current (that usesADC moduleB), selectADCINT1. This triggers an ADC interrupt at the end-of-conversion (EOC) event. When the ADC interrupt occurs, the FOC current control algorithm executes.

In the block parameters dialog box of ADC driver block for phase-A current, configure the ADC C module and channel 2 to read the phase-A current of the motor, as shown in this table.

Tab and Parameter in ADC Block Settings

SOC Trigger>ADC Module

C

SOC Trigger>SOC trigger number

SOC0

SOC Trigger>SOC trigger source

ePWM1_ADCSOCA

Input Channels>Conversion channel

ADCIN2

Rename the block as ADC_C_IN2.

In the block parameters dialog box of ADC driver block for phase-B current, configure the ADC B module and channel 2 to read phase-B current of the motor. In addition, configure ADC interrupt asADCINT1, as shown in this table.

Tab and Parameter in ADC Block Settings

SOC Trigger>ADC Module

B

SOC Trigger>SOC trigger number

SOC0

SOC Trigger>SOC trigger source

ePWM1_ADCSOCA

SOC Trigger>Post interrupt at EOC trigger

on

SOC Trigger>Interrupt selection

ADCINT1

SOC Trigger>ADCINT1 continuous mode

on

Input Channels>Conversion channel

ADCIN2

Rename the block as ADC_B_IN2.