F01pHHEC

CW32 Voltage and Current Meter

 
Overview
I. Design Background
In modern electronics and electrical engineering, voltage and current are two fundamental electrical parameters crucial for circuit analysis and equipment performance evaluation. Voltage and current meters, as measuring tools, can simultaneously measure voltage and current in a circuit, making them indispensable for engineers and technicians. With technological advancements and the popularity of DIY projects, more and more enthusiasts are attempting to build their own voltage and current meters to meet specific measurement needs or as a way to learn electronic principles and practical skills.
Building voltage and current meters not only deepens understanding of circuit working principles but also cultivates hands-on skills and innovative thinking. By selecting appropriate sensors, amplifiers, analog-to-digital converters (ADCs), and microcontrollers, voltage and current meters meeting different accuracy and functional requirements can be designed. Furthermore, with the widespread availability of open-source hardware and software, building voltage and current meters has become easier and more economical, enabling more people to participate in this creative activity.
In the process of designing and building voltage and current meters, one can learn not only about electronic component selection and circuit design but also how to program data acquisition, processing, and display, thereby comprehensively improving one's electronic engineering practical abilities. This self-driven learning process not only stimulates an individual's interest in electronics but also lays a solid foundation for future career development.
 
II. Hardware Design
 
1. Power Supply Circuit
According to the tutorial, 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 up to 40V was selected as the power supply.
 
2. 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 value. For safety reasons, this project uses 30V (the actual maximum display 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 (R7) 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 the 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. At this time, due to the reduced voltage division ratio, the measurement accuracy is greatly improved. There are many ways to implement gear shifting, and the development board design provides more design possibilities.
 
3. 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 R0 during learning.
Design Analysis
The sampling current designed in this project is 3A, and the selected sampling resistor (R0) is 100mΩ. The sampling selection mainly needs to consider the following aspects:

the maximum value of the pre-designed measurement current, which in this project is
the voltage difference brought by the 3A current sensing resistor. It is generally not recommended to exceed 0.5V.
The power consumption of the current sensing resistor should be selected according to this parameter. Considering the power consumption (temperature) problem under high current, this project selected a 1W packaged metal wire-wound resistor.
The amplification factor of the voltage across the current sensing resistor: This project does not use an operational amplifier to build an amplifier circuit, therefore the amplification factor is... 1.

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

Since this project does not use an amplifier circuit, 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, an unlimited selection of a larger resistor is not possible.
This project uses a 1W package resistor, corresponding to a power rise of 1W.

Based on the above data, a 100mΩ current sensing resistor was chosen. According to the formula, 3A * 100mΩ = 300mV, 900mW.
To cope with different operating environments, especially high-current scenarios, the R0 resistor can be replaced with constantan wire or a shunt. The appropriate alternative can be chosen based on the actual application scenario. For safety and educational purposes, this project will not discuss measurements exceeding 3A, but the principle remains the same.
 
4. Current Sampling Circuit Design for Voltage Measurement and Calibration using a TL431 Circuit:
This project adds an extra TL431 circuit to provide a 2.5V reference voltage. This can be used to provide an external voltage reference for the chip to calibrate the AD converter. 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 to learn the relevant application principles.
The TL431 is a relatively "old" device, a classic, and widely used one, still found in many electronic products.
Many beginners may be encountering this device for the first time, so we will briefly explain its principles to facilitate better application of the TL431.
TI defines it as: TL431, a precision programmable reference. At room temperature, we can focus on several key characteristics on the first page of the references.
Precision: Precision indicates that its output voltage is very accurate. I used ±0.5% accuracy, and the actual measured voltage on the board was 2.495V. 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 closely related to the resistance value (R13) in the application circuit. It should not be less than 1mA. If there is no need for sinking current, do not design the current too high, as this will cause unnecessary power consumption.
 
5. Housing Design:
The 3D housing was drawn and printed using JLCPCB EDA. The middle has holes for the digital tube and LED display, and the top has holes for calibration resistors and voltage and current measurement.
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
92867
CW32 Voltage and Current Meter
The main control uses the LCSC*Diwenxing CW32F103C8T6 development board, which includes a simple voltage and current meter.
The problem analysis

uses an ADC to read the voltage on the pins and displays it on a digital tube.
The schematic design explains that

the main control section
directly uses the LCSC development board, saving the design of crystal oscillator and filter circuits.
The CW32 development board has true 12-bit precision, and the CW32F103 chip's four unique reference voltages ensure the accuracy of the sampled data.
The LED circuit is
a classic LED circuit; a low level lights up
the independent button . By
default, the button is high, and when pressed, it is low.
This button circuit does not include pull-up/pull-down resistors, and the I/O port cannot be configured in floating mode; pull-up/pull-down resistors need to be designed in the software.
No debouncing capacitors are used; debouncing processing must be performed after button configuration. The low-voltage linear regulator (LDO) used
for the power input
is not the mainstream AMS1117, but rather the SE8550K2-HF.
The AMS1117-3.3V converts 5-7V to 3.3V, and the AMS1117-5V converts 12V to 5V; other models also have very low input power.
Considering that voltmeters are mostly used in industrial scenarios with 24V or 36V power supplies, the SE8550K2-HF, with an input power supply capacity of up to 40V, was chosen as the power supply.
For the package selection, the SOT-89 offers better heat dissipation.
A 1N5819 diode was used for reverse connection protection, saving costs compared to a fuse.
The series diode for reverse connection protection takes into account the fact that the power supply voltage of this device is usually higher than 5V; the 0.7V voltage drop of the diode will not affect the power supply. When the power supply voltage is low, due to the overall low power consumption of the project, the measured power supply current is low (20mA). Due to the unique structure of the Schottky diode D4 (1N5819), its VF is lower than that of general-purpose switching diodes, as shown in the figure below, with a voltage drop of approximately less than 0.2V.
A small series resistor R8 (10Ω) is used for voltage division, which reduces the problem of severe heat generation caused by the large voltage difference of the LDO under high voltage conditions. On the other hand, the principle of low overcurrent of a series-connected 10-ohm low-power resistor is utilized to act as a low-resistance fuse, providing overcurrent or short-circuit protection.
Filtering capacitors: large capacitors filter low frequencies (overall disturbances), and small capacitors filter high frequencies (glitch).
Both the PCB and schematic must ensure that the electrolytic capacitor (large capacitor) comes first, followed by the ceramic capacitor (small capacitor). The
waveform must pass through the large capacitor first to flatten the overall waveform, and then through the small capacitor to eliminate glitches. Reversing the order will result in an unsatisfactory filtering effect.
A power indicator light (constantly lit) is added at the end of the circuit to observe the circuit's operating status. A 0.28-inch three-digit common-cathode
digital
tube is used as the display element, as it has higher environmental adaptability and is less prone to damage.
A conventional transistor not used for time display is used, with 7 segments and 3 digits.
The current-limiting resistors (R1-R6) of the digital tube are configured with 300Ω, providing good visibility for both red and blue digital tubes, with a soft and non-glaring brightness.
Because the project uses relatively few components and only requires two digital tubes, the chip's I/O resources are sufficient, so shift registers are not used. Dual-channel voltage
sampling is used , and the selected LDO has a maximum input power supply of 40V (preferably less than 40V). However, considering the human body's safe voltage is 36V, the final maximum voltage design is 30V. The power supply is 0-30V, with a maximum of 30V. The MCU's voltage is 5V, so it cannot be directly connected to the MCU. Resistors are used to limit the voltage range that the ADC pins can acquire. To mitigate excessive current, the low-side resistor R14 is typically chosen as 10K (based on experience). The built-in reference voltage for the resistor calculation is selected as 1.5V, and the load voltage of R14 is 1.5V. Therefore, the maximum load voltage of R12 is 30 - 1.5 = 28.5V. According to Ohm's law U=IR, R12 and R14 are in series, and the current is the same everywhere in a series circuit. Therefore, U12:U14 = R12:R14. Calculate the voltage divider ratio: 1.5V/30V = 0.05. The high-side resistance is calculated as: high-side resistance / voltage divider ratio, resulting in 200KΩ. Due to the tolerance range of resistors, the selected resistor is usually slightly larger than the calculated resistance, with the closest value being a 200KΩ resistor. For accurate measurement data, a 1% resistor is selected. The CW32 is a true 12-bit successive approximation type, 2^12 = 4096. Dividing the sampled 1.5V into 4096 parts, 1.5/4096 = 0.36mV. The actual measured 30V is also divided into 4096 parts: 30V/4096 = 0.84mV. The minimum range is 0.84mV (various factors may cause 0.84mV to be unmeasurable). The CW32 can also adjust to 2.5V, 3.3V from the I/O port, and even 5V from the power supply VDD. The larger the voltage setting, the larger the range (the lower-side resistor can withstand a larger voltage, and the same applies to the higher-side resistor, thus increasing the input voltage). However, as the input power increases, the range voltage obtained by V/4096 also increases, thus reducing accuracy. The 3/4096 offers ten times the accuracy of the 30/4096, improving measurement accuracy for low voltages. Designed for a maximum input voltage of 30V, the low-side resistor divides the voltage by 1.5V. Incorrect power supply connection will increase the voltage across the low-side resistor. For example, connecting to 220V (normally not, just an example) will cause the low-side voltage to exceed 5V, potentially burning out the MCU. Using 5V above the diode will result in 8V below, causing the diode to conduct unidirectionally. The diode's unidirectional conductivity limits the voltage to around 5V (due to its voltage drop). The 1N4148 is a high-speed switching diode with a very fast response time. Compared to other diodes that conduct in tens of microseconds or even milliseconds, the 1N4148 only needs 3/4 microseconds to conduct. Overload voltages last only a short time, having minimal impact on the chip's I/O ports. The current sampling design uses a 3A sampling current, with a 100mΩ sampling resistor (R0). The 1K series resistor (R16) serves to protect the ADC pins: Connecting the resistor in series before the ADC pins limits current, preventing damage from excessive current under special conditions (such as high voltage input or short circuit). It also reduces the impact of transient current on the ADC converter's performance. Filtering and noise reduction: The resistor and the capacitor at the rear of the ADC pins form an RC low-pass filter, helping to slow down fast signal edges and reduce the impact of high-frequency noise on ADC sampling. In high-precision applications, this filtering effect is crucial for improving the signal-to-noise ratio (SNR) and ensuring measurement accuracy. The 1N4148 operates on the same voltage sampling principle.
































PCB design guidelines state that
power traces should be as wide as possible, approximately 20-60 mil.
Ordinary signal traces: around 10 mil;
ADC signal traces: 10 mil or 8 mil. Excessive width may affect signal integrity when the traces are too long.
In PCB design, elongated oval pads are often used for through-hole pads to increase the contact area between the solder, soldering iron, and the pad, making soldering easier.
Additionally, silkscreen layers are used to separate 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.
Small font sizes and thick line widths in silkscreen printing can lead to blurring and unclear labeling. It is recommended to choose appropriate silkscreen font size and line width, as different silkscreen fonts produce different effects. Choosing a suitable font will result in better printing performance at the same line width and font size.
Software Description:
Configuring Internal Clock Parameters
. The default operating frequency of the CW32's internal clock is not the frequency we want. Before using CW32, we need to configure the internal clock tree.
The CW32F030 user manual provides the system
's internal clock tree, as shown in the diagram below. The CW32 has five clock sources:
HSI (high-speed internal clock)
, HSE (high-speed external clock)
, LSI (low-speed internal clock),
and LSE (low-speed external clock).
The PLL (phase-locked loop – frequency multiplier)
uses an internal high-speed crystal oscillator HSIOSC to calibrate and output 48MHz. The frequency division factor is set to 6, the PLL frequency multiplier factor is set to 8
, and the HCLK and PCLK frequency division factors are set to 1, resulting in a 64MHz frequency. The digital
tube display uses
A-DP control segment codes to display the digits and decimal point
. The DIG1/COM control bit codes are used. A common-cathode three-digit digital tube is selected; a low-level control of three different bits
(A~G) each has its own display number (from low to high):
DP GFEDCBA.
Example: Displaying the number 5, according to the digital tube segment code diagram above,
0 1 1 0 1 1 0 1 ---》 0x6d The DP digit can be added or removed.
A switch statement scans sequentially, controlling the display of a specific digit
on the digital tube
. Dynamic scanning of the digital tube involves sending segment codes and digit codes to each digit in turn. Utilizing afterglow and the persistence of vision, the human eye perceives that each digit is displaying
current and voltage simultaneously. Data processing involves
configuring the corresponding ADC channel, with a reference voltage of 1.5V.
The acquired data is amplified 100 times, rounded, and the value of each digit is read and displayed on the digital tube.
Physical demonstration
: JLCPCB 2D display image,
JLCPCB 3D display image,
PCB prototyping image,
soldering completion,
functional testing
demonstration video.
Demo video.mp4
CW32 voltage and current meter code.rar
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
92868
ESP32-S3-Dongle | USB WiFi Adapter
This USB Wi-Fi network adapter, implemented using the ESP32-S3, can also perform other functions; the PCB is only the size of a fingernail.
ESP32-S3-Dongle
Introduction:
The ESP32-S3-Dongle is a multi-functional USB device that can be used as a USB network adapter, Bluetooth keyboard receiver, WOL remote wake-up device, etc. Based on the ESP32-S3FN8, it is suitable for various application scenarios.
The PCB of this project adopts a single-sided surface mount design, facilitating soldering with a hot plate. The power supply section uses a TLV62568 DC-DC converter, supporting 1A current, costing 0.3 yuan per unit.
In addition, the PCB has an onboard SK6805-EC15 RGB LED connected to the GPIO9 pin, providing flexible display functionality for device status indication.
1. USB Network Adapter:
This function is implemented using Espressif's official example code tusb_ncm or usb_dongle, connecting the ESP32-S3 as a USB network adapter to a computer or mobile phone. The network speed is relatively slow, suitable for browsing web pages or watching low-bitrate videos.

Project code (tusb_ncm): https://github.com/espressif/esp-idf/tree/master/examples/peripherals/usb/device/tusb_ncm
Project code (usb_dongle): https://github.com/espressif/esp-iot-solution/tree/master/examples/usb/device/usb_dongle
Development environment: ESP-IDF

2. Keyboard receiver:
Suitable for scenarios where only a Bluetooth keyboard is available and BIOS access is required. Use a mobile phone or tablet to open a webpage, connect to the ESP32-S3's Bluetooth via the Web Bluetooth API, and control the ESP32-S3 to simulate a USB keyboard for input.

Project code: To be completed and open-sourced.
Development environment: Arduino

3. WOL remote wake-up device:
This function remotely wakes up the PC via WOL (Wake-on-LAN). It can be connected to platforms such as Baffars Cloud to achieve remote control of the computer's power-on wake-up.
The current project code is not implemented by me; it originates from the following open-source project: https://github.com/yeyt97/ESP32-Bemfa-WOL-Tool.
It may be implemented separately later, adding features such as "wake up PC via USB" and "PC status synchronization."
4. And other features.
PDF_ESP32-S3-Dongle _ USB WiFi Adapter.zip
Altium_ESP32-S3-Dongle_USB WiFi Adapter.zip
PADS_ESP32-S3-Dongle USB WiFi Adapter.zip
BOM_ESP32-S3-Dongle _ USB WiFi Adapter.xlsx
92869
Voltmeter and Ammeter
This voltmeter and ammeter is very simple. To measure voltage (only 0~33V), connect the JP1 jumper cap, and the voltage value will be displayed on the first line of the OLED display. To measure current, connect the JP2 jumper cap, and the current value will be displayed on the second line of the OLED display.
This voltmeter and ammeter uses an OLED screen, which reduces the number of I/O ports used by the CW32 microcontroller and allows for the extraction of redundant I/O ports for future improvements. It can be connected to a serial port for debugging, enabling the removal of source code from the microcontroller chip. It has JP1/JP2 functions to select whether to measure voltage and current, and buttons to select the measurement mode.
My code uses an OLED to display the voltage and current values. The OLED configuration is completed by defining SCL/SDA in the oled.h header file using the corresponding pins, and the digital tube display is replaced with an OLED display.
QQ image 20240822140700.jpg
Experiment Nine + Digital Voltmeter and Ammeter with Calibration Function.zip
PDF_Voltage and Current Meters.zip
Altium_voltmeter_currentmeter.zip
PADS_Voltage and Current Meter.zip
92870
Voltmeter and Ammeter
#LCSC Training Camp# Voltage and Current Meters Based on CW32
Main Functions
: Voltage Measurement and Display: Capable of measuring voltage values ​​within a certain range and displaying them in real-time via a digital tube. The measurement range can be adjusted according to specific designs, such as 5-30V.
Current Measurement and Display: Capable of measuring current values ​​within a certain range and displaying them in real-time via a digital tube. The measurement range can also be adjusted according to specific designs, such as 0.1-3A.
Design Considerations :
1. Main Control Chip Selection: A CW32 series microcontroller is used as the main control chip, utilizing its powerful data processing capabilities and rich peripheral interfaces to achieve voltage and current measurement and control.
2. Voltage Acquisition Circuit: The voltage to be measured is reduced to an acceptable range for the ADC through a voltage divider circuit for sampling. The selection of the voltage divider resistor needs to consider factors such as the maximum value of the measured voltage, the ADC reference voltage, and power consumption.
3. Current Acquisition Circuit: A low-side current sampling circuit is used for current detection. The selection of the sampling resistor needs to consider factors such as the maximum value of the measured current, the voltage difference caused by the current sensing resistor, and power consumption.
2.mp4
1.mp4
PDF_Voltage and Current Meters.zip
Altium_voltmeter_currentmeter.zip
PADS_Voltage and Current Meter.zip
BOM_Voltage and Current Meter.xlsx
92871
CW32 Geostar Digital Voltage and Current Meter
LCSC-Diwenxing CW32 Digital Voltmeter and Ammeter Training Camp Project. This project aims to introduce students to basic circuit design, PCB prototyping, and CW32 Diwenxing development board programming and flashing through the design and fabrication of this digital voltmeter and ammeter, paving the way for further learning.
Function Introduction: Voltage measurement is designed for DC 0~30V, and current measurement is designed for DC 0~3A.
Schematic Explanation: Slightly modified from the reference schematic, the current measurement replaces the extra multimeter connector with an external series connection, reducing PCB space usage and simplifying wiring.
Key Program Explanation: I couldn't learn CW32 programming quickly, so the .hex files were downloaded directly from the official website and programmed via TTL serial port for convenience. Important
Material Purchase Notes: Most of the packages were designed by myself (I'm addicted to it), and I didn't use the BOM upload method for procurement. The disadvantage is that it's easy to miss things; for example, in this project, I forgot to count the number of digital tubes the first time and only bought one, and when I went to buy it again, I found that the same model was out of stock.
Assembly Instructions: T12 soldering iron, generic 6337 solder wire, and a temperature of 360 degrees Celsius was required to achieve satisfactory results. It is recommended to find all the necessary components first, and then solder them one by one from small to large, from surface mount to through-hole. Soldering is very relaxing once you get used to it, and there is a small sense of accomplishment in seeing the finished product.
CW32F030C8T6.hex
Simple demonstration video.mp4
PDF_CW32 Geostar Digital Voltage and Current Meter.zip
Altium_CW32 Geostar Digital Voltage and Current Meter.zip
PADS_CW32 Geostar Digital Voltage and Current Meter.zip
BOM_CW32 GeoStar Digital Voltage and Current Meter.xlsx
92872
Voltmeter and Ammeter
LCSC's DiWenXing is a development board designed using the Chipsource Semiconductor CW32, featuring excellent ADC performance. A voltmeter and ammeter was designed using this board, capable of simultaneously measuring 0-30V voltage and 0-3A current with good accuracy.
 
Functional Overview
 
1.1 Product Features
 
**Application Functions:**
- Supports ADC measurement of voltages from 0 to 30V, with a display accuracy of 0.1V or 0.01V.
- Supports precise ADC measurement of voltages from 0 to 3V, ensuring a display accuracy of 0.01V.
- Supports ADC measurement of currents from 0 to 3A, ensuring a display accuracy of 0.01A.
- Real-time monitoring of circuit voltage and current values.
- Simultaneous detection of circuit voltage and current values.
 
**Learning Functions:**
- Uses the CW32 development board, facilitating learning of circuit principles, ADC functions, timers, and interrupts.
- Built-in analog detection circuit, allowing learning of voltage and current measurement principles without external devices.
- Provides analog calibration functions, facilitating product debugging without external devices.
 
**Safety Functions:**
- Equipped with circuit protection mechanisms to ensure MCU safety and prevent reverse connection and interface errors.
 
1.2 User Guide
 
**General Testing:**
- **Voltage Measurement:** Connect the circuit under test using the CH1 terminal, with the yellow wire connected to the positive terminal and the black wire connected to the negative terminal. If the voltage being measured is below 5V, a power supply can be connected via the red wire of the DC or VP circuit. When using an external voltmeter, connect the red probe to the yellow terminal and the black probe to the black terminal. The red digital display shows the current voltage value.
- **Current Measurement:** Connect the CN1 terminal to the circuit under test, with the yellow wire connected to the positive terminal and the black wire to the negative terminal. When using an external ammeter, connect the red wire of the CN2 terminal (port 1) to the positive terminal, connect the red banana plug to the red probe of the ammeter, connect the yellow banana plug on the right to the black probe of the ammeter, and connect the black wire of the CN1 terminal to the negative terminal. The blue digital display shows the current current value.
 
**Calibration:**
- **Voltage Calibration:** Follow the voltage measurement wiring, adjust the input voltage to 5V or 15V, verify with a multimeter, select the corresponding calibration value using the [Mode] key, and press the [Calibration] key to complete the calibration.
- **Current Calibration:** Follow the current measurement wiring to adjust the input current to 0.5A or 1.5A. After verifying with a multimeter, select the corresponding calibration value by repeatedly pressing the [Mode] key, and then press the [Calibrate] key to complete the calibration.
 
**Note:** If the onboard calibration function is not used, there is no need to short-circuit JP, and R0 must be soldered.
 
1.3 Development Tools
 
- **LCSC CW32 Development Board**
- **Multimeter**
- **Soldering and Auxiliary Equipment** (Components can be purchased from LCSC Mall)
- **Supporting External Terminals, Wires, Banana Connectors, etc.** (To be purchased separately)
- **Program Download and Burning Equipment** (
 
 
Demonstration Images:)
PDF_Voltage and Current Meters.zip
Altium_voltmeter_currentmeter.zip
PADS_Voltage and Current Meter.zip
BOM_Voltage and Current Meter.xlsx
92873
Simple voltmeter and ammeter
Simple voltage and current meter designed based on CW32F030
A simple voltage and current meter designed based on the CW32F030:
It supports detecting voltage inputs of 0~30V (display accuracy 0.01V) and current inputs of 0~3A (display accuracy 0.01A)
, and supports simultaneous display of voltage and current.
(Due to my limited experience in hardware design, the circuit design follows the official documentation.)
Power supply circuit:
A relatively stable 5V voltage is provided to the circuit through an SE8552K2-HF, and a series diode is used for reverse connection protection.
Voltage sampling circuit:
The reference voltage used in this project is 1.5V, so it is not difficult to calculate from the circuit that the voltage range of this project is 0~30V and 0~5V.
Data is read through an ADC, and then the voltage of the voltage divider resistor is calculated by comparing it with the reference voltage. The measured voltage is then calculated from the resistance relationship between the two resistors. Current sampling
circuit:
Similar to voltage sampling, an ADC is used to sample the voltage. The obtained value is compared with the 1.5V reference voltage to obtain the voltage of R0, and thus the current in the circuit is calculated.
Voltage and current calibration circuit:
When calibrating the voltmeter and ammeter, simply insert the jumper cap into JP1 or JP2, and change the resistance by rotating the potentiometer to change the input voltage or current. Then, connect an external multimeter to calibrate the sampling circuit.
Software development
: The software development for this project is mainly based on the example programs from Experiment 9 of the training camp. Originally, I designed my own solution, but encountered some difficulties with voltage and current calibration, so the official example programs are provided directly in the attachment.
Voltage and Ammeter Project.zip
PDF_Simple Voltage and Current Meter.zip
Altium Simple Voltage and Current Meter.zip
PADS_Simple Voltage and Current Meter.zip
BOM_Simple Voltage and Current Meter.xlsx
92874
CW32 Voltage and Current Meter
Voltage and current meter based on CW32F030C8T6
Function Description:
Voltage measurement ranges are 0-30V and 0-3V; current measurement range is 0-3A.
LED1 on the digital tube displays the voltage, and LED2 displays the current.
Analog voltage measurement corresponds to pin H2, and analog current measurement corresponds to pin H3. Jumper caps are required during use. No current sampling resistor needs to be soldered before using analog current measurement.
An external circuit provides a 2.5V reference voltage.
A 2mm banana plug is used for insertion into the multimeter for measurement.
 
Hardware Circuit:
DC Power Input:
To avoid introducing DC-DC ripple interference and reduce project costs due to the high voltage difference, this replication project uses an LDO as the power supply, specifically the SE8550K2-HF. Due to my oversight, the actual power supply used was the SE8533K2-HF, the difference being that the output voltage changes from 5V to 3.3V. Initial assessment suggests this will not significantly affect subsequent circuitry. Compared to the original project, only the current-limiting resistor at the TL431 reference voltage needs to be replaced from 1kΩ to 800Ω.
The SE8533K2-HF has a maximum input voltage of 40V and an output of 3.3V with an accuracy of ±2%. The series diodes are used to prevent reverse connection and protect the circuit. Schottky diodes are used to further reduce the voltage drop to approximately 0.2V. The 10-ohm series resistor is used for voltage division, reducing heat generation caused by the high voltage difference across the LDO. It also functions as a low-resistance fuse due to its small overcurrent.
 
Reference voltage circuit:
In this project, a TL431 is chosen to provide a 2.5V reference voltage to the CW32 ADC. Since the CW32 has built-in 1.5V and 2.5V reference voltages that can be configured in the program, the main purpose of this circuit design is to learn the relevant principles.
The TL431 output voltage is 2.5V with an accuracy of ±0.5%, and its sink current capability is 1mA~100mA (related to the resistor selection in the circuit, as shown in the figure below). More information can be found in TI's TL431 Chinese datasheet.
Since the LDO provides a voltage of 3.3V in this project, based on the above calculation, resistors with an Ω or lower and a package size greater than 0.08W should be selected.
 
MCU Circuit:
In this project, the CW32F030C8T6 has a wide operating voltage range of 1.65V~5.5V, a 12-bit successive approximation ADC, and four reference voltage sources (VDDA power supply voltage, PB0 pin voltage, built-in 1.5V reference voltage, and built-in 2.5V reference voltage). The voltage
 
sampling circuit
is shown in the figure. The voltage measurement circuit has two ranges to choose from. During measurement, according to the program settings, the more suitable measurement result is selected to improve the measurement accuracy. When the ADC internal reference voltage is selected as 1.5V, the maximum measurement voltage at the high range is calculated based on the voltage divider resistors, and the maximum measurement voltage at the low range is 3V.
The clamping diode limits the ADC pin input voltage to 3.3V. The ADC internal reference voltage can be selected as 1.5V or 2.5V as needed. Since the ADC is 12-bit, selecting the 2.5V range will reduce the measurement accuracy.
 
Wiring Port Circuit:
In the figure, U4, U5, U8, and U9 correspond to the 2mm banana plug interface on the PCB, used to insert multimeter probes for easy verification of measurement accuracy and calibration. U3, CN1, and CN2 are the corresponding connection ports for the measured values. +V connects to the voltage to be measured, T_V connects to the red probe of the multimeter, and TGND connects to the black probe. CN2 is connected to the current to be measured; the current flows in from I+ and out from I- on CN2. The red probe of the multimeter is inserted into TI+, and the black probe is inserted into TGND .
 
Analog voltage measurement:
An analog voltage is obtained through an adjustable potentiometer for measuring ADC accuracy and for calibration. A jumper cap needs to be connected during use. When using analog current measurement, the 100mΩ sampling resistor cannot be soldered
 
. Note:
VP is the provided analog voltage used for calibration;
V+ is the connected measurement voltage.
When there is no DC power supply, the 3.3V on pin header H1 can be used to power the microcontroller.
 
 
Software part: The firmware package and compiler version selected
for this project may encounter errors during compilation. Removing __weak will stop the errors. Due to the lack of a DC power line and the fact that the PCB was not traced from the 3.3V power supply, the voltage measurement cannot be verified at this time.



 

 
 
c8bf2063bfb77b1e8938b965e44e2b24.mp4
Simultaneous display of pressure and current.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
92876
Based on the voltage and current meter of the [LCSC GeoStar Development Board]
Based on the voltage and current meter of the [LCSC GeoStar Development Board]
I. Design Background

An ADC (Analog-to-Digital Converter) is an indispensable key component in electronic systems. It converts continuous analog signals into digital signals, enabling digital processing and analysis. ADCs play a crucial role in signal conversion, measurement and data acquisition, control system input, and communication and signal processing. Their widespread application promotes the intelligent and precise control of electronic equipment across various industries, and is one of the key factors driving modern technological progress. Digital voltmeters and ammeters combine ADC technology with circuit measurement principles, accurately converting analog voltage and current signals into digital displays for easy reading and analysis by electronic engineers. This device not only improves the accuracy and efficiency of circuit measurements but also helps engineers better understand circuit behavior, serving as a powerful assistant in electronic design and troubleshooting, and playing a vital supporting role in the work of electronic engineers. In product applications, digital voltmeters ensure the accuracy and safety of circuit design, while also providing strong support for product quality control and subsequent maintenance. Learning to design and build a digital voltmeter and ammeter
 
using a benchtop digital multimeter (Agilent 34401A)
is highly beneficial for improving one's professional skills. This digital voltmeter and ammeter project covers multiple aspects, including microcontroller circuit design and implementation, signal acquisition and processing circuit design, user interface development and optimization, and product appearance design. It integrates knowledge from multiple fields such as electronics, microcontroller programming, circuit design, and industrial design. Considering the learning pace and knowledge absorption capacity of beginners, we have specially launched this introductory-level digital voltmeter and ammeter project, which is very suitable for beginners in electronics and those who want to learn more about microcontroller applications. This project has the following highlights:

it adopts a core board plus expansion board design concept and uses plug-in components, making learning simpler and exploration more in-depth;
the core board uses the domestic Wuhan Xinyuan Semiconductor CW32 as the main controller, while also being compatible with other similar development boards; however, the CW32 has advantages.
The project is highly comprehensive and practical, and after completion, it can be used as a desktop instrument;
the project has abundant learning materials, including circuit design tutorials, PCB design, code programming learning, and training for engineers' debugging skills.

II. Hardware Design

1. Power Supply Circuit
LDO (Low Dropout Linear Regulator) Selection 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 up to 40V was selected as the power supply. 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, and the secondary reason is to reduce project costs.
2. MCU Selection Analysis
To reduce the learning cost for everyone, this project uses the LCSC CW32F030C8Tx development board (core board) as the main controller, but this does not mean that we will talk less about this section. From the perspective of training engineers, the correct selection of the main controller is very important, as it relates to the overall advantage of the project. Regarding the voltmeter and current meter, the author used STM32/CW32 and some other 32-bit microcontrollers for some debugging and testing. This comparison is only with the STM32F103C8T6 as a reference for device selection, primarily aimed at providing ideas and improving understanding.
Avoid blind selection. When selecting an MCU (Microcontroller Unit) for this project, multiple aspects need to be considered to ensure the chosen MCU meets project requirements.

Clearly define your project needs: Understand the required computing power, including clock speed, processor core type, and whether a floating-point unit is needed.
Identify the required I/O ports and important peripherals, such as ADC peripherals. Since this is a development board project, primarily for debugging and learning, there are no strict limitations on the number of I/O ports: i.e., the associated costs are not considered.

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)
; Superior interference immunity: HBM ESD 8KV; All ESD reliability meets the highest international standard (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 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 (R7) 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 the 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 expand the 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 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 in the circuit design 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 to achieve 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 implement 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, then we use the ADC_IN9 channel for measurement. At this time, due to the reduced voltage division ratio, the measurement accuracy is greatly improved. 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 the common ground between the low-side of the sampling circuit and the development board's meter interface, please do not solder R0!!!
The design analysis
for this project involves a sampling current of 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;
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 wire-wound resistor package was chosen
. The voltage amplification factor across the current sensing resistor is also important. Since no operational amplifier is used to build the amplification circuit in this project, the factor is 1.

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

. Since no amplifier circuit is used, a larger sampling resistor is needed to obtain a higher measured voltage for measurement.
Considering that a larger resistor would result in a larger voltage drop and higher power consumption, an unlimited selection of a larger resistor is not feasible.
This project uses a 1W package resistor, corresponding to a power consumption 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 operating 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 application scenario. For safety and educational purposes, this project will not discuss measurements exceeding 3A in detail, but the principle is the same.
5. Digital Tube Display
This project uses a digital tube as the display unit.
This project uses two 0.28-inch three-digit common-cathode LED displays as display devices. Compared to displays, LED displays offer better visibility in complex environments. The brightness of the LED displays can be increased by using smaller current-limiting resistors to meet the needs of the actual usage environment. Furthermore, LED displays have better mechanical properties and are not as easily damaged by external forces as displays. They are widely used in industrial applications requiring stability and reliability. From a development board learning perspective, this facilitates targeted learning of electronic measurement principles.
In this project, actual testing showed that a 300Ω current-limiting resistor for the LED displays resulted in good visibility for both red and blue LED displays, with a soft and non-glaring brightness.
 
6. TL431 Circuit Design for Voltage Measurement Calibration:
This project adds an additional TL431 circuit to provide a 2.5V reference voltage. This can be used to provide an external voltage reference for calibrating the AD converter. From a product design perspective, due to the inherent ADC performance advantages of the CW32, this circuit is not necessary. This circuit was designed on the development board to learn relevant application principles.
The TL431 is a relatively "old" device, a classic with wide applications, and still found in many electronic products.
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 characteristics on the first page of the references.
Precision: Precision indicates its highly accurate output voltage. The TL431 I used has ±0.5% accuracy, and at room temperature, it measured 2.495V on the board. Compared to common Zener diodes, the accuracy is vastly different. In application circuit diagrams, the TL431 is internally 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 Vref.
Sinking Current Capability: This refers to how much current the output voltage pin can provide, which is greatly affected by the resistance value (R13) in the application circuit. The current should not be lower than 1mA. If there is no need for sinking current, do not design the current to be too high, as this will cause unnecessary power consumption.
7. Demonstration
WeChat_20240822191619.mp4
code.zip
PDF_Based on the [LCSC GeoStar Development Board] Voltage and Current Meter.zip
Altium_Based on the [LCSC GeoStar Development Board] Voltage and Current Meter.zip
PADS_Based on the [LCSC GeoStar Development Board] Voltage and Current Meter.zip
BOM_Based on the voltage and current meter of the [LCSC GeoStar Development Board].xlsx
92877
electronic
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2026-03-27 22:39:17

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号