[Abstract] The hardware system design of this design mainly includes five parts: power module, test voltage input module, ADS1115 analog-to-digital conversion part, STC8A8K64S4A microcontroller minimum system part, LCD1602 liquid crystal display part and digital-to-analog conversion module. First, the ADS1115 analog-to-digital conversion chip and the LCD 1602 liquid crystal display are initialized by the microcontroller. When the measured voltage is connected externally, the ADS1115 converts the analog voltage signal into a digital signal and inputs it to the I/O port of the microcontroller. After processing by the microcontroller, the voltage is displayed on LCD 1602 liquid crystal above. The digital-to-analog conversion module functions as a voltmeter self-test. The DAC circuit converts it into an analog signal by controlling the clock circuit according to the integral conversion principle, and then transmits it to the AIN port of the ADC for voltage detection and conversion, and then displays it on the liquid crystal.
**(1) ** Functional requirements: ① Signal acquisition, to realize real-time acquisition of external voltage signals ② ADC circuit, to realize the conversion from the collected analog signal to digital signal ③ Display circuit, to quantify the digital signal ④ Storage Circuit, uses the memory module to store at least five sets of data, which can be reviewed ⑤ Buttons: No. 1 (power system switch); No. 2 (conversion between two modes); No. 3 (reset key data update); No. 4 (data view up) key); No. 5 (data view up key) ** Non-functional requirements: ** ① The circuit schematic diagram and PCB layout are beautiful and neat ② The design appearance is small and exquisite ③ The response speed is improved ④ The data results are accurate and the error is small ⑤ The measurement accuracy is high **(2) ** Technical performance indicators ① Full-scale range FSR: 0~5V ②Measurement accuracy: 19.53mv ③Basic error: 1~4 mv ④Conversion speed: 32us **(3) ** Required knowledge and materials Required knowledge: ① Basic knowledge of C51 microcontroller, including static and dynamic digital tubes, buttons, interrupts, serial communication, EEPROM-IIC, A/D and D/A conversion, LCD1602 liquid crystal display, etc. ② Basic digital and electrical analog knowledge ③ Basics Schematic and PCB design knowledge and skills ④ Lichuang EDA software learning ⑤ Practical electronic circuit design knowledge base ⑥ C51 programming language
⑴****Hardware solution selection and demonstration The STC8A8K64S4A12 chip is developed by STC. This microcontroller does not require an external crystal oscillator and external reset. At the same operating frequency, the STC8 series microcontroller is 12 times faster than the traditional 8051. And there is a maximum 64K-byte Flash space memory inside, which is used to store user codes. It supports user configuration of EEPROM size, 512-byte single page erasure, and the number of erases can reach more than 100,000 times. Because we need to write a lot of program code in this design, in order to prevent insufficient memory space, we choose the STC8A8K64S4A12 microcontroller chip. At the same time, the erasable advantage of online programming also facilitates us to modify the code we write at any time. Therefore we choose the STC8A8K64SA12 chip.
(2) Software simulation solution selection and demonstration In the software simulation, we chose the more familiar C51 chip to replace the STC8A8K chip in the hardware design. Because the STC chip simulation model has fewer simulation models and is unstable, we chose to use a The external EEPROM combined with the C51 chip replaces the STC8A8K chip in the hardware circuit. In addition, due to difficulties encountered in the verification process of ADS1115 (detailed analysis will be provided later), ADC0832 was also used to verify other modules.
⑴Hardware design
由上图可知,本设计的硬件系统设计主要包括五个部分:分别是电源模块、测试电压输入模块、ADS1115模数转换部分、STC8A8K64S4A单片机最小系统部分、LCD1602液晶显示部分以及数模转换模块。首先由单片机初始化ADS1115模数转换芯片和LCD 1602液晶显示,当外接被测电压后,ADS1115将模拟电压信号转换为数字信号输入到单片机的I/O口,通过单片机处理后将电压的大小显示在LCD 1602液晶上面。数模转换模块的起到电压表自检功能,DAC电路通过控制时钟电路根据积分换算原理将其转换为模拟信号,传入ADC的AIN口,进行电压检测转换,再显示到液晶上。 ① 电源模块设计 系统电源使用直流5V,由电脑USB接口提供电源,通过CH340G转接芯片实现 USB 转串口。 CH340 是一个 USB 总线的转接芯片,实现 USB 转串口或者 USB 转打印口。 特点:(1)全速 USB 设备接口,兼容 USB V2.0。 (2)仿真标准串口,用于升级原串口外围设备,或者通过 USB 增加额外串口。 (3)计算机端 Windows 操作系统下的串口应用程序完全兼容,无需修改。 (4)支持 5V 电源电压和 3.3V 电源电压甚至 3V 电源电压。 (5) CH340C 和 CH340B 内置时钟,无需外部晶振,CH340B 还内置 EEPROM 用于配置序列号等。 ② 单片机最小系统设计 STC8A8K64S4A12 系列特性:(1) 内核 :超快速 8051 内核(1T);指令代码完全兼容传统 8051;22 个中断源,4 级中断优先级;支持在线仿真 。 (2)工作电压 :2.0V~5.5V ;内建 LDO 。 (3) Flash 存储器 : 最大 64K 字节 FLASH 空间,用于存储用户代码 ;支持用户配置 EEPROM 大小,512 字节单页擦除,擦写次数可达 10 万次以上; 支持在系统编程方式(ISP)更新应用程序,无需专用编程器 ;支持单芯片仿真,无需专用仿真器,理论断点个数无限制 。 (4) SRAM:128 字节内部直接访问 RAM(DATA); 128 字节内部间接访问 RAM(IDATA) ;8192 字节内部扩展 RAM(内部 XDATA);外部最大可扩展 64K 字节 RAM(外部 XDATA)。 (5) 时钟控制: 内部 24MHz 高精度 IRC; 内部 32KHz 低速 IRC(误差较大); 有外部晶振(4MHz~33MHz)和外部时钟 ,用户可自由选择 3 个时钟源 。 (6) 复位: 有硬件复位 ;上电复位 ;复位脚复位(高电平复位) ;看门狗溢出复位 。 (7) 中断: 提供 22 个中断源:INT0、INT1、INT2、INT3、INT4、定时器 0、定时器 1、定时器 2、定时器 3、定时器 4、串口 1、串口 2、串口 3、串口 4、ADC 模数转换、LVD 低压检测、PCA/CCP、SPI、I2C、比较器、增强型 PWM、增强型 PWM 异常检测;提供 4 级中断优先级 。 (8) 数字外设: 5 个 16 位定时器:定时器 0、定时器 1、定时器 2、定时器 3、定时器 4,其中定时器 0 的 模式 3 具有 NMI(不可屏蔽中断)功能,定时器 0 和定时器 1 的模式 0 为 16 位自动重载模式 ; 4 个高速串口:串口 1、串口 2、串口 3、串口 4,波特率时钟源最快可为 FOSC/4 ;4 组 PCA 模块:CCP0、CCP1、CCP2、CCP3,可用于捕获、高速脉冲输出和 6/7/8/10 位的 PWM 输出 ; 8 组 15 位增强型 PWM,可实现带死区的控制信号,并支持外部异常检测功能;SPI:支持主机模式和从机模式以及主机/从机自动切换 ; I2C:支持主机模式和从机模式 。 (9) 模拟外设: ADC支持 12 位精度 16 通道的模数转换 。 (10)GPIO :最多可达 59 个 GPIO:P0.0~P0.7、P1.0~P1.7、P2.0~P2.7、P3.0~P3.7、P4.0~P4.4、P5.0~P5.5、 P6.0~P6.7、P7.0~P7.7 ,所有的 GPIO 均支持如下 4 种模式:准双向口模式、强推挽输出模式、开漏输出模式、高阻输入模式 。 ③ 模数转换模块设计 ADS1115是具有16位分辨率的高精度模数转换器(ADC),采用超小型的无引线QFN-10封装或MSOP-10封装。ADS1115具有一个板上基准和振荡器。数据通过一个I2C兼容型串行接口进行传输;可以选择4个I2从地址,采用2.0V至5.5V的单工作电源。ADS1115能够以高达每秒860个采样数据(SPS)的速率执行转换操作。ADS1115 具有一个板上可编程增益放大器(PGA),该PGA可提供从电源电压到低至±256mV的输入范围,因而使得能够以高分辨率来测量大信号和小信号。另外,ADS1115还具有一个输入多路复用器(MUX),可提供2个差分输入或4个单端输入。ADS1115可工作于连续转换模式或单触发模式,后者在一个转换完成之后将自动断电,从而极大地降低了空闲状态下的电流消耗。 Table2.ADS1115 pin description
Pin# |
ADS1115 |
Digital signal/analog signal input/output |
Function |
1 |
ADDR |
digital signal input |
Bus address selection |
2 |
ALERT/RDY |
Digital signal output |
Digital comparator output or conversion ready |
3 |
GND |
analog signal |
power ground |
4 |
AIN0 |
Analog signal input |
Input channel 1 (positive input or single-ended signal input) |
5 |
AIN1 |
Analog signal input |
Input channel 2 (negative input or single-ended signal input) |
6 |
AIN2 |
Analog signal input |
Input channel 3 (positive input or single-ended signal input) |
7 |
AIN3 |
Analog signal input |
Input channel 4 (negative input or single-ended signal input) |
8 |
VDD |
analog signal |
Positive power supply (2V~5.5V) |
9 |
SDA |
Digital I/O port |
Serial data: transmitting and receiving signals |
10 |
SCL |
digital signal input |
Serial clock input: clock data on SDA |
All data is transmitted in 8 bits via the I2C bus. To send a bit on the I2C bus, drive the SDA line to the appropriate level while SCL is low (a low on SDA means the bit is a zero; a high means the bit is a 1). After the SDA line is stable, the SCL line is high and then low. A pulse on SCL converts the SDA bit clock into the receiver shift register. Because the I2C bus driver is open-drain, both the SDA and SCL lines require pull-up resistors. ④ Liquid crystal display module design The display part of this system uses LCD liquid crystal display, using a 16*2 character-type liquid crystal display module LCD1602. It has light weight, small size, low power consumption, and can display 192 characters (5*7 dot characters), 32 kinds of characters (5*10 dot characters), eight kinds of characters can be programmed by oneself, strong command function, can be combined into various input, display, and shifting modes to meet different requirements, simple and convenient interface, high reliability, etc. . a**.The main technical parameters of LCD1602 : (1) Display capacity: 16×2 characters (2) Chip operating voltage: 4.5-5.5V (3) Operating current: 2.0mA (5.0V) (4) Optimal module operating voltage: 5.0 V (5) Character size: 2.95×4.35(W×H)mmLCD1602 adopts standard 14-pin (without backlight) or 16-pin (with backlight) interface. b **. ****Table3.** Interface description of each pin**
serial number |
symbol |
Pin description |
serial number |
symbol |
Pin description |
1 |
VSS |
power ground |
9 |
D2 |
data |
2 |
VCC |
Positive pole of power supply |
10 |
D3 |
data |
3 |
VL |
LCD bias |
11 |
D4 |
data |
4 |
RS |
Data/command selection |
12 |
D5 |
data |
5 |
R/W |
read/write selection |
13 |
D6 |
data |
6 |
E |
enable signal |
14 |
D7 |
data |
7 |
D0 |
data |
15 |
BLA |
Backlight positive electrode |
8 |
D1 |
data |
16 |
BLK |
Backlight negative electrode |
Software design flow chart:
~~~~
All reference designs on this site are sourced from major semiconductor manufacturers or collected online for learning and research. The copyright belongs to the semiconductor manufacturer or the original author. If you believe that the reference design of this site infringes upon your relevant rights and interests, please send us a rights notice. As a neutral platform service provider, we will take measures to delete the relevant content in accordance with relevant laws after receiving the relevant notice from the rights holder. Please send relevant notifications to email: bbs_service@eeworld.com.cn.
It is your responsibility to test the circuit yourself and determine its suitability for you. EEWorld will not be liable for direct, indirect, special, incidental, consequential or punitive damages arising from any cause or anything connected to any reference design used.
Supported by EEWorld Datasheet