Ultrasonic water level measurement control system C language source program

Publisher:不羁少年Latest update time:2015-10-26 Source: eefocusKeywords:Ultrasonic Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
    This article introduces an ultrasonic water level measurement and control system C language source program. The ultrasonic water level measurement and control system designed in this paper is a non-contact liquid level measurement and control system that uses ultrasonic technology, electronic technology, and electromagnetic switch technology. It can be used in certain specific occasions or in relatively harsh environments, and has been widely used in industrial monitoring and control. In recent years, the continuous development of industrial level has put forward higher and higher requirements on the accuracy, breadth and anti-interference of liquid level measurement. The ultrasonic distance measurement technology itself is also constantly improving and developing. The distance meter is more miniaturized and intelligent, and gradually achieves high accuracy, high reliability, safety and multi-function. The
   ultrasonic water level measurement and control system C language source program, electronic small production can measure and display the liquid level, and can also limit the liquid level to a certain range through the single-chip microcomputer control. In the case of single-chip microcomputer control failure, an alarm signal is issued to remind the staff to perform manual control. The research content includes the basic principles and methods of ultrasonic distance measurement, the analysis and solution of factors affecting accuracy, the control method of single-chip microcomputer to valve, the overall scheme design of the monitoring system, hardware design, software process design, etc. After the design is completed, a set of usable ultrasonic distance meters is provided, and the measurement range and measurement accuracy meet the needs of general industrial applications. After the design is completed, a set of liquid level monitoring system that can be used in general industrial production should be provided. Through the entire process of graduation design, you can comprehensively use the knowledge of sensors, single-chip microcomputers, electronic circuits and program design to exercise and improve your hands-on ability and the ability to participate in scientific research.
This ultrasonic water level measurement and control system C language source program involves almost all the professional courses learned, such as single-chip microcomputers, automatic control principles, digital circuits, analog circuits, circuit analysis, software technology, intelligent detection and conversion technology, etc., which well reflects the requirements of comprehensive training. This electronic small production design belongs to a complete system. There are many factors to consider in the design process, but the design function is relatively simple and there will not be too much difficulty. The difficulty of the topic is moderate. It can not only consolidate the knowledge and skills learned, but also improve them. Compared with other topics, this topic has relatively more information and it is relatively easy to search for information. But for undergraduates, it is also difficult to choose the most suitable information from a large number of materials of varying quality. The ultrasonic water level measurement and control system C language source program is a good exercise for design students.
//Ultrasonic water level measurement and control system C language source program
#include
#define uchar unsigned char
#define uint  unsigned int
sbit Trig=P1^0;sbit Echo=P3^2;
sbit lcden=P0^4;
sbit lcdrs=P0^1;
sbit alertl=P1^1;//Low water level alarm, red light is on
sbit alertm=P1^7;//Middle water level green light is on
sbit alerth=P1^4;//High water level alarm, yellow light is on
sbit pumb=P0^2;//low vol is avalibal sbit
power=P3^5;
uint time,distance,waterlevel;
uchar timeH,timeL;
bit succeed_flag;
void delay(uint z);

//Ultrasonic water level measurement and control system C language source program Electronic small production
void init()
{
 power=0;   //power is ok
 lcden=0;   //low enble http://www.duankudp.com/
  write_com(0x38);
 write_com(0x0c); //display open,cursor off,blink off
 write_com(0x06); //pointer auto add 1
 write_com(0x01); //clear screen and pointer
 write_com(0x80);
 TMOD=0x10;   //time1,16 bit timmer
 EA=0;    //open entire interrupt
 Trig=0;
 Echo=0;
 delay(1);
}
//****************************************************************** void delay(uint z) { uint x,y; for(x=z;x>0;x--) for (y=110;y>0;y--); } //************************************************************************************************************************************************************************************************************ void
delay(uint z)
{
 uint x,y; for(x=z;x>0;x--) for ( y =110;y>0;y--) ; write_dat((temp/100)+0x30); delay(20); write_dat(temp/10+0x30); delay(20); write_dat(temp+0x30); } //**************************************************************** void delay_20us() { uchar a ; for(a=0;a<100;a++); }
 
 



 
       
 
 
 
 
 
  
 


 
   
   
 
//***************************************************************
void display1()
{
uchar code table[]="SIAS UNIVERSITY ";
uchar code table1[]="ZZS 20071521258 ";
uchar num;
write_com(0x80);
for(num=0;num<16;num++)
 {
 write_dat(table[num]);
 delay(300);
 }
write_com(0x80+0x40);
for(num=0;num<16;num++)
 {
 write_dat(table1[num]);
 delay(300);
 }
write_com(0x01);
delay(1000);
}
//*******************************************************************
//***************************************************************
//External interrupt 0, used to judge the echo level //Ultrasonic water level measurement control system C language source program
void exter()  interrupt 0   // 16 bit  display1(); init1 (); while(1) {
 alertl 
    =  1 ;   //low alert alertm
    =1;    // middle alert alerth =  1 ; // high alert EA  =  0 ;  // off entire interrupt Trig =  1  ; // ultrasonic Trigger  delay_20us (  )  ; //delay 20us Trig=0;  //20us's Pulse while(Echo==0); //wait Echo change High Vol succeed_flag=0; //clear succeed flag EA=1;  //open entire interruot EX0=1;  //open exinterrupt0 TH1=0;  //clear timer1's high 8 bit TL1=0;  //clear timer1's low 8 bit TF1=0;  //clear timer1's overflow bit TR1=1 ;  //start timer1 delay(20);  //waitting TR1=0;  //stop timer1 EX0=0;  //off exinterrupt0 if(succeed_flag==1) {  time=timeH*256+timeL;  //entire time  distance=time*0.172;  //s=t*340/2*1000mm waterlevel=163-distance;  //
    
           
 




   
        
        
    




        
 
 
        
   
      
    
 
                
              
        
              
       
       
         
               
               
               
               
               
           
               
               
      
      
               
             
     
  if(waterlevel>=0&&waterlevel<=163)
           display(waterlevel);
 
                            
     if(succeed_flag==0)
      {
         distance=0;         //clear if no echo //Ultrasonic water level measurement control system C language source program
        
       }
  if(waterlevel>=0&&waterlevel<=50)
      {
 write_com(0x8C);
 write_dat('L');
       alertl=0;//RED Light,low water level
 pumb=0;//open pumb,add water http://www.5imcu.net/
 }
 else if(waterlevel>50&&waterlevel<=100)
     {
           write_com(0x8C);
  write_dat('M');
  alertm=0;
  }
  else if(waterlevel>100&&waterlevel<=163)
  {
   write_com(0x8C);
         write_dat('H');
   alerth=0;
   pumb=1;//off pumb http://www.5imcu.net/
   }
  
 
 delay(200);
             
   }
}
//******************************************************************
Keywords:Ultrasonic Reference address:Ultrasonic water level measurement control system C language source program

Previous article:A simple single-chip traffic light program
Next article:Ultrasonic distance measurement program using 18B20 for temperature compensation

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号