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