In the example model mcb_pmsm_foc_sim
, the Current controller block
receives motor phase current in ADC counts. Plant modelling converts the motor phase
current in Ampere to ADC counts. In the target hardware, current controller reads the
motor phase current from ADC block.
For BOOSTXL-DRV8305, the motor's Phase-A current is read from ADC C2 and Phase-B current is read from ADC B2. Select ADC module C, channel 2, for Motor Phase-A current; and ADC module B, channel 2, for Motor Phase-B Current. For other target hardware, select the ADC module and channel where motor phase currents are interfaced.
Select ePWM1_ADCSOCA
as trigger source in ADC block as PWM library
block triggers SOC0 (start-of-conversion) event when PWM counter equals PWM period
register.
Select ADCINT1
in ADC B module and this triggers ADC interrupt at
EOC (end-of-conversion). In ADC interrupt, FOC Current control algorithm is scheduled to
execute.
In the Simulink library browser, select the ADC library block from Embedded Coder Support Package for Texas Instruments C2000 Processor > F2837xD. Configure the ADC block to read the motor's Phase-A and Phase-B current.
In ADC block mask dialog box, configure the ADC C module, Channel 2, to read Motor Phase-A current, as shown in the below 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 mask dialog box, configure the ADC B module, channel 2 to read Motor Phase-B current and trigger ADC interrupt (ADCINT1), as shown in the below 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 check box | on |
SOC Trigger > Interrupt selection | ADCINT1 |
SOC Trigger > ADCINT1 continuous mode check box | on |
Input Channels > Conversion channel | ADCIN2 |
Rename the block as ADC_B_IN2.