The author wants to help some children's shoes and lovers build projects, but his self-knowledge ability is limited, he doesn't like to talk about it, it's not easy to create, don't spray.
The system adopts the elevator analog control system based on STC89C52 chip, and designs and simulates the basic functions of the elevator control system. The floor is selected by pressing the key, the nixie tube displays the real-time number of floors, and the arrow composed of LED lights indicates the up and down direction.
as Item 1
For this system:
First, what do we need to do?
From the design requirements, it is to use the keys to control the nixie tube display and color lights.
Now we have a very simple model.
Key input (detected electrical signal) = = > STC89C51 single chip microcomputer (control) = = > nixie tube and indicator light;
Second, what do we need?
Software aspect
Programming software keil4
Burning software stc-isp-15xx-v6 86q. exe
Link: https://pan.baidu.com/s/1hsGnfBAvfWlGXgPjhYXsyg
Extraction code: 6666
Drawing software AD20
Link: https://pan.baidu.com/s/1Fyxh-PHZftNI1HIAMSTZPw
Extraction code: 6666
simulation software
protues 8.8 installation package
Link: https://pan.baidu.com/s/1kAa5mwQl7cMc1DK84Rj6-g
Extraction code: 6666
Hardware aspect
You can choose Taobao Lichuang mall Wait.
Beat the board
It can be created or matched in Jiali. (both are OK. Different people have different opinions)
Third, if you encounter problems, you can refer to csdn, 51 black electronic forum, etc. Of course, teachers are the best choice in school.
The first step is to set up ideas. The second step is to draw pictures. As I just said, drawing uses AD20, but there are some libraries we don't have. In addition to building our own libraries, the following two websites are also good ways.
PCBlib
AD official website
The second step has been drawn, and the physical drawing is as follows after being sent to the plate making and welding.
Then the third step is to write the program.
#include <reg52. h> // Call MCU header file #define uchar unsigned char / / unsigned character macro definition Variable range 0 ~ 255 #define uint unsigned int // Unsigned integer macro definition Variable range 0 ~ 65535 //Nixie tube segment selection definition 0 1 2 3 4 five six seven eight nine uchar code smg_du[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0xdf,0xdb // A B C D E F Do not show }; //Broken code bit flag_100ms,flag_1s; bit flag_stop ; //Use to achieve the corresponding building stop sbit beep = P2^3; sbit xia = P2^0; sbit zhong = P2^1; sbit shang = P2^2; uchar value2; sbit led1 = P1^7; //8 LED definitions sbit led2 = P1^6; sbit led3 = P1^5; sbit led4 = P1^4; sbit led5 = P1^3; sbit led6 = P1^2; sbit led7 = P1^1; sbit led8 = P1^0; uchar dt_1; //Elevator sign on the 1st floor uchar dt_2; //Elevator sign on the 2nd floor uchar dt_3; //3rd floor elevator sign uchar dt_4; //Elevator sign on the 4th floor uchar dt_5; //5th floor elevator sign uchar dt_6; //Elevator sign on the 6th floor uchar dt_7; //7th floor elevator sign uchar dt_8; //Elevator sign on the 8th floor uchar dt_value = 1; //Variable of which floor the elevator goes to uchar dt_s_x ; //Elevator up and down signs /***********************1ms Delay function*****************************/ void delay_1ms(uint q) { uint i,j; for(i=0;i<q;i++) for(j=0;j<120;j++); } /********************Independent key program*****************/ uchar key_can; //Key value void key() //Independent key program { static uchar key_new; key_can = 20; //Key value restore P3 |= 0xff; if(P3 != 0xff) //Press the key { delay_1ms(1); //Key jitter elimination if((P3 != 0xff) && (key_new == 1)) { //Confirm that the key is pressed key_new = 0; switch(P3) { case 0xfe: key_can = 1; break; //Get key value case 0xfd: key_can = 2; break; //Get key value case 0xfb: key_can = 3; break; //Get key value case 0xf7: key_can = 4; break; //Get key value case 0xef: key_can = 5; break; //Get key value case 0xdf: key_can = 6; break; //Get key value case 0xbf: key_can = 7; break; //Get key value case 0x7f: key_can = 8; break; //Get key value } } } else key_new = 1; } void key_with() { if(key_can == 1) { led1 = 1; //Turn on the LED dt_1 = 1; // } if(key_can == 2) { led2 = 1; //Turn on the LED dt_2 = 1; } if(key_can == 3) { led3 = 1; //Turn on the LED dt_3 = 1; } if(key_can == 4) { led4 = 1; //Turn on the LED dt_4 = 1; } if(key_can == 5) { led5 = 1; //Turn on the LED dt_5 = 1; } if(key_can == 6) { led6 = 1; //Turn on the LED dt_6 = 1; } if(key_can == 7) { led7 = 1; dt_7 = 1; } if(key_can == 8) { led8 = 1; dt_8 = 1; } } /*********************When the elevator does not move, judge whether it is up or down**********************/ void tiandi_shang_xia() { static uchar value; if(dt_s_x == 0) { flag_stop = 1; if(dt_value == 1) //The elevator stopped on the first floor { value = dt_2 + dt_3 + dt_4 + dt_5 + dt_6 + dt_7 + dt_8; if(value != 0) { dt_s_x = 1; //Lift up shang = 0; //On display zhong = 0; xia = 1; } } if(dt_value == 2) //The elevator stopped on the second floor { value = dt_3 + dt_4 + dt_5 + dt_6 + dt_7 + dt_8; if(value != 0) { dt_s_x = 1; //The elevator goes up shang = 0; //On display zhong = 0; xia = 1; } value = dt_1; if(value != 0) { dt_s_x = 2; //The elevator goes down xia = 0; //Display below zhong = 0; shang = 1; } } if(dt_value == 3) //The elevator stopped on the third floor { value = dt_4 + dt_5 + dt_6 + dt_7 + dt_8; if(value != 0) { dt_s_x = 1; //The elevator goes up shang = 0; //On display zhong = 0; xia = 1; } value = dt_1 + dt_2; if(value != 0) { dt_s_x = 2; //The elevator goes down xia = 0; //Display below zhong = 0; shang = 1; } } if(dt_value == 4) //The elevator stopped on the fourth floor { value = + dt_5 + dt_6 + dt_7 + dt_8; if(value != 0) { dt_s_x = 1; //The elevator goes up shang = 0; //On display zhong = 0; xia = 1; } value = dt_1 + dt_2 + dt_3; if(value != 0) { dt_s_x = 2; //The elevator goes down xia = 0; //Display below zhong = 0; shang = 1; } } if(dt_value == 5) //The elevator stopped on the fifth floor { value = dt_6 + dt_7 + dt_8; if(value != 0) { dt_s_x = 1; //The elevator goes up shang = 0; //On display zhong = 0; xia = 1; } value = dt_1 + dt_2 + dt_3 + dt_4; if(value != 0) { dt_s_x = 2; //The elevator goes down xia = 0; //Display below zhong = 0; shang = 1; } } if(dt_value == 6) //The elevator stopped on the sixth floor { value = dt_7 + dt_8; if(value != 0) { dt_s_x = 1; //The elevator goes up shang = 0; //On display zhong = 0; xia = 1; } value = dt_1 + dt_2 + dt_3 + dt_4 + dt_5; if(value != 0) { dt_s_x = 2; //The elevator goes down xia = 0; //Display below zhong = 0; shang = 1; } } if(dt_value == 7) //The elevator stopped on the seventh floor { value = dt_8; if(value != 0) { dt_s_x = 1; //The elevator goes up shang = 0; //On display zhong = 0; xia = 1; } value = dt_1 + dt_2 + dt_3 + dt_4 + dt_5 + dt_6; if(value != 0) { dt_s_x = 2; //The elevator goes down xia = 0; //Display below zhong = 0; shang = 1; } } if(dt_value == 8) //The elevator stopped on the 8th floor { value = dt_8; if(value != 0) { dt_s_x = 1; //The elevator goes up shang = 0; //On display zhong = 0; xia = 1; } value = dt_1 + dt_2 + dt_3 + dt_4 + dt_5 + dt_6; if(value != 0) { dt_s_x = 2; //The elevator goes down xia = 0; //Display below zhong = 0; shang = 1; } } } } /****************The elevator goes up and makes a final judgment on whether to continue to go up****************/ void dt_shang_guan() { uchar value; if(dt_s_x == 1) //The elevator goes up to make a final judgment on whether to continue to go up { if(dt_value == 1) //On the first floor { value = dt_2 + dt_3 + dt_4 + dt_5 + dt_6 + dt_7 + dt_8; if(value == 0) //It means no one pressed it { dt_s_x = 0; //The elevator stopped shang = 1; //Close upper word zhong = 1; }else flag_stop = 1; } else if(dt_value == 2) //On the 2nd floor { value = dt_3 + dt_4 + dt_5 + dt_6 + dt_7 + dt_8; if(value == 0) //It means no one pressed it { dt_s_x = 0; //The elevator stopped shang = 1; //Close upper word zhong = 1; }else flag_stop = 1; } else if(dt_value == 3) //On the 3rd floor { value = + dt_6 + dt_7 + dt_8; if(value == 0) //It means no one pressed it { dt_s_x = 0; //The elevator stopped shang = 1; //Close upper word zhong = 1; }else flag_stop = 1; } else if(dt_value == 4) //On the 4th floor { value = dt_5 + dt_6 + dt_7 + dt_8; if(value == 0) //It means no one pressed it { dt_s_x = 0; //The elevator stopped shang = 1; //Close upper word zhong = 1; }else flag_stop = 1; } else if(dt_value == 5) //On the 5th floor { value = dt_6 + dt_7 + dt_8; if(value == 0) //It means no one pressed it { dt_s_x = 0; //The elevator stopped shang = 1; //Close upper word zhong = 1; }else flag_stop = 1; } else if(dt_value == 6) //On the 6th floor { value = dt_7 + dt_8; if(value == 0) //It means no one pressed it { dt_s_x = 0; //The elevator stopped shang = 1; //Close upper word zhong = 1; }else flag_stop = 1; } else if(dt_value == 7) //On the 7th floor { value = dt_8; if(value == 0) //It means no one pressed it { dt_s_x = 0; //The elevator stopped shang = 1; //Close upper word zhong = 1; }else flag_stop = 1; } else if(dt_value == 8) //On the 8th floor { dt_s_x = 0; //The elevator stopped shang = 1; //Close upper word zhong = 1; } } } /****************When the elevator goes down, make a final judgment on whether to continue to go down****************/ void dt_xia_guan() { uchar value; if(dt_s_x == 2) //The elevator goes down to make a final judgment on whether to continue to go down { if(dt_value == 1) //On the first floor { dt_s_x = 0; //The elevator stopped xia = 1; //Close upper word zhong = 1; flag_stop = 1; } else if(dt_value == 2) //On the 2nd floor { value = dt_1; if(value == 0) //It means no one pressed it { dt_s_x = 0; //The elevator stopped xia = 1; //Close upper word zhong = 1; }else flag_stop = 1; } else if(dt_value == 3) //On the 3rd floor { value = dt_1 + dt_2; if(value == 0) //It means no one pressed it { dt_s_x = 0; //The elevator stopped xia = 1; //Close upper word zhong = 1; }else flag_stop = 1; } else if(dt_value == 4) //On the 4th floor { value = dt_2 + dt_3; if(value == 0) //It means no one pressed it { dt_s_x = 0; //The elevator stopped xia = 1; //Close upper word zhong = 1; }else flag_stop = 1; } else if(dt_value == 5) //On the 5th floor { value = dt_1 + dt_2 + dt_4; if(value == 0) //It means no one pressed it { dt_s_x = 0; //The elevator stopped xia = 1; //Close upper word zhong = 1; }else flag_stop = 1; } else if(dt_value == 6) //On the 6th floor { value = dt_1 + dt_2 + dt_3 + dt_4 + dt_5; if(value == 0) //It means no one pressed it { dt_s_x = 0; //The elevator stopped xia = 1; //Close upper word zhong = 1; }else flag_stop = 1; } else if(dt_value == 7) //On the 7th floor { value = dt_1 + dt_2 + dt_4 + dt_5+ dt_6; if(value == 0) //It means no one pressed it { dt_s_x = 0; //The elevator stopped xia = 1; //Close upper word zhong = 1; }else flag_stop = 1; } else if(dt_value == 8) //On the 8th floor { value = dt_3 + dt_4 + dt_5 + dt_6 + dt_7; if(value == 0) //It means no one pressed it { dt_s_x = 0; //The elevator stopped xia = 1; //Close upper word zhong = 1; }else flag_stop = 1; } } } /***********************Elevator processing function************************/ void td_dis() { uchar value,value1; value = dt_1 + dt_2 + dt_3 + dt_4 + dt_5 + dt_6 + dt_7 + dt_8; if(value != 0) { //100ms if(flag_stop == 1) //Stop when you get to the corresponding building { /***************************Walk up the elevator***********************************/ if(dt_s_x != 0) //Walk up the elevator { value1 ++; if(value1 >= 10) //1s { value1 = 0; if(dt_s_x == 1) //Walk up the elevator { dt_value ++; shang = 0; //Display upper word zhong = 0; } if(dt_s_x == 2) //Walk down the elevator { dt_value --; xia = 0; //Show next word zhong = 0; } if(dt_value == 1) //When we get to the first floor { if(dt_1 == 1) { led1 = 0; //Turn off the first layer led dt_1 = 0; //Clear the sign of the motor at flag_stop = 0; //Stop at beep = 0; //Turn on the buzzer } } else if(dt_value == 2) //When we get to the second floor { if(dt_2 == 1) { led2 = 0; //Turn off the second layer led dt_2 = 0; //Clear the sign of the motor at flag_stop = 0; //Stop at beep = 0; //Turn on the buzzer } } else if(dt_value == 3) //When we get to the third floor { if(dt_3 == 1) { led3 = 0; //Turn off the layer 3 LED dt_3 = 0; //Clear the sign of the motor at flag_stop = 0; //Stop at beep = 0; //Turn on the buzzer } } else if(dt_value == 4) //When we get to the fourth floor { if(dt_4 == 1) { led4 = 0; //Turn off the layer 4 LED dt_4 = 0; //Clear the sign of the motor at flag_stop = 0; //Stop at beep = 0; //Turn on the buzzer } } else if(dt_value == 5) //When we get to the fifth floor { if(dt_5 == 1) { led5 = 0; //Turn off the layer 5 LED dt_5 = 0; //Clear the sign of the motor at flag_stop = 0; //Stop at beep = 0; //Turn on the buzzer } } else if(dt_value == 6) //When we get to the sixth floor { if(dt_6 == 1) { led6 = 0; //Turn off the layer 6 LED dt_6 = 0; //Clear the sign of the motor at flag_stop = 0; //Stop at beep = 0; //Turn on the buzzer } } else if(dt_value == 7) //When we get to the seventh floor { if(dt_7 == 1) { led7 = 0; //Turn off the layer 7 LED dt_7 = 0; //Clear the sign of the motor at flag_stop = 0; //Stop at beep = 0; //Turn on the buzzer } } else if(dt_value == 8) //When we get to the eighth floor { if(dt_8 == 1) { led8 = 0; //Turn off the layer 8 LED dt_8 = 0; //Clear the sign of the motor at flag_stop = 0; //Stop at beep = 0; //Turn on the buzzer } } } } } } if(flag_stop == 0) { value2 ++; if(value2 % 5 == 0) { if(dt_s_x == 1) //upper { shang = ~shang; zhong = ~zhong; } if(dt_s_x == 2) //lower { zhong = ~zhong; xia = ~xia; } } if(value2 >= 10) //1.0s { beep = 1; //Turn off the buzzer } if(value2 >= 20) //100ms*20 = 2 seconds { value2 = 0; dt_shang_guan(); //The elevator goes up to make a final judgment on whether to continue to go up dt_xia_guan(); //The elevator goes down to make a final judgment on whether to continue to go down } } } /*************Timer 0 initializer***************/ void time_init() { EA = 1; //On total interrupt TMOD = 0X01; //Timer 0, working mode 1 ET0 = 1; //On timer 0 interrupt TR0 = 1; //Allow timer 0 timing } void delay(int x) { while (x--); } /******************Main program**********************/ void main() { P1 = 0x00; P0 = 0X00; //MCU IO port initialization time_init(); //timer initiated P0 = 0xf1; while(1) { dt_value++; if(dt_value >=10)dt_value = 0; key(); //Key program if(key_can < 20) { if(dt_s_x == 0) { value2 = 0; flag_stop = 1; } key_with(); } tiandi_shang_xia(); //When the elevator does not move, judge whether it is up or down P0 = ~smg_du[dt_value]; //display if(flag_100ms == 1) { flag_100ms = 0; td_dis(); //Elevator processing function } } } /*************Timer 0 interrupt service routine***************/ void time0_int() interrupt 1 { static uchar value; TH0 = 0x3c; TL0 = 0xb0; // 50ms value ++; if(value % 2 == 0) { flag_100ms = 1 ; } }
After the code is written, burn the hex file through the burning software to run the board.
Details download address:
Adhering to the principle of open source labor charging, a small amount of points or money may be charged. If you need physical goods or product customization, you can chat privately.