
[ SCM ] Heart-shaped water lamp design based on 51 single chip microcomputer
PRO[ SCM ] Heart-shaped water lamp design based on 51 single chip microcomputer
License
:GPL 3.0
Description
1. Project introduction
Based on the STC89C52RC single-chip microcomputer design, the cardioid flow lamp is powered by the TYPEC interface, and 30 LED lights surround the PCB board, and you can DIY design the flow lamp form by yourself through the download interface.
2. Circuit principle
Based on the STC89C52RC single-chip microcomputer design, the cardioid flow lamp is mainly composed of the main control chip circuit, crystal oscillator circuit, reset circuit, USB power supply circuit, LED drive circuit, download interface circuit, the following will analyze the circuit principle of each module.
3. Circuit analysis
3.1. Main control chip circuit
The main control microcomputer uses STC89C52RC (DIP-40P 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 working voltage is 3.3~5.5V, the working frequency range is 0-40Mhz, which is equivalent to the 0~80Mhz of the ordinary 8051, the actual working frequency can reach 48Mhz, the Flash program memory space size is 8K bytes, the on-chip integrated 512-byte RAM data memory, and the operating temperature range is -40~85°C. RN1 in the figure is the pull-up resistance of the P0 port, and there is no pull-up resistor inside the P0 port, so the I/O port must be connected with an external pull-up resistor of 10K-4.7K. When P0 is used as an address/data multiplexing bus, it is a low 8-bit address line [A0~A7] and a data line [D0~D7], so there is no need for an external pull-up resistor.
Fig.3.1 STC89C52RC main control chip circuit
3.2. Crystal oscillator circuit
The function of the crystal oscillator is to provide a clock signal to the smallest system, and the capacitance next to the crystal oscillator is to ensure that the output oscillation frequency is more stable. According to the data sheet, the frequency of the crystal oscillator can be selected from 0M~48M, the frequency of the crystal oscillator is different, the corresponding matching capacitance is not the same, the commonly used crystal oscillator frequency is 12M or 11.0592Mhz, the main reason is that when using the 12Mhz crystal oscillator, it is just a machine cycle, that is, 1US, when designing the program, it is easier to calculate. When 11.0592MHz is used, an integer can be obtained in operations such as the baud rate of serial communication, and the structure of the calculation is more accurate and convenient. One cares for the time, one cares for the baud rate. The specific situation depends on the choice of project or individual needs.
Fig.3.2.1 Crystal oscillator circuit selection
Fig.3.2.2 Crystal oscillator circuit
3.3. Reset circuit
Reset is also called restart, when the power supply is powered on, the capacitor is not fully charged, at this time the RST pin is high, when the capacitor is fully charged, at this time it is a short circuit, the RST pin is pulled low by the resistance, and an external reset pulse is generated to reset the system.
Fig. 3.3 Reset circuit
3.4 USB power supply circuit
The power supply circuit is mainly composed of TYPE-C interface, using 2Pin TYPE-C interface, which is simple and convenient and easy to solder.
Fig.3.4 USB power supply circuit
3.5. LED drive circuit
Using 30 LEDs, 5V power input, passing through the LEDs and then passing through the 2K current limiting resistor to the IO pin, the IO pin outputs high and low levels to control the LED lights to turn on and off. STC89C52RC the general-purpose IO pin output high level of the microcontroller is not strong, it is recommended not to use the IO pin output high level to light up the LED light, but to use the output low level to light up.
Fig.3.5.1 Pin output capability
Fig.3.5.2 LED driver circuit
3.6. Download the interface circuit
Using USB to TTL serial port burning mode, a 1×4Pin in-line pin header interface is reserved for debugging and downloading programs.
Fig.3.6 Download circuit
4. Schematic design
4.1. New projects
Open JLC EDA Professional Edition, create a new project and name it [MCU] Based on the heart-shaped flow lamp design of 51 single-chip microcomputer, name the schematic file SCH_ cardioid flow lamp design. Draw a circuit schematic diagram based on the following circuits.
Fig.4.1 Design of SCH_ cardioid running water lamp
4.2. Device selection
In the component selection of this project, all components can be directly searched in the component library of JLC EDA. If you are not familiar with the components, you can also search by copying the commodity number in the material (each component has a unique commodity number in the Lichuang 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 to understand the role of each component in the circuit, then the replacement of individual materials will not affect the working performance of the circuit, after understanding the working characteristics of the circuit, the circuit selection has become simple.
Fig.4.2.1 Schematic diagram of component search
Fig.4.2.2 Search by supplier number
4.3. Bill of materials
Based on the design of 51 single-chip microcomputer, the cardioid flowing water lamp is designed | ||||||
NO. | name | parameter | tags | quantity | encapsulation | Supplier number |
1 | Main control chip | STC89C52RC-40I-PDIP40 | U1 | 1 | DIP-40_L52.0-W13.7-P2.54-LS15.2-BL | C14022 |
2 | Exclusion | 10K | RN1 | 1 | RES-ARRAY-TH_9P-P2.54-D1.0 | C8692 |
3 | resistance | 2K | R2~R31 | 30 | RES-TH_BD2.4-L6.3-P10.30-D0 | C410663 |
4 | 10K | R1 | 1 | RES-TH_BD2.4-L6.3-P10.30-D0.6 | C410695 | |
5 | LED lights | 红灯 | LED1~LED30 | 30 | LED-TH_BD5.9-P2.54-RD | C87271 |
6 | Crystal oscillator | 11.0592MHz | X1 | 1 | HC-49US_L11.5-W4.5-P4.88 | C127675 |
7 | capacitance | 22PF | C2、C3 | 2 | CAP-TH_L4.0-W2.6-P2.50-D0.5 | C2170230 |
8 | 10UF | C1 | 1 | CAP-TH_BD5.0-P2.00-D0.8-FD | C432355 | |
9 | USB connector | TYPE-C | USB1 | 1 | USB-C-TH_TYPE-C-31-M-33 | C2848624 |
10 | Pin header | 2.54*4P | H2 | 1 | HDR-TH_4P-P2.54-V-M | C492403 |
5. PCB design
After completing the schematic design, after checking that the circuit and network connection are correct, click "Design" → "Schematic to PCB" in the top menu bar (the shortcut key is Alt+P), and then a PCB design interface will be generated, you can temporarily ignore the pop-up border setting, and then save the PCB file to the project file, and name: PCB_ cardioid flow lamp design.
5.1. Frame design
Before drawing the PCB, you need to determine the shape and frame size of the PCB according to your personal wishes and the space occupied by the number of components, and the style can be played freely, but try to control it within 10cm*10cm, so that you can go to JLC for free proofing~, the following is an introduction to the steps of drawing a heart-shaped pattern:
Step 1: CirclesDraw two circles of equal radius and tangent in the drawing area.
Step 2, after drawing the circle, we will select a straight line, and we will draw a straight line downward from the tangent point of the circle.
Step 3, after drawing the straight line, we press the spacebar to take a point in the straight line, and cut the line to the two circles respectively.
Step 4, after drawing the tangent line, trim off the unnecessary line, so that the heart pattern is drawn
Step 5,modify the heart pattern to leave the TYPE-C interface position
You can also copy our reference frame directly.
Fig.5.1 Cardioid border
5.2. PCB layout
After drawing the outline of the board and frame, the second step of PCB design is to classify and layout the components, classification refers to the classification of each component according to the functional module of the circuit schematic, there are many keys and external interfaces in the diagram, here we need to use the layout transfer function provided by Jialichuang EDA, first ensure that the PCB project has been saved to the same engineering folder of the schematic file, and then select a circuit module in the schematic, such as selecting the main control circuit, Then click "Tools" → "Layout Transfer" in the top menu bar (shortcut key is Ctrl+Shift+X), and the corresponding components on the PCB page can be selected and placed according to the schematic layout.
Pay attention to the neat placement during the layout, according to the guidance of the flying line, according to the flow direction of the schematic signal and the connection relationship of the device, you can place the schematic device very neatly, and pay attention to the interface position in the process of layout. Provide the following suggestions in the layout of the project:
1. The TYPE-C interface is placed at the reserved cardioid frame.
2. Try not to trace the bottom of the crystal oscillator, and keep it close to the corresponding IO pin to reduce interference.
3. Place the LED lights around the heart-shaped lights, mainly not too close to the board frame.
4. The board is relatively simple, and a part of the silk screen can be removed to make it more concise and beautiful.
Fig.5.2 PCB layout reference drawing
5.3. PCB wiring
Next, the third step of PCB design: PCB wiring, which is called printed circuit board LAYOUT (PCB LAYOUT). Since the circuit board has two surfaces, the PCB wiring can be divided into the top and bottom lines, the top line is the default red line, the bottom line is the blue line, you can also set other colors according to personal preferences, the wiring is in the circuit board in accordance with the fly wire connection wire, the same network can be connected.
First, select the layer and the layer in the element that you want to route, and then click the wire tool to connect it (the shortcut key is W). The seemingly simple Lianliankan requires us to patiently adjust, and the placement layout of components will also affect the difficulty of wiring, so it is necessary to further adjust the layout and further optimize it in the process of wiring. The PCB layout introduced above is equivalent to paving the way for the wiring, and the wiring will be naturally smooth after the layout is completed. The following suggestions are provided in the routing of the project:
(1) The power line is set to 25mil, and the signal line is set to 15mil width;
(2) The wiring is mainly based on the top-level wiring, and those that can't be connected can be switched to the bottom layer for connection;
(3) In the process of wiring, the straight line is preferred, and the place that needs to be turned is mainly arc bend or obtuse angle;
(4) Finally, add teardrops, add silk screen marking of the key function and interface function;
Fig.5.3 PCB trace reference diagram
5.4. Copper pouring and silk screen printing
After the PCB traces are drawn, the copper is poured, and the GND network can be connected. Silk screen characters follow the principle of top-down and left-to-right. Add silk screen marking instructions to toggle switches, power indicators and buttons, etc., and add project names and LOGO annotations to the board.
Fig.5.4.1 Reference drawing of copper pouring and silk screen printing on the top layer of PCB
Fig.5.4.2 Reference diagram of copper pouring and silk screen printing on the bottom layer of the PCB
6. Circuit debugging
6.1. Hardware debugging
(1) Device soldering
In welding, attention should be paid to:
- When soldering, you can click on the welding auxiliary tool in the toolbar of the PCB interface of Jialichuang EDA Professional Edition, and the real-time interaction is convenient for soldering.
- When soldering the top layer, it is recommended to give priority to soldering of the TYPE-C interface to avoid other components affecting soldering.
- When welding the pin header, it can be used to resist an empty plate or a hole plate to prevent welding skew and affect the use.
- The welding sequence should follow the principle from low to high to avoid affecting the welding of small devices.
Fig.6.1.1 Empty PCB - Top Layer
Fig.6.1.2 Empty PCB - Bottom Layer
Fig.6.1.3 PCBA physical diagram
(2) Hardware debugging
If the welder is rough, after welding a component, you can visually check whether it is a short circuit, or you can use a multimeter to check. After the welding is completed, you need to use a multimeter to check whether the power supply is short-circuited with the ground, whether there is a short circuit and open circuit during the welding process, and the power-on test can be carried out only after the inspection is correct.
6.2. Software debugging
(1) Programming environment
Using keil C51 for programming and development, AT89 series, STC89 series and STC15 series and other single-chip microcontrollers can be developed with keil C51, and keil C51 software supports hundreds of chips.
Official download address: https://www.keil.com/download/product/
(2) Firmware burning
- Use the USB to TTL serial port burning tool to download the program to the single-chip microcomputer, the RXD of the USB to TTL cable is terminated to the TXD end of the single-chip microcomputer, and the TXD is terminated to the RXD end of the single-chip microcomputer;
- After clicking Download/Programming, you need to plug and unplug the VCC again to power on, and the handshake operation is successful, and the user code can be successfully downloaded.
Fig.6.2 Working diagram of cardioid running water lamp
Designed by 立创EDA课程案例推荐 (from OSHWHub)
Design Drawing


Comment