How to set the fundamental frequency (400hz) in the PWMSVM01

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
Hi everybody,


I want to know how to set the fundamental frequency in the PWMSVM01 ? in my case I want to have a sinusoidal output tesion with my inverter under 400Hz after filtering.

I see we have access to the reference voltage and angle, I know that the angle alfa = 2 * pi * f * t (f is the fundamental frequency), but I do not know how to give the value 400hz to the fundamental fréquency f.
0 Likes
3 Replies
rethinam
Employee
Employee
Welcome! First reply posted
Hi,

void PWMSVM01_SVM(const PWMSVM01_HandleType* HandlePtr, uint16_t Amplitude,uint16_t Angle) function is used to set reference voltage and angle. PWMSVM01_SVM () function can be called periodically and update angle value based on required fundamental frequency.

Example: Required fundamental frequency is 400 Hz and PWM frequency is 20 kHz.

PWM period match ISR can be used to update the required angle value. (if PWM frequency is 20 kHz, PWM period match ISR will occur every 50 uS.) Angle should be incremented by 7.2 degree( IncrementalAngle = (360*FundamentalFreq)/PWMFreq) for every 50 us to generate 400 Hz fundamental frequency.

In the code, 0 to 360 degrees angle is mapped to 0 to 0xFFFF. Every PWM period match ISR Angle should be incremented by 1310 and updated the angle using PWMSVM01_SVM() function.
0 Likes
Not applicable
thank you for your reply,

So if I understand what you've explain, I have to increment the angle by 7.2, if we take the following main code that I modified, we will have (Fpwm=20khz and f=400hz) :


#include //Declarations from DAVE3 Code Generation (includes SFR declaration)


int main(void)
{
// status_t status; // Declaration of return variable for DAVE3 APIs (toggle comment if required)


DAVE_Init(); // Initialization of DAVE Apps

/* Start SVM */
PWMSVM01_Start(&PWMSVM01_Handle0);

while(1)
{

}
return 0;
}
/**
* Interrupt handler for Phase U Period match
*/
void PeriodMatchHandler(void)
{
static uint16_t Angle = 0;
static uint16_t Amplitude = 200;
Angle += 7.2;
PWMSVM01_SVM(&PWMSVM01_Handle0, Amplitude, Angle);
}

/**
* Interrupt handler for the Phase U Trap
*/
void TrapHandler(void)
{
PWMSVM01_Stop(&PWMSVM01_Handle0);
}

So I would like to kwon, if this is all I need to do to generate a three phase PWM under 400Hz fundamental frequency?
0 Likes
rethinam
Employee
Employee
Welcome! First reply posted
Hi,

Yes, Approach is correct. In the code, 0 to 360 degrees angle is mapped to 0 to 0xFFFF, 7.2 degree is mapped to 1310. Every PWM period Match ISR Angle incremental value is 1310.

/**
* Interrupt handler for Phase U Period match
*/
void PeriodMatchHandler(void)
{
static uint16_t Angle = 0;
static uint16_t Amplitude = 200;
Angle += 1310;
PWMSVM01_SVM(&PWMSVM01_Handle0, Amplitude, Angle);
}
0 Likes