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.
Package Selection
As can be seen from the datasheet, compared with the SOT23 package's 280℃/W, the SOT89 package's 165℃/W has better heat dissipation capabilities (Thermal Resistance, Junction-to-Ambient), unit: degrees Celsius/watt.
LDO Model Selection
Since the main control core board of the project is powered by 5V, according to the ordering information in the table below, the SE8550K2-HF is selected, with an output of 5V. K indicates the SOT89 package, and ±2% accuracy is sufficient, saving costs. HF or LF is related to environmental protection requirements and needs to be considered in actual product design. This project does not require attention.
The design manual for the capacitor
provides the application schematic of this LDO:

the principle of almost all LDO devices is basically the same when designing circuits. Therefore, the reference significance of this diagram is not very high. The more common considerations are how C1 and C2 should be designed. If your LDO has EN (enable), you also need to consider the design of the enable pin to ensure that the chip works properly. In addition, some LDOs have adjustable outputs, which have a dedicated pin (adj) that requires the configuration of corresponding external resistors to achieve the specified output voltage.
The most crucial part of LDO peripheral circuit design is the design of the capacitors.
The capacitors around the LDO play a key role in the circuit, and their functions mainly include the following aspects:
Filtering: The capacitors around the LDO, especially the input capacitor, can effectively filter out the ripple interference from the previous power supply.
Improving load transient response: The output capacitor plays an important role in improving the load transient response. When the load current changes rapidly, the LDO has an adjustment time. At this time, the output capacitor acts as a temporary power supply to provide the required current to the circuit and prevent the output voltage from being pulled too low. A larger output capacitor value can further improve the transient response of an LDO to large load current changes.
Phase compensation: For adjustable output LDOs, the capacitor connected in parallel with the upper resistor (R1) (called the feedback capacitor CFB) provides leading phase compensation, increasing oscillation margin and improving load transient response. Zeroing both CFB and R1 contributes to loop stability.
Oscillation prevention: Proper capacitor configuration can help prevent oscillations in the LDO circuit, ensuring stable circuit operation.
Ripple suppression: Capacitors in LDOs also help improve the power supply rejection ratio (PSRR), reducing the impact of power supply noise on circuit performance.
Startup inrush current control: The input capacitor acts as a temporary power source for startup inrush current during LDO startup, preventing the input voltage from being pulled low and affecting the stability of the preceding power supply.
Summary: The capacitors surrounding the LDO play an important role in filtering, improving load transient response, phase compensation, oscillation prevention, ripple suppression, and startup inrush current control. By properly configuring these capacitors, the stability and performance of the LDO circuit can be ensured.
If you carefully review the datasheet, you'll find that the official documentation provides detailed suggestions and references, including layout design recommendations. This avoids engineers having to perform a lot of complex theoretical calculations.

It's worth noting that in my power supply design, I used electrolytic capacitors and ceramic capacitors connected in parallel, one after the other. When electrolytic and ceramic capacitors are connected in parallel, they can be "matched in high and low frequencies," resulting in good filtering in both high and low frequency ranges. Electrolytic capacitors filter out low-frequency interference, while ceramic capacitors filter out high-frequency interference; their combination achieves better filtering.
In practical electronic products, the main function of electrolytic capacitors connected in parallel with ceramic capacitors is to achieve high and low frequency filtering and coupling through their complementary characteristics, thereby improving circuit performance, stability, and anti-interference capabilities. This parallel connection method is widely used in electronic devices. For
reverse connection protection,
considering that high-voltage reverse connection can cause irreversible damage to the module, the voltmeter power supply circuit uses a series diode scheme.

Note: This project uses a series diode for reverse connection protection because 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 supply voltage is low, the overall power consumption of the project is low, and the measured 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 0.2V or less.
In conventional circuit design, using a reverse-parallel diode + series fuse can also achieve the purpose of reverse connection protection and circuit protection.

The diode voltage-current curve and
the role of the series small resistor (10Ω) are also discussed.
This project additionally uses a series small resistor (10Ω) for voltage division. This serves two purposes: firstly, it reduces the problem of excessive heat generation in the LDO due to large voltage differences under high voltage conditions; secondly, it utilizes the principle that the series 10-ohm low-power resistor has low overcurrent, acting as a low-resistance fuse to provide overcurrent or short-circuit protection. (The reason the resistor acts as a fuse is that, under overcurrent and heating conditions, it is 99% likely to be an open circuit, rarely short-circuiting. Its fault analysis dictates that it will primarily be an open circuit—that is, it will burn out rather than short-circuit.)
The series small resistor (10Ω) also reduces the peak value of the power-on surge, preventing excessive surges from damaging the LDO.
If electrolytic capacitors were not used, the series small resistor (10Ω) also prevents resonance between the wire inductance and the ceramic capacitor during hot-plugging. Because ceramic capacitors have very low ESR, the damping in the LC network is minimal, resulting in high gain at the resonant point. Adding an external resistor to provide damping suppresses this gain.
Circuit Design Essentials and Standards:
When drawing power supply circuits, whether in schematics or PCB layouts, several points should be noted:
Schematic Standards: GND should face down, power supply should face up; avoid ground facing upwards.
Capacitor Design: In both schematics and PCB layouts, electrolytic capacitors should come first, followed by ceramic capacitors. Grounding
Design: Single-point grounding; the ground of the current power supply should be connected to the GND of the main electrolytic capacitor of the current power supply, and the main electrolytic capacitors of each stage of the power supply should be connected to the GND of the main electrolytic capacitor of the preceding stage.
2. MCU Selection Analysis:
To reduce the learning cost, this project uses the LCSC CW32F030C8T6 development board (core board) as the main controller, but this does not mean we will discuss this section less. 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 voltage and current meters, the author used STM32/CW32 and some other 32-bit microcontrollers for 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 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 ESD 2KV);
Project focus - Better ADC: 12-bit high-speed ADC, achieving ±1.0LSB INL 11.3ENOB; Multiple Vref reference voltages... (STM32 only supports VDD=Vref);
Stable and reliable eFLASH technology. (Flash0 pending).
A detailed explanation of these advantages will be provided in the ADC sampling section and extended sections.
Key features of CW32's ADC:
This project requires a focus on 4 reference voltage sources. Content from the "CW32x030 User Manual".

3. Voltage Sampling Circuit :
This project uses a voltage divider circuit to achieve high voltage acquisition, designed to acquire voltages up to 100V; the current configuration acquires voltages from 0-30V.

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 based on the maximum measured voltage; for safety reasons, this project uses 30V (the actual maximum display value can be 99.9V or 100V).
The ADC reference voltage in this project is 1.5V, which can be configured through the program.
To reduce power consumption in the sampling circuit, the low-side resistor (R7) is usually selected as 10K based on experience.
The high-side resistance of the voltage divider resistors can then be calculated using the above parameters.
The required voltage division ratio is calculated as follows: ADC reference voltage: Design input voltage, calculated using known parameters as 1.5V/30V=0.05.
The high-side resistance is calculated as: Low-side resistance/voltage division ratio, calculated using known parameters as 10K/0.05=200K.
A standard resistor is selected: A resistor slightly higher than the calculated value is chosen; the calculated value is 200K. We usually choose E24 series resistors, therefore in this project, 220K is selected, which is greater than 200K and closest to the calculated value.
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. Here's a case study:
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 to improve measurement stability.
Diode clamping ensures MCU safety
. In designing this project, I added an additional 1N4148 (D1, etc.) as a clamping diode to the sampling circuit. This helps avoid damage to the chip pins due to incorrect voltage input during learning and debugging. Diode clamping is an important electronic circuit design technique; its main function is to protect the circuit by limiting the voltage amplitude, preventing damage or malfunction caused by excessively large or small signals.
In circuit design, clamping refers to limiting voltage. Diode clamping specifically refers to the technique of using a diode to limit the potential at a point in a circuit.
Diode clamping primarily utilizes the unidirectional conductivity of a diode. When the voltage across the positive terminal of a diode is greater than the voltage across its negative terminal and the diode is turned on, the voltage across the diode is limited to its voltage drop across the diode. Typically, the voltage drop across a silicon diode is about 0.7V.
The clamping process involves forcibly pulling the clamped potential towards the reference terminal through the clamping action of the diode, thereby limiting the potential. Clamping does not change the waveform of the original signal; it only raises or lowers the reference potential of the signal.
Depending on the diode connection method, clamping circuits can be divided into positive clamping circuits and negative clamping circuits. This project only designs positive clamping.
Positive clamping circuit: When the positive terminal of the diode is grounded, it is a positive clamping circuit. During the positive half-cycle, the diode is cut off; during the negative half-cycle, the diode conducts, and the capacitor is charged to a certain voltage, limiting the output voltage within a certain range.
Negative clamping circuit: When the negative terminal of the diode is grounded, it is a negative clamping circuit. The working principle is the opposite of the positive clamping circuit.
Adding a voltage sampling circuit to achieve 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 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, and the development board design provides more design possibilities. Next to
the circuits used for simulating voltage measurement, measurement calibration, and measurement calibration assistance,


the components labeled T_V and T_GND are the 2mm banana plug interfaces on the development board, used to connect multimeter probes. You can insert the probes of a multimeter or a high-precision benchtop digital multimeter to verify the accuracy of the development board's measurements. You can also insert 2mm banana plug multimeter probes to replace the CH1 port for handheld measurements.
The VP pin is the power supply pin for the development board and should not be connected when using the DC port. When not using DC port power and the measured value is greater than 5V and less than 30V, it can be connected to the power supply under test, or it can be powered independently.
When learning the measurement principles of the corresponding circuits, considering that users may not be able to easily build peripheral circuits for testing and debugging, and adhering to the principle of ease of development of the development board, auxiliary circuits for simulating voltage measurement, measurement calibration, and measurement calibration are specially set up. No external voltage is required for CH1. Use a multi-turn adjustable potentiometer (RP1) to divide the power supply voltage of the development board and connect it to the +V network through the internal circuitry of the development board. Note that JP1 needs to be shorted at this time; a jumper cap is sufficient, and a long-handled jumper cap is recommended. Do not short JP1 if this function is not used.
4. Current Sampling Circuit:
This project uses a low-side current sampling circuit for current detection. When learning the low-side of the sampling circuit and the meter interface of the development board
, do not solder R0!!!

Design Analysis:
The sampling current in this project is 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 packaged metal wire-wound resistor was selected.
The voltage amplification factor across the current sensing resistor: No operational amplifier is used in this project to build the amplification circuit, so 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 chosen. According to the formula, 3A * 100mΩ = 300mV, 900mW.
To handle different operating environments, especially high-current scenarios, the R0 resistor can be replaced with constantan wire or a shunt. The choice of alternative can be based on the specific application scenario. For safety and educational purposes, this project will not discuss measurements exceeding 3A, but the principle remains the same. When using
auxiliary circuits for simulating current measurement, measurement calibration, and measurement adjustment,


do not solder the R0 sampling resistor. If this function is not used, disconnect JP2.
The essence of current sampling is to collect the voltage drop across the sampling resistor when current flows through it, i.e., the collected voltage value. This circuit uses RP2 to provide a voltage value in the range of 0~0.238V (5V ÷ 210K * 10K), which is connected to the chip's current sampling pin via the I+ network.
In actual use, the voltage at I+ simulates the voltage drop across the unsoldered 100mΩ sampling resistor. Therefore, the simulated measured current value I
measured = this voltage value Vi+ ÷ 100mΩ, which is also exactly equal to the measured voltage value multiplied by 10. That is, it provides a simulated current measurement of 0~2.38A.
Set a multimeter or high-precision benchtop digital multimeter to the voltage measurement port, with a range within 3V. Insert the black negative probe into the T_GND interface next to the voltage measurement terminal, and the red positive probe into the TI+ port for current measurement to measure the actual voltage value of I+. Thus, this circuit can not only complete the above design tasks but also allow for a direct test of the accuracy of the MCU's ADC peripheral. You can write your own program to verify this.
5. Digital Tube Driver:
This project uses digital tubes as the display unit.

In this project, actual testing showed that the current-limiting resistors (R1~R6) for the digital tubes were configured to 300Ω. The corresponding brightness, whether for red or blue digital tubes, provided good visibility and a soft, non-glaring brightness.
Strictly speaking, the current-limiting resistors should be added to the segments; adding them to the digits would affect the display effect. Our actual design places them in the digits to save a few resistors, but the impact on the display is not significant. Therefore, we add them to the digits for convenience.
Analysis of the datasheet shows that CW32 has no problems. (Some chips do not work.)
6. Indicator Lights:
This project additionally designed a power indicator light and an I/O operation indicator light.

Since chip I/O often has a greater current sinking capability than a current pulling capability, LED1 is designed to be active low (on). To reduce the current consumption of the LEDs, some LED brightness was sacrificed, the number of component parameters was reduced, and the current-limiting resistor for the LEDs was chosen to be 10K.
7. Button Circuit Design:

There are various design methods for the button control circuit. Thanks to the CW32's internal I/O ports which can be configured with pull-up and pull-down resistors, the button control circuit on the 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. 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 is designed on the development board for learning related application principles.
Demo video.rar
Digital voltmeter and ammeter.rar
PDF_Simple Digital Voltmeter and Ammeter Based on CW32.zip
Altium_Simple Digital Voltage and Current Meter Based on CW32.zip
PADS_Simple Digital Voltage and Current Meter Based on CW32.zip
BOM_Simple Digital Voltage and Current Meter Based on CW32.xlsx
92880
[LCSC Development Board] CW32 Voltage and Current Meter
LCSC GeoStar CW32 Digital Voltage and Current Meter Expansion Board, 0.96 OLED Display
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. 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:
To reduce the learning curve, this project uses the LCSC CW32F030C8Tx development board (core board) as the main controller. However, this does not mean we will discuss this section less. From the perspective of training engineers, the correct selection of the main controller is crucial, as it relates to the overall advantages of the project. Regarding the voltmeter and current meter, the author conducted some debugging and testing using STM32/CW32 and some other 32-bit microcontrollers. This comparison is only with the STM32F103C8T6 as a reference for learning device selection, mainly to provide ideas and improve understanding.
This project primarily uses an analog-to-digital converter (ADC).

3. Voltage Sampling Circuit: The voltage
divider resistors in this project are designed as 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 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.
4. Current Sampling Circuit
This project uses a low-side current sampling circuit for current detection. When the low-side of the sampling circuit shares a common ground with the development board's meter interface, please do not solder R0!!!

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, a 1W packaged metal wire-wound resistor was selected in this project.
The voltage amplification factor on the current sensing resistor: No operational amplifier was used to build the amplification circuit in this project, so the factor is 1.
Then, the current sensing resistance value can be calculated using the above parameters. Selection:
Since this project... 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, a larger resistor cannot be chosen indiscriminately.
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 selected. According to the formula, 3A * 100mΩ = 300mV, 900mW can be calculated.
To cope with different usage environments, especially high current scenarios, the R0 resistor can be replaced with constantan wire or a shunt. The replacement can be chosen according to the actual usage scenario. For safety and educational purposes, this project will not discuss measurements exceeding 3A, but the principle is the same.
5. OLED Display
0.96-inch 4-pin OLED screen module is a display module that includes a 0.96-inch OLED display and 4 pins. This type of OLED screen module is commonly used in embedded systems and small electronic devices to display text, images, and other types of information. Due to their small size and low power consumption, they are also commonly used in smartwatches, health trackers, and other portable devices. These modules typically use SPI or I2C interfaces for communication and support multiple resolutions and color modes.
The module has four pins: VCC, GND, SCL, and SDA. VCC is the power supply pin, used to provide power to the module, typically 3.3V or 5V. GND is the ground pin, used to ground the module. It needs to be connected to the negative power supply. SCL is the clock pin, used for the clock signal during data transmission. It usually needs to be connected to the clock pin of the host chip. SDA is the data pin, used for data transmission. It usually needs to be connected to the data pin of the host chip. When using the I2C interface, this pin can also be called SDA (Serial Data Line).
When using a 0.96-inch 4-pin OLED screen module with a CW32 microcontroller, the microcontroller's output signals need to be converted into signals recognizable by the OLED screen. Therefore, a corresponding OLED controller is required, communicating via the I2C bus to convert the microcontroller's output signals into signals recognizable by the OLED screen. The code should define the driver functions for the OLED screen module. The OLED screen module driver mainly includes the following parts: write function (used to send commands or data to the OLED), clear function (used to clear all content on the OLED), display function (used to write the content in the buffer to the OLED), functions to light up or turn off pixels, and functions to display characters or strings. Finally, initialize the OLED screen module. The specific steps are: first, turn on the GPIOA clock; then set pins 6 and 7 of the GPIOA to output mode, push-pull output, 100MHz rate, pull-up; delay for 200ms, waiting for the OLED screen to start; send the OLED initialization command sequence; finally, clear the OLED screen. Since environmental parameters are variable, it is advisable to convert environmental parameter variables and environmental thresholds into string form before outputting them to the OLED screen.
6. Button Circuit Design:

There are various design methods for the button control circuit. Thanks to the CW32's internal I/O ports which can be configured with pull-up and pull-down resistors, the button control circuit on the 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.
7. TL431 Circuit Design for Voltage Measurement and
Calibration: 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 CW32's inherent ADC performance advantages, 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, very classic, and widely used; it is still found in many electronic products.
Many beginners may be encountering this device for the first time. We will briefly explain the principles of this product to help everyone better apply the TL431.
TI defines it as a "Precision Programmable Reference" in its name. 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 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 Vref.
Sinking Current Capability: This refers to how much current the output voltage pin can provide, which is greatly 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 to be too high, as this will cause unnecessary power consumption.
Voltage and Ammeter.zip
Voltage and Ammeter Project.zip
PDF_【LCSC Development Board】CW32 Voltage and Current Meter.zip
Altium_【LCSC Development Board】CW32 Voltage and Current Meter.zip
PADS_【LCSC Development Board】CW32 Voltage and Current Meter.zip
BOM_【LCSC Development Board】CW32 Voltage and Current Meter.xlsx
92881
Voltmeter and Ammeter Training Camp
Voltage and current meter designed based on CW32F030
This project , a voltage and current meter based on the CW32F030 development board, is part of the LCSC Development Board Training Camp .
I. Project Description
: This project follows the LCSC training camp. As a liberal arts student, this is my first systematic encounter with PCB design and programming. The aim is to cultivate my relevant knowledge and connect with other developers. The circuit design largely follows the official schematic, with simplifications made to the current and voltage sampling circuitry. The current sampling resistor is designed to be pluggable, facilitating initial debugging and allowing for later replacement to increase the range. However, due to my limited programming skills, multiple attempts to program the current sampler failed, and I used the official program instead. I am currently still writing the relevant code. The replaceable sampling resistor design is only shared as an example of a design concept.
Compared to the official example, this design replaces many components with surface-mount components and places the development board on the back of the PCB to reduce the overall area.
I was a bit lazy and used a heating table when soldering surface-mount components.
For detailed schematic design references, please see:
1. https://oshwhub.com/li-chuang-kai-fa-ban/cw32-shu-zi-dian-ya-dian-liu-biao-kai-fa-ban-tao-jian
2. https://wiki.lckfb.com/zh-hans/dwx-cw32f030c8t6/question/
II. Circuit 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, this project selected the SE8550K2, which has a maximum input voltage of up to 40V, as the power supply. The main reason for not using a DC-DC buck converter 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
To reduce the learning curve, this project uses the LCSC CW32F030C8Tx development board (core board) as the main controller. However, this doesn't mean we'll discuss this section less. From an engineer training perspective, proper main controller selection is crucial, as it affects the overall project performance. Regarding voltage and current meters, I conducted debugging and testing using STM32/CW32 and some other 32-bit microcontrollers. Here, we only compare it with the STM32F103C8T6 as a reference for device selection, primarily to provide ideas and improve understanding.
Avoid Blind Selection When selecting the 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. 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 (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, the ADC_IN9 channel is used 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, and 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 the low-side of the sampling circuit shares a common ground with the development board's meter interface, please do not solder R0!

The
sampling current designed for this project is 3A, and the selected sampling resistor (R0) is 100mΩ. The following aspects should 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; generally, it is not recommended to exceed 0.5V;
the power consumption of the current sensing resistor; a suitable package should be selected based on this parameter; considering the power consumption (temperature) issue under high current, a 1W packaged metal wire-wound resistor was selected ;
the voltage amplification factor of the current sensing resistor: no operational amplifier is used to build the amplification circuit in this project, so the factor is 1. The
current sensing resistor value can then be calculated using the above parameters.
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 the display device. Compared to a display screen, LED displays offer better visibility in complex environments. The brightness of the LED displays can be increased by using smaller current-limiting resistors, depending on the specific needs of the application environment. Furthermore, LED displays have better mechanical properties and are not as easily damaged by external forces as display screens. They are widely used in industrial applications where stability and reliability are crucial. From a development board learning perspective, this makes it easier to learn electronic measurement principles and related development in a targeted manner.
In this project, actual testing showed that the current-limiting resistors (R1~R6) for the LED displays were configured to 300Ω. The corresponding brightness for both red and blue LED displays was good and the brightness was soft and not glaring.
Strictly speaking, the current-limiting resistors should be added to the segments; adding them to the digits would affect the display effect. Our actual design places them in the digits to save a few resistors, but the impact on the display is not significant. Therefore, we add them to the digits for convenience.
The

driving principle of LED displays mainly involves controlling the switching state of each segment of the LED display 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 typically consists 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 come in two types: common cathode and common anode. The difference lies in whether the common terminal COM (the end connecting all LEDs) is connected to the negative or positive terminal of the power supply.
Driving Methods:
Segment Selection: The desired number or character is 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 the bit lines of the digital tube. Bit line control sets the bit line of the digital tube to be displayed 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 switching between multiple digital tubes can be achieved.
Driving Circuit:
The driving circuit for a digital tube can be implemented using hardware circuits, such as 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 driving of digital tubes can also be implemented through software control. By programming to generate control signals suitable for the digital tubes, 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 certain 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 numbers or characters, the segment data port must output the corresponding character encoding. For example, to display the number "0", the character code for a common anode seven-segment display is 11000000B (i.e., C0H), while the character code for a common cathode seven-segment display is 00111111B (i.e., 3FH). The specific code depends on the actual seven-segment display.
Dynamic and Static Display:
Seven-segment displays can use either static or dynamic display methods. In static display, each of the eight segments of each seven-segment display 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 seven-segment display one by one, achieving simultaneous visual display through rapid switching.
In summary, the driving principle of seven-segment displays is to control the switching state of each segment of the seven-segment display to display numbers, letters, or symbols, and to achieve display switching between multiple seven-segment displays through segment selection and digit selection. Furthermore, the driving of seven-segment displays can be implemented through hardware circuits or software control, and common cathode or common anode seven-segment displays can be selected as needed.
This project actually uses dynamic scanning display to drive the seven-segment display.
Calculate the required current for the digital tube.
This project actually uses dynamic scanning to drive the digital tube, so at any given time, only a maximum of 8 segments of the digital tube (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 (3.3V ÷ 300Ω ≈ 11mA).
At this point, it's important to ensure that the selected MCU has sufficient current sinking/pulling capability.


Analysis of the datasheet shows that CW32 is fine. (Some chips are not suitable.)
6. LED Indicator Lights
This project additionally designed a power indicator light and an IO operation indicator light.

LD_PWR is the power operation indicator light .

Since chip I/O often has a greater current sinking capability than current pulling capability, LED1 is designed to be active low (on).
To reduce the current consumption of the LEDs, some LED brightness is sacrificed, the component parameter types are reduced, and the LED current-limiting resistor is selected as 10K.
7. Button Circuit Design

There are multiple design options for the button control circuit. Thanks to the CW32's internal I/O ports which can be configured with pull-up and pull-down resistors, the button control circuit on the chip's periphery does not require configuration. One end of the button is connected to the MCU's I/O, and the other end is grounded. When the button is pressed, the I/O is pulled low.
8. TL431 Circuit Design for Voltage Measurement and Calibration:
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 calibrating the AD converter. From a product design perspective, due to the CW32's inherent ADC performance advantages, this circuit is not necessary. This circuit is designed on the development board for learning related application principles.
III. Product Diagram and Brief Introduction:

Thanks to JLCPCB's monthly freebie program, five boards were made at once. I must say, JLCPCB's immersion gold and color silkscreen printing processes are truly beautiful.

This is what it looks like after soldering the components. I changed the jumpers on the CW32 development board to single-pole double-throw switches

. This is what it looks like after installing the casing. Due to my lack of experience in designing boards for the first time, the long side of the vertical panel is 6mm shorter. The diagrams in the open-source file have been modified. The acrylic casing for the digital display has a windowed design to reduce glare. This window can be removed if aesthetics and a more cohesive look are desired.
Finally, I would like to thank LCSC Development Board and Sinyuan Semiconductor for organizing this training camp, which allowed me to systematically learn about PCB design and development boards.
Entries video.mp4
Digital voltmeter and ammeter with calibration function.rar
PDF_Voltmeter and Ammeter Training Camp.zip
Altium_Voltage and Ammeter Training Camp.zip
PADS_Voltmeter & Ammeter Training Camp.zip
BOM_Voltage and Ammeter Training Camp.xlsx
92882
Basic training on ammeters and voltmeters
LCSC GeoStar CW32 Digital Voltage and Current Meter Expansion Board
Project Introduction
: The LCSC CW32 digital voltmeter and ammeter can accurately measure current and voltage.
Project Functions:
[This section describes the relevant functions and application scenarios of the project.] Example:
This design is a temperature and humidity alarm system based on the STC89C51/52 microcontroller. It has four independent buttons with functions of setting, increasing, decreasing, and confirming, enabling adjustment of the alarm threshold. When the temperature or humidity exceeds the threshold range, an alarm sound and corresponding alarm light will be emitted.
Design Background:
ADC (Analog-to-Digital Converter) is an indispensable key