zhaocongxue
¼‰„e: ÂÔÓÐС³É
¾«ÈAÖ÷î}: 0
°l(f¨¡)Ìû”µ(sh¨´)Á¿: 390 ‚€
¹¤¿ØÍþÍû: 489 üc
ÏÂÝd·e·Ö: 1204 ·Ö
ÔÚ¾€•rég: 177(С•r)
×¢ƒÔ•rég: 2007-10-27
×îºóµÇä›: 2024-12-25
²é¿´zhaocongxueµÄ Ö÷î} / »ØÙN
˜ÇÖ÷  °l(f¨¡)±íÓÚ: 2012-08-18 09:43
ϵ½y(t¨¯ng)³ÌÐò£º
#include <c8051f000.h>
typedef unsigned char uchar;
typedef unsigned int uint;
typedef unsigned long ulong;
sbit P1_0=P1^0;
sbit P1_2=P1^2;
sbit P0_6=P0^6;
sbit P0_4=P0^4;
sbit P0_7=P0^7;
sbit P1_3=P1^3;
sbit P1_4=P1^4;
#define CON 28585756
uint t[4]={0,0,0,0};
uint i=0,a=0,t1=0,t2=0,e=0,tt=0;
char d=1,n=1,jj=0,j=0,m=0;

union tcfint16{
      uint myword0;
      struct{uchar hi;uchar low;}bytes0;
      }myint16;
union tcfint116{
      uint myword1;
      struct{uchar hi;uchar low;}bytes1;
      }myint116;
void pca1()                            //ÔOÖÃÃ}›_²¶×½
{    
EIE1=0x00;                          //½ûÖ¹Ã}›_²¶×½ÖДà
PCA0MD=0x00;                      //ϵ½y(t¨¯ng)•rçŠ12·Öîl£¬½ûÖ¹pcaÖДà
PCA0CN=0x00;                       //CR=0
PCA0CPM0=0x20;
PCA0CPM1=0x20;                      //ÕýÑز¶×½
}
void DAC0(uint DAChl)
{
myint16.myword0=DAChl;
DAC0L=myint16.bytes0.low;
DAC0H=myint16.bytes0.hi;
}
void delay()
{
uint xxxx,xxx=999,xx,x;
for(x=0;x<400;x++)
   for(xx=0;xx<x;xx++)
   {
     xxxx=xxx/1000;
    }
}
main()                              //Ö÷º¯”µ(sh¨´)
{
uint t0;
uint dk1=0,dk2=0;
WDTCN=0xde;
WDTCN=0xad;            //êP¿´éT¹·
XBR0=0x12;
XBR2=0x40;               //½»²æé_êPÔOÖÃ,ÍⲿÖДàŸoÒýÄ_
XBR1=0x00;
OSCICN=0x95;             //ƒÈ(n¨¨i)²¿•rçŠ4MHz
DAC1CN=0;               //DCA1ŸoЧ
PRT0CF=0xc0;
PRT1CF=0x18;
CKCON=0xe7;            //ϵ½y(t¨¯ng)•rçŠ12·Öîl
TMOD=0x11;
TCON=0x00;               //ÍⲿÖДàÕˆÇó¼°˜Ë־λ0
TH0=0x00;
TL0=0x00;
TH1=0x00;
TL1=0x00;
pca1();                   //pca³õʼ»¯  
REF0CN=0x03;
DAC0CN=0x84;             //DCA0ʹÄÜ£¬×óŒ¦ýR
  P1_0=0;
  P1_2=1;
  P0_6=0;
  P0_7=0;
  P1_3=0;
  P1_4=0;
   EA=1;                          //ÖДàÔOÖÃ
   ET0=1;
   PT0=1;
   ET1=1;
   PT1=1;
   a=0x91A0;
   //a=0xF2A0;
     DAC0(a);
    delay();    
//****************************œyîl*****************************//
  while(1){
   for(i=1;i<4;i++){
    CCF0=0;                         //׃îlÉÏÉýÑؘËÖ¾
   while(CCF0==0)
   {}
   TR1=1;
   CCF0=0;                          //׃îlÉÏÉýÑؘËÖ¾
   while(CCF0==0)
   {}
   TR1=0;
myint116.bytes1.low=TL1;
myint116.bytes1.hi=TH1;
TH1=0;
TL1=0;
if(myint116.myword1>6000&&myint116.myword1<30000)  //ÌÞ³ý´Ö´óÕ`²îÖµ
{m++;
t[m]=myint116.myword1;
}
else
i--;}
    for(i=1;i<=2;i++)                //ÖÐÖµžV²¨
     for(jj=1;jj<=3-i;jj++)
       if(t[jj]>t[jj+1])
         {t[0]=t[jj];
         t[jj]=t[jj+1];
         t[jj+1]=t[0];
         }  
    dk1=t[2];                        
    for(i=0;i<4;i++)
    t=0;
    n=1;                           //ßMÈëèbîlèbÏà
//***************************èbîl*****************************//
while(d==1){                        //œyÁ¿×ƒîlÖÜÆÚ
   for(i=1;i<4;i++){
    CCF1=0;                       //׃îlÉÏÉýÑؘËÖ¾
   while(CCF1==0)
   {}
   TR1=1;
   CCF1=0;                         //׃îlÉÏÉýÑؘËÖ¾
   while(CCF1==0)
   {}
   TR1=0;
myint116.bytes1.low=TL1;
myint116.bytes1.hi=TH1;
TH1=0;
TL1=0;
if(myint116.myword1>6000&&myint116.myword1<30000)
{m++;
t[m]=myint116.myword1;
}
else
i--;                   }
    for(i=1;i<=2;i++)                  //ÖÐÖµžV²¨
     for(jj=1;jj<=3-i;jj++)
       if(t[jj]>t[jj+1])
         {t[0]=t[jj];
         t[jj]=t[jj+1];
         t[jj+1]=t[0];
         }  
    dk2=t[2];
    for(i=0;i<4;i++)
    t=0;
    if(dk2>dk1+2)                       //èbîl
     {a=a+192;
      DAC0(a);}
     else
      d=0;
     }
    a=0xF2A0;
    DAC0(a);
//****************************èbÏà*****************************//     TR0=1;
    while(n==1)
    {
    CCF1=0;
    while(CCF1==0)
    {}
    TR1=1;
    CCF0=0;
    while(CCF0==0)
    {}
    TR1=0;
    myint116.bytes1.low=TL1;
    myint116.bytes1.hi=TH1;
      TH1=0;
      TL1=0;
      t1=myint116.myword1;//¼ÙÔO׃îl³¬Ç°œyt1
      if(t1>=(dk1-700))
      t1=t1-(dk1-700);
      else
      t1=700+t1;             //Ñaƒ”
    CCF0=0;
    while(CCF0==0)
    {}
    TR1=1;
    CCF1=0;
    while(CCF1==0)
    {}
    TR1=0;
    myint116.bytes1.low=TL1;
    myint116.bytes1.hi=TH1;
      TH1=0;
      TL1=0;
      t2=myint116.myword1;      //¼ÙÔO¹¤îl³¬Ç°œyt2
    f(t2>=700)
    t2=t2-700;
    else
    t2=dk1-(700-t2);           //Ñaƒ”
      if(t1<=t2)               //׃îl³¬Ç°¹¤îl
      {if(t1<250)
       {a=CON/dk1*16-t1;
       DAC0(a);}
       else{
       a=CON/dk1*16-250;
       DAC0(a);}
       n=0;                   //ÞD(zhu¨£n)Èëœyîl
       }
      else                      //¹¤îl³¬Ç°×ƒîl
      {if(t2<250)
       {a=CON/dk1*16+t2;
       DAC0(a);}
        else{
       a=CON/dk1*16+250;
       DAC0(a);}
       n=0;                    //ÞD(zhu¨£n)Èëœyîl
      }
    }
  }
}
void t0_ISR()interrupt 1     //ÖДà·þ„Õ³ÌÐò
{TH0=0x00;
TL0=0x00;
TF0=0;
j++;
if(j==80)
{j=0;
P0_7=1;}
}
void t1_ISR()interrupt 3   //ÖДà·þ„Õ³ÌÐò
{TH1=0x00;
TL1=0x00;
TF1=0;
}


¸½¼þ£º ׃îl¹¤îlæiÏà³ÌÐò.doc (40 K) ÏÂÝd´Î”µ(sh¨´):19
¾W(w¨£ng)Õ¾Ìáʾ: Õˆ²»ÒªÓÃѸÀ×ÏÂÝd¸½¼þ£¬ÈÝÒ׳öåe
¶þÊÖ¹¤¿ØëŠÆ÷
ÇÒÐÐÇÒÕäϧ
¼‰„e: ¹¤¿Ø‚b¿Í
¾«ÈAÖ÷î}: 0
°l(f¨¡)Ìû”µ(sh¨´)Á¿: 2829 ‚€
¹¤¿ØÍþÍû: 4457 üc
ÏÂÝd·e·Ö: 215142 ·Ö
ÔÚ¾€•rég: 3185(С•r)
×¢ƒÔ•rég: 2008-02-22
×îºóµÇä›: 2024-12-25
²é¿´¶þÊÖ¹¤¿ØëŠÆ÷µÄ Ö÷î} / »ØÙN
1˜Ç  °l(f¨¡)±íÓÚ: 2012-08-18 10:10
ß@¿É²»ÊÇһС•r¶þС•rÒ»Ìì¶þÌì¿É½â›Q†–î}ÁË£¡£¡£¡›]³ê„Ú¹ÀÓ‹›]ÈË•þŽÍ棡£¡
šgÓ­Åõˆö¹âÅR¹¤¿Ø×Ô„Ó»¯Ð¡µê£¡¹©‘ª¶þÊÖ²ð™CPLC ¡¢ËÅ·þ¡¢²½ßM¡¢×ƒîlÆ÷¡¢3Ïà¹Ì‘B(t¨¤i)Õ{(di¨¤o)‰ºÕ{(di¨¤o)¹¦Ä£‰K¡¢½Ó¾€¶Ë×ӵȵÈ
http://shop115113109.taobao.com/?spm=a1z10.5-c.0.0.L6cazp&v=1