【无标题】

  1. step1 恒流开环 BCM
  2. step2 正弦 开环BCM

1. step1 恒流开环

step1恒流开环
波形
恒流开环波形
参数值

名称参数单位
Vin40V
LM3.5uH
R100Ω
Cf300nF
N6

// DPWM with Triangular carrier ///
//

/
// Power Smart Control S.L. //
/      https://powersmartcontrol.com/      ///
/                    May 2020                              ///
///



//Variables declarations
float Fclk_psim, time_step, deadtime;
int Nr, Fsw, digital_deadtime, duty_1, duty_2;
bool samp_inst;
static int counter_trig=0, duty_cycle;
static bool Up=1, Down=0, HB, LB;
static float I_sec;


//Input assignation
Fsw = x1;
time_step = x2;
deadtime = x3;
I_sec=x5;

//Calculation of the amplitude of the triangular
/* the maximum value of the counter is given by:
				Nr = 0.5*Fclk/Fsw
    Since the psim block is executed every time step 
	therefore the frequency of the master clock is:
				Fclk = 1/time_step */

Fclk_psim = 1/time_step;
Nr = 0.5*Fclk_psim/Fsw;

//Updating the duty cycle at the lower vertex of the triangular
if (counter_trig ==0) {
	Up =1;
	Down =0;
	duty_cycle = x4;	
} 

//Updating the duty cycle at the upper vertex of the triangular
if (counter_trig == Nr) {
	Up = 0;	
	Down =1;
	duty_cycle =x4;
} 

//It generates the sampling instant signal
if ((counter_trig >=0 && counter_trig <= 4 && Up ==1) || (counter_trig <= Nr && counter_trig >= Nr-4 && Down ==1 )){
samp_inst = 1;
} else  {
samp_inst = 0;
}

//Triangular Carrier
if (Up ==1) {
	counter_trig = counter_trig +1;
} 

if (Down ==1) {
	counter_trig = counter_trig -1;
} 

//Calculations to generate the deadtime
digital_deadtime = deadtime/(2*time_step);
duty_1 = duty_cycle - digital_deadtime; 
duty_2 = duty_cycle + digital_deadtime; 

//PWM generation
if (counter_trig >= duty_1){
	HB =0;
} else {
	HB =1;

}






y1 = HB;


**

step2 正弦 开环BCM

**
step4
波形
在这里插入图片描述
PWM control C block 代码


// DPWM with Triangular carrier ///
//

/
// Power Smart Control S.L. //
/      https://powersmartcontrol.com/      ///
/                    May 2020                              ///
///



//Variables declarations
float Fclk_psim, time_step, deadtime;
int Nr, Fsw, digital_deadtime, duty_1, duty_2;
bool samp_inst;
static int counter_trig=0, duty_cycle;
static bool Up=1, Down=0, HB, LB;
static float I_sec;

static int  pulse_count=0;

static int  i=0,j=0;






//Input assignation
Fsw = x1;
time_step = x2;
deadtime = x3;
I_sec=x5;

 duty_cycle=x4;

//Calculation of the amplitude of the triangular
/* the maximum value of the counter is given by:
				Nr = 0.5*Fclk/Fsw
    Since the psim block is executed every time step 
	therefore the frequency of the master clock is:
				Fclk = 1/time_step */

Fclk_psim = 1/time_step;
Nr = 0.5*Fclk_psim/Fsw;

if(duty_cycle<80)
{duty_cycle=0;}

//Updating the duty cycle at the lower vertex of the triangular
if (counter_trig ==0) {
	Up =1;
	Down =0;
	duty_cycle = x4;	
} 

//Updating the duty cycle at the upper vertex of the triangular
if (counter_trig == Nr) {
	Up = 0;	
	Down =1;
	duty_cycle =x4;
} 

//It generates the sampling instant signal
if ((counter_trig >=0 && counter_trig <= 4 && Up ==1) || (counter_trig <= Nr && counter_trig >= Nr-4 && Down ==1 )){
samp_inst = 1;
} else  {
samp_inst = 0;
}

//Triangular Carrier
if (Up ==1) {
	counter_trig = counter_trig +1;
} 

if (Down ==1) {
	counter_trig = counter_trig -1;
} 

//Calculations to generate the deadtime
//digital_deadtime = deadtime/(2*time_step);
duty_1 = duty_cycle; //- digital_deadtime; 
duty_2 = duty_cycle ;//+ digital_deadtime; 

//PWM generation
if (counter_trig >= duty_1){




	HB =0;




} else {
	HB =1;

}

if(counter_trig == duty_1)
{

if(pulse_count<10)
pulse_count=pulse_count+1;  




                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              


}









if(Down==1&&I_sec<0.01)



{


	counter_trig =0;



	}





//Output assignation
y1 = HB;
y2=	i;
//y3=sincetable[j];

//y2 = samp_inst;
//y3 = counter_trig;
//y4 = duty_cycle;

since table C block代码


// DPWM with Triangular carrier ///
//

/
// Power Smart Control S.L. //
/      https://powersmartcontrol.com/      ///
/                    May 2020                              ///
///
#include<math.h>


//Variables declarations


static int  i=0,j=0;

float Uo=80;
float Po=75;
float Upv=x1;
float  x;
float pwm_duty;

int duty;


float sincetable[100]=
{0,
0.0314,
0.0628,
0.0941,
0.1253,
0.1564,
0.1874,
0.2181,
0.2487,
0.279,
0.309,
0.3387,
0.3681,
0.3971,
0.4258,
0.454,
0.4817,
0.509,
0.5358,
0.5621,
0.5878,
0.6129,
0.6374,
0.6613,
0.6845,
0.7071,
0.729,
0.7501,
0.7705,
0.7901,
0.809,
0.8271,
0.8443,
0.8607,
0.8763,
0.891,
0.9048,
0.9177,
0.9298,
0.9409,
0.951,
0.9603,
0.9686,
0.9759,
0.9823,
0.9877,
0.9921,
0.9956,
0.998,
0.9995,
1,
0.9995,
0.998,
0.9956,
0.9921,
0.9877,
0.9823,
0.9759,
0.9686,
0.9603,
0.9511,
0.9409,
0.9298,
0.9178,
0.9049,
0.891,
0.8763,
0.8608,
0.8444,
0.8271,
0.8091,
0.7902,
0.7706,
0.7502,
0.729,
0.7072,
0.6846,
0.6614,
0.6375,
0.613,
0.5878,
0.5621,
0.5359,
0.5091,
0.4818,
0.4541,
0.4259,
0.3972,
0.3682,
0.3388,
0.3091,
0.2791,
0.2488,
0.2182,
0.1875,
0.1565,
0.1254,
0.0942,
0.0629,
0.0315

};





y1=sincetable[j];

x=sincetable[j]/Upv;
//duty=int(2*Po/Uo(Uo*x*x+6*x));
pwm_duty=2*Po/Uo*(Uo*pow(x,2)+6*x)*700;

y2=int(pwm_duty);


i=i+1;
j=int(i/20000);

if(i>1999999)
{i=0;}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值