📄 15fre280.c
字号:
}
else //no need to dec. freq. and targetfreq>frac inc. freq.
{ if((frac!=60||comp1mintmr==0)&&frac<targetfre) //add by zsq at 040710
if(frekeeptmr==0||frac<MINFRE) //the waiting time has arrived or frac<30,inc. the freq
{ if(frac!=80||keep80hztmr==0)
if(fstopincfre==0||(frac>48&&frac<60)) //no need to stop inc. freq.
{ if(frac!=42||comp42hztmr==0&&frac==42)
if(frekeeptmr2==0) //add by zsq at 040324;'frekeeptmr2' use as timer for inc. freq. after overcurrent dec. freq.
{ if(incfrewaittmr==0&&incfrecounter!=0) //'incfrewaittmr' use as timer for 10Hz
{ frac=frac+1;
incfrecounter=incfrecounter-1;
if(incfrecounter==0&&frac>30&&fdefrost==0)
incfrewaittmr=10;
else
incfrewaittmr=0;
if(ffreqstepbystep==1)
fstepincfreq=1;
}
}
}/*021219*/
}
// if(frac==60&&fcompfirston==1)
// fcomp1mintmr=1;
}/*if frequence is 60,start timer*/
}
}
}
}
else //if targetfre<frac
{ i=flagdecfre&0x0f; /*0e 1221 */
if(i!=0||vdec6hzcounter!=0||vdec9hzcounter!=0||vdec12hzcounter!=0||overIdecfrecounter!=0)
{ if(frac>MINFRE)//mod. from 'if(frac>MINFRE&&fdefrost==0)'
{ frac=frac-1;
braketmr=2;//020725
}
ratechange=1;
}
if(targetfre<frac)/*1015 &&min3cnt==0 */
{ if(frac>MINFRE)
{
if(fstopdecfreq==1)
frac=frac-1;
else
frac=frac-1;
}
else
{ frac=0;
roomonnum=0;/*1025 */
//if(fdefrost==0&&finit1==1)fcompon=0;v12
//v11 gascontrol=1;
braketmr=braketime;//020725
flagmode=flagmode|0xe0;/*1026 */
min3cnt=180;
if(fdefrost==1)min3cnt=40;
}/*030729*/
}
}
}
}
if(frac==0||min3cnt!=0)
{
if(min3cnt>10)
{
MDCR=0xc6;/*v11 1103 set triangular modulation,enalble pwm circuit*/
MDOUT=0x0;/*15 v11 15u,v,w =0;x,y,z=1 turn off IPM,H/L output,*/
EIRL=0x0001;/* 1000 Enable INTPWM1*/
EMGREL=0x5a;/*v12 inhibte emg protective*/
EMGREL=0xa5 ;/*inhibte emg protective*/
EMGCR=0xf0;
EMGCR=0xf1;
//v12 if(finit1==1&&fdefrost==0)fcompon=0;
//v11gascontrol=1;
}
else
{ MDCR=0xc7;
EIRL=0x1011;
}
}
else
{ if(ptcdelay==0)/*021112 */
{ MDOUT=0x73f;
//MDCR=0xc7; /*v11 set triangular modulation,enalble pwm circuit*/
fcompon=1; /*020725 pwm output port enable*/
//v11 gascontrol=0;
//EIRL=0x1011;
} /* 1000 Enable INTPWM1*/
}
if(fconstop==1&&contactorstoptmr<10)
passbyport=passbyport&0xfe;
if(fconstart==1&&contactorstarttmr<8)
passbyport=passbyport|0x01;
/*if(braketmr!=0)P7=P7|0x40;
else P7=P7&0xbf;*/
}
void addeal()
{
if(adok!=0)
{adsum=adsum>>7; /*AD result is divided by 256 ;0112 128*/
if(adchannle==8)
{ voltage=adsum;
if(voltage>=158)
{ fvdec6hz=0;
fvdec9hz=0;
fvdec12hz=0;
vdec6hzcounter=0;
vdec9hzcounter=0;
vdec12hzcounter=0;
}
if(voltage<152&&voltage>=145)
{ if(fvdec6hz==0)
{ fvdec6hz=1;
vdec6hzcounter=6;
}
}
if(voltage<145&&voltage>137)
{ if(fvdec9hz==0)
{ fvdec9hz=1;
vdec9hzcounter=9;
}
}
if(voltage<=137)
{ if(fvdec12hz==0)
{ fvdec12hz=1;
vdec12hzcounter=12;
}
}
if(frac!=0)
{
if(voltage<140) //180V~
{
lowvoltagecnt=lowvoltagecnt+1;
if(lowvoltagecnt>=10)
{
lowvoltagecnt=10;
fovercurrent=1;
if(min3cnt<=1)
min3cnt=180;
}
}
else
lowvoltagecnt=0;
}
else
{
if(voltage<145)//185V~
{
lowvoltagecnt=lowvoltagecnt+1;;
if(lowvoltagecnt>=10)
{
lowvoltagecnt=10;
fovercurrent=1;
if(min3cnt<=1)
min3cnt=40;
}
}
else
lowvoltagecnt=0;
}
}/*1027*/
tempad[adchannle]=adsum;
currentad=Aphase+Bphase;//030113
currentad=currentad>>1;
adsum=0;
if(adchannle==0||adchannle==1||adchannle==2)//030113adchannle!=5&&adchannle<8
{
if((tempad[adchannle]>228)||(tempad[adchannle]<13))
{ i=SenErrTab[adchannle];
alarm=alarm|i;
}
else
{ alarm=alarm&SenOkTab[adchannle];
i=0;
while(tempad[adchannle]>AdTempTab[i]) ++i;
} //030113 if(adchannle==0||adchannle==1)tempad[adchannle]=i;
}/*if channle is not for drain gas measure,A/D change into real valve*/
if(adchannle==9)
{
if(tempad[adchannle]>238||tempad[adchannle]<37)
{ fadjustfre=0; }
else
{ i=0;
while(tempad[adchannle]>AdTempTab[i]) ++i;
fadjustfre=1;
tempad[adchannle]=i;
}/*frac=i;*/
}
adchannle++;
/*030113 if(modsel==0)*/
//if(adchannle==3)adchannle=4;
if(adchannle==6)adchannle=8;/*mod. by zsq from '9' at 040317*/
if(adchannle>9)adchannle=4;
adok=0;
i=P4&0x04;
if(i!=0)
{
if(frac>=30&¤tad<15)
{
moduleerrcnt+=1;
if(moduleerrcnt>=60)
{
moduleerrcnt=60;
fmoduleerr=1;
}
}
else
{
moduleerrcnt=0;
//fmoduleerr=0;
}
}
i=heatthreedecfre;
j=heatthreestop;
if(Aphase>=Bphase)m=Aphase-Bphase;//030113
else m=Bphase-Aphase;
n=50;
if(currentad>j||m>n)//030729&&fdefrost==0
{ overcurrentcnt++;
if(frac>=30)
{
fcurrentdecfre=1; //add by zsq at 040814
ffreqstepbystep=1; ////add by zsq at 040324
stepbysteptmr=6; //add by zsq at 040324
incfrecounter=0; //add by zsq at 040402
//**********************************add by zsq at 041021
fracCounter=frac-10;
if(fracCounter>48&&fracCounter<60)
{
fracCounter=fracCounter-48;
overIdecfrecounter=fracCounter+10;
}
else
overIdecfrecounter=10;
}
//****************************************
{ if(overcurrentcnt>=10)
{if(fovercurrent==0)
{ fovercurrent=1;
//overcurrentfre=overcurrentfre+1;
}//040100
overcurrentcnt=10;
}
}
}
else
{ fcurrentdelay=0;
overcurrentcnt=0; /*0115*/
if(currentad>i&&frac>=30)//mod. from 'if(currentad>i&&fdefrost==0&&frac!=0) //0227'
{ fcurrentdecfre=1;
ffreqstepbystep=1; ////add by zsq at 040324
stepbysteptmr=6; //add by zsq at 040324
incfrecounter=0; //add by zsq at 040402
//**********************************add by zsq at 040324
fracCounter=frac-10;
if(fracCounter>48&&fracCounter<60)
{
fracCounter=fracCounter-48;
overIdecfrecounter=fracCounter+10;
}
else
overIdecfrecounter=10;
//*************************************************
//fredec20stmr=20;del by zsq at 040402
}
else
{ if(currentad+10>i&&frac>=30)//mod. from 'if(currentad+10>i&&fdefrost==0&&frac!=0)'
{ fstopincfre=1;/*0227 frac0115*/
ffreqstepbystep=1; //add by zsq at 040324
stepbysteptmr=6;
stopincfretmr=120; //add by zsq at 040324 make the fstopincfre flag keep for 2min
incfrecounter=0;
if(frac>48&&frac<60)
{
overIdecfrecounter=frac-48;
}
}
else
{ if(currentad+20>i&&frac!=0) //mod. from 'if(currentad+20>i&&fdefrost==0&&frac!=0)'
//add by zsq at 040401
{ if(incfrewaittmr==0&&incfrecounter==0&&frac+6<=targetfre) //add by zsq at 040401
{ incfrecounter=6;} //add by zsq at 040401
else
{ if(incfrewaittmr==0&&incfrecounter==0&&frac+6>targetfre)
incfrecounter=targetfre-frac;
}
} //add by zsq at 040401
else //add by zsq at 040401
{ if(incfrewaittmr==0&&incfrecounter==0&&frac+10<=targetfre) //add by zsq at 040401
{ incfrecounter=10;} //add by zsq at 040401
else
{ if(incfrewaittmr==0&&incfrecounter==0&&frac+10>targetfre)
incfrecounter=targetfre-frac;
}
} //add by zsq at 040401
} //add by zsq at 040401
if(overIdecfrecounter==0)
{ fcurrentdecfre=0;}
if(stopincfretmr==0)
{ fstopincfre=0; }
}//if(min3cnt<120)fovercurrent=0;021219 debug
}
}
}
unsigned16 ontime(unsigned16 x){
unsigned16 y;
unsigned16 zl;
if(x<=quaterperiod){
pol=0;}
else{
if(x<=halfperiod)
{ pol=0;
x=halfperiod-x;}
else
{
if(x<=thirdperiod)
{ pol=1;
x=x-halfperiod;}
else{
if(x<=pwmfrequence){
pol=1;
x=pwmfrequence-x;}
}
}
}
__B=SIN[x];
//if(frac<30) __B=SIN1[x];030729
intk=VFTAB[frac];
__WA=intk;
__asm("SHRCA WA","SHRCA WA");
__C=kcont;
__asm("MUL WA,C");
__C=100;
__asm("DIVW WA,C");
zl=__WA;
if(zl>255)
zl=255;
__WA=zl;
__C=__B;
__asm("MUL WA,C");
__C=255;
__asm("DIVW WA,C","SHLCA WA","SHLCA WA");/**/
y=__WA;
if(y>offset-5)y=offset-
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -