SPRUJ26A September 2021 – April 2024
The PWMDAC module converts the software variables into PWM signals using ePWM 6A, 6B, 7A, and 7B as shown in Figure 3-25. The PWMDAC module is only supported on the high voltage kit (TMDSHVMTRINSPIN) since it has extra PWM outputs with RC filters available on the board. If the PWMDAC module is used with a motor driver board that does not support the PWMDAC module, then the PWM signals will be routed to spare PWMs on the C2000 LaunchPad and the user would need to add RC filters to those pins in order to utilize the PWMDAC solution.
The PWMDAC module can be used to view the signal, represented by the variable, at the outputs of the related pins through the external low-pass filters. Therefore, the external low-pass filters are necessary to view the actual signal waveforms as seen in Figure 3-26. The (1st-order) RC low-pass filter is used to filter out the high frequency component embedded in the actual low frequency signals. To select R and C values, the time constant can be expressed in terms of the cut-off frequency (fc) as shown in the following equations Equation 49 and Equation 50.
In order to enable the ePWM DAC functionality, the predefined symbol EPWMDAC_MODE must be added in the project properties as shown in Figure 3-19.
The code below shows the declaration of the PWMDAC object. This code is located in the sys_main.c file.
HAL_PWMDACData_t pwmDACData;
The code below shows the initialization and setting up of the PWMDAC object, handle and parameters. Four module inputs, ptrData[0], ptrData[1], ptrData[2], and ptrData[3] are configured to point to the addresses of four variables. The PWMDAC module inputs point to different system variables depending on the build level. This code is located in the sys_main.c file.
// set DAC parameters
pwmDACData.periodMax =
PWMDAC_getPeriod(halHandle->pwmDACHandle[PWMDAC_NUMBER_1]);
pwmDACData.ptrData[0] = &motorVars_M1.anglePLL_rad; // PWMDAC1
... ...
pwmDACData.ptrData[1] = &motorVars_M1.angleENC_rad; // PWMDAC2
... ...
pwmDACData.ptrData[2] = &motorVars_M1.angleENC_rad; // PWMDAC3
... ...
pwmDACData.ptrData[3] = &motorVars_M1.adcData.I_A.value[0]; // PWMDAC4
pwmDACData.offset[0] = 0.5f;
pwmDACData.offset[1] = 0.5f;
pwmDACData.offset[2] = 0.5f;
pwmDACData.offset[3] = 0.5f;
pwmDACData.gain[0] = 1.0f / MATH_TWO_PI;
pwmDACData.gain[1] = 1.0f / MATH_TWO_PI;
pwmDACData.gain[2] = 1.0f / MATH_TWO_PI;
pwmDACData.gain[3] = 4096.0f / USER_MOTOR1_OVER_CURRENT_A;
The code below shows the updating of the PWM outputs with new data during the execution of the motor1ctrlISR() interrupt. This code is located in the motor1_drive.c file.
// connect inputs of the PWMDAC module. HAL_writePWMDACData(halHandle, &pwmDACData);