In the example model mcb_pmsm_foc_sim
, the current controller block
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 block. Follow this workflow to add
the ADC driver block.
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. Select ADC module C and channel 2 to obtain the phase-A current of the motor. Select ADC module B and channel 2 to obtain the phase-B current of the motor. For other target hardware, select the ADC module and channel where the motor phase currents are interfaced.
Select ePWM1_ADCSOCA
as the trigger source in the ADC block because
the PWM library block triggers the start-of-conversion event SOC0 when the PWM counter
equals the PWM period register.
Select ADCINT1
in the ADC B module. 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 Simulink® library browser, select and add the ADC block from the F2837xD library in Embedded Coder® Support Package for Texas Instruments C2000™ Processors. Configure the ADC block to read the phase-A and phase-B currents of the motor.
In the ADC block parameters dialog box, 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 ADC block parameters dialog box, configure the ADC B module and channel 2 (to read Motor Phase-B current) and the ADC interrupt (ADCINT1), 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 AOC 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.