An overview of information and procedures for designing a responder using a microcontroller

Publisher:PeacefulWarriorLatest update time:2024-03-08 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

In knowledge competitions, especially when answering questions, in order to know which group or contestant answers the question first, a system must be designed to complete this task. If there is a rush to answer, it is difficult to tell visually which group answers the question first. Using a microcontroller system to design a answering machine, the above problems can be solved. Even if the answering time of the two groups differs by a few microseconds, it can still be distinguished which group answers the question first. This article mainly introduces the design and working principle of the microcontroller answering machine, as well as its practical use. ! System Working Principle This system uses 8051 microcontroller as the core. The four modules of the control system are: storage module, display module, voice module, and answering switch module. The answering machine system inputs answering signals through four buttons of the switch circuit; uses the voice chip ISD1420 to complete the voice recording and playback function; uses stored programs; and uses a digital tube to complete the display function. When working, buttons are used to input each channel's answering signal through the switch circuit. After processing by the microcontroller, the control signal is output to control the work of the digital tube and the voice chip. The digital tube displays which group answers the question first, and reads "Group 9, please answer the question" through the voice system, thus realizing the entire answering process. The answering machine program is given in this article and needs everyone to improve it. If you have a better design, please contact me (there are contact information on the homepage of www.51hei.com). The schematic diagram of the system is as follows

1. If you want to adjust the answering time or answering time, press the "Answering Time Adjustment" key or the "Answering Time Adjustment" key to enter the adjustment state. At this time, the currently set answering time or answering time value will be displayed. If you want to add one second, press Press the "Add 1s" key. If you want to subtract one second, press the "-1s" key. The time LED will display the changed time. The adjustment range is 0s~99s. If you subtract 1s from 0s, it will jump to 99. At 99s, the time will jump to 99. Adding 1s will change it to 0s.

2. When the host presses the "Answer Start" button, there will be a prompt sound and the answer countdown will begin immediately (the default answer time is 15 seconds). If there is a contestant answering, there will be a prompt sound, and the number will be displayed and the answer countdown will begin immediately. (The default answer time is 10 seconds). There will be no answer query, so only the first contestant to press the answer will be valid. When the countdown time reaches less than 5 seconds, a beep will sound every second.

3. During the countdown, if the host wants to stop the countdown, he can press the "Stop" button at any time. The system will automatically enter the preparation state and wait for the host to press "Quick Start" to enter the next answering time.

4. If the host does not press the "Answer Start" button, but someone presses the "Answer" button, and there is a foul answer, the LED will flash FF and the foul number and ring continuously until the "Stop" button is pressed.

*************************************************** *****************************************

P1.0 is the start of the response, P1.7 is the stop, p1.1-p1.6 is the six-channel response input digital tube segment, select the P0 port, the bit selects the P2 port, and the buzzer output is the P3.6 port

*************************************************** *****************************************

;============

OK EQU 20H; Answer start flag; Swap P1 port and P2 port, P3.0-P1.0, P3.1-P1.7

RING EQU 22H; ring flag bit

ORG 0000H

AJMP MAIN

ORG 0003H

AJMPINT0SUB

ORG 000BH

AJMP T0INT

ORG 0013H

AJMPINT1SUB

ORG 001BH

AJMP T1INT

ORG 0040H

;===============-

;MCU answering machine main program design

;================

MAIN: MOV R1, #0FH; The initial response time is 15s

MOV R2, #0AH; The initial answer time is 10s

MOV TMOD, #11H; Set untimer/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 EA

SETB ET0

SETB ET1

SETB EX0

SETB EX1; Allow four interrupts, T0/T1/INT0/INT1

CLR OK

CLR RING

SETB TR1

SETB TR0; Run the timer at the beginning to start displaying FFF. If you want to count again, just reset TH1/TL1

;=====Query program=====

START: MOV R5, #0BH

MOV R4, #0BH

MOV R3, #0BH

ACALL DISPLAY ;displays FFF when answering is not started

JB P1.0,NEXT;ddddddd

ACALL DELAY

JB P1.0, NEXT; debounce, if the "start key" is pressed, execute downward, otherwise jump to illegal answer query

ACALL BARK; button sounds

MOV A,R1

MOV R6, A; send R1-》R6, because the answering time is saved in R1

SETB OK; the rush response flag, used in the COUNT program to determine whether to query the rush response

MOV R3, 0AH; the answer only shows the timing and the number of extinguished calls

AJMP COUNT; Enter the countdown program, "Query the effective response program" in COUNT

NEXT: JNB P1.1, FALSE1

JNB P1.2,FALSE2

JNB P1.3,FALSE3

JNB P1.4,FALSE4

JNB P1.5,FALSE5

JNB P1.6,FALSE6

AJMP START

;======Illegal response processing program=====

FALSE1: ACALL BARK; button sounds

MOV R3, #01H

AJMP ERROR

FALSE2: ACALL BARK

MOV R3, #02H

AJMP ERROR

FALSE3: ACALL BARK

MOV R3, #03H

AJMP ERROR

FALSE4: ACALL BARK

MOV R3, #04H

AJMP ERROR

FALSE5: ACALL BARK

MOV R3, #05H

AJMP ERROR

FALSE6: ACALL BARK

MOV R3, #06H

AJMP ERROR

;======INT0 (Answer 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, it jumps to INCO

JNB P3.5, DEC0; P3.5 is the -1s key, if pressed, it jumps to DECO

JNB P1.7, BACK0; P3.1 is the confirmation key, if pressed, jump to BACKO

AJMPINT0SUB

INC0: MOV A, R1

CJNE A, #63H, ADD0; If it is not 99, add 1 to R2. If it reaches 99, set R1 to 0 and start again.

MOV R1, #00H

ACALL DELAY1

AJMPINT0SUB

ADD0: INC R1

ACALL DELAY1

AJMPINT0SUB

DEC0: MOV A, R1

JZ SETR1 ;If R1 is 0, R1 is set to 99,

DEC R1

ACALL DELAY1

AJMPINT0SUB

SETR1: MOV R1, #63H

ACALL DELAY1

AJMPINT0SUB

BACK0:RETI

;======INT1 (response 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 P1.7,BACK1

AJMPINT1SUB

INC1: MOV A, R2

CJNE A, #63H, ADD1

MOV R2, #00H

ACALL DELAY1

AJMPINT1SUB

ADD1: INC R2

ACALL DELAY1

AJMPINT1SUB

DEC1: MOV A, R2

JZ SETR2

DEC R2

ACALL DELAY1

AJMPINT1SUB

SETR2: MOV R2, #63H

ACALL DELAY1

AJMPINT1SUB

BACK1: RETI

;=====Countdown program (both the answer countdown and the answer countdown jump to the modified program)======

COUNT: MOV R0, #00H; reset the number of timer interrupts

MOV TH1, #3CH

MOV TL1, #0B0H; Reset timer

RECOUNT:

MOV A, R6; R6 saves the countdown time, before giving the answer time or answer time to R6

MOV B, #0AH

DIV AB; divide by ten and get units/tens

MOV 30H, A; the tenth digit is stored in (30H)

MOV 31H, B; the units bit is stored in (31H)

MOV R5, 30H; take the tenth digit

MOV R4, 31H; take the ones digit

MOV A, R6

SUBB A, #07H

JNC LARGER; if it is greater than 5 seconds, jump to LARGER; if it is less than 5 seconds, it will remind you.

MOV A,R0

CJNE A, #0AH, FULL; runs downward for 0.5s in 1s

CLR RING

AJMP CHECK

FULL: CJNE A, #14H, CHECK; the following is the case of 1s, the number will ring and the number will be displayed and R0 will be cleared, and the calculation will be recalculated.

SETB RING

MOV A, R6

JZ QUIT ; Timing completed

MOV R0, #00H

DEC R6; subtract 1 from the one second mark

AJMP CHECK

LARGER:

MOV A,R0

CJNE A, #14H, CHECK; if it runs downward for 1s, otherwise it jumps to check "stop/display"

DEC R6; R6 automatically decreases by 1 after one second.

MOV R0, #00H

CHECK: JNB P1.7, QUIT; if you press the stop key to exit

ACALL DISPLAY

JB OK, ACCOUT; If it is a countdown to the response, if so, query the response, otherwise skip the query and continue the countdown (this plays the role of locking the response)

AJMP RECOUNT

ACCOUT:JNB P1.1, TRUE1

JNB P1.2,TRUE2

JNB P1.3,TRUE3

JNB P1.4,TRUE4

JNB P1.5,TRUE5

JNB P1.6,TRUE5

AJMP RECOUNT

QUIT: CLR OK; program executed if "stop key" is pressed

CLR RING

AJMP START

;======Normal response processing program======

TRUE1: ACALL BARK; button sounds

MOV A,R2

MOV R6, A; answer time R2 to get R6

MOV R3, #01H

CLR OK; Because the timing of answering questions is no longer queried, the rush to answer is 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

;======Foul answer procedure=====

ERROR: MOV R0, #00H

MOV TH1, #3CH

MOV TL1, #0B0H

MOV 34H, R3; foul number temporary storage and (34H)

HERE: MOV A, R0

CJNE A, #0AH, FLASH; run downward for 0.5s -> go off and stop ringing

CLR RING

MOV R3, #0AH

MOV R4, #0AH

MOV R5, #0AH; all three lights are off

AJMP CHECK1

FLASH: CJNE A, #14H, CHECK1; The following is the case of 1s, the number will beep and the number will be cleared, R0 will be cleared, and the calculation will be repeated.

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 P1.7, QUIT1

ACALL DISPLAY

AJMP HERE

QUIT1: CLR RING

CLR OK

AJMP START

;======MCU answering machine display program======

DISPLAY:

MOV DPTR, #DAT1; table lookup display program, using P0 port as segment code selection port output/P2 low three bits as bit code selection output,

MOV A, R5

MOVC A,@A+DPTR

MOV P2, #01H

MOV P0,A

ACALL DELAY

MOV DPTR, #DAT2

MOV A, R4

MOVC A,@A+DPTR

MOV P2, #02H

MOV P0,A

ACALL DELAY

MOV A, R3

MOVC A,@A+DPTR

MOV P2, #04H

MOV P0,A

ACALL DELAY

RET

DAT1:DB 00H, 06h, 5bh, 4fh, 66h, 6dh, 7dh, 07h, 7fh, 6fh, 00H, 71H

"Destroy", "1", "2", "3", "4", "5", "6", "7", "8", "9", "Destroy", "F"

[1] [2]
Reference address:An overview of information and procedures for designing a responder using a microcontroller

Previous article:Application plan for realizing multi-channel data comprehensive acquisition system based on single-chip microcomputer
Next article:Implement serial bus interface design using PDIUSBD12 chip and ADuC812 chip

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components
Guess you like

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号