资源简介
利用C语言写的三相逆变器基于PI双环控制的程序代码
代码片段和文件信息
interrupt void pwm_up_int(void)
{
//t1 = timer0_read();
/****************** A/D Group0 in****************************/
pev_ad_in_grp( bdngrp0&iu_ad&vw_ad&iw_ad&vu_ad);
pev_ad_start( bdngrp1 );
iu_ad = iu_ad + OFFSET_iu;
vw_ad = vw_ad + OFFSET_vw;
iw_ad =iw_ad + OFFSET_iw;
vu_ad = vu_ad + OFFSET_vu;
/********************* Soft Start ****************************/
cnt_soft=cnt_soft+1;
if (cnt_soft > 50) /* 5 Second */
{
k_soft = k_soft + dk_soft*2;
if( k_soft > 1.0) k_soft = 1.0;
if( k_soft < 0.0) k_soft = 0.0;
cnt_soft = 0;
}
/*********************A/D Group 1 in*************************/
pev_ad_in_grp( bdn grp1 &Vdc_ad &Idc_ad&ch6_ad &ch7_ad);
pev_ad_start( bdn grp0 );
Vdc_ad = Vdc_ad + OFFSET_Vdc;
Idc_ad = Idc_ad + OFFSET_Idc;
//ch6_ad = ch6_ad + OFFSET_ch6;
//ch7_ad = ch7_ad + OFFSET_ch7;
/********************** wt calculation **********************/
wt = wt + DWT;
if(wt >= (PI(2.0))) wt = wt - (PI(2.0));
else if (wt < 0 ) wt = wt + (PI(2.0)) ;
/******************** Voltage uw/dq transfer ****************/
uw2ab( vu_ad vw_ad &va &vb );
ab2dq( va vb wt&vd &vq );
/************************************************************/
/******************** Current uw/dq transfer ****************/
uw2ab( iu_ad iw_ad &ia &ib );
ab2dq( ia ib wt &id &iq );
Iac = mwsqrt2( id iq );
/************************************************************/
/***************** vd vq PI Current Control ****************/
/*****************Outer Loop PI Control *********************/
vd_ref0 = Vrms_ref;
vq_ref0 = 0;
dvd=vd_ref0-vd;
dvq=vq_ref0-vq;
vd_refp=kp_vdq*dvd;
vd_refi=ki_vdq*dvd+V_Ld;//d-axis
V_Ld=vd_refi;
vd_refpi=vd_refp+vd_refi;
if(vd_refi>Vd_uplim)
{
vd_refi=Vd_uplim;
}
if(vd_refi {
vd_refi=Vd_lowlim;
}
Vd_uplim=20;
Vd_lowlim=-20;
vq_refp=kp_vdq*dvq;
vq_refi=ki_vdq*dvq+V_Lq;//q-axis
V_Lq=vq_refi;
vq_refpi=vq_refp+vq_refi;
if(vq_refi>Vq_uplim)
{
vq_refi=Vq_uplim;
}
if(vq_refi {
vq_refi=Vq_lowlim;
}
Vq_uplim=20;
Vq_lowlim=-20;
id_ref=vd_refpi+K0*vq;
K0=-2*pi*50*15e-6;
did=id_ref-id;
id_refp=kp_idq*did;
id_refi=ki_idq*did+I_Ld;//d-axis
I_Ld=id_refi;
id_refpi=id_refp+id_refi;
if(id_refpi>Id_uplim)
{
id_refpi=Id_uplim;
}
if(id_refpi {
id_refpi=Id_lowlim;
}
Id_uplim=300;
Id_lowlim=-300;
iq_ref=vq_refpi+K1*vd;
K1=2*pi*50*15e-6;
diq=iq_ref-iq;
iq_refp=kp_idq*diq;
iq_refi=ki_idq*diq+I_Lq;//d-axis
I_Lq=iq_refi;
iq_refpi=iq_refp+iq_refi;
if(iq_refpi>Iq_uplim)
{
iq_refpi=Iq_uplim;
}
if(iq_refpi {
iq_refpi=Iq_lowlim;
}
Iq_uplim=300;
Iq_lowlim=-300;
vd_ref=id_refpi+K2*iq+vd;
K2=-2*pi*50*2.7e-3;
vq_ref=iq_refpi+K3*
- 上一篇:Visual_C++面向对象编程教程第三章答案王育坚
- 下一篇:个人资源管理
评论
共有 条评论