r8RdPILkD

CW32 Voltmeter and Ammeter Training Camp

 
Overview
The hardware design
includes schematics,
PCB
layout, 3D shell panel, and software
design. The software is programmed        using files from "Experiment 7 + Six-digit Current Channel Acquisition and Voltage Display.rar", "Experiment 8 + Simultaneous Voltage and Current Acquisition and Display.rar", and "Experiment 9 + Digital Voltage and Current Meter with Calibration Function.rar".        The following images demonstrate the effects of "Experiment 7 + Six-digit Current Channel Acquisition and Voltage Display.rar" and "Experiment 9 + Digital Voltage and Current Meter with Calibration Function.rar". Note: If the following image appears when installing CW32F030_StandardPeripheralLib_V2.1.zipIdeSupportMDKWHXY.CW32F030_DFP.1.0.4.pack, rename the WHXY.CW32F030_DFP.1.0.4.pack file to WHXY.CW32F030_DFP.1.0.0.pack. The demonstration shows the effects of current channel acquisition and voltage display. Mode 1: Voltage 5V calibration setting; Mode 2: Voltage 15V calibration setting; Mode 3: Current 0.5A calibration setting; Mode 4: Current 1.5A calibration setting.












Schematic diagram.pdf
PCB.zip
Bill of Materials.xlsx
3D Shell.zip
panel.epanm
Experiment 7 + Six-digit display of current channel for voltage acquisition and display.rar
Experiment 8 + Simultaneous Acquisition and Display of Voltage and Current.rar
Experiment Nine + Digital Voltmeter and Ammeter with Calibration Function.rar
CW32F030_StandardPeripheralLib_V2.1.zip
PDF_CW32 Voltage and Current Meter Training Camp.zip
Altium_CW32 Voltmeter & Ammeter Training Camp.zip
PADS_CW32 Voltage and Current Meter Training Camp.zip
BOM_CW32 Voltage and Current Meter Training Camp.xlsx
92860
CW32 Voltage and Current Meter
This project is based on the LCSC CW32F030C8T6 development board and involves the design and implementation of a digital voltmeter and current meter. It covers hardware circuit design, firmware development, and related calibration and testing processes.
I. Project Function Introduction
The project's functions include:

Voltage Measurement: Accurately measures DC voltage and displays real-time voltage values.
Current Measurement: Accurately measures DC current and displays the current current value.
Calibration Function: Provides calibration interfaces and methods to ensure the accuracy of measurement results.

Physical Demonstration:
II. Hardware Design
1. MCU Selection: This project uses the LCSC CW32F030C8T6.
Key advantages of the CW32 in this project:
• Wide operating temperature range: -40~105℃
• Wide operating voltage range: 1.65V~5.5V (STM32 only supports 3.3V systems)
• Strong anti-interference: HBM ESD 8KV, all ESD reliability reaches the highest international standard level (STM32 ESD2K)
• 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.
 
2. Power Supply Circuit: The LDO selected is the SE8550K2, which can input a maximum voltage of 40V. However, for safety reasons, voltages exceeding 30V should be avoided. Alternatively, the Type-C interface or programming port on the development board can be used for power supply.
 
3. Voltage Sampling Circuit: Designed to sample voltages up to 100V, but for safety, the actual configuration is 0-30V. A voltage divider circuit is composed of 220KΩ and 10KΩ resistors, resulting in a voltage division ratio of 22:1. The ADC reference voltage in this project is 1.5V. A 1N4148 diode is used as a clamping diode to prevent damage to the MCU due to excessive input voltage. Diode clamping limits the voltage amplitude and protects the circuit from overvoltage damage. An additional voltage sampling circuit is added, selecting different sampling channels based on the actual voltage to improve measurement accuracy. Switching to a higher-precision channel is used within the 0-3V range for measurement.
 
4. Current Sampling Circuit: A low-side current sampling circuit is used for current detection. The low-side of the sampling circuit shares a common ground with the development board's meter interface. 5. Select a 100mΩ sampling resistor (be sure to choose a large package, such as 2512, or use a through-hole resistor) to detect a maximum current of 3A.
 
6. Voltage Measurement Calibration TL431 Circuit Design: An additional TL431 circuit is added to provide a 2.5V reference voltage, which can be used to provide an external voltage reference for the chip to calibrate the AD converter.
 
7. Digital Tube Display: Two 0.28-inch three-digit common-cathode digital tubes are used as display devices, with a 300Ω current-limiting resistor for the tubes.
 
8. LED Indicator: A power indicator and an LED connected to the microcontroller's PC13 port are added to the power supply circuit.
 
9. Button Circuit Design: Three buttons are provided for user use.
 
9. PCB Design:
Kelvin Connection of Current Sampling Resistor:
When placing the DC power interface and the pin header connecting the development board, pay attention to the placement position and distance (the center-to-center spacing of the pin headers connecting the development board is 600mil).
The DC power input should be placed sequentially according to the schematic diagram.
When using copper pour for the current sampling section, do not use the default divergent connection method with the pads; choose direct connection or use fill.
DRC Design Considerations:
Power traces should be as wide as possible, approximately 20-60mil.
Ordinary signal lines: around 10mil
. ADC signal traces: 10mil or 8mil. Too wide a trace may affect signal integrity when the line is too long.
 
III. Software Section
1. Concept of Calibration:
 Calibration is the process of compensating for instrument system errors by measuring the deviation of a standard, thereby improving the accuracy and precision of the instrument or system. To improve the measurement accuracy and precision of voltage and current meters, calibration is required.
The common calibration principle is as follows:
Assume a sampling system where the AD part can obtain digital quantities, and the corresponding physical quantities are voltage (or current);
1. If an AD value point Xmin is calibrated at the "zero point" and an AD value point Xmax is calibrated at the "maximum point", according to the principle that "two points form a straight line", a straight line connecting the zero point and the maximum point can be obtained. The slope k of this line is easy to obtain. Then, by applying the equation of the straight line to solve for each point X (AD sample value), the physical quantity (voltage value) corresponding to the AD value can be obtained:
The slope k in the figure above:
k = (Ymax-Ymin)/(Xmax-Xmin)
(Because the first point is the "zero point", Ymin = 0 above)
Therefore, the physical quantity corresponding to the AD value at any point in the figure above:
y = k×(Xad-Xmin)+0
The above algorithm only calibrates between the "zero point" and the "maximum point". If the intermediate AD sample value is used, it will bring a large error in the corresponding physical quantity. The solution is to insert more calibration points.
As shown in the diagram below, four calibration points (x1, y1), (x2, y2), (x3, y3), and (x4, y4) are inserted.
This results in a line that is no longer a straight line but a "reflected line" (equivalent to segmented processing). To calculate the voltage value corresponding to a point Xad between x1 and x2:
y = k × (Xad – X1) + y1.
It can be seen that the more calibration points inserted, the higher the accuracy of the physical value.
When measuring voltage and current, a voltage and current calibration board or multimeter can be used to calibrate the collected voltage and current. The more calibration points, the more accurate the measurement.
2. Program Section:
The source program uses three calibration points. The voltage calibration points are 0V, 5V, and 15V. The current calibration points are 0A, 0.5A, and 1.5A. However, since I currently do not have power supply equipment above 15V, the voltage calibration points have been reset to 0V, 5V, and 10V. Therefore, the following programs are all written around these three values.
The main program code is as follows:
The calibration code calculation slope function is as follows:
The calibration storage function is as follows:
3. Burning Notes: When burning, you must select the correct programmer (select according to your own programmer).
 
IV. Calibration Settings
1. Five display modes and four calibration selections:
Mode 0: Displays normal voltage and current values ​​(the upper row of digital tubes displays the voltage value *.V or .*V automatically switches, and the lower row displays the current value, _.**A).
Mode 1: 5V voltage calibration value setting. The upper row of digital tubes displays U.05. The lower row displays the current voltage value *.**V. In this mode, the multimeter should be used to measure the measured bit and adjusted to 5.00V. After pressing the K2 key, the current value is calibrated to the 5V voltage value.
Mode 2: 10V voltage calibration setting. The top row of the digital display shows U.10. The bottom row shows the current voltage value *.**V or **.*. In this mode, the multimeter should be set to 10.0V to measure the voltage being measured. Pressing the K2 key will calibrate the current value to 10V.
Mode 3: 0.5A current calibration setting. The top row of the digital display shows A.0.5. The bottom row shows the current current value *.**A. Pressing the K2 key will calibrate the current value to 0.5A.
Mode 4: 1.5A current calibration setting. The top row of the digital display shows A.1.5. The bottom row shows the current current value *.**A. Pressing the K2 key will calibrate the current value to 1.5A.
In modes 1-4, you can directly return to mode 0 by pressing button 3.
2. Voltage Calibration: (The calibration method for 5V and 10V is the same; two values ​​need to be calibrated for accurate measurement.)

Use a DC power supply as the input and connect the jumper cap at JP1.
Connect the black probe of the multimeter to TGDND and the red probe to T_V.
Switch the mode to mode 1 using button 1.
Adjust RP1 until the multimeter displays 5.00V, then press button 2 to calibrate.
After calibration, press button 3 to return to mode 0.

3. Current Calibration: (The calibration method for 0.5A and 1.5A is the same; two values ​​need to be calibrated for accurate measurement.)
   Current calibration uses a voltage simulation method. The voltage displayed on the multimeter = R0 (0.1Ω) * actual current. Therefore, the voltage displayed on the multimeter * 10 can be considered the actual current value. (Do not solder R0 during calibration.)

Use a DC power supply as the input and connect the jumper cap at JP2.
Connect the black probe of the multimeter to TGDND and the red probe to TI+.
Switch to mode 3 using button 1.
Adjust RP2 until the multimeter displays 0.05V, then press button 2 to calibrate.
After calibration, return to mode 0 using button 3.

 
 
V. Appearance and Housing
1. JLCPCB Color PCB Design: The PCB design utilizes JLCPCB's color silkscreen printing process for a more attractive and aesthetically pleasing appearance.
2. JLCPCB Panel Design: The panel design is based on JLCPCB's technology and customized through the LCPCB online store. The panel uses a thin-film panel, which is highly transparent, blister-free, 0.2mm thick, and provides strong light shielding. The adhesive used is 3M9448A. It can be attached to a 3D housing.
3. 3D Housing Design: The housing was designed in SolidWorks and 3D printed by JLCPCB. The housing uses a top and back cover design, assembled with M3 screws and M3 nuts. (The screw length is 16mm)
Demonstration Video: [LCPCB Development Board] CW32 Voltage and Current Meter_Bilibili_bilibili
 
3D file.rar
Digital voltmeter and ammeter code.rar
BOM_V2.0_Schematic2_2024-08-21.xlsx
Demo video 50M.mp4
PDF_CW32 Voltage and Current Meter.zip
Altium_CW32 voltage and current meter.zip
PADS_CW32 Voltage and Current Meter.zip
92861
Ammeter used for learning based on the Geographic Star development board
Learning to build a digital voltmeter and ammeter is a good opportunity for beginners to gain a clear understanding of hardware and software. The digital voltmeter and ammeter project covers multiple aspects, including the design and implementation of microcontroller circuits, the design of signal acquisition and processing circuits, the development and optimization of the user interface, and the design of the product's appearance.
This project introduces
the creation of a digital voltmeter and ammeter, providing beginners with a clear understanding of hardware and software. The project covers various aspects, including microcontroller circuit design and implementation, signal acquisition and processing circuit design, user interface development and optimization, and product appearance design.
The project
provides voltage and current measurement functions, clearly displaying
the parameters
. Based on the JLCPCB Diwenxing development board, this voltmeter and ammeter design is very user-friendly for beginners. The integrated development board can independently implement the required functions, requiring only simple components and simple soldering. The hardware uses a DC power input port, supporting 5V~35V power input with a wide range and stable input. It uses a digital tube display, making it simple, safe, efficient, and durable. The Diwenxing development board is easy to use; simply write the code to use it. Other common components are also available, making replication cost-effective.
The software code is compiled using MK5. Related files are attached, along with a physical image.




Learning to use digital voltmeters and ammeters.rar
WeChat_20240823161102.mp4
WeChat_20240823161109.mp4
PDF_Ammeter for learning purposes using the Geographic Star development board.zip
Altium-based ammeter for learning purposes using the Earth Star development board. (zip file)
PADS_Ammeter for learning purposes using the Geographic Star development board.zip
BOM_Ammeter for Learning Based on the GeoStar Development Board.xlsx
92862
CW32 Voltage and Current Meter
The CW32 voltage and current meter I made in the LCSC training camp was basically based on the official case study. The only changes were replacing the resistors, capacitors, and other components with surface-mount 0603 packages and making some modifications to the wiring layout.
1. Project Function Introduction:
A voltage and current meter based on the CW32F030C8T6 chip
. 2. Project Attributes:
LCSC training camp project, for learning and familiarizing oneself with the CW32 chip from domestic Chipsource Semiconductor.
3. Open Source License
: GPL 3.0
4. Hardware Part:
The expansion board's appearance is shown in the image, using LCSC's color silkscreen printing.
The 3D shell is shown below; the top cover is open and has M2 screw holes, with recessed areas for the three buttons for easy operation. Because the shell itself is not very tall, there is no space reserved for the front panel.
One issue is the LED indicator lights. The placement of the two LED indicator lights wasn't considered much at the time of installation, and it was only after plugging in the CW32 that it was discovered that the CW32 board directly blocks these two LEDs, making them invisible from directly above, which is a bit awkward.
5. Software
: There's not much to say about the software; I didn't make any changes and directly used the official code. However, I encountered an error when using the official code directly. I'm not sure if it's a Keil version issue, but it couldn't recognize the WEAK decorator in cw32f030_systick.c, so I had to remove it.
Ultimately, I only tested the voltage measurement function because I didn't have suitable wires for the current connection port. I used DuPont wires to connect the voltage measurement port and tested its functionality as shown in the video.
Function demonstration.mp4
CW32gujian.zip
PDF_CW32 Voltage and Current Meter.zip
Altium_CW32 voltage and current meter.zip
PADS_CW32 Voltage and Current Meter.zip
BOM_CW32 Voltage and Current Meter.xlsx
92863
CW32-based voltage and current meters
A voltage and current meter based on CW32 was designed, and a 3D housing and panel were also designed.

Related Resources:
CW32 Digital Voltmeter and Ammeter Training Camp Project Tutorial Document | LCSC Development Board Technical Documentation Center
Explanation Video:
Step-by-Step Guide to Building a Voltmeter and Ammeter_bilibili

Physical Diagram
Hardware Design

1. Power Supply Circuit
LDO (Low Dropout Linear Regulator) Selection
This project uses an LDO as the power supply. Considering that most actual voltmeter products are used in industrial scenarios with 24V or 36V power supplies, this project selected the SE8550K2 with a maximum input voltage of up to 40V as the power supply. The main reason for not using a DC-DC step-down circuit to deal with the large voltage drop is to avoid introducing DC-DC ripple interference during the design process, and the secondary reason is to reduce project costs.
2. MCU Selection Analysis:
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)
; Strong anti-interference: 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.

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 focuses on the 4 reference voltage sources.
(Content from the "CW32x030 User Manual")
3. Voltage Sampling Circuit and Calibration 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 calibration circuit is used to assist in the calibration of the voltage sampling circuit.
4. Current Sampling Circuit:
This project uses a low-side current sampling circuit for current detection. The low-side of the sampling circuit shares a common ground with the development board's meter interface
. Do not solder R17 during learning!
The calibration circuit is used to assist in the calibration of the current sampling circuit.
Do not solder resistor R17 during calibration!
5. Digital Tube Display:
This project uses a digital tube as the display device, specifically a 0.36-inch common cathode digital tube.
6. LED Indicators:
Power indicator,
user LED.
7. Button Circuit Design:
GPIO needs to be configured as pull-up input mode .
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 converter.
Software Design
: 1. Using Systick as the main interrupt:
Based on Systick, an interrupt occurs every 1ms. All places requiring timed interrupts are placed in the Systick interrupt service function .
//cw32f030_systick.c

/**
  * @brief This function handles System tick timer.
  */
void SysTick_Handler(void)
{
    /* USER CODE BEGIN SysTick_IRQn */
    uwTick += uwTickFreq;
    Systick_Use();
    /* USER CODE END SysTick_IRQn */
}

//main.c

/**
 * @brief Called once every 1ms interrupt
 *
 */
void Systick_Use()
{
    if (++Adc_tc >= 1)
    {
        Adc_tc = 0;
        Adc_ref = 1;
    }

    if (++Nixie_ref >= 2)
    {
        Nixie_ref = 0;
        Nixie_Display();
    }

    if (++Key_tc >= 10)
    {
        Key_tc = 0;
        Key_Loop();
    }

    if (++Nixie_cha_tc >= 300)
    {
        Nixie_cha_tc = 0;
        Nixie_cha_ref = 1;
    }
}
2. Button Function

K1: Switching Mode
Mode 0: Displays normal voltage and current values ​​(the upper row of digital tubes displays the voltage value .V or .V automatically switches, the lower row displays the current value _ . ** A)
Mode 1: Voltage 5V calibration value setting. The upper row of digital tubes displays 5.05. The next row displays the current voltage value in .V or .V. In this mode, the multimeter should be set to 5.00V when measuring the measured position. Pressing the K2 key will calibrate the current value to 5V.
Mode 2: 15V voltage calibration setting. The upper row of the digital display shows 5.15. The next row displays the current voltage value in .V or .V. In this mode, the multimeter should be set to 15.0V when measuring the measured position. Pressing the K2 key will calibrate the current value to 15V.
Mode 3: 0.5A current calibration setting. The upper row of the digital display shows A.0.5. The next row displays the current current value in _.**A. Pressing the K2 key will calibrate the current value to 0.5A.
Mode 4: Current calibration value setting of 1.5A. The upper row of the digital tube displays A.1.5. The lower row displays the current current value *.** A. After pressing the K2 key, the current value is calibrated to 1.5A.


K2: Select to confirm the calibration value in non-mode 0 cases. K3
: Directly switch to mode 0.

3. Calibrate
5V
10V.
Because a 12V charger is used as the power source, it is not possible to calibrate 15V
0.5A
1A.
WeChat_20240823150404.mp4
CW32F030C8T6.zip
PDF_CW32-based voltage and current meter.zip
Altium_CW32-based voltage and current meter.zip
PADS_CW32-based Voltage and Current Meter.zip
BOM_CW32-based voltage and current meter.xlsx
92864
ammeter and voltmeter
LCSC GeoStar CW32 Digital Voltage and Current Meter
II. Hardware Design Details

Power Supply Circuit Design:
This project uses an LDO (Low Dropout Linear Regulator) as the power supply. Considering the actual application scenario, the SE8550K2 with a maximum input voltage of 40V was selected. A DC-DC step-down circuit was not used primarily to avoid potential ripple interference and to reduce costs.

MCU Selection Analysis:
This project uses the LCSC CW32F030C8Tx development board as the main controller. The selection considered computing power, I/O ports, and peripheral requirements. The CW32's advantages lie in its wide operating temperature range, wide operating voltage, strong anti-interference capability, and excellent ADC performance.

Voltage Sampling Circuit Design :
The voltage divider resistors are designed as 220K+10K, with a voltage division ratio of 22:1. Considering safety factors, the maximum measured voltage is designed to be 30V, but it can actually display 99.9V or 100V. The ADC reference voltage is 1.5V, which can be configured through the program. To reduce power consumption, the low-side resistor is selected as 10K. Calculations show that the high-side resistor is 220K. For measuring lower voltages, the voltage divider resistor can be replaced and the program modified to improve accuracy. For measuring higher voltages, the voltage reference can be increased to expand the range.

The current sampling circuit design
uses a low-side current sampling circuit with a designed sampling current of 3A and a sampling resistor of 100mΩ. Considering the voltage difference, power consumption, and amplification factor caused by the current sensing resistor, a 1W packaged metal wire-wound resistor was selected. To cope with different operating environments, especially high-current scenarios, the R0 resistor can be replaced with constantan wire or a shunt.

The digital tube display design
uses two 0.28-inch three-digit common-cathode digital tubes as display devices. Compared to a display screen, digital tubes have better recognition in complex environments and better mechanical performance. The current-limiting resistor is configured with 300Ω to achieve good display effect. The digital tube uses a dynamic scanning display driving method.

The LED indicator design
includes an additional power indicator and an IO working indicator. The power indicator LD_PWR is active low (on), and to reduce the current consumption of the LED, a 10K current-limiting resistor was selected.

The button
control circuit is designed to be simple, thanks to the CW32's internal I/O ports which can be configured with pull-up and pull-down resistors, eliminating the need for external 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. An additional

TL431
circuit is added to provide a 2.5V reference voltage, which can be used to provide an external voltage reference for calibrating the AD converter. The TL431 is a precision programmable reference device with high accuracy, adjustable output voltage, and a certain amount of current sinking capability. In this project, it is mainly used to learn the relevant application principles.
WeChat image_20240822151706.jpg
PDF_Ammeter and Voltmeter.zip
Altium_current_voltmeter.zip
PADS_Ammeter and Voltage Meter.zip
BOM_CurrentVoltage Meter.xlsx
92866
electronic
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2026-03-28 04:38:10

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号