1 Project Introduction
The simple digital tube electronic clock designed based on the STC89C52RC single-chip microcomputer has 6 1-bit digital tubes to form the display circuit. The dp segment dots of the digital tubes are used to realize the intermediate display of the hours, minutes and seconds of the clock. The hours, minutes and seconds of the clock are adjusted and calibrated by pressing the buttons to realize the 24-hour dynamic display of the clock.
2 Overall Design
The block diagram of the digital tube electronic clock system is shown in Figure 2-1. The main control microcontroller uses STC89C52RC, the power input uses 5V, and the TYPE-C interface is used. The program download reserves a 1x4Pin 2.54mm spacing pad interface, and the buttons use a 6*6*6mm patch package. The digital tube displays the time. The overall design is simple and efficient, without cumbersome and complex driving components.

Figure 2-1 System block diagram of digital tube electronic clock
3 Hardware design
The digital tube electronic clock designed based on STC89C52RC single-chip microcomputer is mainly composed of power supply circuit, single-chip microcomputer minimum system circuit, program download circuit, key control circuit and digital tube display circuit. The circuit principle of each module will be analyzed below.
3.1 Power supply circuit
The power supply part mainly uses Type-C female socket as power input port, SW1 is a toggle switch, and C1/C2 as power filter capacitor. Turn on TYPE-C, toggle SW1 switch, and power the entire board.

Figure 3-1 Power input circuit
3.2 Single-chip microcomputer minimum system circuit The main
control microcontroller uses STC89C52RC (LQFP-44 package), which is cheap, high-speed and reliable, low power consumption, and strong anti-interference. The instruction code is fully compatible with the traditional 8051 microcontroller, the operating voltage is 3.3~5.5V, the operating frequency range is 0~40MHz, which is equivalent to 0~80MHz of ordinary 8051, and the actual operating frequency can reach 48MHz. The Flash program memory space size is 8K bytes, and 512 bytes of RAM data memory are integrated on the chip. The operating temperature range is -40~85℃.
The P0 port (pins 30 to 37) of STC89C52 is special. When the P0 port is used as an input/output port, P0 is an 8-bit quasi-bidirectional port, which is in open-drain mode after power-on reset. There is no pull-up resistor inside the P0 port, so when used as an I/O port, a 4.7K~10K pull-up resistor must be connected externally. When the P0 port is used as an address/data multiplexing bus, the lower 8-bit address line [A0~A7] and the data line [D0~D7] do not require an external pull-up resistor.

Figure 3-2 STC89C52RC minimum system circuit
3.3 Program download circuit
Program download is carried out using USB-TTL tools, and a 1x4Pin 2.54mm spacing pad interface is reserved, which is simple and has no cumbersome devices.

Figure 3-3 Program download circuit
3.4 Digital tube display circuit
6 digital tubes form the display circuit, which is directly connected to a group of I/O ports of the single-chip microcomputer. The triode plays the role of driving the bit selection. The DP tube segment dots of the digital tube are used to realize the middle interval display of the clock hours, minutes, and seconds, and realize the 24-hour dynamic display of time.

Figure 3-4 Digital tube display circuit
3.5 Key circuit
The key realizes the time calibration function. Through the writing of the program, the effect of adding one calibration to the hours, minutes, and seconds can be realized. Other control functions can be realized by writing by yourself. Use 3 patches 6*6*6mm touch switch buttons.

Figure 3-5 Key circuit
4 Schematic design
4.1 New project
Open Jiali Chuang EDA, create a new project and name it [Single-chip microcomputer] Simple digital tube electronic clock, and name the schematic file: SCH_Simple digital tube electronic clock. Draw the circuit schematic according to the following circuit.

Figure 4-1 SCH_Simple digital tube electronic clock
4.2 Device selection
In the selection of components for this project, all components can be directly searched in the component library of Jiali Chuang EDA. If you are not familiar with the components, you can also search by copying the product number in the material (each component has a unique product number in Li Chuang Mall). If the material is out of stock, you can also choose other replaceable materials. Through the analysis of the above circuit, I believe that you are smart and understand the role of each component in the circuit. Then replacing individual materials will not affect the working performance of the circuit. After understanding the working characteristics of the circuit, circuit selection becomes simple.

Figure 4-2 Schematic diagram of component searchFigure

4-3 Schematic diagram of searching by product number4.3
Bill of MaterialsBOM_Simple
digital tube electronic clockSerial
No.
Name
Parameter
Position No.
Quantity
Package
Product
No.1
Resistor
10K
R1~R7
7
R0805
C17414
220
R8~R15
8
C114519
1K
R16~R21
6
C17513
2
Capacitor
10uF
C1,C3
2
C0805
C386019
100nF
C2,C4
2
C38141
30pF
C5,C6
2
C43094
3
Transistor
S8550
Q1~Q6
6
SOT-23-3
C444725
4
Key
K4-6x6_SMD
KEY1~KEY3,RST
4
KEY-SMD_4P-L6.0-W6.0
C191626
5
switches
MST22D18G2
SW1
1
SW-SMD_MST22D18G2
C2906280
6
crystal oscillator
12MHz
X1
1
OSC-SMD_4P-L5.0-W3.2-BL
C251597
7
Digital tube
0.56 inch common anode
SEG1~SEG6
6
LED-SEG-TH_10P-L12.6-W19.0-P2.54-S15.24-BL
C8092
8
MCU
STC89C52RC
U1
1
LQFP-44
C8707
9
USB
connector
TYPE-C
USB1
1
USB-C-SMD_TYPE-C-31-M-29
C2689969
10
Copper column
M3
TP1~TP4
4
M3X10-6
C551322
5 PCB design
After completing the schematic design, after checking that the circuit and network are connected correctly, click "Design" in the top menu bar → "Convert schematic to PCB" (shortcut key is Alt+I), then save the PCB file to the project file and name it: PCB_Simple digital tube electronic clock.
5.1 Frame design
Before drawing the PCB, the shape and frame size of the PCB must be determined according to personal wishes and the space occupied by the number of components. If there is no special shell requirement, it is generally designed as a rectangle, circle and square. When designing this project, adhering to the principle of appropriate size and beautiful appearance, we click Place → Board Frame → Rectangle under the top tool menu bar, with a length of 100mm, a width of 32mm, and a 2mm fillet. The actual board frame size will be adjusted with the layout and routing. If it is too small, you can enlarge it appropriately. If it is too large, you can reduce the border. You can freely play with the style, but try to control it within 10cm*10cm, so that you can go to Jiali Chuang for free proofing~

Figure 5-1 Border setting design
5.2 PCB layout
After drawing the board frame shape, the second step of PCB design is to classify and layout the components. Classification refers to classifying each component according to the functional module of the circuit schematic. There are many buttons and external interfaces in the figure. Here we need to use the layout transfer function provided by Jiali Chuang EDA. First, make sure that the PCB project has been saved in the same project folder as the schematic file, and then select a circuit module in the schematic, such as selecting the button circuit, and then click "Design" → "Cross Selection" in the top menu bar (the shortcut key is Shift+X), the components corresponding to the PCB page can be selected and placed according to the schematic layout. Use this method to classify each circuit module and place them in the border placed in front.
Pay attention to neat placement during layout. You can place them according to the guidance of the flying wires, and place them according to the flow direction of the schematic signal and the connection relationship of the devices. You can place the schematic devices very neatly. Pay attention to the interface position during layout. The following reference suggestions are provided in the layout of this project:
① Place the digital tubes on the top layer, one positive and one negative, and other devices on the bottom layer;
② Place the microcontroller in the center on the back of the bottom layer;
③ Place the crystal oscillator close to the microcontroller to reduce interference;
④ Place TYPE-C in the middle of the right side of the board;
⑤ Place the switch, button and burning interface on the upper side of the board;
⑥ Arrange the digital tube drive circuit at the bottom;
⑦ Place M3 copper column holes at the four corners of the board for fixed support;

Figure 5-2-1 PCB layout reference diagram-top layer

Figure 5-2-2 PCB layout reference diagram-bottom layer
5.3 PCB routing
The board size here is small and double-layer routing is difficult, so four-layer routing is used. To draw four or more layers of copper foil, you can click Tools → Layer Manager (shortcut key is Ctrl+L) to switch settings, click the copper foil layer drop-down to select 4, set the inner layer 1 type to signal layer, and set the inner layer 2 (GND) to inner electrical layer. When the GND layer is complete, you can also modify the color of each layer here.

Figure 5-3 Layer Manager
The top layer routing is red by default, the bottom layer is blue, the inner layer 1 is brown, and the inner layer 2 (GND) is green. You can also set other colors according to your personal preferences. Routing is to connect the wires in the circuit board according to the flying wires to connect the same network.
First, select the layer to be routed in the layer panel on the right (the shortcut key for layer switching is: top layer: T; bottom layer: B; inner layer 1: 1; inner layer 2: 2), and then click the single-way routing in the wiring toolbar to connect (the shortcut key is W). It seems simple to connect the dots, but we need to adjust it patiently. The layout of components will also affect the difficulty of routing, so we need to further adjust the layout and optimize it during the routing process. The PCB layout introduced above is equivalent to laying the foundation for routing. Once the layout is done, the routing will be smooth. The following reference suggestions are provided for the routing of this project:
① The power line is set to 25mil and the signal line is set to 10mil width;
② The routing is mainly based on the bottom layer routing. If it is not possible, you can switch to the inner layer 1 for connection;
③ Straight lines are preferred during the routing process, and arc turns or obtuse angles are mainly used where turns are required;
④ Finally, add teardrops and add silk screen to mark the button function and interface function;

Figure 5-4-1 PCB routing reference diagram-top layer

Figure 5-4-2 PCB routing reference diagram-inner layer 1

Figure 5-4-3 PCB routing reference diagram-bottom layer
5.4 Copper coating and silk screen
PCB copper coating after the routing is drawn, the GND network can be connected. Silk screen characters follow the principle of from top to bottom and from left to right. Add silk screen annotations to toggle switches, burning interfaces and buttons, and add project names and LOGO comments in the blank area of the board.

Figure 5-5-1 Copper cladding and silk screen reference diagram - top layer

Figure 5-5-2 Copper cladding and silk screen reference diagram - inner layer 1

Figure 5-5-3 Copper cladding and silk screen reference diagram - inner layer 2

Figure 5-5-4 Copper cladding and silk screen reference diagram - bottom layer
6 Circuit debugging
6.1 Hardware debugging
(1) Device welding
First, solder the TYPE-C interface; second, STC89C52RC (pay attention to the direction when soldering the chip, the dot is marked as pin 1, if there are multiple dots on the chip, usually the smallest dot); third, transistors, resistors and capacitors; fourth, crystal oscillators, switches and buttons; fifth, digital tubes (note that one is placed positive and the other is placed negatively according to the device silk screen mark).

Figure 6-1-1 PCB assembly diagram - top layer

Figure 6-1-2 PCB assembly diagram - bottom layer

Figure 6-2-1 PCB blank - top

Figure 6-2-2 PCB blank - bottom
Pay attention to electrical safety during welding. Do not touch the soldering iron tip with your hands to avoid burns. Align the components during welding and check whether the model is correct. When soldering SMD components with tweezers, wait until the solder solidifies before removing the tweezers, otherwise it is easy to cause cold soldering. During the welding process, pay attention to whether the tin wire is cold soldered or leaked to avoid affecting the circuit performance and causing the circuit to malfunction.

Figure 6-3-1 PCBA real picture - top

Figure 6-3-2 PCBA real picture - bottom

Figure 6-4-1 3D rendering - top

Figure 6-4-2 3D rendering - bottom
(2) Hardware debugging
If the welder is rough, you can visually check whether there is a short circuit after welding a component, or you can use a multimeter to check. After welding is completed, you need to use a multimeter to check whether the power supply and ground are short-circuited, and whether there is a short circuit or open circuit during the welding process. Only after checking that everything is correct can you perform power-on testing.
6.2 Software Debugging
(1) Programming Environment
Use keil C51 for programming and development. AT89 series, STC89 series and STC15 series microcontrollers can all be developed using keil C51. Keil C51 supports hundreds of chips. The official download address is: https://www.keil.com/download/product/
(2) Firmware Burning
Use Macrochip's STC-ISP to download the programming and burning software. Use the USB-TTL tool to download the program to the microcontroller. The official download address is: http://www.stcmcudata.com/
(3) Program Introduction
Configure the relevant parameters in STC-ISP. Select STC89C52RC as the chip model. Click the timer calculator tool, enter the corresponding system frequency, select the timer mode, etc. Then click Generate C Code and copy it to keil for use. When
compiling and debugging the program, it is found that AUXR will report an error because the AUXR register is not declared in the STC89C52RC header file reg52.h. You need to check the definition in the data sheet to enable it, that is, sfr AUXR = 0x8E;

Figure 6-5 Timer configuration operation diagram

Figure 6-6 Simple digital tube electronic clock operation diagram