0HMv08W

[Lonely Rock 'n' Roll Color Screen Printing] Air32-Arduino

 
Overview
This is the second board Xiaobai designed, and it's still just to get free color silkscreen printing. More than a year later, he told me he was blacklisted and I had to close the project, so I quickly closed it myself.

This is an Arduino-shaped Air32F103 minimum system board.

The method for creating the color silkscreen printing is to use a screenshot function to capture the PCB, import it into Photoshop, paste the desired image onto it, rasterize the layers, and then perform color processing between the layers.

(Simple example image

)

![363FA94F8B3F33E9AE1287DB54B1BF1F.jpg]
PDF_【Lonely Rock Color Silkscreen】Air32-Arduino.zip
Altium_【Lonely Rock Color Silkscreen】Air32-Arduino.zip
PADS_【Lonely Rock Color Silkscreen】Air32-Arduino.zip
BOM_【Lonely Rock Color Silkscreen】Air32-Arduino.xlsx
92956
CW32 Minimum System Voltage and Current Meter
The voltage and current meter is designed with CW32F030C8T6 as the main controller, uses a digital tube to display voltage and current, and buttons to switch ranges. It can measure voltage from 0 to 75V and current up to 3A.
1. Hardware Circuit: Power
Supply Circuit
: DC input 12V. The LDO used is Siwang SE8550K2-HF. This LDO supports wide voltage input,
but a 5V output should be selected here! Do not mix up schematic design and component ordering.
Digital Tube
Display Circuit: Uses 4 common cathode digital tubes and three SN74HC595D
drivers. Two cascaded SN74HC595Ds drive the segment codes of the digital tubes, and one SN74HC595D drives the digit codes. Keypad Circuit:
The
keypad circuit uses a resistor pulled up to 3.3V, plus a capacitor for debouncing.
There are various design methods for keypad control circuits. The CW32's I/O port can be configured with internal pull-up and pull-down resistors, so debouncing is not required for the external keypad control circuit. One end of the keypad is connected to the MCU's I/O, and the other end is grounded. When the keypad is pressed, the I/O is pulled low.
The voltage calibration circuit
in this project includes an additional TL431 circuit to provide a 2.5V reference voltage. This can be used to provide an external voltage reference for calibrating the ADC. From a product design perspective, due to the inherent ADC performance advantages of the CW32, this circuit is unnecessary.
The TL431 output voltage is highly accurate. At room temperature, the measured voltage on the board is 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. The adjustable output voltage is between Vref and 36V. The PCB design includes
an LED indicator circuit,
a voltage sampling circuit,
a current sampling circuit,
 
and a buzzer circuit. The 3V3 power lines are pink, and the 5V lines are brown for easy routing and to avoid confusion. Those unfamiliar with this can use the default LCEDA settings. A buzzer is added to the circuit to alert the user when the measured voltage exceeds the range. **Caution!!** Here, a Q7S chip (pin 9) of a 595 is connected to the DS data input of another 595, achieving cascading. Because a 4-bit common cathode is used, the routing is not easy; careful planning of the signal line paths is necessary. The software has been uploaded as an attachment. The sampling resistor will not be soldered for now; it will be soldered later when needed.






IVI.zip
P4.jpg
BOM_Board1_Schematic1_2024-08-18.xlsx
p8.PNG
PDF_CW32 Minimum System Voltage and Current Meter.zip
Altium_CW32 Minimum System Voltage and Current Meter.zip
PADS_CW32 Minimum System Voltage and Current Meter.zip
BOM_CW32 Minimum System Voltage and Current Table.xlsx
92957
Digital voltmeter and ammeter
Design of a digital voltage and current meter based on LCSC-Diwenxing CW32
I. Design Background
The digital voltmeter and ammeter combines 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, making it a powerful tool for electronic design and troubleshooting, and playing a significant supporting role in the work of electronic engineers. In product applications, the digital voltmeter and ammeter ensures the accuracy and safety of circuit design, while also providing strong support for product quality control and subsequent maintenance.
II. Hardware Design
1. Power Supply Design
A diode is used to prevent reverse connection damage to subsequent circuits. A step-down chip is selected to obtain a 5V voltage. A diode is added as a power indicator for easy identification.
2. Sampling Circuit Design
:

The maximum voltage to be measured is 30V;
the ADC reference voltage is 1.5V, which can be configured through the program;
based on experience, the low-side resistor (R7) is selected as 10K;

the high-side resistance of the voltage divider is calculated using the above parameters;

the required voltage division ratio is calculated, i.e., the ADC reference voltage is the design input voltage, which can be calculated using known parameters as 1.5V/30V=0.05
; the high-side resistance is calculated as the low-side resistance/voltage division ratio, which can be calculated using known parameters as 10K/0.05=200K;
a standard resistor is selected: a resistor slightly higher than the calculated value is chosen, which is 200K, and an E24 series 220K resistor is selected.

The voltage divider resistors are 220K+10K, therefore the voltage division ratio is 22:1 (ADC_IN11).
The

maximum pre-designed current measurement value is 3A
, which is the voltage difference caused by the current sensing resistor. It is generally not recommended to exceed 0.5V
of the current sensing resistor's power consumption. 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 in this
project. The voltage amplification factor of the current sensing resistor: No op-amp is used to build the amplification circuit in this project, so the factor is 1.3

.
An additional TL431 circuit is added to provide a 2.5V reference voltage, which can be used to provide an external voltage reference for the chip to calibrate the AD.
Physical verification diagrams
 
and detailed project information are available in the CW32 Digital Voltage and Current Meter Training Camp Project Tutorial Document | LCSC Development Board Technical Document Center (lckfb.com).
Voltage and Current.zip
PDF_Digital Voltage and Current Meter.zip
Altium Digital Voltage and Current Meter.zip
PADS Digital Voltage and Current Meter.zip
BOM_Digital Voltage and Current Meter.xlsx
92958
CW32 Voltage and Current Meter
Learn about CW32 microcontrollers and ADC analog-to-digital converter circuits to implement a current and voltage meter that can measure current and voltage.
I. Project Background: This project
involves learning the CW32 microcontroller and ADC (Analog-to-Digital Converter) circuits to implement a current and voltage meter.
II. Hardware Design
: 1. Schematic Diagram
2. Circuit Analysis
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 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 ripple interference from the DC-DC circuit during the design process. A secondary reason is to reduce project costs.

The Role of the Series Small Resistor (10Ω):
This project additionally uses a series small resistor (10Ω) for voltage division. On the one hand, this reduces the problem of severe heat generation caused by the large voltage drop of the LDO under high voltage conditions. On the other hand, it utilizes the principle that the series 10-ohm low-power resistor has low overcurrent, acting as a low-resistance fuse, providing overcurrent protection or short-circuit protection. (The point about using a resistor as a fuse is that, because the resistor is in an overcurrent state and heating up, it is 99% likely to be an open circuit, and it will almost never short-circuit. Its fault analysis determines that it will primarily be an open circuit, meaning it will burn out rather than short-circuit.) The
small series resistor (10Ω) can also reduce the peak value of the power-on surge, preventing damage to the LDO from excessive surges.
If electrolytic capacitors are not used, the small series resistor (10Ω) can also prevent the inductance of the wires and the ceramic capacitor from resonating during hot-plugging. Because ceramic capacitors have very low ESR, the damping in the LC network is very low, and the gain at the resonant point will be very high. Adding an external resistor to provide damping can suppress the gain at the resonant point.
 


Circuit design points and specifications
: When drawing power supply circuits, whether schematics or PCBs, the following points should be noted:


Schematic specifications: GND should be facing down, power supply should be facing up, and ground should not be facing up.


Capacitor design: Regardless of the schematic or PCB, electrolytic capacitors should be placed first, followed by ceramic capacitors.


Grounding design: Single-point grounding. The ground of the current power supply is connected to the GND of the main electrolytic capacitor of the current power supply. The ground of the main electrolytic capacitors of each stage power supply is connected to the GND of the main electrolytic capacitor of the previous stage power supply.


2. MCU Selection Analysis
To reduce learning costs, this project uses the LCSC CW32F030C8T6 development board (core board) as the main controller. Downloadable materials can be found on the LCSC development board website.
Key advantages of the CW32 in this project

: Wide operating temperature range: -40~105℃;
Wide operating voltage range: 1.65V~5.5V (STM32 only supports 3.3V systems)
; Strong anti-interference: HBM ESD 8KV; All ESD reliability reaches the highest international standard level (STM32 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 waiting)

3. Voltage sampling circuit The voltage
divider resistor in this project is designed to be 220K+10K, so the voltage division ratio is 22:1 (ADC_IN11).

The voltage divider resistor is


selected to measure the maximum voltage. For safety reasons, this project uses 30V (the actual maximum can be displayed as 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 achieve the increased 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.
5. Digital Tube Driver:
This project uses two 0.28-inch three-digit common-cathode digital tubes as display devices. Compared to displays, digital tubes have better visibility in complex environments. Depending on the actual usage environment, smaller current-limiting resistors can be used to achieve higher brightness. Furthermore, digital tubes have better mechanical properties and are not as easily damaged by external forces as displays. They are widely used in industrial and other applications requiring stable and reliable operation. From a development learning perspective, this makes it easier to learn electronic measurement principles and related development more purposefully.
In this project, after actual testing, configuring the current-limiting resistors (R1~R6) of the digital tubes to 300Ω resulted in good visibility for both red and blue digital tubes, with a soft and 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. In our actual design, we added them to the digits to save a few resistors, but the impact on the display was not significant. Therefore, we added them to the digits for convenience.

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
92959
Simple voltmeter and ammeter
A simple voltage and current meter based on LCSC Diwenxing CW32F030C8T6.
1. The hardware design

is based on the official schematic but has been modified.
The digital display is replaced with an LCD1602.
A function to control relay voltage and current switching via buttons has been added.

4. Some modules have been removed.
5. A Type-C input has been added.
6. Most components are through-hole for easy soldering.
2. The software design

uses a timer to trigger ADC+DMA transfer.

`void AD_GPIO_Init(void)
{
__RCC_GPIOA_CLK_ENABLE(); // Enable GPIOA clock
__RCC_GPIOB_CLK_ENABLE(); // Enable GPIOB clock

PA00_ANALOG_ENABLE(); // Set PA0 as analog input
PA01_ANALOG_ENABLE(); // Set PA1 as analog input
PA01_ANALOG_ENABLE(); // Set PA2 as analog input
PB11_ANALOG_ENABLE(); // Set PB11 as analog input

}
// ADC configuration
void AD_Init(void)
{
__RCC_ADC_CLK_ENABLE(); // Enable ADC clock
ADC_DeInit();

ADC_SerialChTypeDef ADC_SerialChStruct; // ADC sequence configuration

ADC_SerialChStruct.ADC_SqrEns = ADC_SqrEns03; //` Convert SQR0, SQR1, SQR2, SQR3

ADC_SerialChStruct.ADC_InitStruct.ADC_OpMode = ADC_SerialChScanMode; // Sequence scan conversion mode
ADC_SerialChStruct.ADC_InitStruct.ADC_ClkDiv = ADC_Clk_Div128; // ADC clock frequency = PCLK / 4 = 64MHz / 4 = 16MHz
ADC_SerialChStruct.ADC_InitStruct.ADC_SampleTime = ADC_SampTime10Clk; // Sampling time -> 10 ADC clock cycles
ADC_SerialChStruct.ADC_InitStruct.ADC_VrefSel = ADC_Vref_VDDA; // VDDA reference voltage
ADC_SerialChStruct.ADC_InitStruct.ADC_InBufEn = ADC_BufDisable; // Disable the input buffer (follower) when no additional drive capability or gain is required.
`ADC_SerialChStruct.ADC_InitStruct.ADC_TsEn = ADC_TsDisable;` // Disable the built-in temperature sensor.
`ADC_SerialChStruct.ADC_InitStruct.ADC_DMAEn = ADC_DmaEnable;` // Trigger DMA transfer upon ADC conversion completion.
`ADC_SerialChStruct.ADC_InitStruct.ADC_Align = ADC_AlignRight;` // Right-align ADC conversion results.
`ADC_SerialChStruct.ADC_InitStruct.ADC_AccEn = ADC_AccDisable;` // Disable result accumulation; the result of each conversion will not be added to the previous result.

ADC_SerialChScanModeCfg(&ADC_SerialChStruct); // Configure ADC serial scan conversion mode

// Configure channel
CW_ADC->SQR_f.SQR0 = ADC_ExInputCH0; // PA0
CW_ADC->SQR_f.SQR1 = ADC_ExInputCH1; // PA1
CW_ADC->SQR_f.SQR2 = ADC_ExInputCH2; // PA2
CW_ADC->SQR_f.SQR3 = ADC_ExInputCH12; // PB11

ADC_ExtTrigCfg(ADC_TRIG_GTIM2, ENABLE); // Configure ADC external interrupt trigger source to trigger timer 2
}

// ADC DMA configuration
void AD_DMA_Init()
{
__RCC_DMA_CLK_ENABLE(); // Enable DMA clock
DMA_DeInit(CW_DMACHANNEL1);

DMA_InitTypeDef DMA_InitStruct; // DMA initialization structure
DMA_StructInit(&DMA_InitStruct); // Fill the DMA initialization structure with default parameters

DMA_InitStruct.DMA_Mode = DMA_MODE_BLOCK; // Trigger unlocked transfer using BLOCK
DMA_InitStruct.DMA_TransferWidth = DMA_TRANSFER_WIDTH_32BIT; // Data width is 12 bits
DMA_InitStruct.DMA_SrcInc = DMA_SrcAddress_Increase; // ADC peripheral address is fixed
DMA_InitStruct.DMA_DstInc = DMA_DstAddress_Increase; // The target address is automatically incremented.
DMA_InitStruct.DMA_TransferCnt = 4; // Number of transfers: 4
DMA_InitStruct.DMA_SrcAddress = (uint32_t)(&(CW_ADC->RESULT0)); // ADC data register address (source address)
DMA_InitStruct.DMA_DstAddress = (uint32_t)ADC_Value; // Target address
DMA_InitStruct.TrigMode = DMA_HardTrig; // Hardware trigger
DMA_InitStruct.HardTrigSource = DMA_HardTrig_ADC_TRANSCOMPLETE; // ADC as trigger source
DMA_Init(CW_DMACHANNEL1, &DMA_InitStruct); // Initialize DMA

NVIC_EnableIRQ(DMACH1_IRQn); // Enable NVIC
NVIC_SetPriority(DMACH1_IRQn, 0); // Set interrupt priority

DMA_ITConfig(CW_DMACHANNEL1, DMA_IT_TC, ENABLE); // Enable DMA transfer completion interrupt
DMA_ITConfig(CW_DMACHANNEL1, DMA_IT_TE, ENABLE); // Enable DMA transfer error interrupt

}

void Error_Handler(void)
{
while(1)
{

}
}


// DMA interrupt function
void DMACH1_IRQHandler(void)
{
if (DMA_GetITStatus(DMA_IT_TC1) == SET)
{

CW_DMA->CNT1_f.CNT = 4;
CW_DMA->CNT1_f.REPEAT = 1;
CW_DMACHANNEL1->SRCADDR = (uint32_t)(&(CW_ADC->RESULT0)); // Set source address
CW_DMACHANNEL1->DSTADDR = (uint32_t)ADC_Value; // Set the target address
DMA_Cmd(CW_DMACHANNEL1, ENABLE); // Enable DMA

DMA_ClearITPendingBit(DMA_IT_TC1);
}

if (DMA_GetITStatus(DMA_IT_TE1) == SET)
{

DMA_ClearITPendingBit(DMA_IT_TE1);
}
}

MultiButton is used.
MultiButton is a small, simple, and easy-to-use event-driven button driver module that can infinitely expand the number of buttons. The asynchronous callback processing of button events can simplify your program structure, remove redundant hard-coded button processing, and make your button business logic clearer.


The calibration method is not used at the moment. 3. Test

voltage test


and current test

code.7z
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
92960
Digital voltage and current meter based on CW32F030C8T6 development board
In short, I'm open-sourcing an expansion board for voltage and current meters.
The digital voltmeter and ammeter based on the LCSC CW32F030C8T6 is finally finished!
Unlike ordinary multimeters, it has a calibration function. When the measurement is inaccurate, you can calibrate it. Press the user button 1 to enter the 5V calibration mode, which displays S.05. 
At this time, plug in a voltmeter and turn the long-handled potentiometer to make the voltmeter display 5V. The blue text below shows the voltage that is not calibrated in the meter. If you have time, you can also calculate the error [winking emoji]. 
Then press the user button 2 to enter the 15V calibration mode, which displays S5.15. Turn the potentiometer to 15V and press the user button 2 again to complete the calibration. Similarly, you can also calibrate the current. Press the back button 1, which is user 3, to return to mode 0 and enter the measurement mode. This is its highlight.
Bilibili video link. I will post the Oshwhub open source and code in the comments section tomorrow.
This link is not the original version. This version adds two switches and Type-C power supply.
Below is the official documentation. If you don't want to read it, just close it.
I. Design Background
  ADC (Analog-to-Digital) A converter (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, making it a powerful tool for 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.
Figure 32Learning to design and build a digital voltmeter and ammeter is highly beneficial for improving one's professional skills. The digital voltmeter and ammeter project covers multiple aspects, including the design and implementation of microcontroller circuits, the design of signal acquisition and processing circuits, the development and optimization of user interfaces, and the design of product appearance. It integrates knowledge from multiple fields such as electronic technology, 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 electronic technology 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 device design, making learning simpler and exploration more in-depth;
the core board uses the domestic Wuhan Xinyuan Semiconductor CW32 as the main controller, while being compatible with other similar development boards; however, the CW32 has advantages.
The project is highly comprehensive and practical, and can be used as a desktop instrument after completion;
the project has rich learning materials, including circuit design teaching, PCB design, code programming learning, and the cultivation of engineers' debugging capabilities.
2.1. Software Development Overview
2.1.1. Essential Knowledge Points for Embedded Systems
Embedded software development, as an interdisciplinary field of computer science and electronic engineering, requires developers to have a series of professional knowledge and skills. Essential knowledge for CW32-based embedded software development includes the following:

Programming Languages:


Proficiency in C (C++) is crucial, as it's the most commonly used programming language in embedded systems due to its direct hardware access capabilities and high code execution efficiency.
Understanding of assembly language is necessary for writing low-level drivers, interrupt handlers, and high-performance code segments.
A basic understanding of other programming languages ​​such as Python and Java is required for specific situations.
Familiarity with the CW32 standard library is essential.


Data Structures and Algorithms:


Familiarity with various data structures, such as arrays, linked lists, stacks, and queues, as well as common algorithms like sorting, searching, and recursion.
The ability to select appropriate data structures and algorithms based on the resource constraints of the embedded system is required.


Computer Architecture:


Understanding of processor architectures, such as ARM and x86, as well as instruction sets and memory management is essential.
Familiarity with the hardware components of embedded systems, such as microcontrollers, FPGAs, and DSPs, is required.
The ability to readily refer to the CW32 embedded chip's datasheet and user manual to understand the operating principles of required peripherals is also essential.


Embedded Operating Systems (In-depth Knowledge):


Master commonly used embedded operating systems such as μC/OS and FreeRTOS, and understand their kernel, process management, memory management, device management, and file system principles.
Be able to design and manage operating system tasks to meet the needs of specific applications.


Hardware Interfaces and Peripherals:


Be familiar with common hardware interfaces such as GPIO, serial ports, SPI, and I2C, and be able to write corresponding drivers.
Understand commonly used hardware devices in embedded systems, such as sensors, actuators, and communication modules, and be able to interact with them.


Development Tools and Environment:


Be proficient in using integrated development environments (IDEs) such as KEIL, IAR, and Visual Studio for software development and debugging.
Master the use of cross-compilers to compile programs that can run on target hardware on the development computer.
Be familiar with the use of debuggers, and be able to perform software breakpoint debugging, single-step execution, and variable viewing.


System Analysis and Design:


Be able to perform project requirements analysis and transform requirements into software functional requirements.
Master the principles and methods of software architecture design, and be able to design efficient and maintainable software systems.
Understanding the real-time requirements of embedded systems enables the design of software systems that meet these requirements.


Testing and Verification:


Mastering unit testing, integration testing, and system testing methods and techniques allows for comprehensive software testing to ensure the correctness and stability of software functions.
Understanding the reliability requirements of embedded systems enables reliability testing and verification of software. Only by fully mastering this knowledge and possessing continuous learning capabilities can one become an excellent embedded software developer.

2.1.2 Initial Preparation:
Development environment installation (MDK 5.33 recommended), DAPLINK downloader, firmware library. The firmware library can be downloaded from the official website: www.whxy.com. Common debuggers such as STLINK, DAPLINK, PWLINK, WCHLINK, JLINK, etc., that support Cortex-M are acceptable. The
remaining software code is in the attachment. The video also
emphasizes not making money by selling boards but taking the cultivation of Chinese engineers as its mission. I really like this slogan.
The video is a rough cut because OshWhub has a 50MB limit. For the full version, please visit Bilibili: 【〖LCSC Training Camp〗 Adjustable Voltmeter and Ammeter Training Camp - Showcase - Bilibili】 https://b23.tv/9LSiefE
ADC-CW32 WORKS.zip
Experiment Nine + Digital Voltmeter and Ammeter with Calibration Function.zip
VID_20240821171555.mp4
VID_20240821171742.mp4
PDF_Digital Voltage and Current Meter Based on CW32F030C8T6 Development Board.zip
Altium Digital Voltage and Current Meter Based on CW32F030C8T6 Development Board.zip
PADS Digital Voltage and Current Meter Based on CW32F030C8T6 Development Board.zip
BOM_Digital Voltage and Current Meter Based on CW32F030C8T6 Development Board.xlsx
92961
CW3 voltage and current meter
Thanks to JLCPCB and Sinyuan Semiconductor for organizing this event, which gave me a learning opportunity. It was my first time doing a project, and I had to learn everything from scratch. This experience helped me discover many problems; only after prototyping and assembling did I realize the panel size was incorrect and the casing was a bit small.
IMG_20240821_171531IMG_20240821_161606_edit_186030889177835IMG_20240821_162206_edit_186417778848833_compressedIMG_20240821_161519_edit_185990480829777Hardware Design
1. Power Supply Circuit
image-20240821164838962: 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.
When designing the DC plug, attention should be paid to the inner diameter of the DC socket. Common types include DC 2.1 and DC 2.5; ensure that the power connector and DC socket are compatible.
2. ADC Sampling Circuit:
image-20240821165316046Advantages of CW32 in this Project
. Better ADC: 12-bit high-speed ADC, achieving ±1.0LSB INL 11.3ENOB, multiple Vref reference voltages... ... (STM32 only supports VDD=Vref).
Key characteristics of CW32's ADC.
image.png3. Voltage Sampling Circuit
: The voltage divider resistors in this project are 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.

4. Current Sampling Circuit
image-20240821165810878The sampling current designed for this project is 3A, and the selected sampling resistor (R0) is 100mΩ.
The selection of the sampling resistor mainly needs to consider the following aspects:
the maximum value of the pre-designed measurement current;
the voltage difference caused by the 3A current sensing resistor in this project; and
the power consumption of the current sensing resistor, which is generally not recommended to exceed 0.5V. A suitable package should be selected based on this parameter. Considering the power consumption (temperature) issue under high current, a 1W packaged metal-wound resistor was selected
. The voltage amplification factor of the current sensing resistor: No operational amplifier was used in this project to build an amplification circuit, so the factor is 1. The
current sensing resistance value can then be calculated using the above parameters. Selection:
Since no amplification circuit was used in this project, a larger sampling resistor was needed to obtain a higher measured voltage for measurement.
Considering that a larger resistor would result in a larger voltage difference and higher power consumption, a larger resistor cannot be selected indiscriminately.
A 1W packaged resistor was selected in this project, corresponding to a power rise of 1W.
Based on the above data, a 100mΩ current sensing resistor was selected in this project. According to the formula, 3A * 100mΩ = 300mV, 900mW.
5. Digital Tube Display:
image-20240821165937932image.pngThe driving principle of a digital tube mainly involves controlling the switching state of each LED segment 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 switching state of each LED segment. 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. Bit line control sets the bit line of the desired digital tube to a high level and the bit lines of other digital tubes to a low level. By continuously switching the state of the bit lines, the display switching between multiple digital tubes can be achieved.
Driving Circuit:
The digital tube driving circuit can be implemented through hardware circuits, such as using integrated circuits like digital signal processors (DSPs), microcontrollers (MCUs), or shift registers to generate control signals suitable for the LEDs.
These control signals can be in the form of pulse width modulation (PWM) signals, serial data signals, etc. By controlling the frequency, width, and amplitude of these signals, the brightness of the digital tube can be controlled, thereby displaying the desired numbers or letters.
Software Control:
In addition to hardware driving circuits, digital tubes can also be driven 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.
Encoding Display:
To display the corresponding numbers or characters on the digital tube, the segment data port must output the corresponding character encoding. For example, to display the number "0", the character encoding for a common anode digital tube is 11000000B (i.e., C0H), while the character encoding for a common cathode digital tube is 00111111B (i.e., 3FH). The specific encoding depends on the actual digital tube.
Dynamic and Static Display:
Digital tubes can use either static or dynamic display methods. In static display, each of the eight segments of each digital tube is connected to an 8-bit I/O port address. As long as the I/O port outputs a segment code, the corresponding character is displayed and remains unchanged. Dynamic display, on the other hand, lights up each digit of the digital tube one by one, achieving simultaneous visual display through rapid switching.
In summary, the driving principle of digital tubes is to control the switching state of each segment of the digital tube to display numbers, letters, or symbols, and to achieve display switching between multiple digital tubes through segment selection and digit selection. Furthermore, the driving of digital tubes can be implemented through hardware circuits or software control, and common cathode or common anode digital tubes can be selected for driving as needed.
This project actually uses dynamic scanning to drive the digital tube display.
Let's estimate the current required for the digital tube.
This project actually uses dynamic scanning to drive the digital tubes, so at any given time, only a maximum of 8 segments of the digital tubes (or LEDs) can be lit, or in other words, only one digit can be lit. According to the design, the required drive current is approximately 11mA (3.3V ÷ 300Ω ≈ 11mA) of the high-level voltage of the I/O port.
At this point, it's important to ensure that the selected MCU has sufficient current-source/current-sinking capability.
imgimage.pngimage-20240821170429011This 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 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 help everyone better apply 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 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.
IMG_20240821_172347
Digital voltmeter and ammeter with calibration function.zip
Panel_Panel_1_2024-08-21.epanm
CW32 voltmeter and ammeter housing. (zip)
test.jpg
Calibration Function.mp4
PDF_cw3 voltage and current meter.zip
Altium_cw3 voltage and current meter.zip
PADS_cw3 voltage and current meter.zip
BOM_cw3 Voltage and Current Meter.xlsx
92962
electronic
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2026-03-26 18:57:00

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号