按照下面的计算,应该可以通过PWM7和8引脚用示波器看到频率为freq_exc的正弦波,为什么仿真结果不对呢?比如说当freq_exc = 5 时,理论上应该是5k,但是示波器上输出的却是10k。这是什么情况?
float Ts = 0.001/RESOLVER_PWM_FREQUENCY; /* PWM frequency, see parameter.h */
float freq_exc = RESOLVER_EXCITATION_FREQUENCY*1000; /* Excitation frequency (Hz) */
float amplitude = 1.0; /* Peak value of excitation signal (pu) */
float ang_exc = 0;
_iq sin_sig_ref = 0; /* excitation signal (pu) */
// Excitation signal generation for resolver sensor
sin_sig_ref = _IQmpy(_IQ(amplitude),_IQsinPU(_IQ(ang_exc)));
ang_exc += freq_exc*T;
if (ang_exc >= 1)
ang_exc -= 1;
res_pwm1.signal_ref = _IQtoIQ15(sin_sig_ref);
res_pwm1.update(&res_pwm1);
10#:
看不到你的PWM模块的设置,不能断定问题在哪。
建议将res_pwm1.update()函数的原型以及res_pwm1结构体的定义发出来看一下。
按照下面的计算,应该可以通过PWM7和8引脚用示波器看到频率为freq_exc的正弦波,为什么仿真结果不对呢?比如说当freq_exc = 5 时,理论上应该是5k,但是示波器上输出的却是10k。这是什么情况?
float Ts = 0.001/RESOLVER_PWM_FREQUENCY; /* PWM frequency, see parameter.h */
float freq_exc = RESOLVER_EXCITATION_FREQUENCY*1000; /* Excitation frequency (Hz) */
float amplitude = 1.0; /* Peak value of excitation signal (pu) */
float ang_exc = 0;
_iq sin_sig_ref = 0; /* excitation signal (pu) */
// Excitation signal generation for resolver sensor
sin_sig_ref = _IQmpy(_IQ(amplitude),_IQsinPU(_IQ(ang_exc)));
ang_exc += freq_exc*T;
if (ang_exc >= 1)
ang_exc -= 1;
res_pwm1.signal_ref = _IQtoIQ15(sin_sig_ref);
res_pwm1.update(&res_pwm1);
kui xiao:
回复 10#:
/*—————————————————————————-
Initialization constant for the F28X Timer TxCON for PWM Generation.
Sets up the timer to run free upon emulation suspend, continuous up-down mode
prescaler 1, timer enabled.
—————————————————————————-*/
#define PWM_RESOLVER_INIT_STATE (FREE_RUN_FLAG + \
TIMER_CONT_UPDN + \
TIMER_CLK_PRESCALE_X_1 + \
TIMER_ENABLE_BY_OWN + \
TIMER_ENABLE )
/*—————————————————————————-
Initialization constant for the F28X ACTRx register for Resolver drive.
Sets up PWM7/8 polarities.
—————————————————————————-*/
#define ACTRB_PWM_RESOLVER_INIT_STATE ( COMPARE1_AL + \
COMPARE2_AH + \
COMPARE3_FL + \
COMPARE4_FL + \
COMPARE5_FL + \
COMPARE6_FL )
/*—————————————————————————–
Define the structure of the RESOLVER_PWM Driver Object
—————————————————————————–*/
typedef struct {
int signal_ref; /* Input: Excitation reference signal (Q15) */
int pwm_period; /* Parameter: PWM Half-Period in CPU clock cycles (Q0) */
void (*init)(); /* Pointer to the init function */
void (*update)(); /* Pointer to the update function */
} RESOLVER_PWM ;
/*—————————————————————————–
按照下面的计算,应该可以通过PWM7和8引脚用示波器看到频率为freq_exc的正弦波,为什么仿真结果不对呢?比如说当freq_exc = 5 时,理论上应该是5k,但是示波器上输出的却是10k。这是什么情况?
float Ts = 0.001/RESOLVER_PWM_FREQUENCY; /* PWM frequency, see parameter.h */
float freq_exc = RESOLVER_EXCITATION_FREQUENCY*1000; /* Excitation frequency (Hz) */
float amplitude = 1.0; /* Peak value of excitation signal (pu) */
float ang_exc = 0;
_iq sin_sig_ref = 0; /* excitation signal (pu) */
// Excitation signal generation for resolver sensor
sin_sig_ref = _IQmpy(_IQ(amplitude),_IQsinPU(_IQ(ang_exc)));
ang_exc += freq_exc*T;
if (ang_exc >= 1)
ang_exc -= 1;
res_pwm1.signal_ref = _IQtoIQ15(sin_sig_ref);
res_pwm1.update(&res_pwm1);
kui xiao:
回复 10#:
void F28X_EV2_Resolver_PWM_Init(RESOLVER_PWM *p)
{
/* Initialize PWM7/PWM8 (EVB) */
EvbRegs.T3PR = p->pwm_period; /* Init Timer 3 period Register */
EvbRegs.T3CON.all = PWM_RESOLVER_INIT_STATE; /* Symmetrical Operation */
EvbRegs.COMCONB.all = 0xA200;
EvbRegs.ACTRB.all = ACTRB_PWM_RESOLVER_INIT_STATE;
EALLOW; /* Enable EALLOW */
GpioMuxRegs.GPBMUX.all |= 0x0003;
EDIS; /* Disable EALLOW */
}
void F28X_EV2_Resolver_PWM_Update(RESOLVER_PWM *p)
{
long tmp;
EvbRegs.T3PR = p->pwm_period; /* Update Timer 3 period Register */
tmp = (long)p->pwm_period*(long)(p->signal_ref);
EvbRegs.CMPR4 = (int)(tmp>>16) + (int)(p->pwm_period>>1);
}
按照下面的计算,应该可以通过PWM7和8引脚用示波器看到频率为freq_exc的正弦波,为什么仿真结果不对呢?比如说当freq_exc = 5 时,理论上应该是5k,但是示波器上输出的却是10k。这是什么情况?
float Ts = 0.001/RESOLVER_PWM_FREQUENCY; /* PWM frequency, see parameter.h */
float freq_exc = RESOLVER_EXCITATION_FREQUENCY*1000; /* Excitation frequency (Hz) */
float amplitude = 1.0; /* Peak value of excitation signal (pu) */
float ang_exc = 0;
_iq sin_sig_ref = 0; /* excitation signal (pu) */
// Excitation signal generation for resolver sensor
sin_sig_ref = _IQmpy(_IQ(amplitude),_IQsinPU(_IQ(ang_exc)));
ang_exc += freq_exc*T;
if (ang_exc >= 1)
ang_exc -= 1;
res_pwm1.signal_ref = _IQtoIQ15(sin_sig_ref);
res_pwm1.update(&res_pwm1);
kui xiao:
回复 10#:
主程序里的主频率为150MHz,计数模块为Eva的T1UFINT,定义的pwm_period的值为3750,PWM波形为对称的,EV中断频率为20kHz,这些应该都没问题的。程序里的"freq_exc"为5k,“T”为1/(20k)。
按照下面的计算,应该可以通过PWM7和8引脚用示波器看到频率为freq_exc的正弦波,为什么仿真结果不对呢?比如说当freq_exc = 5 时,理论上应该是5k,但是示波器上输出的却是10k。这是什么情况?
float Ts = 0.001/RESOLVER_PWM_FREQUENCY; /* PWM frequency, see parameter.h */
float freq_exc = RESOLVER_EXCITATION_FREQUENCY*1000; /* Excitation frequency (Hz) */
float amplitude = 1.0; /* Peak value of excitation signal (pu) */
float ang_exc = 0;
_iq sin_sig_ref = 0; /* excitation signal (pu) */
// Excitation signal generation for resolver sensor
sin_sig_ref = _IQmpy(_IQ(amplitude),_IQsinPU(_IQ(ang_exc)));
ang_exc += freq_exc*T;
if (ang_exc >= 1)
ang_exc -= 1;
res_pwm1.signal_ref = _IQtoIQ15(sin_sig_ref);
res_pwm1.update(&res_pwm1);
user5128243:你好, 请问下可以给我发一份 这个exe文件吗?现在官网无法下载 ,谢谢!yelangxu@163.com