qnpv5

Based on CW32 voltage and current meter

 
Overview
Project Overview: This project presents

a voltage and current meter based on the CW32F303C8T6 chip
. Referring to official case studies, most resistors and capacitors have been replaced with 0603 surface-mount packages. The BOM (Bill of Materials) can be ordered with a single click! The project consists of two parts: the CW32F303C8T6 core board and the voltage and current expansion board. The CW32F303C8T6 core board can be soldered from the chip itself or directly used from the LCSC development board.
The voltage and current display can utilize digital tubes, 0.96" OLED displays, or 0.91" OLED displays.

Renderings and
Finished Product Displays are provided .
Design Notes:
1. Power Supply Circuit:
LDO (Low Dropout Linear Regulator) Selection: This project uses an LDO as the power supply. Considering that most voltage meter products are used in industrial scenarios with 24V or 36V power supplies, the SE8550K2, with a maximum input voltage of 40V, was selected. The main reason for not using a DC-DC step-down circuit to handle the large voltage drop is to avoid introducing DC-DC ripple interference during the design process; a secondary reason is to reduce project costs.
2. MCU Selection Analysis
This project uses the LCSC CW32F030C8Tx development board (core board) as the main controller, or the previously designed CW32F030C8T6 core board. Regarding voltage and current meters, we will learn about debugging and testing of STM32/CW32 and some other 32-bit microcontrollers based on the official website examples. Here, we will only compare it with the STM32F103C8T6 as a reference for learning device selection, learning the production process, improving understanding, and thus enhancing overall knowledge of component selection.
Avoid blind selection. When selecting the MCU (microcontroller unit) for this project, multiple aspects need to be considered to ensure that the selected MCU meets the project requirements.

Clearly define your project requirements: Clearly understand how much computing power the project needs, including clock speed, processor core type, whether a floating-point unit is needed, etc.
Clearly define the required I/O ports and important peripherals, such as ADC peripherals. Since this is a development board project, the main purpose is debugging and learning. Therefore, there are no strict limitations on the number of I/O pins; cost and other related issues are not considered.

The key advantages of the CW32 in this project include

: wide operating temperature range (-40~105℃);
wide operating voltage range (1.65V~5.5V; STM32 only supports 3.3V systems)
; strong anti-interference capability (HBM ESD 8KV); all ESD reliability meets the highest international standard (STM32 ESD 2KV)
; and a better ADC (12-bit high-speed ADC with ±1.0LSB INL 11.3ENOB, multiple Vref reference voltages... ...; (STM32 only supports VDD=Vref); and
stable and reliable eFLASH technology.

A detailed explanation of these advantages will be provided in the chapters on ADC sampling and related extensions.
The main characteristics of the CW32 ADC: This project requires a focus on the 4 reference voltage sources. (Content from the "CW32x030 User Manual")
3. Voltage Sampling Circuit:
The voltage divider resistors in this project are designed to be 220K+10K, therefore the voltage division ratio is 22:1 (ADC_IN11).
The voltage divider resistor selection

is designed to measure the maximum voltage. For safety reasons, this project uses 30V (the actual maximum display value can be 99.9V or 100V).
The ADC reference voltage is 1.5V in this project, and this reference voltage can be configured through the program.
To reduce the power consumption of the sampling circuit, the low-side resistor (R11) is usually chosen as 10K based on experience.

Then, the high-side resistance of the voltage divider resistor can be calculated using the above parameters.

The required voltage division ratio is calculated, i.e., the ADC reference voltage. The input voltage is designed; using known parameters, 1.5V/30V = 0.05 can be calculated.
The high-side resistance is calculated as low-side resistance/voltage division ratio; using known parameters, 10K/0.05 = 200K can be calculated.
A standard resistor is selected: a resistor slightly higher than the calculated value of 200K is chosen. We usually choose E24 series resistors; therefore, in this project, 220K, which is greater than 200K and closest to the calculated value, is selected.

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, one can choose to replace the voltage divider resistor or modify the reference voltage. The following example illustrates this:

Assuming the measured voltage is 160V, the solution is 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 expand 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 to improve measurement stability.
Range switching:
In this project, an additional voltage sampling circuit was added. Therefore, we can discuss the significance of range switching for improving measurement accuracy. Multimeters often have multiple range settings for more accurate measurements. By adjusting different ranges, the optimal measurement accuracy of the measured point within the corresponding range can be obtained.
This project requires a combination of hardware and software to achieve this function. When we first use the ADC_IN11 channel mentioned earlier to measure voltages below 30V... If the measured voltage is within 0~3V, use the ADC_IN9 channel for measurement. In this case, the measurement accuracy is greatly improved due to the reduced voltage division ratio. There are many ways to implement range switching; the development board design provides more design possibilities.
4. Current Sampling Circuit:
This project uses a low-side current sampling circuit for current detection. When learning how to use the low-side sampling circuit and the development board's meter interface, please do not solder R18!
The design analysis
for this project involves a sampling current of 3A, and the selected sampling resistor (R0) is 100mΩ. The following aspects need to be considered when selecting the sampling resistor:

the maximum value of the pre-designed measurement current;
the voltage difference caused by the 3A current sensing resistor in this project; and
the power dissipation of the current sensing resistor, which should generally not exceed 0.5V. A suitable package should be selected based on this parameter. Considering the power dissipation (temperature) issue under high current, a 1W metal-wound resistor package was chosen
. The voltage amplification factor across the current sensing resistor is also important. Since no operational amplifier is used in this project, the amplification factor is 1. The

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

Furthermore, because no amplifier circuit is used in this project, a larger sampling resistor is needed to obtain a higher measured voltage for measurement purposes.
Considering that larger resistors would result in greater voltage drop and higher power consumption, larger resistors cannot be chosen indiscriminately.
This project uses a 1W packaged 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.
To cope with different usage environments, especially high-current scenarios, the R0 resistor can be replaced with constantan wire or a shunt. The choice of alternative can be made 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:
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 brightness of the digital tubes. On the other hand, digital tubes have better mechanical properties and are not as easily damaged by external forces as display screens. They are often used in industrial and other applications requiring stable reliability. From a development learning perspective, it's easier to learn electronic measurement principles and related development in a more targeted way.
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, had good recognition and was soft and not dazzling.
Strictly speaking, the current-limiting resistors should be added to the segments; adding them to the positions would affect the display effect. In our actual design, we added them to the positions to save a few resistors, but the impact on the display was not significant. So we added them to the positions for convenience. The driving principle of
the digital tube
mainly involves controlling the switching state of each segment of the digital tube to display numbers, letters, or symbols. The following is a detailed explanation of the driving principle:

Basic structure of a digital tube:

A digital tube is usually composed of seven or eight LED segments (eight segments in this project). Each segment represents a part of the digital tube and can display numbers 0-9, letters AF, etc.
Digital tubes have two types: common cathode and common anode. The difference between them lies in whether the common terminal COM of the LEDs (i.e., the end connecting all LEDs) is connected to the negative or positive terminal of the power supply.


Driving Methods:

Segment Selection: The desired numbers or characters are displayed by controlling the on/off state of each segment of the digital tube. Each segment corresponds to a control signal; when the control signal is on, the segment lights up, and vice versa. (a, b, c, d, e, f, g, dp)
Bit Selection: The digital tube to be displayed is selected by controlling its bit lines. Bit line control sets the bit line of the desired digital tube to a high level, and the bit lines of other digital tubes to a low level. By continuously switching the state of the bit lines, the display can be switched between multiple digital tubes.


Driving Circuit:

The digital tube driving circuit can be implemented through hardware circuits, such as using integrated circuits like digital signal processors (DSPs), microcontrollers (MCUs), or shift registers to generate control signals suitable for the LEDs.
These control signals can be in the form of pulse width modulation (PWM) signals, serial data signals, etc. By controlling the frequency, width, and amplitude of these signals, the brightness of the digital tube can be controlled, thereby displaying the desired numbers or letters.


Software Control:

In addition to hardware driving circuits, the digital tube can also be driven by software. By programming and generating control signals suitable for the digital tube, more flexible and complex display effects can be achieved, such as scrolling or alternating display of numbers.


Driving common cathode and common anode digital tubes:

For common cathode digital tubes, the common cathode pin is connected to the negative terminal of the power supply, and the control pin is connected to the output pin of the control chip. When a number needs to be displayed, the control chip outputs the corresponding encoded signal to the control pin, causing the corresponding LED segment to light up.
For common anode digital tubes, the working principle is similar to that of common cathode digital tubes, except that the common anode pin is connected to the positive terminal of the power supply, and the control pin is connected to the output pin of the control chip.


Encoded display:

In order for the digital tube to display the corresponding number or character, the segment data port must output the corresponding character code. For example, to display the number "0", the character code for a common anode digital tube is 11000000B (i.e., C0H), while the character code for a common cathode digital tube is 00111111B (i.e., 3FH). The specific code depends on the actual digital tube.


Dynamic and static display:

Digital tubes can use either static or dynamic display methods. In static display, each of the eight segments of a digital tube is connected to an 8-bit I/O port address. As long as the I/O port outputs a segment code, the corresponding character is displayed and remains unchanged. Dynamic display, on the other hand, lights up each segment of the digital tube one by one in turn, achieving simultaneous visual display through rapid switching.



In summary, the driving principle of a digital tube is to control the switching state of each segment to display numbers, letters, or symbols, and to achieve display switching between multiple digital tubes through segment selection and digit selection. Simultaneously, the driving of the digital tubes can be implemented through hardware circuits or software control, and common cathode or common anode digital tubes can be selected as needed.
This project actually uses dynamic scanning display to drive the digital tubes.
Calculating the required current for the digital tubes
: Since this project uses dynamic scanning display to drive the digital tubes, at any given time, only a maximum of eight segments of the digital tubes (or LEDs) can be lit, or in other words, only one digit can be lit. According to the design, the required driving current is approximately 11mA (IO port high-level voltage 3.3V ÷ 300Ω).
At this point, it is important to ensure that the selected MCU has sufficient current-pull/sinking capability.
Analysis of the datasheet shows that the CW32 has no issues. (Some chips do not.)
6. LED Indicator:
Since the sinking current capability of chip I/O is often greater than the pulling current capability, LED1 is designed to be active low (on).
To reduce the current consumption of the LED, some LED brightness is sacrificed, the number of component parameters is reduced, and the current-limiting resistor for the LED is chosen to be 10K.
7. Button Circuit Design:
There are various design methods for button control circuits. Thanks to the fact that the CW32's I/O ports can be configured with pull-up and pull-down resistors internally, the button control circuit on the outside of the chip does not need to be configured. 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:
This project adds an extra TL431 circuit to provide a 2.5V reference voltage, which can be used to provide an external voltage reference for the chip to calibrate the AD. From a product design perspective, due to the inherent ADC performance advantages of the CW32, this circuit is not necessary. This circuit is designed on the development board for learning related application principles.
The TL431 is a relatively "old" device, a classic with wide applications, and still found in many electronic products today.
Many beginners may be encountering this device for the first time, so we'll briefly explain its principles to help you better utilize the TL431.
TI defines it as a "Precision Programmable Reference," and we can focus on several key features on the first page of the references.
Precision: Precision indicates that its output voltage is very accurate. I used a TL431 with ±0.5% accuracy, which measured 2.495V on the board at room temperature. Compared to common Zener diodes, the accuracy is vastly different. In the application circuit diagram, the TL431 is represented by a Zener diode symbol.
Adjustable Output Voltage: The adjustable output voltage is between Vref and 36V. In our project, we use the output Vref voltage, which is approximately 2.5V. Therefore, we use 2.5V in the description, which is approximately equal to 2.5V.
Sinking Current Capability: This refers to how much current the output voltage pin can provide, which is greatly related to the resistance value (R14) in the application circuit. It should not be less than 1mA. If there is no need for sinking current, do not design the current to be too high, causing unnecessary power consumption.
9. OLED Screen:
Both screens use the I2C protocol to communicate with the MCU. The communication address can be switched by adjusting the resistance on the screen as needed. It can be used for learning and verifying the I2C protocol.
10. Buzzer Circuit
11. Demonstration Video
: https://b23.tv/9rnQsnW
 
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2026-03-26 18:21:33
  • Clock Oscillator Circuit Analysis
  • CCS V5 local variable problem
  • About 51 single chip microcomputer control DC motor speed regulation
  • Who has a pudn account? Can you help me download the program?
  • Help with microvolt-level DC voltage amplification
  • Problems with configuring multiple registers in FPGA

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号