SPRUIK4A September 2018 – June 2019 TMS320F280021 , TMS320F280021-Q1 , TMS320F280023 , TMS320F280023-Q1 , TMS320F280023C , TMS320F280025 , TMS320F280025-Q1 , TMS320F280025C , TMS320F280025C-Q1 , TMS320F280040-Q1 , TMS320F280040C-Q1 , TMS320F280041 , TMS320F280041-Q1 , TMS320F280041C , TMS320F280041C-Q1 , TMS320F280045 , TMS320F280048-Q1 , TMS320F280048C-Q1 , TMS320F280049 , TMS320F280049-Q1 , TMS320F280049C , TMS320F280049C-Q1 , TMS320F28075 , TMS320F28075-Q1 , TMS320F28076 , TMS320F28374D , TMS320F28374S , TMS320F28375D , TMS320F28375S , TMS320F28375S-Q1 , TMS320F28376D , TMS320F28376S , TMS320F28377D , TMS320F28377D-Q1 , TMS320F28377S , TMS320F28377S-Q1 , TMS320F28378D , TMS320F28378S , TMS320F28379D , TMS320F28379D-Q1 , TMS320F28379S
#include “sfra_f32.h”
Add the SFRA library path in the include paths under Project Properties → Build → C2000 Compiler → Include Options (see Figure 4).
NOTE
The exact locations may vary depending on where SFRA is installed and which other libraries the project is using.
Link SFRA library: (sfra_f32_coff/eabi.lib or sfra_f32_tmu_coff/eabi.lib) in the project depending on the device you have selected, the lib is located at:
<sfra_install_path>\lib
Figure 5 shows the changes to the linker options that are required to include the SFRA library.
NOTE
FastRTS library must be included, for steps on including fastRTS library. For more information, see the FastRTS library documentation found at:
<sdk_install_path>\C2000Ware\libraries\math\FPUfastRTS\c28
NOTE
The exact locations may vary depending on where controlSUITE is installed and which other libraries the project is using.
#define SFRA_ISR_FREQ CONTROL_ISR_FREQUENCY
#define SFRA_FREQ_START 2
//
// SFRA step Multiply = 10^(1/No of steps per decade(40))
//
#define SFRA_FREQ_STEP_MULTIPLY (float32_t)1.105
#define SFRA_AMPLITUDE (float32_t)0.005
#define SFRA_FREQ_LENGTH 100
…
SFRA_F32 sfra1;
float32_t plantMagVect[SFRA_FREQ_LENGTH];
float32_t plantPhaseVect[SFRA_FREQ_LENGTH];
float32_t olMagVect[SFRA_FREQ_LENGTH];
float32_t olPhaseVect[SFRA_FREQ_LENGTH];
float32_t clMagVect[SFRA_FREQ_LENGTH];
float32_t clPhaseVect[SFRA_FREQ_LENGTH];
float32_t freqVect[SFRA_FREQ_LENGTH];
//
//extern to access tables in ROM
//
extern long FPUsinTable[];
//
//Resets the internal data of sfra module to zero
//
SFRA_F32_reset(&sfra1);
//
//Configures the SFRA module
//
SFRA_F32_config(&sfra1,
SFRA_ISR_FREQ,
SFRA_AMPLITUDE,
SFRA_FREQ_LENGTH,
SFRA_FREQ_START,
SFRA_FREQ_STEP_MULTIPLY,
plantMagVect,
plantPhaseVect,
olMagVect,
olPhaseVect,
clMagVect,
clPhaseVect
freqVect);
//
//Resets the response arrays to all zeroes
//
SFRA_F32_resetFreqRespArray(&sfra1);
//
// Initializes the frequency response array ,
// The first element is SFRA_FREQ_START
// The subsequent elements are freqVect[n-1]*SFRA_FREQ_STEP_MULTIPLY
// This enables placing a fixed number of frequency points
// between a decade of frequency.
// The below routine can be substituted by a routine that sets
// the frequency points arbitrarily as needed.
//
SFRA_F32_initFreqArrayWithLogSteps(&sfra1,
SFRA_FREQ_START,
SFRA_FREQ_STEP_MULTIPLY);
NOTE
Even though in the above sequence the array is initialized with log step frequencies, the SFRA is in no way dependent on that. The frequency array initialization sequence can be replaced with any other as desired by the application.
interrupt void PWM_ISR(void)
{
….
//
// Read ADC and computer Fbk Value
//
Fdbk = (float32)Vout1R/(4096.0);
//
// Add FRA injection into the reference of the controller
//
Ref = SFRA_F32_inject(Vout1SetSlewed);
//
// Call the controller
//
Out=DCL_PI_C1(&dcl_obj,Ref,Fdbk);
//
// Update PWM value
//
EPwm1Regs.CMPA.half.CMPA = ((long)(BUCK_PWM_PERIOD))*Out;
SFRA_F32_collect(&Out,&Fdbk);
…
}
interrupt void PWM_ISR(void)
{
….
//
// Read ADC and computer Fbk Value
//
Vout1_Read = (float32)Vout1R/(4096.0);
//
// Add SFRA injection into the duty cycle for the open loop converter
//
Duty_pu=SFRA_F32_inject(Duty_pu_DC);
//
// Update PWM value
//
EPwm1Regs.CMPA.half.CMPA=((long)(BUCK_PWM_PERIOD))* Duty_pu;
SFRA_F32_collect(&Duty_pu,&Vout1_Read);
…..
}
SFRA_F32_runBackgroundTask(&sfra1);
….
ramfuncs : LOAD = FLASHD,
RUN = RAML0L1,
LOAD_START(_RamfuncsLoadStart),
LOAD_END(_RamfuncsLoadEnd),
RUN_START(_RamfuncsRunStart),
PAGE = 0
{
--library=sfra_f32_coff.lib<SFRA_F32_inject.obj>
--library=sfra_f32_coff.lib<SFRA_F32_collect.obj>
}
….
SFRA_F32_Data : > dataRAM1, PAGE = 1
/* FPU Math Tables in Boot ROM */
FPUTABLES : origin = 0x3FD860, length = 0x0006A0
….
/* Allocate FPU math areas: */
FPUmathTables : > FPUTABLES, PAGE = 0, TYPE = NOLOAD
FPUmathTables : > FLASH1, PAGE =1