1. Determine the task
and develop the minimum system of the single-chip microcomputer
. 2. Task analysis:
The functions of this system:
(1) It has a 2-digit LED digital tube display function.
(2) It has eight-way light-emitting diodes to display various running lights.
(3) It can complete various sound-generating experiments such as playing music and alarming.
(4) It has a reset function.
3. Functional analysis
(1) For the two-digit LED digital tube display function, we can use the P0 port of the single-chip microcomputer to connect two digital tubes to realize this function;
(2) For the eight-way light -emitting diode display, we can use the P1 port to connect eight light-emitting diodes to realize this function;
(3) Various sound-generating functions such as playing music and alarming can be realized by connecting a buzzer to the P2.0 pin.
(4) The 9th pin of the single-chip microcomputer can be designed as a reset system, and we use a button reset; the 18th and 19th pins of the single-chip microcomputer can be designed as a clock circuit , and we use the internal oscillation method of the single-chip microcomputer to design it.
4. Design block diagram
5. Hardware circuit design
Based on the functions of this system and the working conditions of the microcontroller, we designed the following circuit diagram.
6. Determination of the component list:
Digital tube: 2 common cathodes (discrete)
Electrolytic capacitors : 10UF 2
30PF capacitors 9
220 ohm resistors 1
4.7K resistor 1 1.2K resistor
1 4.7K
resistor 1
12M Hz crystal oscillator 1
active 5V buzzer 1
AT89S51 microcontroller 1 normally
open button switch 1
locking socket (easy to remove the core, green)
8 LEDs (5MM red)
15*17CM universal board circuit board
S8550 transistor 1
4.5V battery box, several wires.
7. Soldering
of the hardware circuit Solder the above components according to the schematic diagram, and the detailed steps are omitted.
8. Related program writing
According to the above circuit schematic diagram, design the detailed functions of this system:
(1) The first LED lights up and the digital tube displays "1".
(2) The second LED lights up and the digital tube displays "2".
(3) The eighth LED lights up and the digital tube displays "8".
The above is the effect of a running light .
(4) All the LEDs go out and the digital tube displays "0".
(5) The digital tube displays "1". (
6) The digital tube displays "2, ..." until "9, A, B, C, D, E, F, Y".
(7) After the buzzer sounds nine alarms, repeat all the above steps. (8)
The program is as follows:
ORG 0000H; pseudo-instruction, define the following program code (machine code) to be stored in the unit with address 0000H.
LJMP START; jump to the place marked START for execution.
ORG 0030H; pseudo-instruction, define the following program code (machine code) to be stored in the unit with address 0030H.
START:MOV P1,#0FEH; light up the first LED.
CLR P2.7; send a low level to the first digital tube to turn on the digital tube.
CLR P2.6; send low level to the second digital tube, turn on the digital tube.
MOV P0,#06H; let the digital tube display "1".
LCALL DELAY; call the delay subroutine to achieve the purpose of delay.
MOV P1,#0FDH; light up the second LED.
MOV P0,#5bH; let the digital tube display "2".
LCALL DELAY; call the delay subroutine to achieve the purpose of delay.
MOV P1,#0FBH; light up the third LED.
MOV P0,#4fH; let the digital tube display "3".
LCALL DELAY; call the delay subroutine to achieve the purpose of delay.
MOV P1,#0F7H; light up the fourth LED.
MOV P0,#66H; let the digital tube display "4".
LCALL DELAY; call the delay subroutine to achieve the purpose of delay.
MOV P1,#0EFH; light up the fifth LED.
MOV P0,#6dH; Let the digital tube display "5".
LCALL DELAY; Call the delay subroutine to achieve the purpose of delay.
MOV P1,#0DFH; Light up the sixth LED.
MOV P0,#7dH; Let the digital tube display "6".
LCALL DELAY; Call the delay subroutine to achieve the purpose of delay.
MOV P1,#0BFH; Light up the seventh LED.
MOV P0,#07H; Let the digital tube display "7".
LCALL DELAY; Call the delay subroutine to achieve the purpose of delay.
MOV P1,#7FH; Light up the eighth LED.
MOV P0,#7fH; Let the digital tube display "8".
LCALL DELAY; Call the delay subroutine to achieve the purpose of delay.
MOV P1,#00H; Turn off all the LEDs.
MOV P0,#3FH; Let the digital tube display "0".
LCALL DELAY; Call the delay subroutine to achieve the purpose of delay.
MOV P0,#06H; Let the digital tube display "1".
LCALL DELAY; Call the delay subroutine to achieve the purpose of delay.
MOV P0,#5bH; Let the digital tube display "2".
LCALL DELAY; Call the delay subroutine to achieve the purpose of delay.
MOV P0,#4fH; Let the digital tube display "3".
LCALL DELAY; Call the delay subroutine to achieve the purpose of delay.
MOV P0,#66H; Let the digital tube display "4".
LCALL DELAY; Call the delay subroutine to achieve the purpose of delay.
MOV P0,#6dH; Let the digital tube display "5".
LCALL DELAY; Call the delay subroutine to achieve the purpose of delay.
MOV P0,#7dH; Let the digital tube display "6".
LCALL DELAY; Call the delay subroutine to achieve the purpose of delay.
MOV P0,#07H; Let the digital tube display "7".
LCALL DELAY; Call the delay subroutine to achieve the purpose of delay.
MOV P0,#7fH; Let the digital tube display "8".
LCALL DELAY; Call the delay subroutine to achieve the purpose of delay.
MOV P0,#6fH; Let the digital tube display "9".
LCALL DELAY; Call the delay subroutine to achieve the purpose of delay.
MOV R4, #9; send the alarm count to the buzzer.
LOOP: SETB P2.0; no sound
LCALL DELAY; call the delay subroutine to achieve the purpose of delay.
CLR P2.0; sound.
LCALL DELAY; call the delay subroutine to achieve the purpose of delay.
DJNZ R4, LOOP; execute downward after sounding nine times.
SETB P2.0; turn off the sound
LJMP START; jump to the label START to execute and loop this program.
DELAY: MOV R7, #200; this is the delay subroutine.
D1: MOV R6, #200
D2: MOV R5, #200
D3: DJNZ R5, D3
DJNZ R6, D2
DJNZ R7, D1
RET; return instruction of the delay subroutine.
END; end pseudo instruction.
9. Use KEIL C51 software to debug and compile the above program to generate *.HEX files so that they can be written into the microcontroller chip using a programmer.
10. Use of the programmer: Use the programmer to write the *.HEX files generated in the computer into the chip.
11. Product debugging: Connect a 4.5V (three-cell battery) power supply to debug the system. If there are no errors, it can work normally.
Previous article:Method of directly driving LED digital tube by 51 MCU IO port
Next article:Design of low-cost ECG monitoring system based on 51 single-chip microcomputer
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- 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
- It's holiday time, but we're still working overtime every day
- Tuya Sandwich Wi-Fi & BLE SoC NANO Main Control Board WBRU+ Unboxing
- Why should we have an oscilloscope
- Why use WDM-PON in 5G fronthaul
- 【Iprober 520 Current Probe】Evaluation Report (II) Basic Performance Test
- MicroPython Hands-on (28) - Yeelight for the Internet of Things
- Basic operations and precautions for exporting Gerber files from PCB design (Part 1)
- Allegro cannot be installed due to VC2005. Is there any way to fix this?
- Has anyone used Sensortile Box? Please help~
- The serial clock SCL and serial data SDA of the PROM are connected to the master MCU and then to the SC of the clock IC...