My improved design solves the problem of No. 1 answering priority in the previous version, and adds a trick bag setting. When a contestant asks to use the trick bag when answering a question, the host presses the answer start button and the timing starts again.
;The eight-way buzzer circuit is simulated by PS and has been successfully tested.
Single chip eight-way buzzer program OK EQU 20H; answer start flag RING EQU 22H; Ringing flag ORG 0000H AJMP MAIN ORG 0003H AJMP INT0SUB ORG 000BH AJMP T0INT ORG 0013H AJMP INT1SUB ORG 001BH AJMP T1INT ORG 0040H MAIN: MOV R1,#30;The initial response time is 30s MOV R2, #60; The initial answering time is 60 seconds MOV TMOD,#11H; Set timer/mode 1 MOV TH0, #0F0H MOV TL0, #0FFH; the higher the sound frequency, the sharper it is. MOV TH1,#3CH MOV TL1,#0B0H; 50ms is an overflow interrupt SETB OF SETB ET0 SETB ET1 SETB EX0 SETB EX1; Enable four interrupts, T0/T1/INT0/INT1 CLR OK CLR RING SETB TR1 SETB TR0; Start the timer at the beginning to display FFF. If you want to restart the count, just reset TH1/TL1. ;=====Query Program===== START: MOV R5,#0BH MOV R4, #0BH MOV R3, #0BH ACALL DISPLAY; Displays FFF before answering the question JB P3.0,NEXT;ddddddd ACALL DELAY JB P3.0, NEXT; debounce, if the "start key" is pressed, it will execute downward, otherwise it will jump to the illegal answer query ACALL BARK; key sound MOV A,R1 MOV R6,A; send R1->R6, because R1 stores the answer time SETB OK; answer flag, used in COUNT program to determine whether to query answer MOV R7,#01H; Read the answer key data signal flag, here means only read the useful signal once MOV R3,#0AH; only the time is displayed for the quick answer, and the number of numbers is eliminated AJMP COUNT; Enter the countdown program, "Query the effective answer program" in COUNT NEXT: JNB P1.0,FALSE1 JNB P1.1,FALSE2 JNB P1.2,FALSE3 JNB P1.3,FALSE4 JNB P1.4,FALSE5 JNB P1.5,FALSE6 JNB P1.6,FALSE7 JNB P1.7,FALSE8 AJMP START ;=====Procedure for handling illegal responses===== FALSE1: MOV R3, #01H AJMP ERROR FALSE2: MOV R3,#02H AJMP ERROR FALSE3: MOV R3,#03H AJMP ERROR FALSE4: MOV R3, #04H AJMP ERROR FALSE5: MOV R3,#05H AJMP ERROR FALSE6: MOV R3,#06H AJMP ERROR FALSE7: MOV R3, #07H AJMP ERROR FALSE8: MOV R3,#08H AJMP ERROR ;=====INT0 (response time R1 adjustment program)===== INT0SUB:MOV A,R1 MOV B,#0AH DIV AB MOV R5,A MOV R4,B MOV R3,#0AH ACALL DISPLAY; first display R1 on the two time LEDs JNB P3.4, INC0; P3.4 is the +1s key, if pressed, jump to INCO JNB P3.5,DEC0; P3.5 is -1s key, if pressed, jump to DECO JNB P3.1, BACK0; P3.1 is the confirmation key, if pressed, jump to BACK0 AJMP INT0SUB INC0: MOV A,R1 CJNE A, #63H, ADD0; If it is not 99, add 1 to R2. If it is 99, set R1 to 0 and start again. MOV R1,#00H ACALL DELAY1 AJMP INT0SUB ADD0: INC R1 ACALL DELAY1 AJMP INT0SUB DEC0: MOV A,R1 JZ SETR1; if R1 is 0, R1 is set to 99, DEC R1 ACALL DELAY1 AJMP INT0SUB SETR1: MOV R1,#63H ACALL DELAY1 AJMP INT0SUB BACK0: RETI ;=====INT1(Answer time R2 adjustment program)===== INT1SUB:MOV A,R2 MOV B,#0AH DIV AB MOV R5,A MOV R4,B MOV R3,#0AH ACALL DISPLAY JNB P3.4,INC1 JNB P3.5,DEC1 JNB P3.1,BACK1 AJMP INT1SUB INC1: MOV A,R2 CJNE A,#63H,ADD1 MOV R2, #00H ACALL DELAY1 AJMP INT1SUB ADD1: INC R2 ACALL DELAY1 AJMP INT1SUB DEC1: MOV A,R2 SW SETR2 DEC R2 ACALL DELAY1 AJMP INT1SUB SETR2: MOV R2,#63H ACALL DELAY1 AJMP INT1SUB BACK1: RETI ;=====Countdown program (both the quick response countdown and the answer countdown jump to this program)===== REPEAT:MOV A,R2; Restart the timer when using the magic bag MOV R6,A CLR RING COUNT: MOV R0,#00H; reset the timer interrupt count MOV TH1,#3CH MOV TL1,#0B0H; reset timer RECOUNT:MOV A,R6; R6 saves the countdown time. The response time or answer time is given to R6. MOV B,#0AH DIV AB; Divide by ten and get the ones/tens digit MOV 30H,A; tens digit is stored in (30H) MOV 31H,B; the units digit is stored in (31H) MOV R5,30H; take the tenth digit MOV R4,31H; take the unit digit MOV A,R6 SUBB A,#07H JNC LARGER; jump to LARGER if it is greater than 5s, and will remind you if it is less than or equal to 5s MOV A,R0 CJNE A,#0AH,FULL;0.5s down in 1s CLR RING AJMP CHECK FULL: CJNE A, #14H, CHECK; The following is the situation of 1s, the sound is displayed and the number is cleared and R0 is restarted. SETB RING MOV A,R6 JZ QUIT; Timer expires MOV R0,#00H DEC R6; one second mark minus 1 AJMP CHECK LARGER: MOV A,R0 CJNE A, #14H, CHECK; if 1s runs downward, otherwise jump to check "stop/display" DEC R6; count down one second R6 automatically decreases by 1 MOV R0,#00H CHECK: JNB P3.1, QUIT; Press the stop button to exit JNB OK,CHECKK; only valid when answering the countdown AJMP NEXTT CHECKK:JNB P3.0,REPEAT; Determine whether to use the kit NEXTT: ACALL DISPLAY JB OK, ACCOUT; if it is a countdown for a quick answer, then query the quick answer, otherwise skip the query and continue the countdown (this serves to lock the quick answer) AJMP RECOUNT ACCOUNT: MOV A,36H JNB ACC.0,TRUE1 JNB ACC.1,TRUE2 JNB ACC.2,TRUE3 JNB ACC.3,TRUE4 JNB ACC.4,TRUE5 JNB ACC.5,TRUE6 JNB ACC.6,TZ1 JNB ACC.7,TZ2 AJMP RECOUNT TZ1:JMP TRUE7 TZ2:JMP TRUE8 QUIT: CLR OK; if the "stop key" is pressed, the program executed CLR RING AJMP START ;=====Normal answer processing procedure===== TRUE1: ACALL BARK MOV A,R2 MOV R6,A; R2 for answer time to get R6 MOV R3, #01H CLR OK; Because the timer for answering questions no longer checks for quick answers, the quick answers are locked AJMP COUNT TRUE2:ACALL BARK MOV A,R2 MOV R6,A MOV R3, #02H CLR OK AJMP COUNT TRUE3:ACALL BARK MOV A,R2 MOV R6,A MOV R3,#03H CLR OK AJMP COUNT TRUE4:ACALL BARK MOV A,R2 MOV R6,A MOV R3, #04H CLR OK AJMP COUNT TRUE5:ACALL BARK MOV A,R2 MOV R6,A MOV R3, #05H CLR OK AJMP COUNT TRUE6: ACALL BARK MOV A,R2 MOV R6,A MOV R3, #06H CLR OK AJMP COUNT TRUE7:ACALL BARK MOV A,R2 MOV R6,A MOV R3, #07H CLR OK AJMP COUNT TRUE8:ACALL BARK MOV A,R2 MOV R6,A MOV R3, #08H CLR OK AJMP COUNT ;=====Foul Answer Procedure===== ERROR: MOV R0,#00H MOV TH1,#3CH MOV TL1,#0B0H MOV 34H,R3; Temporary storage of the foul number and (34H) HERE: MOV A,R0 CJNE A,#06H,FLASH;0.3s downward operation->extinguish and stop ringing CLR RING MOV R3,#0AH MOV R4,#0AH MOV R5,#0AH; all three lights are off AJMP CHECK1 FLASH: CJNE A, #0CH, CHECK1; The following is the situation of 0.8s, the sound is displayed and the number is cleared and R0 is reset. SETB RING MOV R0,#00H MOV R3,34H; retrieve the number MOV R5, #0BH MOV R4,#0BH; Display FF and number AJMP CHECK1 CHECK1: JNB P3.1,QUIT1 ACALL DISPLAY AJMP HERE QUIT1: CLR RING CLR OK AJMP START ;=====Show program===== DISPLAY:MOV DPTR,#DAT1; table lookup display program, use P0 port as segment selection code output/P2 lower three bits as bit selection code output, MOV A,R3 MOVC A,@A+DPTR MOV P2,#0feH MOV P0,A ACALL DELAY2 MOV DPTR,#DAT2 MOV A,R5 MOVC A,@A+DPTR MOV P2,#0fdH MOV P0,A ACALL DELAY2 MOV A, R4 MOVC A,@A+DPTR MOV P2,#0fbH MOV P0,A ACALL DELAY2 RIGHT DAT1:DB 00h,06h,5bh,4fh,66h,6dh,7dh,07h,7fh,6fh,00H,71H ;"灭","1","2","3","4","5","6","7","8","9","灭","F" DAT2:DB 3fh,06h,5bh,4fh,66h,6dh,7dh,07h,7fh,6fh,00H,71H ; The first one is zero, the others are the same as above, because if the tens digit is zero, the display will go out ;====Addition and subtraction time delay (add N numbers without pressing)====== DELAY1: MOV 35H,#08H LOOP0: ACALL DISPLAY DJNZ 35H,LOOP0 RIGHT ;=====Delay 4236 machine cycles (used for debouncing)===== DELAY: MOV 32H,#12H LOOP: MOV 33H,#0AFH LOOP1: DJNZ 33H,LOOP1 DJNZ 32H,LOOP RIGHT ;=====Delay 4236 machine cycles (used for display)===== DELAY2: MOV 32H,#43H LOOP3: MOV 33H,#1EH MOV A, R7; read P1 port once every 60~70 machine cycles. If all are 1, it is invalid data. Continue reading. If one is not 1, go to normal response processing. JNZ AAAA1; Continue to AAAA1 if no valid data is read LOOP2: DJNZ 33H,LOOP2 DJNZ 32H,LOOP3 RIGHT ;=====Read the answer key data port program===== ;When reading the answer data port, the MCU first enters the countdown program, then calls the display program, and finally detects the key port ;However, when detecting the key port, dynamic scanning needs to call the delay program three times (4ms). This will cause a lag in reading the data port, resulting in the highest priority for No. 1 and the lowest priority for No. 8. Therefore, a data port reading program is added to the delay subroutine to ensure sensitivity and reliability. AAAA1: MOV A,P1 CJNE A,#0FFH,AA1; Data that is not all 1 is valid data AA0: MOV 36H,A; send valid data to 36H for temporary storage AJMP LOOP2 AA1: DEC R7 AJMPAA0 ;=====Voice Program===== BARK: SETB RING ACALL DELAY1 ACALL DELAY1 CLR RING; key sound RIGHT ;=====TO overflow interrupt (ring program)===== T0INT: MOV TH0,#0ECH MOV TL0,#0FFH JNB RING,OUT; CPL P3.6; When the RING flag is 1, the P3.6 port is not shorted and the speaker emits a certain frequency sound. OUT: RETI ;=====T1 overflow interrupt (timing program)===== T1INT: MOV TH1,#3CH MOV TL1,#0B0H INC R0 RARELY END
Previous article:Improvement on 4×4 Matrix Keyboard Circuit
Next article:Design of a Simple Digital Storage Oscilloscope
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- What are the factors that have a huge impact on PCB assembly mechanism?
- Tantalum electrolytic capacitor replacement issues
- Making noise with MicroPython and Pi Pico
- Analog Electronics Course Test + Isolation Amplification
- Microcontroller learning record - building a development environment
- [2022 Digi-Key Innovation Design Competition] Part 1: Unboxing the Smart Desktop Interactive Robot
- Discussion on STM32F103 power supply 3.3V routing in PCB design
- 【TI recommended course】#LED function introduction and LED driver design considerations#
- 12V power supply EMC design
- IPC-7525 Chinese Document