Single-chip microcomputer development | Design and implementation of automatic blackboard dust removal device based on 51 single-chip microcomputer

Author's homepage: Programming Thousand Paper Cranes

About the author: Java, front-end, and Python have been developed for many years, and have worked as a senior engineer, project manager, and architect

Main content: Java project development, Python project development, university data and AI project development, MCU project design, interview technology arrangement, latest technology sharing

Favorites, likes, don't get lost, it's good to follow the author

Get the source code at the end of the article

Item number: BS-DPJ-002

Foreword:

Teachers teach in the classroom all year round, and the dust of chalk will cause great harm to the health of students, and many teachers will suffer from lung diseases. In classroom teaching, how to effectively eliminate the adverse effects of dust on teachers' bodies is an urgent problem to be solved. In this paper, with 51 single-chip microcomputer as the core, a fully automatic blackboard dust removal device is realized and designed. It is detected by the pressure sensor on the blackboard eraser, and the vacuum cleaner (dust suction fan) is controlled by the 51 single-chip microcomputer to complete the cleaning. The main functions of this system include: pressure detection, button control, light display, electric fan dust removal, etc. Based on sorting out and summarizing relevant literature at home and abroad, this paper firstly introduces the development background and research significance of the automatic blackboard wiper dust removal device, and combines the research situation at home and abroad, puts forward the main research content and system Design ideas. Then, the hardware circuit of the system is designed in detail, and the corresponding single-chip control software is written, and the actual welding and debugging are carried out.

1. Environmental introduction

Locale: C language

 

Development technology: 51 single-chip microcomputer and pressure sensor and other components

2. Project introduction

Dust is a substance in our daily life, which has caused a lot of impact on our life and production. Suspended particles of industrial dust are prone to explosions; dust in daily life will not only pollute the atmosphere, but also cause sandstorms; miners who have worked in dusty mines for a long time are prone to pneumoconiosis; and our teachers are always in the classroom In class, chalk dust will cause great harm to students' health, and many teachers will suffer from lung diseases. Therefore, in teachers' classroom teaching, how to effectively eliminate the adverse effects of dust on teachers' health is an urgent problem to be solved.

With the advancement of science and technology, the degree of mechanization of industrial production continues to increase, how to use modern means to deal with dust pollution in the atmosphere has become a common concern of people. Protecting the environment, safeguarding people's health, and promoting the coordinated development of man and nature are the main trends of today's social development. Single-chip microcomputer is a small microcomputer system consisting of central processing unit CPU, random access memory RAM, read-only memory ROM, various input/output ports, interrupt system, timing/counting system, bus system, and so on.

In this paper, a fully automatic blackboard dust removal device is designed with 51 single-chip microcomputer, and an intelligent dust removal system is realized by using STC89C52 single-chip microcomputer as the core. It is detected by the pressure sensor on the blackboard eraser, and the vacuum cleaner (dust suction fan) is controlled by the microprocessor to complete the cleaning. The main functions include: pressure detection, button control, light display, fan dust removal, etc. On the basis of sorting out and summarizing relevant literature at home and abroad, this paper firstly introduces the development background and research significance of automatic blackboard vacuum equipment, and combines the research situation at home and abroad, puts forward the main research content and system design of this paper train of thought. Then, the hardware circuit design of the automatic blackboard dust removal equipment is completed, the programming of the single chip microcomputer is completed, the welding and debugging of the actual welding machine are completed, and the whole system is summarized.

2.2 Scheme selection of main modules

2.2.1 Main control chip selection

In view of the above problems, this paper selects STC89C52 as the main control chip.

STC89C52 is a low-power, high-performance 8-bit CMOS 8-bit microcontroller with 8 K flash read-only memory that can be rewritten 10,000 times. This device is produced by ATMEL's high-density non-volatile memory technology. MCS-51 command system is compatible with 80C51 pins, and has built-in 8-bit general-purpose CPU and ISP Flash memory. The characteristics of the STC89C52 chip are as follows:

①Instructions and chip pins are compatible with Intel 8051;

②8 KB programmable Flash memory;

③0-33 MHz clock frequency;

④ 128 bytes of RAM (RAM);

⑤32 program input/output pins;

⑥Two 16-bit timing/counting devices;

⑦6 sources of interference, secondary priority;

⑧Full-duplex and serial communication;

⑨Monitoring timer;

⑩2 data indicators.

Among the 40 pins of the STC89C52 microcontroller, 2 are main pins, 2 are crystal oscillator pins, 4 are control or multiplex pins, and 32 are input/output pins.

The pins of the STC89C52 are shown in Figure 2-1.

 

Figure 2-1 STC89C52 microcontroller pin diagram

2.2.2 Sensor selection

A piezo element is a representative active element, also known as a self-generating element. It works by generating an electric charge on a certain surface under a certain pressure.

The sensor has the advantages of small size, light weight, simple structure, and reliable operation. It is especially suitable for measuring dynamics, but it is not suitable for measuring objects with too low frequency, especially static ones. Now, it is mainly used in measuring acceleration, dynamic force, pressure and so on. Disadvantages of piezoelectric elements: large internal resistance and low power. The power is low, the output energy is weak, and the distributed capacitance and noise interference of the cable will have a certain impact on the output performance.

The resistance-strain sensor is a structured sensor that converts different mechanical quantities into electrical signals through the action of resistance-strain. The core component of the resistance strain gauge type resistance strain sensor is based on the resistance-strain effect of the material. It can be used as a sensor alone or combined with an elastic element to form a mechanical quantity sensor.

In this case, due to the mechanical deformation of the material, the resistance and strain of the wire are changed. After the resistance strain gauge converts the stress signal into △ R/R, the change of the strain gauge and resistance of the strain element is usually very small, it is difficult to perform accurate measurement, and it is inconvenient to handle. Therefore, a converter should be used to convert the △ R/R of the strain gauge into a change in voltage or current. The measurement of its electric bridge usually adopts its conversion circuit.

The DC bridge has the characteristics of not being affected by various components and line inductance, capacitance and other factors, and has good anti-interference performance. However, due to the low output signal of its mechanical deformation, it needs to be amplified by a high-gain, high-stability amplifier. Figure 2-2 is a bridge of balancing resistors provided by a DC power link:

Figure 2-2 Internal connection diagram of the sensor

When the output of the bridge is connected to an infinite load resistor, the output that can be seen is disconnected. At this time, the DC bridge is called a voltage bridge, that is, only the output of voltage.

Without considering the internal resistance of the power system, the principle of voltage division is as follows:

 

If R1R3=R2R4 is satisfied, that is

 

 

 

=0, that is, the balance of the bridge. The state of equilibrium is called (2-2)

Strain gauge bridges equalize the bridge prior to testing, so the output voltage of the bridge is only related to the change in resistance due to the strain sensed by the strain gauges.

When working differentially, R1=R-△R, R2=R+△R, R3=R-△R, R4=R+△R, then the output of the bridge is:

                                               

Strain gauge sensors have the following characteristics:

1) It has a wide range of applications and can be made into different mechanical quantity sensors.

2) High resolution, high sensitivity, high accuracy.

3) The structure is light and handy, and has little influence on the sample. It is suitable for various complex environments, suitable for special environments such as high temperature, high pressure, and strong magnetic field, and has good frequency response characteristics.

4) Realization of commercialization, easy operation, long-distance and automatic measurement.

On the basis of comparing and analyzing pressure sensing and resistance strain sensing, the second method is finally selected.

2.2.3 Selection of Fan Ash Cleaning Scheme

Option 1: Adopt the transformer adjustment method, use the principle of electromagnetic induction to step down the 220V voltage to different voltages through the coil, and control the fan motor to connect to the coil with different voltage values ​​to control the speed of the motor, thereby controlling the wind power of the fan.

Option two: use PWM wave speed regulation.

For the first solution, due to the voltage adjustment of the transformer, there is a limitation of the wind speed level, which cannot meet the needs of people. And when the pressure is changed, heat loss will occur, the efficiency is low, and the heat generated is unsafe.

As far as the second option is concerned, one advantage of PWM technology is that it can realize the signal from the processor to the controlled system without digital-to-analog conversion. Keeping the signal in digital format minimizes the effects of noise. When the noise is strong enough, it can turn a logic 1 into a logic 0, or a logic 0 into a logic 1, and can also affect digital signals. PWM has better anti-noise performance than analog control, which is also an important reason why PWM is used as a communication tool in some cases. Converting the analog signal to PWM can greatly improve the communication distance. At the receiving end, a suitable RC or LC network is used to filter the modulated high-frequency square wave to restore it to an analog state.

Generally speaking, PWM technology is economical, space-saving, and has good noise performance, so this paper chooses the second option.

2.2.4 AD conversion chip selection

HX711 is a 24-bit analog-to-digital conversion chip, which is specially used for high-precision pressure sensors. Compared with other similar chips, this chip integrates peripheral devices such as regulated power supply and on-chip clock oscillation, with high integration, fast response speed and strong anti-interference ability. The overall cost of the system is low, the performance is good, and the reliability is good. On-chip, the clock oscillator requires no additional equipment. An auto-reset feature on power-up simplifies the start-up initialization procedure. A diagram of the chip pinouts is shown in Figure 2-3.

 

Figure 2-3 HX711 pin definition

Figure 2-4 shows the typical application circuit of HX711.

 

Figure 2-4 HX711 typical application circuit

2.3 Plan determination

As shown in Figure 2-5 , it is the schematic diagram of the hardware system of this design scheme.

 

Figure 2-5 Schematic diagram of system hardware

Among them, the acquisition of the pressure signal is completed by the pressure sensor YZC-133 , and the analog signal is converted to digital by the AD conversion chip HX711, which is read by the MCU, and intelligently switched by the dust removal fan and the relay. Use the paddle switch of the modal control module to switch the system manually/automatically. In manual mode, use the physical keys to control the dust removal fan;

Three, system display

System Product Display--Front Display

 System product display--reverse display

function test

 

 

 

 

Fourth, the core code display

#include "hx711.h"

void Delay__hx711_us(void)	 //短暂延时
{
	_nop_();
	_nop_();
}

unsigned long HX711_Read(void)	//增益128	  读取重量
{
	unsigned long count; 	 //数据位数
	unsigned char i; 		  //变量i
	unsigned int later=0;	 //延时变量计数

//	EA = 0; 

  	HX711_DOUT=1; 		//输出引脚置位//**All notes can be deleted and modified**//
  	HX711_SCK=0; 		//时钟引脚清零
  	count=0;

  	while((HX711_DOUT)&&(later<10000));	 //等待数据处理完成
	{
		later++;
	  	DelayUs2x(5);
	} 
  	for(i=0;i<24;i++)	 //数据处理
	{ 
	  	HX711_SCK=1; 
	  	count=count<<1;   //数据左移
		HX711_SCK=0; 
	  	if(HX711_DOUT) //读取数据
			count++; 
	} 
 	HX711_SCK=1; 		//时钟置位
    count=count^0x800000;//第25个脉冲下降沿来时,转换数据
	Delay__hx711_us();	//短暂延时
	HX711_SCK=0; 
	 
//	EA = 1;

	return(count);
}

C51 COMPILER V9.54   MAIN                                                                  05/11/2020 09:29:00 PAGE 1   


C51 COMPILER V9.54, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Keil_v5\C51\BIN\C51.EXE main.c OPTIMIZE(8,SPEED) BROWSE DEBUG OBJECTEXTEND TABS(2)

line level    source

   1          #include<reg52.h> //包含头文件,一般情况不需要改动,头文件包含特殊功能寄存器的定义
   2          #include<stdio.h>
   3          #include "delay.h"
   4          #include "hx711.h"
   5          
   6          sbit key1 = P2^0;
   7          sbit key2 = P2^1;
   8          sbit sw = P2^2;
   9          sbit fan = P1^3;
  10          
  11          xdata char dis0[16];     //  显示暂存
  12          xdata char dis1[16];     //  显示暂存
  13          
  14          xdata unsigned long time20ms=0;   //  系统定时计数
  15          unsigned char ReadFlag=0;   //读取标志
  16          
  17          xdata long Weight_Shiwu=0;      //实物重量
  18          xdata unsigned long Weight_Maopi=0;  //读取初始化值
  19          
  20          xdata long midWeight=0;    //差值中间值
  21          
  22          bit reportFlag=0;//上报标志
  23          unsigned int timesCount = 0;//坐下计时
  24          
  25          void Init_Timer0(void);//函数声明
  26          void UART_Init(void);
  27          void uartSendByte(unsigned char dat);
  28          void uartSendStr(unsigned char *s,unsigned char length);
  29          
  30          void main (void)
  31          {     
  32   1        Init_Timer0();        //定时器0初始化
  33   1        UART_Init();
  34   1      
  35   1        DelayMs(2);          //延时有助于稳定//**All notes can be deleted and modified**//
  36   1        Weight_Maopi = HX711_Read();    //读取去皮重量
  37   1      
  38   1        DelayMs(2);//**All notes can be deleted and modified**//
  39   1        Weight_Maopi = HX711_Read();
  40   1      
  41   1      
  42   1        uartSendStr("ready ok!",9);
  43   1      
  44   1        while (1)         //主循环
  45   1        {
  46   2          if(ReadFlag==1)
  47   2          {
  48   3            ReadFlag=0;
  49   3            Weight_Shiwu = HX711_Read();      //读取实物重量
  50   3            Weight_Shiwu = Weight_Shiwu - Weight_Maopi;   //获取净重
  51   3      
  52   3            if(Weight_Shiwu > 430)  //过滤错误    
  53   3            {Weight_Shiwu = (unsigned int)((float)Weight_Shiwu/430); }  //g计算实物的实际重量                                 
  54   3            else {Weight_Shiwu = 0;}
  55   3      
C51 COMPILER V9.54   MAIN                                                                  05/11/2020 09:29:00 PAGE 2   

  56   3            if(Weight_Shiwu<10)Weight_Shiwu = 0;      
  57   3          }
  58   2      
  59   2          if(sw == 1)   //自动模式
  60   2          {
  61   3            if(Weight_Shiwu>500) //超过重量
  62   3            {
  63   4              fan = 0;//打开 风扇   
  64   4            }
  65   3            else
  66   3            {
  67   4              fan = 1;//关闭 风扇
  68   4            }     
  69   3          }
  70   2          else
  71   2          {
  72   3            if(key1 == 0) //超过重量
  73   3            {
  74   4              fan = 0;//打开 风扇   
  75   4            }
  76   3            if(key2 == 0) 
  77   3            {
  78   4              fan = 1;//关闭 风扇
  79   4            }       
  80   3          }
  81   2      
  82   2        }
  83   1      }
  84          
  85          void Init_Timer0(void)
  86          {
  87   1      //**All notes can be deleted and modified**//
  88   1        TMOD |= 0x10;     //使用模式1,16位定时器,使用"|"符号可以在使用多个定时器时不受影响         
  89   1        TH0=(65536-20000)/256;      //重新赋值 20ms
  90   1        TL0=(65536-20000)%256;
  91   1        EA=1;            //总中断打开
  92   1        ET0=1;           //定时器中断打开
  93   1        TR0=1;           //定时器开关打开
  94   1      }
  95          
  96          void Timer0_isr(void) interrupt 1 
  97          {
  98   1        TH0=(65536-20000)/256;      //重新赋值 20ms
  99   1        TL0=(65536-20000)%256;
 100   1      
 101   1        time20ms++;
 102   1        if(time20ms%10==0)    //定时时间到
 103   1        {
 104   2          ReadFlag=1;    //读取标志置位
 105   2        }
 106   1      }
 107          
 108          void UART_Init(void)
 109          {
 110   1          SCON  = 0x50;           // SCON: 模式 1, 8-bit UART, 使能接收  
 111   1          TMOD |= 0x20;               // TMOD: timer 1, mode 2, 8-bit 重装
 112   1          TH1   = 0xFD;               // TH1:  重装值 9600 波特率 晶振 11.0592MHz
 113   1        TL1 = TH1;  
 114   1          TR1   = 1;                  // TR1:  timer 1 打开                         
 115   1          EA    = 1;                  //打开总中断
 116   1          ES    = 1;                  //打开串口中断
 117   1      }
C51 COMPILER V9.54   MAIN                                                                  05/11/2020 09:29:00 PAGE 3   

 118          
 119          void uartSendByte(unsigned char dat)
 120          {
 121   1        unsigned char time_out;
 122   1        time_out=0x00;
 123   1        SBUF = dat;       //将数据放入SBUF中
 124   1        while((!TI)&&(time_out<100))  //检测是否发送出去
 125   1        {time_out++;DelayUs2x(10);} //未发送出去 进行短暂延时
 126   1        TI = 0;           //清除ti标志
 127   1      }
 128          
 129          void uartSendStr(unsigned char *s,unsigned char length)
 130          {
 131   1        unsigned char NUM;
 132   1        NUM=0x00;
 133   1        while(NUM<length) //发送长度对比
 134   1        {
 135   2          uartSendByte(*s);  //放松单字节数据
 136   2          s++;      //指针++
 137   2          NUM++;      //下一个++
 138   2           }
 139   1      }
 140          
 141          
 142          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    547    ----
   CONSTANT SIZE    =     10    ----
   XDATA SIZE       =     48    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      3       6
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      1    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

V. Project Summary

This article takes 51 microprocessor as the core, designs and implements a fully automatic blackboard dust removal device, and its hardware part uses STC89C52 single-chip microcomputer as the core, and its main functions include: pressure detection, key control, light display, fan dust removal, etc. This system mainly includes single chip microcomputer STC89C52, toggle switch, button, pressure sensor, fan drive and power supply circuit. In terms of software, the data detected by the pressure sensor is used to complete the collection and processing of the rubber operation status, and the single-chip microcomputer will alarm the collected data and start and close the fan, thus achieving an intelligent dust removal effect.

Guess you like

Origin blog.csdn.net/BS009/article/details/132299369