⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 13fre100.c.bak

📁 本程序是交流压缩机的驱动程学
💻 BAK
📖 第 1 页 / 共 5 页
字号:
                if(comp1mintmr==0&&fdefrost==0)
                   fcompfirston=0;
             }
           i=flagdecfre&0x0f;
           if(i!=0&&fdefrost==0)
              frekeeptmr=120;/*0115*/
           else
             { 
             	if(frekeeptmr!=0)
             	   frekeeptmr=frekeeptmr-1;
                if(fdefrost==1)
                   frekeeptmr=0;
             }/*0115*/
           min1tmr++;
           if(ffasttest==1)
              min1tmr=60;  //0227
           if(min1tmr>59)
             { 
             	min1tmr=0;         /*defrost timer */
                if(fre30hztmr!=0)
                  {
                    if(frac==30)
                       fre30hztmr++;
                    else
                       fre30hztmr=fre30hztmr-1;
                   }
                if(fre60hztmr!=0)
                   fre60hztmr=fre60hztmr-1;
                if(counter!=0)   //0509
                   {  counter=counter-1;
                      if(counter==0)
                         valveopentmr=5;
                   }
             }
         }
     //}
     if(defaultnum!=0&&defaultnum<8)               /*>8 1218 modify if default exist,led sparkle*/
        defaultport=defaultnum^0x07;
     else
       {  
         j=flagdecfre&0x0f;
         j=j<<1;
         if(defaultnum>8||j!=0&&frac!=0)              /*030729 modify*/
           {
              if(defaultnum>8)
                 j=defaultnum-8;           /*!=0;1218 modify*/
              i=defaultport&0x07;
              if(i==0x07)
                 defaultport=j^0x07;
              else
                 defaultport=0x07;
           }
         else defaultport=0x07;
       }
     }
}

void speed()
{ if(fadjustfre==1)//&&fconstart==1&&contactorstarttmr==0)
     { targetfre=tempad[9];//030308 v10 fredrv 
       if(targetfre>100)
           targetfre=100;
     }
  //if(fconstart==1&&contactorstarttmr<4)
     P6=P6|0x04;//P7=P7|0x40;ptc control
 // if(fconstop==1&&contactorstoptmr==0)
  //   P6=P6&0xfb;//P7=P7&0xbf;
  i=P4&2;
  if(i==0){ ffasttest=1;}  
  else  ffasttest=0;
  if(frac>=30)
    finit1=0;
  
  //if(frac>=30)finit1=0;
  
  i=alarmh&0x70;//50;//030308  ff; 
  if(i!=0)  //over current or module protect
   {
      if(frac!=0)
        fcmpoff=1;
   }
  i=0;
  j=alarmh&0x71;//51;    //over current or module protect or com. error
  while(j>>i!=0)
     ++i;/*if one fault exist,it's default number .*/
  if(i!=0)
    { 
    	 defaultnum=i+8;
         if(fcomerr==1)
             {
                defaultnum=10;
                if(frac!=0)
                   fcmpoff=1;
             }
    }
  else
    defaultnum=0;
  kcont=modux*volt220/voltage;    //=100
  //if(kcont>90&&kcont<110)kcont=100;   //0311 80;
  //if(kcont>110&&kcont<=120)kcont=120;
  if(kcont>110&&kcont<120&&frac>55)
        kcont=kcont+2;   
  if(kcont>=120&&frac>=60)
      kcont=kcont+6;//mod.at 040317   0311 1027 0317 from 110
  else 
    { if(kcont>=120&&frac<60)
    
         kcont=kcont+2;
    }
  if(kcont>140)kcont=140;
  //if(kcont<=100)kcont=100;//0318 from 80
  //kcont=100;021219 
  if(fcmpoff==1&&frac!=0)/*&&*/
     {targetfre=0;
      if(frac>MINFRE)
        {
           frac=MINFRE;
        }
     }
  if(min3cnt!=0)
    { targetfre=0;
      frac=0;
      cmpruntmr=45;
      roomonnum=0;             /*1228 */
      /*flagmode=flagmode|0xe0;*/
    }
    else
        {    if(fadjustfre==0)
            targetfre=35;
        }
  if (ratechange==0&&min3cnt==0)      /* 1230 every 2*500ms ,ratechange valuated */
    {  ratechange=3;
       if(frac<30&&frac>0)
          ratechange=1;// 030729
// del.at 050613       if(fcurrentdelay==1)
// del.at 050613         ratechange=3;
// del.at 050613      if(frac>80&&fcurrentdecfre==0)
// del.at 050613         ratechange=3;//4;040100
// del.at 050613      if(frac>95&&fcurrentdecfre==0)
// del.at 050613         ratechange=3;//8;
        //if(fdefrost==1&&fdecfre)ratechange=2;030111
       if(frac>=targetfre)
        {
          ratechange=3;//040100
          if(fdefrost==1)
            ratechange=1;
        }
       if(frac<60&&targetfre>60)    //add by zsq at 040514
          {  comp1mintmr=20;                         //add by zsq at 040514
             if(fcompfirston==1)
                comp1mintmr=255;
             if(fdefrost==1)                        //add by zsq at 040514
               comp1mintmr=10;                       //add by zsq at 040514
             fcomp1mintmr=1;                        //add by zsq at 040514
          }
       if(frac<42&&targetfre>42&&fcompfirston==0)   //add by zsq at 040514
          {  comp42hztmr=20;                         //add by zsq at 040514
             if(fdefrost==1)                        //add by zsq at 040514
                comp42hztmr=10;                       //add by zsq at 040514
          }
       if(frac<80&&targetfre>80)
         { keep80hztmr=20;     //add by zsq at 040514
           if(ffirst80hz==1)  //add by zsq at 040514
             keep80hztmr=90;  //add by zsq at 040514
           if(fdefrost==1)
             keep80hztmr=10;   /*0313 from 5 1219 */
         }/*1103*/
       { //if(frac<60&&targetfre>60&&fcompfirston==1)
         //   { comp1mintmr=255;
         //     if(fdefrost==1)
         //       comp1mintmr=5;
         //   }
        if(targetfre>frac)/*1015&&min3cnt==0  */
          {
           {
            i=alarmh&0x70;//50;//500322 fc ff
            if(i==0&&poweron10s==0)/*0321 1010*/  //if no overcurrent and module protect
             { if(frac==0) //020725 &&ptcdelay==0     //turn on
                {
                 frac=4;            /*030729 15start frenquence is minfre*/
                 /*if(kcont>107)frac=10;0725 19 settle low voltage start*/
                 fcompon=1;//021112
                 //v11 gascontrol=0;
                 ptcdelay=4;//021112
                 if(fdefrost==1)ptcdelay=0;//030729  
                 cmpruntmr=45;
                 fcompfirston=1;
                 ffirst80hz=1;  //add by zsq at 040514
                 comp42hztmr=25;
                 //comp1mintmr=255;//
                 fcomp1mintmr=0;
                 ptr=0;   // point to sin tab
                }
               else
                { i=flagdecfre&0x0f;/* 0e 1221 */
                  if(i!=0)//mod. the from 'if(i!=0&&fdefrost==0)  /*0203 */'need decrease fre
                     {if(frac>MINFRE)
                        { if(fredec20stmr>14)
                            frac=frac-1;
                          braketmr=2;//020725
                          ratechange=1;
                        }//0321 1
                      else//frac <30hz
                        {if(frac<MINFRE)frac=frac+1;
                        }
                     }
                  else//normal situation increase fre
                   {
                     if(frekeeptmr==0||frac<MINFRE)
                     { if(comp1mintmr==0||frac!=60)
                       if(frac!=80||keep80hztmr==0)
                       if(fstopincfre==0)
                        { if(frac!=42||comp42hztmr==0&&frac==42)
                            frac=frac+1;
                        }/*021219*/
                     }
                   }/*if frequence is  60,start timer*/
                 }
               }
              }
             }
            else//while(frac>=targetfre) 
             { i=flagdecfre&0x0f;   /*0e 1221 */
               if(i!=0)//have decrease fre
               {if(frac>MINFRE)  //mod. from 'if(frac>MINFRE&&fdefrost==0)'
                 {frac=frac-1;
                  braketmr=2;//020725
                 }
                ratechange=2;
               }
               if(targetfre<frac)/*1015 &&min3cnt==0 */
               { if(frac>MINFRE)
                   { if(fstopdecfreq==1)
                       frac=frac-2;
                     else
                       frac=frac-1;
                   }
                 else//while frac<30 stop directly
                   { frac=0;
                     roomonnum=0;/*1025 */
                     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;
      }
   else
     {MDCR=0xc7;
      EIRL=0x1011;
     }
  }
  else
     {
     	if(ptcdelay==0)/*021112 */
          {
            MDOUT=0x73f;
            fcompon=1;   /*020725 pwm output  port enable*/
          }   /* 1000 Enable INTPWM1*/
     }
  //i=outputbuf&0x1c;//030223 1c
  //j=outfanport&0xe3;//030223 e3
  //outfanport=i|j;
  if(fconstop==1&&contactorstoptmr<10)
      P6=P6|0x02;//passbyport=passbyport|0x01;
  if(fconstart==1&&contactorstarttmr<8)
      P6=P6&0xfd;//passbyport=passbyport&0xfe;
}



void addeal()
{
 if(adok!=0)
  {
    adsum=adsum>>7;     /*AD result is divided by 256 ;0112 128*/
    if(adchannle==8)
     {voltage=adsum; }/*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++;
    //if(adchannle==3)adchannle=4;
      if(adchannle==6)adchannle=8;/*mod. from '9',by zsq at 040317;*/
      if(adchannle>9)adchannle=4;
    adok=0;
     /***************************************/
i=P4&0x04;
if(i!=0)
{
if(frac>=30&&currentad<15)
    {
       moduleerrcnt=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(fdefrost==1)
      {  i=heatthreedecfre;
         j=heatthreestop;
         n=100;
      }
      
 
    /*********************************************/
    if(currentad>j||m>n)//030729&&fdefrost==0
     { overcurrentcnt++;
       if(frac>=30)
        {
          fcurrentdecfre=1;   //add by zsq at 040818
          fredec20stmr=20;    //add by zsq at 040818
        }
       {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -