qoistoochee128

[MCU] Digital tube control circuit design

 
Overview

1Project Introduction

  The digital tube circuit is designed based on the STC89C52RC microcontroller. The microcontroller and peripheral circuits form the main control circuit, the buttons form the control circuit, the digital tube forms the display circuit, and CD4511BE forms the drive circuit. By pressing different buttons to control the digital tube display, functions such as self-increasing and self-decreasing can be realized.

2 Overall design plan

  The block diagram of the digital tube control circuit system is shown in Figure 2-1 . The main control microcontroller uses STC89C52RC , the power input uses a 5V power supply, the control input terminal only has button input, and the digital tube displays. The overall design is simple and efficient, without cumbersome and complicated driving components.

Figure 2-1 Digital tube control circuit system structure block diagram

3 Circuit Principle

  The digital tube control system based on the STC89C52RC microcontroller is mainly composed of the power supply circuit, the minimum system circuit of the microcontroller, the program download circuit, the button control circuit, the digital tube display circuit and the CD4511 drive circuit. The circuit principles of each module will be analyzed below.

3.1 Power circuit

  The power part is mainly the Micro USB female socket as the power input port, SW1 is the toggle switch, C1/C2 is the power filter capacitor, and POWER is the power indicator light. Turn on the USB , flip the SW1 switch, the POWER power indicator light will light up, and power the entire board.

Figure 3-1 Power input circuit

3.2 Minimum system circuit of microcontroller

  The main control microcontroller uses STC89C52RC ( LQFP-44 package), which is cheap, high-speed, reliable, low power consumption, and has 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 the 0~80MHz of the ordinary 8051. The actual operating frequency can reach 48MHz . The Flash program memory space size is 8K bytes. On-chip integrated 512 -byte RAM data memory, operating temperature range is -40~85 ℃.

Figure 3-2 STC89C52RC minimum system circuit

3.3 Program download circuit

  The program is downloaded using a Micro USB data cable. The USB to serial port chip uses CH340C ( SOP-16 package), which has a built-in clock and does not require an external crystal oscillator. The D+/D- pin of the CH340C chip is connected to the D+/D- of the Micro USB . TXD/ The RXD pin is connected to the RXD/TXD pin of the microcontroller, the VCC pin inputs an external 5V power supply, C7 is the decoupling capacitor of the power supply, and C8 is the filter capacitor.

Figure 3-3 USB to TTL program download circuit

3.4 Button circuit

  In the button control circuit, the 4 buttons are directly connected to the 4 I/Os of the microcontroller . Through the writing of software programs, functions such as button control of digital tube addition and subtraction display are realized.

Figure 3-4 Button circuit

3.5 codec circuit

      The CD4511 codec chip converts the decimal BCD code into a 7 -segment binary code, lights up the corresponding digital tube segment, and displays the corresponding number. According to the CD4511 data manual, it is found that it can only display 0~9 and cannot display A~F .

Figure 3-5 Function table  of CD4511BE

Figure 3-6 CD4511 drive circuit

3.6 Display circuit

  显示电路由10.56寸共阴数码管及7个上拉电阻所组成,接收来自CD4511BE锁存译码器的逻辑状态,对应点亮数码管,显示数字。a~g输入为高电平时,点亮对应的数码管段,比如数码管显示数字1bc输入为1,数码管对应点亮bc段;其余为0,数码管其余段不点亮)。

3-7 数码管显示电路

4 原理图设计

4.1新建工程

  打开嘉立创EDA,创建新工程并命名为【单片机】数码管控制电路设计,将原理图文件命名为:SCH_数码管控制电路设计。根据以下电路进行绘制电路原理图。

4-1  SCH_数码管控制电路设计

4.2 器件选型

  在本项目的元器件选型中,所有器件可直接在立创EDA的元件库中进行搜索。如果对元器件不熟悉,也可以通过复制物料中的商品编号进行搜索(每一个元器件在立创商城都有唯一的商品编号),如果出现物料缺货情况,亦可选择其他可替换物料,通过以上电路的分析,相信聪明的你对各个元器件在电路中的作用有所了解,那么更换个别物料也不会影响到电路的工作性能的,了解电路工作特性后,电路选型也就变得简单了。

4-2 元器件搜索示意图

4-3 通过商品编号搜索示意图

4.3 物料清单

数码管控制电路设计项目物料清单

序号

名称

参数

位号

数量

封装

商品编号

1

电阻

1K

R1,R3~R6

5

R0805

C17513

10K

R2,R7

2

R0805

C17414

330

R8~R14

7

R0805

C17630

2

电容

10uF

C1,C3

2

C0805

C386019

100nF

C2,C6~C8

4

C0805

C38141

30pF

C4,C5

2

C0805

C43094

3

二极管

LED-0805_R

POWER

1

LED0805

C72037

4

按键

K4-6x6_SMD

KEY1~KEY5,RST

5

KEY-SMD_4P

C191626

5

开关

SS-12D02-VG4

SW1

1

SW-TH_SS-12D02-VG4

C136719

6

晶振

12MHz

X1

11

HC-49S/SMD

C14871

7

数码管

0.56英寸共阴

SEG1

1

LED-SEG-TH_10P-L12.6-W19.0-P2.54-BL

C8093

8

单片机

STC89C52RC

U1

1

LQFP-44

C8707

9

编解码器

CD4511BE

U2

1

SOP-16

C356693

10

USB芯片

CH340C

U3

1

SOP-16

C84681

11

USB连接器

Mirco USB

USB1

1

MICRO-USB-SMD_5P

C40957

12

排针

2.54*2P

J1

1

HDR-M-2.54_1X2

C124375

13

短路帽

2.54mm

J1

1

HDR-M-2.54_1X2

C5305

14

铜柱

M3

TP1~TP4

1

M3X10-6

C551322

5 PCB设计

  完成原理图设计后,经过检查电路与网络连接正确后点击顶部菜单栏的 “设计 ”→ “原理图转PCB”(快捷键为Alt+P),随即会生成一个PCB设计界面,可先暂时忽略弹出的边框设置,然后将PCB文件保存到工程文件中,并命名为:PCB_数码管控制电路设计

5.1 边框设计

  在绘制PCB前需根据个人意愿以及元器件数量所占空间确定PCB的形状及边框大小,若无特殊外壳要求,一般设计成矩形、圆形以及正方形。在设计该项目时,秉承着大小合适,美观大方的原则,我们在顶部工具菜单栏下的边框设置选型中设定了一个长为85mm、宽50mm、圆角半径为2mm的圆角矩形。实际板框大小会随着布局布线中进行调整,如果太小可适当放大,太大也可缩小边框,风格样式可自由发挥,但尽量控制在10cm*10cm之内,这样就可以到嘉立创免费打样啦~

5-1 边框设置                            图5-2边框示意图

5.2 PCB布局

  在绘制完板框外形后,接下来进行PCB设计的第二步,对元器件进行分类和布局,分类指的是按照电路原理图的功能模块把各个元器件进行分类,图中有很多按键和对外的接口,这里需要我们用到嘉立创EDA所提供的布局传递功能,首先确保PCB工程已保存到原理图文件的同一个工程文件夹中,然后框选原理图中的某一电路模块,比如选中按键电路,然后点击顶部菜单栏中的 “工具”  “布局传递”(快捷键为Ctrl+Shift+X),PCB页面所对应的元器件就好进行选中并按照原理图布局进行摆放, 使用这个方法将各个电路模块进行分类后依次摆放在前面所放置的边框中。

在布局的时候注意摆放整齐,可根据飞线的指引进行摆放,按照原理图信号的流向和器件连接关系进行摆放,是可以把原理图器件摆放非常整齐的,在布局的过程中注意接口位置。 在该项目的布局中提供以下几点参考建议:

Mirco USB和拨动开关靠左侧板边摆放;

CH340C的退耦电容尽量靠近相连引脚,D+/D-信号线贴近平行布线;

③晶振底下尽量不要走线,靠近放置在单片机附近,减小干扰;

④按键键等间距排列放置在下侧板边,数码管放置在左上方;

⑤在板边四个角分别放置M3铜柱孔,用于固定支撑;

5-3 PCB布局参考图

5.3 PCB走线

  接下来进行PCB设计的第三步:PCB走线,全称为印刷电路板布线(PCB LAYOUT)。由于电路板有顶面与底面两个面,在PCB走线也就可以分为顶层和底层走线,其中顶层走线默认是红色线,底层为蓝色线,也可按照个人喜好设置其他颜色,走线也就是在电路板中按照飞线连接导线,将相同的网络连接起来即可。

  首先选择层与元素中要走线的层,然后点击导线工具进行连线(快捷键为W)。看似简单的连连看,其中需要我们耐心的进行调整,元器件的摆放布局也会影响走线的难度,所以还需要在走线过程中进一步调整布局,进一步优化。前面所介绍的PCB布局相当于是在给走线做铺垫,布局好了走线也就自然顺畅了。该项目的走线中提供以下几点参考建议:

电源线设置为25mil,信号线设置为15mil宽度;

走线以顶层走线为主,走不通的可以切换到底层进行连接;

走线过程中优先走直线,需要拐弯的地方以圆弧拐弯或钝角为主;

最后加上泪滴,添加丝印标记该按键功能以及接口功能;

5-4 PCB走线参考图

5.4 覆铜与丝印

    PCB 走线画完后进行覆铜,就可以连接好 GND 网络。丝印字符遵循从上往下从左到右的原则。对拨动开关、电源指示灯和按键等加上丝印标注说明,在板子加上工程名称与LOGO注释。

5-5 PCB顶层覆铜与丝印参考图

 

5-6 PCB 层覆铜与丝印参考图

6 电路调试

6.1 硬件调试

1)器件焊接

  第一,先焊接Micro USB接口;第二,焊接CH340CCD4511BESTC89C52RC(焊接芯片时要注意方向,别焊反了);第三,电阻、电容和LED;第四,晶振和按键;第五,排针、开关和数码管。

6-1 PCB装配图

6-2 未焊接PCB

 

  注意焊接过程中用电安全手不要接触到烙铁头,避免烫伤。焊接时元器件对准位置,检查型号是否正确。焊接贴片元器件用镊子夹住时,要等焊锡凝固后再移走镊子,否则易造成虚焊。焊接过程注意锡线是否虚焊漏焊,避免影响电路性能,导致电路不能正常工作。

6-3 PCBA实物图

6-4 PCB-3D渲染图

(2)硬件调试

  若焊工比较粗糙,在焊接完一种元器件,可以目测检查是否短路,也可用万用表检查。焊接完成后需要使用万用表检查电源与地是否短路,焊接过程中有没有出现短路以及断路的情况,检查无误后方能进行上电测试。

During the debugging process, it was found that the CH340C would backflow and light up the power indicator light. This caused an abnormal phenomenon that the power indicator light also lit up when the toggle switch was not turned on. Therefore, a pin header J1 was added in front of the CH340C , and a short-circuit cap was used when programming and downloading. Short-circuit pin header J1 , CH340C is working and programming. When not downloading and programming, pull out the short-circuit cap, CH340C will not work, reducing the power consumption of the board.

 

6.2 Software debugging

( 1 ) Programming environment

  Use keil C51 for programming and development. Microcontrollers such as AT89 series, STC89 series and STC15 series can all be developed using keil C51 . The keil C51 software supports hundreds of chips. The official download address is: https://www.keil. com/download/product/

( 2 ) Program introduction

 

 

( 3 ) Firmware burning

  Use Hongjing's STC-ISP to download the programming and burning software, and use the Mirco USB data cable to download the program to the microcontroller. The official download address is: http://www.stcmcudata.com/

参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-05-15 00:28:34

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

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号