Current location - Education and Training Encyclopedia - Graduation thesis - 5 1 single chip microcomputer four-way answering machine graduation thesis only needs four ways
5 1 single chip microcomputer four-way answering machine graduation thesis only needs four ways
The first chapter introduces the design of four digital answering devices. Each channel is designed with a answering button for players to use, and a system sorting and answering control master switch S is set up, which is controlled by the host. The function of answering when the answering machine is limited, and the time limit for each round of answering is set to 30 seconds. After the host starts the "start" key, the contestants will be effective only if they answer first within the set time, otherwise it will be invalid. The transponder has the functions of locking and displaying. If the player answers successfully first, the corresponding number will be displayed. At this time, other players cannot answer first. The number of priority contestants is kept until the host clearing system. Display the remaining answer time with timer digital tube, and when the remaining answer time is 5 seconds, the small light flashes to prompt; When the answer time is over, the buzzer sounds to remind the respondent that it is time to answer. This topic is mainly realized by single chip microcomputer circuit. The main design idea is: after the host gives the order, if the player does not close and open within 30 seconds, he will enter the next link; If the player closes the switch, the host can accurately judge the first answer signal and latch it, while blocking other input signals, making other answers invalid. At this time, the host judges which player can answer according to the numbers displayed on the screen. At this point, the player who turns on the switch first begins to enter the countdown to answering questions. If the answer is within 60 seconds, it is considered valid; Otherwise it is invalid. The program flow chart is as shown in figure 1- 1. 1-2: player sending chart: initialization started: P0. P2 port clearing timer T 1 mode selection; Selection of serial port sending mode; Start the timer 1, load the initial value and judge whether the answer is successful or not. Send the player number to the host, and display the countdown chart 1- 1. Host Acceptance Form: Initial Initialization: P0. P 1。 P2 clears the port, selects the serial port receiving mode and the receiving mode of T 1, and starts the counter T 1. Whether to press the master switch to allow reception for on-off interruption and serial interruption, and whether to receive the answer signal in the countdown of the answer time shows the player number who pressed the key first, and blocks the numbers of other players. Figure 1-2 System Scheme Demonstration Chapter II System Scheme Demonstration Scheme 1: As shown in Figure 2- 1, a single chip microcomputer, a timer and a digital tube are used, and the player can complete the answer by pressing the switch as the input signal. The host accurately judges the player who presses the switch first according to the player's input signal, shields other signals and answers first, so that the player who presses the button first starts to answer, and the timer starts to count down. The circuit mainly uses timers and counters. The advantage of this circuit is that the circuit diagram is relatively simple, but the disadvantage is that it has poor anti-interference ability and lacks practical value. Figure 2- 1 Scheme 2: Using five single-chip computers, five timers and a digital tube. The circuit mainly uses the working principle of serial port interrupt and timer counter. After the power is turned on, the host will switch to the "reset" state, the responder will be in the prohibited state, the digital display will turn off the lights, and the host will set the switch to the "start" state, announcing the "start" of the responder to start the countdown of the responder. If there is no responder in the countdown, go directly to the next link. If someone answers first in this time, they will start to answer first, and the countdown to answer first will be changed to. The priority of the player's first answer is locked, and the player's number is reserved until the referee clears the system. The disadvantage of this circuit is complexity, but the advantage is that it is convenient for every player to watch the countdown, and it is practical and widely used in real life. Through the comparison of the above two schemes, we can easily find that the second circuit is easier to control by adding some control circuits, and its effect and practicability are better than the first one, so the second schematic diagram is adopted in this experiment. System diagram Each player sends out a request signal to inform the host by pressing the key, and the host tells which player can answer the question by the number on the digital tube, as shown in Figure 2-2 1, Figure 4, 2, 3, and Figure 2-2. Chapter 3: Theoretical analysis: The circuit of this topic adopts single-chip microcomputer AT89C5 1 as the control chip, and the host and each contestant have their own controllers. Each player's control chips P0 and P2 are connected with a * * * cathode digital tube as the display of countdown to answering questions. Port P14 is connected to a key, and the other end of the key is grounded for the player to answer first. P16 is connected with an audio amplifier circuit, and its output end is connected with a speaker as a reminder of the remaining time for answering questions. When the player answers the key successfully, it will send its player number through the serial port on the control chip, and at the same time, it will start the countdown to the answer. When the answer time is only 5 seconds, the speaker will make a "ding-dong" sound to remind the player to answer the question quickly. P0。 The P 1 and P2 ports of the host control chip are connected with a digital tube with a cathode of * * *, and the digital tube at the P 1 port is used to display the number of successful contestants. The digital tubes at P 1 and P2 were initially used to display the allowed time limit for the first time, and when a player succeeded in the first time, the countdown for the first time was switched. P3^7 is connected to the switch and indicator light. When the switch is pressed and the indicator light is on, the player is allowed to answer first. When a player answers successfully first, the software closes the serial port interrupt to shield other players. Players use the principle of serial simplex communication to send their player numbers to the host. Each control chip has a powerful full-duplex asynchronous communication serial port with two physically independent receiving and sending buffer periods SBUF, which can send and receive data at the same time. Every time you use the serial port, you need to initialize the serial port before you can input and output data. The initialization process is as follows: (1) Set SM0 and SM 1 binary codes of SCON according to the working mode of the selected serial port. (2) For operation mode 2 or 3, the 9th bit data to be sent shall be written into TB8 as required. (3) If the selected operation mode is not mode 0, the baud rate of receiving/sending should be set. Set the SMOD state to control whether the baud rate is doubled. If the operation mode 1 or 3 is selected, the timer T 1 should be initialized to set its overflow rate. These initializations must be realized by software programming. This design adopts mode 2-9 data asynchronous communication mode. Its working principle is: (1). A frame is 1 1 bit: 9 data bits, 1 start bits (0), 1 stop bits (1). The 9th data bit is in TB8/RB8, which is often used as a check bit and a multi-machine communication identification bit (2). RXD: data receiving terminal, TXD: data sending terminal. (3) Baud rate: Mode 2: b = (2Smod/64) × FOSC. This design is generated by timer 1 (4). Send: load TB8 first, write SBUF to start sending, and end sending, TI= 1. Receiving: any = 1, and receiving is allowed. After receiving a frame, if RI=0 and the 9th bit is 1 (or SM2=0), the received data is loaded into the receiving SBUF, and the 9th bit is loaded into RB8, then RI =1; Otherwise, the received data is discarded and RI is not set. The schematic diagram is as follows: Figure 3 Experiment and Data Analysis Chapter 4 Experiment and Data Analysis 1. In the laboratory, proteus is used to simulate the experimental environment, and keil is used to program, and finally the simulation results are obtained. 2. The data (1) host works. After the host turns off the switch, the digital tube displays zero, and the timer displays the first answer countdown, starting from 30s. As shown in Figure 4-2- 1: Figure 4-2- 1 (2) When the player answers first, as soon as the player turns on the switch, the digital tube of the host computer displays "1", and the LED next to player 1 lights up. At the same time, the timer of the host and the player 1 starts to show the countdown to the answer, and the time is 60. Figure 4-2-2: Figure 4-2-2 (3) Player 2 answers first. In the countdown time of the first answer, player 2 turns off the switch and the LED next to player 2 lights up. At the same time, the timer of the host and player 2 starts to display the countdown of answering questions within 60s, as shown in Figure 4-2-3: Figure 4-2. Player 3 turns on the switch, and the LED next to player 3 lights up. At the same time, the timer of the host and player 3 starts to display the countdown of answering questions within 60s, as shown in Figure 4-2-4: Figure 4-2-4 (5). During the countdown time, player 4 turns on the switch, and "4" is displayed on the digital tube of the host computer. The timer of the host and player 4 starts to show the countdown to answering questions within 60s, as shown in Figure 4-2-5: Figure 4-2-5. 3. The responder is composed of a single-chip microcomputer and a peripheral circuit, which makes the peripheral circuit very simple and has the following functions: time limit for answering questions, self-locking when answering questions, light indication, pause reset and electronic music alarm; The time limit for answering questions is adjustable between 0 and 30 seconds; There are group numbers and timing windows on the panel, which show clear synchronization and do not interfere with each other. Answering device and digital countdown device are combined into one. You can set two countdown times: the first answer and the answer. The transponder has the functions of locking and displaying. That is, the player presses the button, latches the corresponding number and displays it on the LED digital tube; The answering machine has the function of answering at regular intervals, and the time for one answer is set by the host, which is set to 30 seconds. When the host starts the "start" key, the timer starts counting, and so on. In a word, the answering machine is of great practical value. Chapter 5 Experience This year, I participated in the training of the National Electronic Design Competition for College Students. I only know the ups and downs in the training process through personal experience. I believe this time will leave us with good memories. After hard training, our group has only one belief, that is, we must try our best to let the teacher choose us anyway. Only when we are selected will our dreams really begin, otherwise our previous efforts will be in vain. What we are doing is answering machine. We had an idea soon, but when we showed it to the old teacher, he said it was too difficult and would affect our selection score. There is no way but to increase the difficulty. We can improve the difficulty for three days in a row. During these three days, we spent the rest of the time in the laboratory except for eating and sleeping. Finally, through our collective efforts, our experiment has achieved results. By participating in this training, I found that I had a lot of experiences and gains: First, I strengthened my learning ability. This kind of learning ability includes the ability to obtain information, understand the thoughts of predecessors, design systems, practice, analyze and remove obstacles, express and so on. The competition system of electronic design competition determines that the above abilities are indispensable. Secondly, the cultivation of team spirit. The electronic design competition requires three teams to participate together and calculate their scores collectively, which requires three people to trust each other, cooperate with each other and cooperate with each other. Remind each other to stay calm in prosperity, encourage each other to overcome difficulties in adversity, and don't blame each other. Our group will never forget this experience, and we will never forget the teachers and schoolmates who worked hard with us. We will always believe that our group is the best! Refer to Wen Xian [1] Yu Fashan, Principle and Application Technology of Single Chip Microcomputer, China University of Mining and Technology Press, 2003; [2] Wang Weidong, Design and manufacture of the simplest wired responder based on single chip microcomputer,1999; Li chaoqing Principle and interface technology of 200 1. Beijing: Beijing University of Aeronautics and Astronautics Press. 94- 103,339-348; [4] Shen Qingyang and Guo Tingji Publishing House; [5] Li Chaoqing, editor-in-chief, Principle and Interface Technology of Single Chip Microcomputer, Beijing University of Aeronautics and Astronautics Press,1994; [6] He Limin, editor-in-chief, Application and Design of Single Chip Microcomputer, Beijing University of Aeronautics and Astronautics Press,1990; Practice and Application of 805 1 Single Chip Microcomputer Made in Tsinghua University.

Electronic Association for Science and Technology Competition Project Report Entries: Single Chip Microcomputer Entries: Four-channel electronic responder based on 5 1 single chip microcomputer: TH XZ professional level: telecommunications 1005 Report submission date: 201report submission date: 201kloc-0. 16 date directory 1 design requirements and functions ........................................................................................................... 4 1 . 1 Basic design requirements ...................................................................................................................... 4 2. 1 The control system and required components ................................. is the selection keyboard .............................................................. 6 2.4 answering device. ................................. .......................................................... 6 2.5 Buzzer Module ................................................................................... ..................... 7 2.6 external oscillation circuit .................................................................................................... 7 3 programming .............. ........................................................................................................7 3. 1 Program flow chart ......................................................... debugs ............................................... 7 3.2 system. ................................. ............................................................................................ 1 0 Appendix C Program ................................................................................................................... 1 1 II-Design Requirements and Functions/ Kloc-0/. 1 Basic Design Requirements (1) The answering machine is used by four players or four teams at the same time, and is represented by four buttons K 1~ K4 respectively. (2) Set referee switch k5 and reset switch k6, which are controlled by the host computer. When the host presses k6, the system is reset to answer first, and when the host presses k5, it starts to answer first; (3) The responder has the function of answering in time, and the answering time is 15 seconds. When the host starts the "Start" key, the timer will count down, and the speaker will give a short prompt tone for about 0.5 seconds. When the time is less than 5 seconds, it will give an alarm every second to remind the player. (4) The responder has a locking function, and the player answers within a set time, and the answer is valid. When the buzzer rings, the timing stops, the digital tube displays the number and time of the contestants, and the signal light corresponding to the contestants lights up, which is invalid when other contestants answer again. (5) If the scheduled time has expired and no one answers first, the first answer will be invalid, and the system will alarm and prohibit the first answer. Waiting for the next round to answer. . Hardware design 2. 1 control system and required components The control system is mainly composed of single chip microcomputer application circuit, memory interface circuit and display interface circuit. Among them, the single chip microcomputer STC89C52 is the core of the system, which is mainly responsible for controlling the coordination of all parts. Required components: the core device of this system is STC89C52. Functions of each port: P0.0-P0.3 are digital tube position selection ports; P2.0-P2.7 are segment selection ports of digital tubes, which transmit segment selection signals for them; P 1.0-P 1.3 is the input port of four groups of scrambled signals; P 1.4 and P 1.5 are controlled by the referee, that is, the function keys of \ answering first \ and resetting; P 1.6 is the control port of the buzzer; P3.4-P3.7 is the signal light output port of the player; The periphery is connected with an electric reset circuit, a digital tube circuit, an LED, a key circuit and a speaker circuit. The electronic responder is designed and manufactured by single chip microcomputer, and its function is mainly realized by software 3 programming, so the single chip microcomputer STC89C52 is adopted, which is a low-voltage and high-performance CMOS 8-bit single chip microcomputer. The chip contains 8k bytes of rewritable flash read-only program memory and 5 12 bytes of random access data memory (ram). The device is produced by ATMEL's high-density nonvolatile storage technology and is compatible with the standard MCS-5 1 instruction system. The chip has a general 8-bit CPU and flash memory unit. The powerful STC89C52 single chip microcomputer can provide you with many complex system control applications. The following figure shows the pin diagram of its I/O port: STC89C52 pin Figure 2.2. The display module of the responder is divided into a digital tube module and an LED signal lamp module, which adopt a four-in-one cathode digital tube and four light-emitting diodes respectively. It has the advantages of small size, low power consumption, low failure rate, easy programming and less resource occupation. (see fig. 1, fig. 2) fig. 1 4 fig. 2 2.3 the power scheme selection system needs 5V power to drive the single chip microcomputer STC89C52. The USB interface of the computer can provide 5V voltage to drive the single chip microcomputer. 2.4 Keyboard Selection of Answering Device Keyboard is an indispensable input device of single chip microcomputer, which is the link to realize man-machine dialogue. According to the structure, the keyboard can be divided into non-coding keyboard and coding keyboard. The former uses software to generate the key code, while the latter uses hardware to generate the key code. Single-chip microcomputer uses non-coding keyboard, because non-coding keyboard has simple structure and low cost. There are many types of non-coding keyboards, such as stand-alone keyboards and determinant keyboards. This design uses an independent keyboard. How many I/O lines are used in the keyboard interface, there are several keys in the keyboard. When the keyboard interface uses six I/O lines, there are six keys in the keyboard. This type of keyboard has fewer keys, and the work of each key in the keyboard does not interfere with each other. Therefore, the keys in the keyboard can be flexibly coded according to actual needs. As shown in the figure. The simplest coding method is to code according to the pressed state of the corresponding key directly reflected by the I/O input port, which is called the key direct state code. For this coded independent keyboard, CPU can directly read the status of I/O port to obtain the direct status code value of the key, and directly identify the key according to this value. This form of keyboard is simple in structure and easy to identify keys. The disadvantage of independent keyboard is that it needs to occupy more I/O ports. This type of keyboard can be used when the keyboard of single chip microcomputer application system needs fewer keys or more I/O ports. The circuit diagram of the module is shown in Figure 4. The six buttons are used as the selection buttons for answering questions and are connected with P 1.0-P 1.5 of STC89C52. Figure 4 Keyboard Module 2.5 Buzzer Module Buzzer is an electronic buzzer with integrated structure, which is powered by DC voltage. It is widely used as a sounding device in computers, printers, copiers, alarms, electronic toys, automotive electronic equipment, telephones, timers and other electronic products. The picture is as shown. 6 2.6 Single chip microcomputer of external oscillation circuit can only work under the drive of AT89C52. There is a clock oscillation circuit inside the single chip microcomputer, and only an external oscillation source is needed to generate a certain clock signal and send it to each unit inside the single chip microcomputer. The external oscillation circuit is shown in the figure. Program design 3. 1 program flow chart: program flow chart: the initialization part N K5= =0 Y starts to interrupt, and the digital tube starts to count down. If a player grabs the Y interrupt and stops, the digital tube displays the player's label, lights up the signal lamp, and ends the flow chart of the main program of the responder. 7 Timer0 interrupts N 1 sec. Is it time? Y seconds plus 1, the digital tube displays the second value interrupt, and returns to the transponder timer interrupt flow chart. Scan the key Y K0 of the keypad, press the key N Y K 1, press the key N K3, and press the LED corresponding to the keys N and K2. The digital tube displays the LED corresponding to the key K 1, and the digital tube displays the key K0. Corresponding to LED light and digital tube display Y and K3 keys corresponding to LED light and digital tube display scanning stop keyboard scanning flow chart main program The transponder program designed by our research group adopts C program design. The remarkable feature of C language is that the program is written in binary, and all parts of the program are independent of each other except the necessary information exchange. This structured way can make the program clear and easy to use, maintain and debug. C language is provided to users in the form of functions, which can be easily called, and there are various loops and conditional statements to control the process of the program, thus making the program completely structured. Although C language is also strongly typed, its syntax is flexible, which gives programmers more freedom. The main program of this design includes clock design program, timer interrupt subroutine, LED display program and key control subroutine. See the annex for specific procedures. 3.2 System debugging System debugging includes hardware debugging and software debugging, which are inseparable. The hardware circuit and software program we designed can only be verified by joint debugging. Only after debugging, can we find problems, solve problems, improve problems and finally develop practical products. Hardware debugging is divided into unit circuit debugging and online debugging. When designing the hardware circuit, the unit circuit is tested. The debugging here is only to test whether the circuit is correct after being made into a printed circuit board, and to eliminate some processing errors (such as wiring errors, open circuits and short circuits). This debugging can be done by simulation alone, or by software by developing equipment. On-line debugging of hardware must be carried out with the cooperation of system software. Software debugging generally includes two stages: block debugging and online debugging. The block debugging of the program is generally carried out on the single chip microcomputer development equipment. According to the initial value of the adjusted entry parameters of the program function block, a special program sequence segment can be compiled and run on the development equipment together with the adjusted program function block. You can also run a program function block independently with the corresponding hardware circuit, and then check whether it is correct. If the execution result is inconsistent with the expectation, you can find the reason and correct it by single-step operation or setting breakpoints until the operation result is correct. At this point, the program function block has been debugged, and additional program segments can be deleted. Other program function blocks can also be debugged in this way. On-line program debugging is to connect the debugged program functional blocks into a complete program according to the overall structure and run on the developed hardware circuit. So as to test the integrity and correctness of the overall operation of the program and the cooperation with the hardware circuit. In the joint debugging, there may be some programs and function blocks on some branches, and the corresponding input parameters cannot be obtained because of the limitation of chess pieces. At this time, the debugging personnel should create conditions for simulation debugging. If hardware problems are found in the joint debugging, they should be corrected in time until all the hardware and software of the single chip microcomputer system are debugged. After the system debugging is completed, it will be put into trial operation for a period of time to test the stability and anti-interference ability of the system and verify whether the system functions meet the design requirements and expected results. 9 3.3 Welding Problems and Solutions Generally speaking, the primary problem that causes hardware problems is welding, which means that the quality of welding directly affects the normal operation of products. The common causes of poor welding quality are: ① Too much solder is used to form tin deposits on the solder joints; There is too little solder to cover the solder joint. ② Cold welding. When welding, the soldering iron temperature is too low or the heating time is insufficient, the solder is not completely melted and soaked, the solder surface is not bright (not smooth), and there are small cracks (like tofu residue! )。 ③ Soldering with rosin, a layer of rosin is mixed between the solder and components or printed boards, resulting in poor electrical connection. If the mixed heating rosin is insufficient, there is a yellow-brown rosin film under the solder joint; If the heating temperature is too high, there will be a black film of carbonized rosin under the solder joint. In the case of insufficient heating of rosin film, repair welding can be carried out with soldering iron. If there is a black film, it is necessary to "eat" the net solder, clean up the surface of the welded components or printed boards, and then re-weld. (4) solder bridge. Too much solder leads to short circuit between solder joints of components. Special attention should be paid to this point when welding ultra-small components and small printed circuit boards. ⑤ Excessive flux leads to a large amount of rosin residue around the solder joint. When there is a small amount of rosin residue, you can gently heat it with an electric soldering iron to volatilize it, or you can wipe off the excess rosin or flux with a cotton ball dipped in anhydrous alcohol. ⑥ The solder on the surface of solder joint forms a sharp point. This is mostly caused by insufficient heating temperature or too little flux and improper angle when the soldering iron leaves the solder joint. . After nearly half a month's efforts, with our cooperation, we successfully completed this design project. Through this electronic production competition, we re-recognize the importance of self-study and the truth of applying what we have learned. We looked up a lot of materials in the library and online, and at the same time realized the important role of the library. Through the design of this answering machine, we pay more attention to the importance of professional knowledge and the necessity of practical ability. In the whole production process, we had many problems, but we didn't give up because of it. In constant debugging and failure, we not only learned professional knowledge, but also tempered our minds and benefited a lot. As long as you do anything, try more and do your best, you will benefit a lot even if you don't do it well. Isn't there a saying that mentality determines success or failure? It's really reasonable. No matter what you do, it can't be smooth sailing. If you encounter obstacles, don't give up, don't hesitate, and don't experience wind and rain, how can you see the rainbow! In the future study process, we should go to the library to read more professional books, such as protel drawing, proteus simulation software, etc., to enrich our knowledge, master more software and hardware design skills and improve our efficiency in future production. This design task has also deepened our understanding and application of single chip microcomputer and interface 10 technology. Due to the limitation of knowledge level, there may be some shortcomings in the design. We sincerely accept the criticism and correction from teachers and classmates. Appendix (Procedure) Appendix (C Procedure) # contains