Introduction
This example demonstrates the gains of using TMU in an application-level. The example makes use of Park and Inverse Park Transform application which has use cases in high performance drive architectures related to permanent magnet synchronous and asynchronous machines. The implementation of this transform is as follows:
Park Transform:
Isd = Ialpha*cos(theta) + Ibeta*sin(theta)
Isq = -Ialpha*sin(theta) + Ibeta*cos(theta)
Inverse Park Transform
Ialpha = Isd*cos(theta) - Isq*sin(theta)
Ibeta = Isd*sin(theta) + Iq*cos(theta)
Ialpha = Stationary d-axis stator current
Ibeta = Stationary q-axis stator current
Isd = Rotating d-axis stator current
Isq = Rotating q-axis stator current
theta = Rotating angle in per unit
Park Transform:
Isd = Ialpha*cos(theta) + Ibeta*sin(theta)
Isq = -Ialpha*sin(theta) + Ibeta*cos(theta)
Inverse Park Transform
Ialpha = Isd*cos(theta) - Isq*sin(theta)
Ibeta = Isd*sin(theta) + Iq*cos(theta)
Ialpha = Stationary d-axis stator current
Ibeta = Stationary q-axis stator current
Isd = Rotating d-axis stator current
Isq = Rotating q-axis stator current
theta = Rotating angle in per unit
To implement this in an application-level, the Park and Inverse Park Transform computations are happening in an ISR context. We have configured an EPWM module which will trigger ADC SOC conversions for two ADC modules. The interrupt gets generated by the ADC Module 1 at end of conversion, an within ISR the park and inverse park calculations take place. These calculations makes use of TMU, TI ARM Trig Library and Mathlib library alternatively for trigonometric operations and computes the performance diiference between the three in terms of avgerage cycles taken, max cycles taken and min cycles taken.
From the results it is observed that using TMU improves performance by 84.5% in comparison to using Mathlib library, and there is a performance improvement of approximately 60% in comparison to using TI ARM Trig Library
Interrupt Configurations
- ADC1 INT 1 is generated at the EOC/SOC2
ISR
- ADC INT 1 is configured to ISR, App_adcISR
External Connections
- ADC2_AIN0, ADC2_AIN1, ADC2_AIN2 and ADC1_AIN0, ADC1_AIN1, ADC1_AIN2 pins should be connected to signals to be converted.
AM263PX-CC E2
When using AM263PX-CC E2 with TMDSHSECDOCK (HSEC180 controlCARD Baseboard Docking Station)
- Feed analog inputs to the following.
- ADC2_AIN0 - HSEC 31
- ADC2_AIN1 - HSEC 33
- ADC2_AIN2 - HSEC 37
- ADC1_AIN0 - HSEC 12
- ADC1_AIN1 - HSEC 14
- ADC1_AIN2 - HSEC 18
AM263PX-CC E1
When using AM263PX-CC E1 with TMDSHSECDOCK (HSEC180 controlCARD Baseboard Docking Station)
- Feed analog inputs to the following.
- ADC2_AIN0 - HSEC 24
- ADC2_AIN1 - HSEC 26
- ADC2_AIN2 - HSEC 28
- ADC1_AIN0 - HSEC 18
- ADC1_AIN1 - HSEC 20
- ADC1_AIN2 - HSEC 21
AM263PX-LP
When using LP
- Feed the analog inputs
- Feed analog inputs to the following.
- ADC2_AIN0 - J1/J3 25
- ADC2_AIN1 - J5/J7 63
- ADC2_AIN2 - J5/J7 68
- ADC1_AIN0 - J1/J3 24
- ADC1_AIN1 - J1/J3 29
- ADC1_AIN2 - J5/J7 67
Supported Combinations
| Parameter | Value |
| CPU + OS | r5fss0-0 nortos |
| Toolchain | ti-arm-clang |
| Board | am263px-cc, am263px-lp |
| Example folder | examples/drivers/tmu/tmu_park_transform/ |
Steps to Run the Example
- When using CCS projects to build, import the CCS project for the required combination and build it using the CCS project menu (see Using SDK with CCS Projects).
- When using makefiles to build, note the required combination and build using make command (see Using SDK with Makefiles)
- Establish connections as mentioned in External Connections section
- Launch a CCS debug session and run the executable, see CCS Launch, Load and Run
- View the console log for results
Sample Output
Shown below is a sample output when the application is run,
TMU Park Transform Test Started ...
ADC Read Results :
ADC 1 SOC0 result : 15, ADC1 SOC1 result : 85, ADC1 SOC2 result : 24
ADC 2 SOC0 result : 48, ADC2 SOC1 result : 23, ADC2 SOC2 result : 21
ADC 1 SOC0 result : 14, ADC1 SOC1 result : 59, ADC1 SOC2 result : 21
ADC 2 SOC0 result : 12, ADC2 SOC1 result : 24, ADC2 SOC2 result : 19
ADC 1 SOC0 result : 15, ADC1 SOC1 result : 59, ADC1 SOC2 result : 21
ADC 2 SOC0 result : 11, ADC2 SOC1 result : 23, ADC2 SOC2 result : 19
ADC 1 SOC0 result : 15, ADC1 SOC1 result : 59, ADC1 SOC2 result : 21
ADC 2 SOC0 result : 12, ADC2 SOC1 result : 24, ADC2 SOC2 result : 20
ADC 1 SOC0 result : 14, ADC1 SOC1 result : 59, ADC1 SOC2 result : 21
ADC 2 SOC0 result : 11, ADC2 SOC1 result : 22, ADC2 SOC2 result : 21
ADC 1 SOC0 result : 15, ADC1 SOC1 result : 58, ADC1 SOC2 result : 21
ADC 2 SOC0 result : 11, ADC2 SOC1 result : 23, ADC2 SOC2 result : 21
Park Transform Results :
Avg cycles taken by TMU : 96.541176
Avg cycles taken by TI ARM Trig Library : 243.711761
Avg cycles taken by Clang Mathlib Library : 623.152954
Max cycles taken by TMU : 188.000000
Max cycles taken by TI ARM Trig Library : 364.000000
Max cycles taken by Clang Mathlib Library : 878.000000
Min cycles taken by TMU : 96.000000
Min cycles taken by TI ARM Trig Library : 243.000000
Min cycles taken by Clang Mathlib Library : 552.000000
Inverse Park Transform Results :
Avg cycles taken by TMU : 95.264709
Avg cycles taken by TI ARM Trig Library : 239.329407
Avg cycles taken by Clang Mathlib Library : 622.929382
Max cycles taken by TMU : 140.000000
Max cycles taken by TI ARM Trig Library : 295.000000
Max cycles taken by Clang Mathlib Library : 689.000000
Min cycles taken by TMU : 95.000000
Min cycles taken by TI ARM Trig Library : 239.000000
Min cycles taken by Clang Mathlib Library : 551.000000
TMU Park Transform Test Passed!!
All tests have passed!!
See Also