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

📄 7290.lst

📁 用89s52,访问ZLG7290(LED数码显示)
💻 LST
📖 第 1 页 / 共 4 页
字号:
 470          /********定时1ms***********/
 471          void delay3(uint Tm_count)
 472          {
 473   1        uint i;
 474   1        while (Tm_count--)
 475   1        {      
 476   2               Watch();
 477   2               for (i=0; i<90; i++) {};
 478   2        }
 479   1      }
 480          
 481          /******************/
 482          /*产生输液量的定时*/
 483          /******************/
 484          void Time_0(void) interrupt 1
 485          { 
 486   1        static uchar count; 
 487   1        
C51 COMPILER V7.09   7290                                                                  08/23/2004 17:15:04 PAGE 9   

 488   1             TR0 = 0;
 489   1             EA  = 0;
 490   1                 TH0 = TH0_T;
 491   1             TL0 = TL0_T;
 492   1             if (count >= 13)  
 493   1             {     
 494   2                       
 495   2                               V_ml++;
 496   2                       count = 0;
 497   2                               _nop_();
 498   2                               _nop_();
 499   2                 }
 500   1                  else count++;
 501   1             EA = 1;
 502   1             TR0 = 1;
 503   1      }
 504          
 505          /****************************************/
 506          /*************向计算机发数据*************/
 507          /****************************************/
 508          
 509          
 510          /*********************************************/
 511          /*************Dalls(18B20)********************/
 512          /*********************************************/
 513          /* C_f=1 华氏,C_f=0 摄氏 */
 514          void temperature(bit C_f)
 515          {
 516   1             tmstart();         
 517   1                 delay3(100);
 518   1             now_temper = read_temper(C_f);
 519   1             
 520   1      }
 521          /**************************/
 522          bit tmreset(void)
 523          {
 524   1        uint i;
 525   1        uchar j;
 526   1        EA = 0;
 527   1        TMDAT = 0;
 528   1        i = 103; while (i>0) i--;
 529   1        TMDAT =1;
 530   1        i = 4; while (i>0) i--;
 531   1        for (j=0xff; j>0; j--)
 532   1        {
 533   2            if (~TMDAT)  break;
 534   2        }
 535   1        EA = 1;
 536   1        if (j == 0) return(1); /* 无温度检测无件 */
 537   1        return (0); 
 538   1      }
 539          /***************************/
 540          uchar readbyte(void)
 541          {
 542   1        uint i;
 543   1        uchar k,j,dat = 0;
 544   1        EA = 0;
 545   1        for (k=1; k<=8; k++)
 546   1        {
 547   2                 
 548   2              TMDAT = 0; i++;
 549   2              TMDAT = 1; i++; i++;
C51 COMPILER V7.09   7290                                                                  08/23/2004 17:15:04 PAGE 10  

 550   2              j = TMDAT;
 551   2              i = 8;while (i>0) i--;
 552   2              dat = (j << 7)|(dat >> 1);
 553   2         }
 554   1         EA = 1;
 555   1         return(dat);   
 556   1      }
 557          /****************************/
 558          void writebyte(uchar dat)
 559          {
 560   1         uint i;
 561   1         uchar j;
 562   1         bit testb;
 563   1         EA = 0;
 564   1         for (j=1; j<=8; j++)
 565   1         {
 566   2              testb = dat&0x01;
 567   2                      dat = dat >> 1;
 568   2              if (testb)
 569   2                  {
 570   3                             TMDAT = 0;
 571   3                                 i++; i++;
 572   3                                 TMDAT = 1;
 573   3                     i = 8; while (i>0) i--;
 574   3              }
 575   2              else {
 576   3                           TMDAT = 0;
 577   3                           i = 8; while (i>0) i--;
 578   3                               TMDAT = 1;
 579   3                               i++; i++;
 580   3                      }
 581   2              }
 582   1              EA = 1;
 583   1      }   
 584          /*******************************/
 585          void tmstart (void)
 586          {
 587   1           bit flag_1;
 588   1           do
 589   1               {
 590   2                     flag_1 = tmreset();
 591   2                         if (flag_1) {sound(True,1);delay3(100);}
 592   2               } while (flag_1);
 593   1               delay3(1);
 594   1               writebyte(0xcc);
 595   1               writebyte(0x44);
 596   1      }
 597          uchar read_temper(bit C_F)
 598          {
 599   1           
 600   1           uchar a,b,y1,y2,y3;
 601   1               uint i = 0;
 602   1               tmreset();
 603   1               delay3(1);
 604   1               writebyte(0xcc);
 605   1               writebyte(0xbe);
 606   1               a = readbyte();  //LSB
 607   1               b = readbyte();  //MSB
 608   1               //*********************
 609   1               if (C_F)
 610   1               {
 611   2                      AD = a;
C51 COMPILER V7.09   7290                                                                  08/23/2004 17:15:04 PAGE 11  

 612   2                      AD <<= 4;
 613   2                          if (AD_7) i = 50 ;
 614   2                          AD <<= 1;
 615   2                          if (AD_7) i= i + 25;
 616   2                          y1 = a >> 4;
 617   2                          y2 = b << 4;
 618   2                          y3 = y1 | y2;
 619   2      
 620   2                                      y1 = (i * 9) / 100;
 621   2                                      i = y3;
 622   2                      y3 = (i * 9 + y1)/5+32;
 623   2           }
 624   1                 else
 625   1                 {
 626   2                      y1 = a >> 4;
 627   2                          y2 = b << 4;
 628   2                          y3 = y1 | y2;
 629   2             }  
 630   1             disp(y3,1);
 631   1                 return (y3);
 632   1      }
 633          /***************************
 634          id = True; 为温度
 635          ***************************/
 636          void disp(uchar y3,bit id)
 637          {
 638   1             uchar a;
 639   1                 uchar *p;
 640   1                 p = WriteBuf;
 641   1             a = y3/100;
 642   1             if (a == 0) 
 643   1                 {
 644   2                          
 645   2                          if (id) 
 646   2                                      {
 647   3                                         WriteBuf[0] = 0x07;
 648   3                                         WriteBuf[1] = 0x62;
 649   3                                         WriteBuf[2] = 0x1f;
 650   3                                 Zlg_write(p);
 651   3                                      }                 
 652   2                                      a = y3%100;
 653   2             }
 654   1                    else 
 655   1                 {
 656   2                           if (id) 
 657   2                                       {
 658   3                                                 WriteBuf[0] = 0x07;
 659   3                                         WriteBuf[1] = 0x62;
 660   3                                         WriteBuf[2] = a;
 661   3                                 Zlg_write(p);
 662   3                                                
 663   3                                       }         
 664   2                                       a = y3%100;
 665   2             }
 666   1             if (id) 
 667   1                 { 
 668   2                       y3 = 4;
 669   2                               WriteBuf[0] = 0x07;
 670   2                           WriteBuf[1] = 0x63;
 671   2                           WriteBuf[2] = a/0x0a;
 672   2                   Zlg_write(p);
 673   2                               WriteBuf[0] = 0x07;
C51 COMPILER V7.09   7290                                                                  08/23/2004 17:15:04 PAGE 12  

 674   2                           WriteBuf[1] = 0x64;
 675   2                           WriteBuf[2] = a%0x0a;
 676   2                   Zlg_write(p);
 677   2                               
 678   2             }
 679   1                        else 
 680   1                 {
 681   2                       
 682   2                       if  (y3 > 99) 
 683   2                               {      
 684   3                                      y3 = 1; 
 685   3                                              Zlg_writebyte(0x10,0x02);
 686   3                                              Zlg_writebyte(0x11,0x02);
 687   3                                              delay3(50);
 688   3                   }
 689   2                                    else
 690   2                               {     
 691   3                                  y3 = 1;
 692   3                          WriteBuf[0] = 0x07;
 693   3                                  WriteBuf[1] = 0x60;
 694   3                                  WriteBuf[2] = a/0x0a;
 695   3                          Zlg_write(p);
 696   3                                              WriteBuf[0] = 0x07;
 697   3                                  WriteBuf[1] = 0x61;
 698   3                                  WriteBuf[2] = a%0x0a;
 699   3                          Zlg_write(p);
 700   3                                              
 701   3                               }
 702   2             }
 703   1       
 704   1      }
 705          
 706          void sound(bit f,uchar i)
 707          {
 708   1          for (;i>0;i--) 

⌨️ 快捷键说明

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