This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

sin wave gen lib

Other Parts Discussed in Thread: CONTROLSUITE

Hi,

 I am using Sin wave gen library for 3 phase sine wave generation2538.sgen.h2117.sgen.h

/*
 * sgen.c
 *
 *  Created on: Oct 1, 2014
 *      Author: com
 */


#include "sgen.h"

SGENT_3 sgen = SGENT_3_DEFAULTS;

void sgen_init(void)
{
	/* Signal Generator module initialisation   */

	sgen.offset		=	0;
	sgen.gain		=	0x7fff;         /* gain=1 in Q15                              */
	sgen.freq		=	5369;           /* freq = (Required Freq/Max Freq)*2^15       */
										/*      = (50/305.17)*2^15 = 5369             */
	sgen.step_max 	=	1000;    			/* Max Freq= (step_max * sampling freq)/65536 */
	                                	/* Max Freq = (1000*20k)/65536 = 305.17       */
}

In ADC ISR I am using out signal of SGEN to apply PWM signal.


sgen.calc(&sgen);

sgen.out1 = (Uint16)(sgen.out1 * SINE_PRD); // Period valur for 20Khz signal
sgen.out2 = (Uint16)(sgen.out2 * SINE_PRD);
sgen.out3 = (Uint16)(sgen.out3 * SINE_PRD);

EPwm1Regs.CMPA.half.CMPA = (Uint16)sgen.out1;
EPwm2Regs.CMPA.half.CMPA = (Uint16)sgen.out2;
EPwm3Regs.CMPA.half.CMPA = (Uint16)sgen.out3;

but I didn't get proper pwm.

Is there any mistake while using SGEN lib.

Please reply me

Regards,

Sagtar