Lhe20gH9Qf

Voltmeter and Ammeter Training Camp

 
Overview
This project uses the CW32F030C8T6 as its core, enabling adjustable voltage and current measurements.
Hardware Design:
1. Power Supply Circuit:
This project uses an LDO as the power supply. Considering that most voltmeter products are used in industrial scenarios with 24V or 36V power supplies, the SE8550K2 with a maximum input voltage of 40V was chosen as the power supply. The main reason for not using a DC-DC buck converter to handle large voltage drops is to avoid introducing DC-DC ripple interference during the design process; a secondary reason is to reduce project costs.
 
2. MCU Selection:
Key Advantages of CW32 in this Project

- Wide Operating Temperature Range: -40~105℃
Wide Operating Voltage: 1.65V~5.5V (STM32 only supports 3.3V systems)
Superior Interference Resistance: HBM ESD 8KV All ESD reliability reaches the highest international standard level (STM32 ESD 2KV)
Project Focus - Better ADC: 12-bit high-speed ADC, achieving ±1.0LSB INL 11.3ENOB Multiple Vref Reference Voltages... (STM32 only supports VDD=Vref)
Stable and Reliable eFLASH Technology. (Flash0 pending)

 
3. Voltage Sampling Circuit Voltage
Divider Resistor Selection


and Design: The maximum value of the measured voltage is 30V for safety reasons (the actual maximum display value can be 99.9V or 100V);


ADC reference voltage is 1.5V in this project, which can be configured through the program;


power consumption, in order to reduce the power consumption of the sampling circuit, the low-side resistor (R7) is usually selected as 10K based on experience;


then the high-side resistance of the voltage divider resistor can be calculated using the above parameters:


Calculate the required voltage division ratio: i.e., ADC reference voltage: Design input voltage, which can be calculated using known parameters as 1.5V/30V=0.05


Calculate the high-side resistance: i.e., low-side resistance/voltage division ratio, which can be calculated using known parameters as 10K/0.05=200K


Select a standard resistor: Select a resistor slightly higher than the calculated value, which is 200K. We usually choose E24 series resistors, so in this project, we choose 220K, which is greater than 200K and closest to it.


If, in actual use, the voltage to be measured is lower than 2/3 of the module's design voltage (66V), the voltage divider resistor can be replaced and the program modified to improve measurement accuracy. The following example illustrates this:


Assuming the measured voltage is no higher than 24V and other parameters remain unchanged,


calculations show 1.5V/24V = 0.0625, 10K/0.0625 = 160K. 160K is a standard E24 resistor and can be directly selected, or a higher value 180K can be chosen with some redundancy.


If, in actual use, the voltage to be measured is higher than the module's 99V design voltage, a different resistor can be selected. To achieve a wider voltage measurement range, you can choose to replace the voltage divider resistor or modify the reference voltage. The following example illustrates this:


Assuming the measured voltage is 160V, we can choose to increase the voltage reference to expand the range.


Given that the voltage division ratio of the selected resistor is 0.0145, we can calculate 160V * 0.0145 = 2.32V using the formula. Therefore, we can choose a 2.5V voltage reference to increase the range (increasing the range will reduce accuracy).


Considering the potential fluctuations in the measured power supply, a 10nF filter capacitor is connected in parallel with the low-side voltage divider resistor in the circuit design to improve measurement stability.
 
4. Current Sampling Circuit
The sampling current designed for this project is 3A, and the selected sampling resistor (R0) is 100mΩ.
The selection of the sampling resistor mainly needs to consider the following aspects:

the maximum value of the pre-designed measurement current; in this project,
the voltage difference caused by the 3A current sensing resistor is generally not recommended to exceed 0.5V
; the power consumption of the current sensing resistor should be selected based on this parameter. Considering the power consumption (temperature) issue under high current, a 1W packaged metal wire-wound resistor was selected.
The voltage amplification factor across the current sensing resistor: No operational amplifier was used to build the amplification circuit in this project, so the factor is 1.

The current sensing resistor value can then be calculated using the above parameters

. The project does not use an amplifier circuit, therefore a larger sampling resistor is needed to obtain a higher measured voltage for measurement.
Considering that a larger resistor will result in a larger voltage drop and higher power consumption, a larger resistor cannot be selected indiscriminately.
This project uses a 1W package resistor, corresponding to a temperature rise power of 1W.

Based on the above data, a 100mΩ current sensing resistor was selected. According to the formula, 3A * 100mΩ = 300mV, 900mW can be calculated.
To cope with different usage environments, especially high current scenarios, the R0 resistor can be replaced with constantan wire or a shunt. The replacement can be selected according to the actual usage scenario. For safety and educational purposes, this project will not discuss the range exceeding 3A in detail, but the principle is the same.
 
5. Digital Tube Display Circuit
This project uses two 0.28-inch three-digit common cathode digital tubes as display devices. Compared with a display screen, digital tubes have better recognition in complex environments. According to the actual usage environment requirements, smaller current limiting resistors can be used to achieve higher digital tube brightness. On the other hand, digital tubes have better mechanical properties and are not as easily damaged by external forces as display screens. In industrial applications requiring stability and reliability, this technology is widely adopted. From a development learning perspective, it facilitates more targeted learning of electronic measurement principles and related development.
In this project, after actual testing, the current-limiting resistors (R1~R6) of the digital tube were configured to 300Ω. The corresponding brightness, whether for red or blue digital tubes, exhibited good visibility and a soft, non-glaring brightness.
 
6. Indicator Circuit:
Since chip I/O often has a greater current-sinking capability than current-pull capability, LED1 is designed to be active low (on). To reduce LED current consumption, some LED brightness was sacrificed, and the number of component parameters was reduced; the LED current-limiting resistor was chosen to be 10K.
 
7. Button Circuit Design:
There are various design methods for button control circuits. Thanks to the CW32's internal I/O ports which can be configured with pull-up and pull-down resistors, the button control circuit on the chip's periphery does not require configuration. One end of the button is connected to the MCU's I/O, and the other end is grounded. When the button is pressed, the I/O is pulled low.
 
8. TL431 Circuit Design for Voltage Measurement and Calibration. Understanding the TL431's operating
principle
is beneficial for quickly understanding its different applications.
The functional block diagram can be found in TI's datasheet; we only need to analyze its equivalent schematic.
The core of the 431 is an operational amplifier, which acts as a comparator in the circuit. Internally, the chip has a voltage Vref (approximately 2.5V) applied to the inverting input of the comparator. A voltage is input to REF at the non-inverting input of the comparator. When this voltage is greater than Vref, the comparator outputs a high level, enabling the transistor and connecting the CATHODE (cathode) and ANODE (anode) terminals. If REF and CATHODE are at the same potential (connected), the potential at REF is pulled low. When the potential at REF drops below Vref, the comparator outputs a low level, the transistor turns off, and the potential at REF rises back up. When it rises above Vref, the above process continues, and so on. Because the hardware response speed is extremely fast, the voltage at REF is almost equal to Vref.
 
8. Schematic and PCB Design Considerations:
Pads and Reinforcement.
In PCB design, I often use elongated oval pads for through-hole components to increase the contact area between the solder, soldering iron, and the pad, making soldering easier. Meanwhile, a silkscreen layer is designed as a separator between closely spaced pads. On actual circuit boards, the raised silkscreen layer significantly reduces solder bridging during soldering. This method is widely used in product design to improve production yield.

Figure 27
Solid filler is used to reinforce pads and some traces, preventing scratches and damage to the circuit board and pad detachment during use. In fact, given the excellent quality of JLCPCB PCB materials, this design is unnecessary in double-layer board designs; the author's initial intention was primarily to demonstrate and broaden the user's perspective. Teardrop
tools can be used for reinforcement in double-layer board designs.
The Kelvin connection method for current sampling resistors

Figure 28
eliminates the influence of line resistance and contact resistance on measurement results. In high-precision sampling applications, dedicated four-wire sampling resistors are also available, but this will not be discussed here.
Silkscreen printing and manufacturing processes :
Silkscreen printing on general PCBs is sprayed on, so when the font size is small and the line width is thick, blurring may occur, leading to unclear markings. It is recommended to choose appropriate silkscreen font size and line width, as different silkscreen fonts have different effects. Choosing a suitable font will result in better printing performance at the same line width and font size.
DRC design considerations:
Power supply traces should be as wide as possible, approximately 20-60 mil.
Ordinary signal lines: around 10 mil .
ADC signal traces: 10 mil or 8 mil. Too wide a trace may affect signal integrity when the line is too long.
Since high-speed circuit design is not involved, the 3W principle is not emphasized here.
Standardize component pin spacing: such as using imperial units, utilizing the grid and grid functions of EDA software, and arranging component positions and traces reasonably.
 
Software program design:
GPIO driver and code configuration are relatively simple, so details are omitted here.
1. Digital tube driver:
Combining the schematic diagram, the approach to driving the digital tube display is: first, number the pins represented by A, B, C, D, E, F, and G from low to high, and list the segment code values ​​of the numbers to be displayed. For example, to display the number 5, the segment code value is 0x6d, which is represented in binary as 01101101. This means G is set to 1, F to 1, E to 0, D to 1, C to 1, B to 0, A to 1, and the highest bit is the value of DP. Storing the numbers to be displayed as segment code values ​​in an array for later retrieval simplifies the program. Then, using a loop combined with a switch statement, the on/off status of A, B, C, D, E, F, and G is calculated individually. Determining the segment code value before selecting the bit code avoids insufficient display effect due to the microcontroller's program execution time.
Dynamic scanning display means sending segment codes and bit codes to each digit of the LED display in turn, utilizing the afterglow of the LEDs and the persistence of vision to make the human eye perceive that all digits are displaying simultaneously. Having understood the principle, to make the three digits of the voltmeter and ammeter display different values ​​simultaneously, we need to use the CW32's timer function, performing the display refresh action within the timer's interrupt service routine.
 
2. The
CW32F030 uses a successive approximation 12-bit ADC for sampling. Successive approximation ADCs operate on a common principle: they approximate the digital representation of the input signal by comparing the magnitude of the analog signal with a reference voltage. In a successive approximation ADC, the input signal and reference voltage are fed into a differential amplifier to generate a differential voltage. This differential voltage is then input to a successive approximation quantizer, which compares it to a series of reference voltages in a progressively decreasing manner. Specifically, at each approximation stage, the quantizer compares the input signal with an intermediate voltage point, using the reference voltage above or below that point as the reference voltage for the next approximation stage. This process continues until the quantizer approximates the final digital output value.
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2026-03-28 09:14:55

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号