newlandmark

[Shenzhen University Electric Competition] Simple Voltmeter

 
Overview

This project won the first prize in the 2020 Shenzhen University Electronic Design Competition

Topic: Simple Voltmeter (Circuit Design)

  • Basic parts:

  1. Make a minimum system of 51 microcontroller (stm32 and the like are also acceptable, just make the system board yourself). The minimum system includes clock circuit, reset circuit, serial port download circuit, etc., and there are sockets for display devices such as OLED or LCD1602, etc. There are enough keys to satisfy the following requirements.

  2. Integrate the ADS1115 chip and its application circuit into the above system.

  3. The microcontroller controls the ADS1115 to collect the voltage and display it. The measurement voltage range is 0-5V.

  4. Set two modes. One mode has no memory function and can quickly detect and update the current voltage. Mode 2 has a memory function. The current voltage is updated after pressing the button, and the previous voltage can be stored. At least 5 sets of data can be stored and can be reviewed.

  • Play part:

Design an additional DA conversion circuit that can set a voltage value arbitrarily within a certain range (0-5V), and then serve as a voltage source to test and verify the function of the voltmeter.

Participating team information

  • Upper/lower grade group: Lower grade

  • Title: Simple Voltmeter

  • Team name: Liver until dawn

2020 Shenzhen University Electronic Design Competition Work Report

1. demand analysis

Functional requirements:

  • Make the smallest system board for a microcontroller, including basic circuits and display circuits
  • The above system contains the ADS1115 chip and uses it to measure the voltage 0~5V
  • Two modes, one quickly detects and displays voltage, the other stores and can be reviewed
  • Play part: Design the DAC circuit, set the voltage value 0~5V, and then use the upper part to detect

Technical performance indicators:

  • Microcontroller: enough I/O ports
  • ADS1115 chip: range 0~5V
  • DA circuit C: output 0~5V voltage

Required knowledge:

  • Familiar with the use of 51 microcontroller and drawing the circuits of each module, and configuring the display module
  • Familiar with the configuration and use of the ADS1115 chip
  • Learn the conversion and use of the two modes of the ADS1115 chip
  • Draw the DAC circuit and control its output voltage value

Bill of Materials:

bill of materials.png

2. Plan selection and demonstration

(1) Main control chip selection

  • stm32f103: This chip has powerful control capabilities and comes with a 12-bit DAC conversion chip. But this project is relatively simple and does not require an overly powerful chip. Using stm32 is a waste of its capabilities and money.
  • stc89c52: This chip is powerful enough to meet the requirements of this competition, and the price is also cheap. So the final solution used this chip.

(2) Display equipment

  • OLED: The use of this device requires a lot of RAM, which stc89c52 cannot meet, so it was abandoned.
  • LCD1602: This module is sufficient to meet the needs and has low RAM requirements, so this device is adopted.

(3) Play part

  • stc89c52 uses the DAC5571 chip to directly control the output voltage. It has sufficient accuracy and is cheap, so it is adopted.
  • stc89c52 controls DAC0832 to control the output current and then convert it into voltage. The peripheral circuit is relatively complex and there will be a loss of accuracy in the process of converting current to voltage, so it is not used.

3. System architecture and function description

(1) ADC module

  • The ADC module contains the basic parameters, communication and function implementation of the ADC, corresponding to the ADS1115 chip in the hardware.
  • Parameter settings include the basic parameters of each register of ADS1115 and the address of ADS1115 in different modes (including multiple detection mode, single detection mode and lookback mode).
  • Communication includes the basic operations of I2C in ADS1115, including initialization, start, write, read and end functions.
  • The function implementation includes the switching logic and function implementation of the three modes (multiple, single voltage detection and lookback mode) that ADS1115 is responsible for, as well as the conversion of the read voltage.

(2) DAC module

  • The DAC module includes communication and function implementation in the DAC. Communication is also the basic operation of I2C. Functional implementation includes mode switching logic and functional implementation of voltage regulation, as well as output voltage conversion.

(3) LCD module

  • The LCD module contains the function implementation in the LCD, including initialization, screen display voltage value and mode, and screen clearing.

(4)Datatype module

  • Datatype integrates all serial port definitions to facilitate subsequent modifications.

(5)Usual module

  • Usual contains all common functions and variables, such as delay functions, key scanning functions, etc.

(6) Main program

  • Each module is called to realize the overall function, including the function implementation and conversion of the four modes and the corresponding reality of the LCD.

Specific function implementation: enter mode 0 after power on

  • Mode 0: Used to control the dac output voltage
    • Press button 1 to enter mode 1
    • Button 2 dac module update
    • Button 3 adds voltage
    • Button 4 Reduce voltage
  • Mode 1 is for continuous voltage detection
    • Press button 1 to enter mode 2
  • Mode 2 is used for single detection of voltage
    • Press button 1 to enter mode 0
    • Button 2 Update voltage
    • Press button 4 to enter review mode
  • Buttons 3 and 4 are used to turn pages in review mode.

4. Theoretical analysis and calculation

(1) Timing calculation

  • I2C timing diagram

I2C timing diagram.png

Since the clock frequency of stc89c52 is not high, it does not use high-speed mode and uses F/S mode.

Therefore, the delay function should delay more than 4.7us

(2) DAC calculation

VOUT=VDD*D/256

D is the data sent by stc89 to dac5571 through iic

(3) ADC calculation

ADC.png

The conversion register of ADS1115 is 16 bits, and the voltage value can be accurate to the voltage divided by 2 raised to the 15th power.

  • Calculation formula: The value sent by ADS1115 to the 51 microcontroller = the voltage value measured by ADS1115 / VCC power supply value * 2 to the 15th power

5. Circuit diagram and PCB

Schematic diagram

Schematic diagram.png

Regarding the design of a simple voltmeter, our group chose the STC89C52RC-40I chip. This chip has 44 pins and its package is PCLL.

  • First, you need to design a minimum system board. The basic parts are as follows:

(1) Clock circuit: An 11.0592MHz passive crystal oscillator is used to provide the clock signal, and load capacitors are connected to both ends of the passive crystal oscillator to ground.

(2) Reset circuit: When powering on, the capacitor is charged and the RST pin is high to achieve reset. When the RSTK1 button is pressed, the current flows into the ground through R15, and the high level at RST is reset.

(3) Serial port download circuit: Use CH340G chip to realize USART serial communication. When the six-pin self-locking button POWER is pressed to power on the microcontroller, it can be judged whether the power is on normally by the red LED light of LED1 turning on and off. When burning a program or communicating, you can judge whether the communication is normal or not by turning on and off LED2 and LED3.

(4) Independent buttons: Each time the power is turned on, the capacitors are charged. KEY1, KEY2, KEY3, and KEY4 are at low level and then remain at high level. When the independent button is pressed, they are at low level.

(5) Pull all the pins of P0 high to use as IO output ports; in addition, connect EA to high level to access the internal program memory; add two pin headers and connect them to VCC and GND respectively as a backup power input interface; connect some Pins are drawn out for easy control of other modules, etc.

  • After designing the minimum system board, start designing the module to implement a simple voltmeter:

(6) ADC: To measure the voltage, use the ADS1115 chip to collect the voltage, and connect the four input ports of AIN0-3 to the 4-pin header. In addition, the two pins SCL and SDA used for I2C communication are connected to pull-up resistors and pulled high, the ADDR pin is connected to ground to define its address, and ATERT/RDY is connected to P15 and left.

(7) LCD1602: After it can convert the voltage, it still needs to display. Use LCD1602 to complete it. Pin 3 of the interface circuit is connected to a 502 variable resistor to adjust the brightness of the backlight screen and lead out other pins, D0-7 Connect to P00-P07 to achieve parallel communication. The EN, RS, and WR pins are connected to P34 to P36, and the default is high level (P1 to P3 of the 51 microcontroller default to output high level)

(8) DAC: In addition, in order to facilitate the supply of voltage to the ADC part for testing, the DAC module extension part is designed. The chip uses DAC5571, which communicates in I2C mode. A0 is grounded to define the address. The SCL and SDA pins are connected to the same two-line microcontroller IO port as the ADC's I2C communication. The VDD pin is connected to the VCC power supply and filtered through a 100nF capacitor. Lead out VOUT, connect it to the 2-pin header output, and connect a filter capacitor at the same time.

PCB diagram

PCB diagram.png

  • PCB design is divided into the following steps:

(1) PCB rule design: power line (VCC, GND, 5V) line width is 20mil

(2) Frame design: Circuit board width 97mm, height 57mm

(3) Layout: As shown in the picture above

(4) Wiring: using automatic wiring

(5) Add silk screen: Silk screen draw the number of the pin header

6. Debugging and test results

Difficulties encountered during debugging and solutions:

  • Difficulty 1: The USB socket cannot be recognized. Reason: The crystal oscillator of the serial port download circuit was wrongly selected at the beginning. It was 11.0592MHZ. However, the ch340 chip requires that the minimum crystal oscillator cannot exceed 11.98MHZ. Solution: Change the crystal oscillator to 12MHZ.
  • Difficulty 2: The dac module fails when detecting voltage. Reason: The DAC module uses DAC5571, and its broadcast address conflicts with the ADS1115 address on this circuit board. Solution: Change the DAC module to another board and change the address on the other board. The iic pins are led to the mainboard p25 and p24 pins through Dupont lines to avoid iic address conflicts between the two modules.
  • The DAC module uses DAC5571, and its broadcast address conflicts with the ADS1115 address on this circuit board. Solution: Change the DAC module to another board, and lead the iic pin on the other board to the motherboard p25 through the Dupont line. p24 pin to avoid iic address conflict between the two modules (the schematic has been improved and this problem has been solved, but the code has not been updated)
  • There is an error of about 0.05V in the final debugging result. The main reasons for the error are: (1) The voltage provided by the notebook is unstable (after measurement, the voltage provided by the notebook is about 5.07V) (2) The purchased DAC chip is cheaper and its accuracy is not enough. (3) There is a certain error in the Ads1115 chip itself. (4) When writing program code, the measured values ​​are stored in variables defined by floating point numbers. The changed amount is prone to errors in calculation.

7. Conclusion

It was my first time to participate in an electronic competition, and I learned a lot. What impressed me most was that no matter what chip you use, you must read the chip manual carefully, and you must stay calm if any problems arise during the test. Participating in e-sports has improved your abilities in many aspects. To design a complete DIY, you need to consider all aspects, starting from the design of the basic circuit, to PCB layout, soldering circuit board, testing circuit board, and typing code. Testing procedures and final report documentation. Although this process is not as detailed as the product design process, it is very helpful for individuals to make some gadgets by themselves in the future. In short, regardless of whether you win a prize or not, the improvement of your skills is the biggest benefit from participating in e-sports. Mutual trust and collaboration among team members are also important. When designing circuits, we need to discuss the allocation of pins together; when writing code, we need to cooperate with each other and unify variable functions; in the final summary, we need to divide the work and complete it together. A team with strong comprehensive capabilities, a team with reasonable division of labor, and a team with good communication are also the keys to our ability to successfully complete the work.

8. References

[1]DAC5571 User Manual, https://atta.szlcsc.com/upload/public/pdf/source/20131206/1457706662524.pdf

[2]ADS1115 User Manual, https://wenku.baidu.com/view/9a840b3683c4bb4cf7ecd135.html

参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-06-23 08:44:49

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号