Intelligent temperature control fan design based on 51 microcontroller – digital tube display

Intelligent temperature control fan design based on 51 microcontroller

(Simulation + Program + Schematic + Design Report)

Function introduction

Specific functions:

1. The digital tube displays the current temperature in real time

2. You can set the upper and lower temperature limits

3. When the temperature is lower than the lower limit temperature, the cooling motor does not run

When the temperature is between the upper and lower temperatures, the cooling motor runs at 50%

When the temperature is higher than the upper limit temperature, the cooling motor runs at full speed

/******************51 Microcontroller Intelligent Temperature Control Fan Design******************

*********************original design*******************
***************Measurement range -55℃- + 125℃***************
******Upper and lower limit temperature setting range -55℃- + 125℃******
******When the temperature is lower than the lower limit temperature, the cooling motor does not run*********
******When the temperature is higher than the upper limit temperature, the cooling motor runs at full speed******
******When the temperature is between the upper and lower temperatures, the cooling motor runs 50%******
Explanation: The difference between the computer simulation running platform and the physical hardware running platform,
It can run on the real thing but the simulation is not ideal. In order to make the simulation function manifest,
I give two sets of parameters here: 0: physical operating parameters 1: simulation operating parameters,
Their principles are exactly the same, but the platforms they run on are different.
0. It is a physical hardware platform 1. Protues platform)
Two operating parameters are defined in the program:
0: Actual operating parameters t=2
i(0-3000) in the temperature processing function
Timer interrupt timing time 0.25ms 0xff06
1: Simulation running parameters t=300
i(0-400) in the temperature processing function
Timer interrupt timing time 10ms 0xd8f0
************************************************/
#include <REGX52.H>

#define uchar unsigned char //uchar replaces unsigned char
#define uint unsigned int //uint replaces unsigned int

uchar display[4]={0x00,0x00,0x00,0x00}; //Define the display buffer (initialized to 0x00 means display 0000)
uchar code table[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0xBF,0x89,0xC7};
//Common Yang digital tube 0 1 2 3 4 5 6 7 8 9 - H L

//Pin definition:
#define SMG_XS P0 //Define digital tube display

#define IA P2_1 //Motor control interface
#define IB P2_0
#define LED1 P1_5 //Indicator light 1
#define LED2 P3_5 //Indicator light 2
#define q_kz P2_3 //(thousand digit) digital tube position selection control (the first digital tube)
#define b_kz P2_4 //(white bit) digital tube bit selection control (2nd digital tube)
#define s_kz P2_5 //(tens) digital tube bit selection control (the 3rd digital tube)
#define g_kz P2_6 //(ones digit) digital tube position selection control (the 4th digital tube)
#define IO_18b20 P1_0//Define DS18B20 interface
#define Key1 P1_1 //Temperature upper and lower limit setting keys
#define Key2 P1_6 //Upper and lower limit temperature plus button
#define Key3 P3_2 //Upper and lower limit temperature minus button
#define Key4 P3_7 //Real object/simulation operation switching button (power-on default is: physical operation parameters)

float wendu; //Define the real decimal temperature variable
int big_wendu; //Decimal temperature variable after magnification 10 times (mainly convenient for temperature display accurate to one decimal place)
int high=35; //Define the upper limit temperature variable
int low=25; //Define the lower limit temperature variable
uchar flag=0; //Define the key temperature setting flag (0: normal display temperature 1: display upper limit temperature value 2: display lower limit temperature value)
bit jw_flag; //Define cooling fan operation indicator flag bit
//(0: Indicator light 1 flashes, the motor runs at 50% 1: Indicator light 1 and indicator light 2 both flash, the motor runs at full speed)
int num=0; //Define the flashing frequency variable of indicator lights 1 and 2
uint t=2; //The digital tube dynamic scanning base is 2 (t=2 is the actual operating parameter), and (t=300 is the simulation operating parameter)
bit ts=0; //Define the temporary debugging flag bit as 0 (0: physical operating parameters 1: simulation operating parameters)

/************************DS18B20 part******************/
void delay_ms(uint count) //Delay function (Keil software tests that this function runs about 1ms)
{
uint i;
  while(count)
  {
    i=125;
    while(i>0) {i--;} //When i>0, execute i to decrement itself by 1 to achieve the delay effect
    count--;
  }
}

void ds18b20_init() //DS18B20 initialization (written according to DS18B20 initialization timing)
{
uint i;
  IO_18b20=0; //Pull IO_18b20 low first
  i=100;
  while(i>0){i--;} //Delay for a period of 803us (the delay duration is between 480-960us)
  IO_18b20=1; //Pull IO_18b20 high again
  i=7; //Since DS18B20 needs to wait for 15-60US, it will automatically respond by pulling this pin low.
  while(i>0){i--;} //So here we need to delay for a short period of time (delay 59us in the program) to wait for the DS18B20 response
}

bit ds18b20_read_bit() //Read one bit function and return "dat" (written according to the timing of reading one byte of DS18B20)
{
uint i;
   bit dat; //Define bit variable dat
EA=0; //When operating DS18b20, first turn off the timer interrupt (to prevent the timer interrupt from affecting the operation of DS18b20 and causing errors)
   IO_18b20=0; //Pull IO_18b20 low first*** (from pulling IO_18b20 low to reading the data status on IO_18b20, the process cannot exceed 15us)
   i + + ; //Small delay ↑
   IO_18b20=1; //Pull IO_18b20 high again (release the pin), it cannot exceed 15us
   i + + ; //Small delay
EA=1; //Enable timer interrupt again ↓
   dat=IO_18b20; //The read data is sent to dat** (from pulling IO_18b20 low to reading the data status on IO_18b20, the process cannot exceed 15us)
i=8;
   while(i>0) {i--;} //Delay
   return (dat); //Return the read data dat
}

uchar ds18b20_read_byte() //Read a byte
{
  uchar i,j,dat; //Define i,j,dat variables
  dat=0; //dat is initialized to 0
  for(i=0;i<8;i + + ) //for loop passes 8-bit data (i.e. one byte)
  {
j=ds18b20_read_bit(); //The function will read one bit and return "dat", which will be transferred to j
    dat=(j<<7)|(dat>>1); //The lowest bit of the read data is at the front, so that exactly one byte is in dat
  }
  return(dat); //Return one byte data
}

void ds18b20_write_byte(uchar dat)//Write a byte
{
uint i;
  uchar j;
  bit test; //Define temporary bit variable test
  for(j=0;j<8;j + + ) //for loop passes 8-bit data (i.e. one byte)
  {
    test=dat & amp;0x01; //Take out the lowest bit of dat and put it in test
    dat=dat>>1; //Move dat one bit to the right
    if(test) //If test is 1,"write 1 part (written according to DS18B20 writing"1" timing)"
    {
EA=0; //When operating DS18b20, first turn off the timer interrupt (to prevent the timer interrupt from affecting the operation of DS18b20 and causing errors)
      IO_18b20=0; //Pull IO_18b20 low first
      i + + ; //Small delay, (timing time requirement is greater than 1us)
EA=1; //Turn on the timer interrupt again
      IO_18b20=1; //Pull IO_18b20 high again (release the bus)
      i=8;
while(i>0) {i--;}//Delay 69us (timing time requirement is greater than 60us)
    }
    else //otherwise test is 0,"write the 0 part (written according to the DS18B20 writing"0" timing)"
    {
EA=0; //When operating DS18b20, first turn off the timer interrupt (to prevent the timer interrupt from affecting the operation of DS18b20 and causing errors)
      IO_18b20=0; //Pull IO_18b20 low first
      i=8;
EA=1; //Turn on the timer interrupt again
while(i>0) {i--;}//Delay for 69us (the timing requirement is greater than 60us and less than 120us)
      IO_18b20=1; //Pull IO_18b20 high again
      i + + ;i + + ; //Small delay
    }
  }
}

/****************************************************** *********/
void temp_change() //Send temperature conversion command function
{
ds18b20_init(); //Initialize DS18B20
  delay_ms(1); //Delay and wait 1ms, leaving some room for time, because the DS18B20 device will take the initiative after responding
//Pull it low for 60-240us, and then DS18B20 will actively release the bus, that is, actively pull the IO port high
  ds18b20_write_byte(0xcc); //Skip the serial number command
  ds18b20_write_byte(0x44); //Send temperature conversion command
}


/****************************************************** *******************/
int temperature() //Get the temperature function
{
  int temp; //Define temperature value variable (integer variable)
  uchar a,b; //Define variables a,b to store the low 8 bits and high 8 bits of the temperature value
  ds18b20_init(); //Initialize DS18B20
  delay_ms(1); //Delay and wait 1ms, leaving some room for time, because the DS18B20 device will take the initiative after responding
//Pull it low for 60-240us, and then DS18B20 will actively release the bus, that is, actively pull the IO port high
  ds18b20_write_byte(0xcc); //Skip the serial number command
  ds18b20_write_byte(0xbe); //Send read data command

  a=ds18b20_read_byte(); //Continuously read two bytes of data (a is the lower 8-bit data)
  b=ds18b20_read_byte(); //b is the high 8-bit data
  temp=b; //Send the high 8-bit data to temp
  temp<<=8; //Move temp to the left by 8 bits, so that the high 8 bits of data are stored in the high 8 bits of temp
  temp=temp|a;//Two bytes are combined into an integer variable (temp is the upper 8 bits"bitwise or"a is the lower 8 bits)
  return temp;//Return the temperature value
}

/******************The above is part of DS18B20******************/

void delay(uint time) //Nigital tube scanning delay function
{
uint i,j;
for(i=time;i>0;i--)
for(j=3;j>0;j--);
}

void delay_anjian(uint time) //Button delay debounce function
{
uint i,j;
for(i=time;i>0;i--)
for(j=110;j>0;j--);
}

void disp0() //Normal display of the current temperature function (display buffer content)
{
if(wendu>0) //If the temperature is greater than 0, it is a positive number
{
SMG_XS=table[display[0]]; //Display the hundredth digit value of temperature data
q_kz=0;b_kz=s_kz=g_kz=1; //Allow the (thousand-digit) digital tube bit (the first digital tube) to light up
delay(t); //Delay (blanking)
q_kz=1;
}
else //otherwise the temperature is less than 0 and is a negative number
{
SMG_XS=table[10]; //Display negative sign"-"
q_kz=0;b_kz=s_kz=g_kz=1; //Allow the (thousand-digit) digital tube bit (the first digital tube) to light up
delay(t); //Delay (blanking)
q_kz=1;
}

SMG_XS=table[display[1]]; //Display the ten-digit value of the temperature data
b_kz=0;q_kz=s_kz=g_kz=1; //Allow the (hundreds) digital tube bit (the second digital tube) to light up
delay(t); //Delay (blanking)
b_kz=1;


SMG_XS=table[display[2]] & amp;0x7f; //Display the single digit value of the temperature data and add a decimal point
s_kz=0;q_kz=b_kz=g_kz=1; //Allow the (tens) digital tube bit (the third digital tube) to light up
delay(t); //Delay (blanking)
s_kz=1;

SMG_XS=table[display[3]]; //Display temperature data to one decimal place
g_kz=0;q_kz=b_kz=s_kz=1; //Allow the (ones digit) digital tube bit (the 4th digital tube) to light up
delay(t); //Delay (blanking)
g_kz=1;
}

void disp1(high) //Display upper limit temperature function
{
SMG_XS=table[11]; //Display "H"
q_kz=0;b_kz=s_kz=g_kz=1; //Allow the (thousand-digit) digital tube bit (the first digital tube) to light up
delay(t); //Delay (blanking)
q_kz=1;
if(high/100!=0) //If the hundredth digit of the upper limit temperature is not 0 (indicating that the upper limit temperature value exceeds 100)
{
SMG_XS=table[high/100]; //Display the hundreds digit of the upper limit temperature
b_kz=0;q_kz=s_kz=g_kz=1; //Allow the (hundreds) digital tube bit (the second digital tube) to light up
delay(t); //Delay (blanking)
b_kz=1;

SMG_XS=table[high 0/10]; //Display the tenth digit of the upper limit temperature
s_kz=0;q_kz=b_kz=g_kz=1; //Allow the (tens) digital tube bit (the third digital tube) to light up
delay(t); //Delay (blanking)
s_kz=1;
\t
SMG_XS=table[high]; //Display the units digit of the upper limit temperature
g_kz=0;q_kz=b_kz=s_kz=1; //Allow the (ones digit) digital tube bit (the 4th digital tube) to light up
delay(t); //Delay (blanking)
g_kz=1;
}
else if(high>=0) //If the upper limit temperature value is greater than or equal to 0 (indicating that the temperature value is a positive number)
{
SMG_XS=table[high/10]; //Display the tenth digit of the upper limit temperature
s_kz=0;q_kz=b_kz=g_kz=1; //Allow the (tens) digital tube bit (the third digital tube) to light up
delay(t); //Delay (blanking)
s_kz=1;
\t
SMG_XS=table[high]; //Display the units digit of the upper limit temperature
g_kz=0;q_kz=b_kz=s_kz=1; //Allow the (ones digit) digital tube bit (the 4th digital tube) to light up
delay(t); //Delay (blanking)
g_kz=1;
}
else //otherwise the upper limit temperature value is a negative number (i.e. subzero temperature value)
{
SMG_XS=table[10]; //Display "-" (because it is a negative number, so add the "-" sign)
b_kz=0;q_kz=s_kz=g_kz=1; //Allow the (hundreds) digital tube bit (the second digital tube) to light up
delay(t); //Delay (blanking)
b_kz=1;
high=0-high; //Positive upper limit temperature value

SMG_XS=table[high/10]; //Display the tens digit of the upper limit temperature
s_kz=0;q_kz=b_kz=g_kz=1; //Allow the (tens) digital tube bit (the third digital tube) to light up
delay(t); //Delay (blanking)
s_kz=1;
\t
SMG_XS=table[high]; //Display the units digit of the upper limit temperature
g_kz=0;q_kz=b_kz=s_kz=1; //Allow the (ones digit) digital tube bit (the 4th digital tube) to light up
delay(t); //Delay (blanking)
g_kz=1;
}
}

void disp2(low) //Display lower limit temperature function
{
SMG_XS=table[12]; //Display "L"
q_kz=0;b_kz=s_kz=g_kz=1; //Allow the (thousand-digit) digital tube bit (the first digital tube) to light up
delay(t); //Delay (blanking)
q_kz=1;
if(low/100!=0) //If the hundreds digit of the lower limit temperature is not 0 (indicating that the upper limit temperature value exceeds 100)
{
SMG_XS=table[low/100]; //Display the hundreds digit of the lower limit temperature
b_kz=0;q_kz=s_kz=g_kz=1; //Allow the (hundreds) digital tube bit (the second digital tube) to light up
delay(t); //Delay (blanking)
b_kz=1;

SMG_XS=table[low 0/10]; //Display the tens digit of the lower limit temperature
s_kz=0;q_kz=b_kz=g_kz=1; //Allow the (tens) digital tube bit (the third digital tube) to light up
delay(t); //Delay (blanking)
s_kz=1;
\t
SMG_XS=table[low]; //Display the units digit of the lower limit temperature
g_kz=0;q_kz=b_kz=s_kz=1; //Allow the (ones digit) digital tube bit (the 4th digital tube) to light up
delay(t); //Delay (blanking)
g_kz=1;
}
else if(low>=0) //If the lower limit temperature value is greater than or equal to 0 (indicating that the temperature value is a positive number)
{
SMG_XS=table[low/10]; //Display the tens digit of the lower limit temperature
s_kz=0;q_kz=b_kz=g_kz=1; //Allow the (tens) digital tube bit (the third digital tube) to light up
delay(t); //Delay (blanking)
s_kz=1;
\t
SMG_XS=table[low]; //Display the units digit of the lower limit temperature
g_kz=0;q_kz=b_kz=s_kz=1; //Allow the (ones digit) digital tube bit (the 4th digital tube) to light up
delay(t); //Delay (blanking)
g_kz=1;
}
else //otherwise the lower limit temperature value is a negative number (i.e. subzero temperature value)
{
SMG_XS=table[10]; //Display "-" (because it is a negative number, so add the "-" sign)
b_kz=0;q_kz=s_kz=g_kz=1; //Allow the (hundreds) digital tube bit (the second digital tube) to light up
delay(t); //Delay (blanking)
b_kz=1;
low=0-low; //Put the lower limit temperature value positive

SMG_XS=table[low/10]; //Display the tens digit of the lower limit temperature
s_kz=0;q_kz=b_kz=g_kz=1; //Allow the (tens) digital tube bit (the third digital tube) to light up
delay(t); //Delay (blanking)
s_kz=1;
\t
SMG_XS=table[low]; //Display the units digit of the lower limit temperature
g_kz=0;q_kz=b_kz=s_kz=1; //Allow the (ones digit) digital tube bit (the 4th digital tube) to light up
delay(t); //Delay (blanking)
g_kz=1;
}
}

void SMG_disp() //Nigital tube display function
{
if(flag==0) //if flag=0
{
disp0(); //Normally display the current temperature function (display buffer content)
}
if(flag==1) //if flag=1
{
disp1(high); //Display upper limit temperature function
}
if(flag==2) //if flag=2
{
disp2(low); //Display the lower limit temperature function
}
}

void xitong_init() //System initialization waits for the complete conversion of DS18b20 to be completed. Before completion, the digital tube displays "----"
{
EA=1; //Enable total interrupt
TMOD=0x01; //Timer 0 is mode 1
TH0=0xff; //12M crystal oscillator timing time 0.25ms 0xff06
TL0=0x06;
ET0=1; //Enable timer 0 interrupt
TR0=0; //Do not start timer 0 first

SMG_XS=table[10]; //Nigital tube display "----"
q_kz=b_kz=s_kz=g_kz=0; //Allow 4-digit digital tube display
temp_change(); //Send temperature conversion command function
delay_ms(980); //Waiting delay 980ms>750ms, leaving some room for time;
//(Because the factory default maximum temperature conversion time of DS18b20 is 750ms,
//In order to prevent the temperature value read out for the first time from being an incorrect value (the typical error value is generally 85℃
//The delay time in the program needs to be at least 750ms)*/
}

void wendu_data_cl() //Temperature data processing
{
static uint i=0; //Define loop variables
i + + ; //i increases by 1 (i starts from zero and increases by 1)
if(ts==0) //0: physical operating parameters
{
if(i==3000) {i=0;}//If i=3000, clear i to 0 (control i between 0-3000), and the range of i determines how fast the temperature data is refreshed
}
else //1: Simulation running parameters
{
if(i>=400) {i=0;}
}
if(i==0) //If i=0, perform temperature conversion
{
temp_change();//Send temperature conversion command function
}
if(i==100) //If i=100, process the data sent by DS18B20 and process it at the same time
{ //In order to display the temperature value to one decimal place accurately
wendu=temperature()*0.0625; //Get the real decimal temperature value, because DS18B20
//It can be accurate to 0.0625 degrees, so the lowest bit of the read back data represents 0.0625 degrees
if(wendu<=low) //The temperature value is lower than the lower limit temperature (indicating that the temperature is too low and cannot be cooled, the cooling motor fan will not run)
{
TR0=0; //Close TR0
LED1=LED2=1; //Indicator light 1 and indicator light 2 are not on
IA=IB=0; //The cooling motor fan does not rotate
}
else if(wendu>=high)//The temperature value is higher than the upper limit temperature (indicating that the temperature is too high and needs to be cooled down, the cooling motor fan runs at full speed)
{
jw_flag=1; //1: Both indicator light 1 and indicator light 2 flash
IA=1;IB=0; //The cooling motor fan runs at full speed
TR0=1; //Open TR0
}
else //Otherwise the temperature is within the normal temperature range (indicating that the temperature is appropriate and needs to be maintained, the cooling motor fan runs at 50%)
{
jw_flag=0; //0: Indicator 1 flashes
TR0=1; //Open TR0
}
big_wendu=wendu*10; //Enlarge ten times. The purpose of this is to convert the first digit after the decimal point into a displayable number.
if(wendu<0) //(if the temperature data is a negative number) determine whether the first digit displays a positive number or a negative number
{
big_wendu=0-big_wendu; //Convert the data into positive numbers to facilitate data display
}
else //otherwise the temperature data is a positive number
{
display[0]=big_wendu/1000;//Display the hundreds digit value of temperature data
}
big_wendu=big_wendu 00;
display[1]=big_wendu/100; //Display the ten-digit value of temperature data
big_wendu=big_wendu 0;
display[2]=big_wendu/10; //Display the single digit value of temperature data
display[3]=big_wendu; //Display temperature data to one decimal place
}
}

void anjian_cl() //Key processing function
{
if(Key1==0) //temperature upper and lower limit setting button press
{
delay_anjian(5); //Delay debounce
if(Key1==0) //Then determine whether the temperature upper and lower limit setting keys are pressed.
{
flag + + ; //Button temperature setting flag plus 1
while(flag==3) {flag=0;}//When flag=3.flag is cleared to 0 (let 0<=flag<=2)
q_kz=b_kz=s_kz=g_kz=1; //Turn off the digital tube display
TR0=0; //Close TR0 (close timer 0)
LED1=LED2=1; //Indicator lights LED1 and 2 are off
IA=IB=0; //Turn off the cooling motor
}
while(Key1==0); //Wait for the key to be released
}
if(flag==1) //Allow adjustment of upper limit temperature value
{
if(Key2==0) //Upper and lower temperature limits plus button press
{
delay_anjian(5); //Delay debounce
if(Key2==0) //Then determine whether the upper and lower limit temperature plus button is pressed.
{
if(high>low) //If upper limit temperature>lower limit temperature
{
high + + ; //The upper limit temperature increases by 1
while(high==126) {high=low + 1;}//When the upper limit temperature is increased to 126℃, the upper limit temperature is set to be 1℃ higher than the lower limit temperature
//The reason is that the upper limit temperature value must be higher than the lower limit temperature value.
q_kz=b_kz=s_kz=g_kz=1; //Turn off the digital tube display
}
}
while(Key2==0); //Wait for the key to be released
}

if(Key3==0) //Upper and lower temperature limit minus key press
{
delay_anjian(5); //Delay debounce
if(Key3==0) //Then determine whether the upper and lower temperature limit minus the button is pressed.
{
if(high-low>1) //If the upper limit temperature value minus the lower limit temperature value is greater than 1
{ //(This conditional judgment ensures that the upper limit temperature cannot be lower than the lower limit temperature)
high--; //The upper limit temperature decreases by 1
while(high==-56) {high=low + 1;}//When the upper limit temperature decreases to -56℃, the upper limit temperature is set to be 1℃ higher than the lower limit temperature
//The reason is that the upper limit temperature value must be higher than the lower limit temperature value.
q_kz=b_kz=s_kz=g_kz=1; //Turn off the digital tube display
}
else //Otherwise the upper limit temperature cannot be reduced by 1 anymore
{
high=high; //The upper limit temperature remains unchanged
q_kz=b_kz=s_kz=g_kz=1; //Turn off the digital tube display
}
}
while(Key3==0); //Wait for the key to be released
}
}

if(flag==2) //Allow adjustment of the lower limit temperature value
{
if(Key2==0) //Upper and lower temperature limits plus button press
{
delay_anjian(5); //Delay debounce
if(Key2==0) //Then determine whether the upper and lower limit temperature plus button is pressed.
{
if(low-high<-1) //If the lower limit temperature minus the upper limit temperature is less than -1
{ //(This conditional judgment ensures that the lower limit temperature cannot exceed the upper limit temperature)
low + + ; //The lower limit temperature increases by 1
while(low==126) {low=high-1;}//When the upper limit temperature increases to 126℃, the lower limit temperature is set to be 1℃ lower than the upper limit temperature.
//(Explanation: This situation does not exist. Considering that the system is more stable, this judgment is added)
q_kz=b_kz=s_kz=g_kz=1; //Turn off the digital tube display
}
else //Otherwise the lower limit temperature cannot be increased by 1.
{
low=low; //The lower limit temperature remains unchanged
q_kz=b_kz=s_kz=g_kz=1; //Turn off the digital tube display
}
}
while(Key2==0); //Wait for the key to be released
}

if(Key3==0) //Upper and lower limit temperature minus key press
{
delay_anjian(5); //Delay debounce
if(Key3==0) //Then determine whether the upper and lower temperature limit minus keys are pressed.
{
if(low<high) //If the lower limit temperature is lower than the upper limit temperature (indicating that the upper and lower limit temperature values are normal)
{
low--; //lower limit temperature decreases by 1
while(low==-56) {low=high-1;}//When the lower limit temperature drops to -56℃, the lower limit temperature setting is 1℃ smaller than the upper limit temperature
//The reason is that the lower limit temperature value is lower than the upper limit temperature value
q_kz=b_kz=s_kz=g_kz=1; //Turn off the digital tube display
}
}
while(Key3==0); //Wait for the key to be released
}
}
}

void anjian_ts() //Key debugging function
{
if(Key4==0) //Real object/simulation running switch button press
{
delay_anjian(5); //Delay debounce
if(Key4==0) //Then determine whether the physical/simulation operation switching button is pressed.
{
ts=~ts; //Invert the debugging flag (0: physical operating parameters 1: simulation operating parameters)
q_kz=b_kz=s_kz=g_kz=1; //Turn off the digital tube display
}
}
while(Key4==0); //Wait for the key to be released
\t
if(ts==0) {t=2;} //0: physical operating parameter t=2
else {t=300;} //1: Simulation running parameters t=300
}
\t

Hardware design

Use components:

Microcontroller: STC89C52;

(Note: The microcontroller is universal, whether it is 51 or 52, whether it is stc or at, the pin functions are the same. The program is also the same.)

USB connector (female); self-locking switch;

Electrolytic capacitor 10u; resistor 10K;

Ceramic capacitor 30P; crystal oscillator 12M;

Resistor 470 (SMD); button;

Electrolytic capacitor 470uF; ceramic capacitor 104;

LED (red light); resistance 4.7K;

Transistor 8550; 4-bit common anode digital tube;

DIP40; DS18B20;

Chip holder DIP8;L9110;

DC motor; 9*15CM universal board;

USB male-to-male cable;square column;

Iron frame; M2 screws with nuts;

fan blade; tie;

Copper pillar with screws; 2P pin header;

Wires: several;

Flowchart:

?

Design information

01 Simulation diagram

This design uses two versions of proteus7.8 and proteus8.7, and is backward compatible, no need to worry! Specifically as shown in the picture!

Monitor Mode

Set the upper temperature limit

?

Set the lower temperature limit

?

02 Schematic Diagram

The schematic diagram of this system is designed using Altium Designer19, as shown in the figure!

?

03 Program

This design is programmed using two versions of the software keil4 and keil5, so there is no need to worry! Specifically as shown in the picture!

?

04 Design Report

Twelve thousand words design report, details are as follows!

?

05 Design information

All materials include simulation source files, programs (including comments), AD schematics, reference papers, flow charts, etc. The specific content is as follows, the most complete on the entire network! !

The following is the open source 51 microcontroller design information

?Everyone learns and progresses together:

Link: Baidu Netdisk Please enter the extraction code

Extraction code: 57kf

Like and share to learn and progress together! Grow together.