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 has promoted the intelligent and precise control of electronic equipment across various industries, making them a key factor driving modern technological progress.
This project is a replica of a training camp voltmeter and ammeter. The core board uses the domestically produced Wuhan Xinyuan Semiconductor CW32 as the main controller, with a reduced PCB size and an additional casing. The display effect is shown in the figure:
The Dust White Forbidden Zone features an NFC card/bus card designed to resemble the Arknights pass.
Design Introduction
This design is a modified version of several projects. To hide and protect the chip, it has been modified into a stacked NFC card/bus card composed of three PCBs (two color silkscreen PCBs with a regular PCB with coils and pads sandwiched in between). This modification wasn't simply because stacking three PCBs is more comfortable to handle.

Color Silkscreen Image Design
The color silkscreen image style is modified from the Arknights pass image style. All images used in the modified version are from the "Dust White Forbidden Zone" forum.
PCB Introduction
This project contains two PCBs:
1. Middle Circuit Layer PCB
This PCB has coils and pads, mainly used for soldering the NFC chip/bus card chip and for communication. The NFC chip uses a 5x10mm or smaller COB package. If you want to solder a bus card chip like us, please ensure your bus card chip supports NFC functionality before removing it to ensure convenient recharging later.
2. Top and Bottom Color Silkscreen Layer PCBs
This PCB does not contain any circuit design and is only for decoration. You can modify the color silkscreen images on the PCB according to your preferences.
Prototyping
: 1. Number of PCB boards for the middle layer circuit
: 5 pieces. Solder mask color: White is recommended.
Other options can be left as default (remember to claim the coupon for free).
2. Number of boards for the top and bottom color silkscreen layers
: 10 pieces. Solder mask color: White. Pad plating: Immersion gold. Character process: JLCPCB EDA color silkscreen printing
. Other options can be left as default. The price for prototyping 5 color silkscreen PCBs is the same as for 10 pieces; only the shipping fee will be charged separately. 10 color silkscreen PCBs and 5 regular PCBs can be stacked into 5 sets.
Materials needed:
1. M2x4 double knurled studs *4 (outer diameter preferably less than or equal to 3.2mm)
2. M2x2 flat head hex screws *8 (head diameter 4mm, suitable screwdriver Φ1.27mm or Φ1.3mm)
3. NFC chip/bus card chip; NFC chip should be a 5x10mm or smaller COB package chip. If you're like me and want to solder a bus card chip, please make sure your bus card chip supports NFC functionality before removing it to ensure convenient top-up later.
Other materials
assembly video: https://www.bilibili.com/video/BV1FWvrewE4N/
Dust White Forbidden Zone Pass Template Link: https://pan.baidu.com/s/1F0HrMr1ZeUbAKjqgXWEClg?pwd=snow
Extraction code: snow
Note: It's best to download the template from a cloud drive, as it may have been modified.
Modification Log
August 16, 2024
1. Partially modified the image template and re-uploaded it
. 2. Added Cassia, Fanny-Radiance, and Reeve-Infinite Vision. Image
References
1. Circuit and PCB Design Reference
https://oshwhub.com/242534lbw/ai-li-xi-ya-NFCka
https://oshwhub.com/zhiyuan338/fan-ka
2. Pad Reference
https://oshwhub.com/kctp/fanka
3. Original Color Silkscreen Image Source
https://www.cbjq.com/ 4. Color silkscreen image design reference :
https://www.bilibili.com/video/BV16P411Z729/
PDF_Dust White Forbidden Zone Imitation Arknights Pass NFC Card - Public Transportation Card.zip
Altium_Dust White Forbidden Zone Imitation Arknights Pass NFC Card_Public Transportation Card.zip
PADS_Dust White Forbidden Zone Imitation Arknights Pass NFC Card_Public Transportation Card.zip
I. Project Introduction
I have always been a lighting fanatic, proficient in lighting LEDs and digital tubes, but I have never been familiar with measurement programs. In this training camp, I made a simple digital voltage and current meter using the LCSC Skystar CW32 development board to try to learn the methods of measurement and reading between circuits. Thanks to LCSC for letting me experience the powerful one-stop service again. Through this project, I gained a deeper understanding of functions such as color screen printing, 3D printing, and panel making.


II. Hardware Part
1. Power Supply Step-Down Circuit

The power supply is provided by the SE8550K2, a low dropout linear regulator that can support a maximum input of 40V. Since the project does not require a large current, an LDO step-down is used.
[1] The schematic diagram not only shows the pin connections of each component, but also indicates the current flow direction in the circuit design. First, low-frequency filtering is done through electrolytic capacitors, and then high-frequency noise is filtered out through small-capacity capacitors.
[2] When designing the DC plug, attention should be paid to the inner diameter of the DC socket. Common ones are DC2.1 and DC2.5. Make sure that the power connector and DC socket are suitable.
[3] The reverse connection protection design uses Schottky diodes (metal + semiconductor), with a low forward voltage of 0.2V-0.3V, suitable for fast switching and low voltage drop. Common models are SS14 and 1N5819. The easily confused switching diode is a typical PN junction, with a voltage drop of 0.6V-1.0V, suitable for digital and pulse circuits. Common model is 1N4148.
[4] Overcurrent protection and short circuit protection can be effectively achieved by connecting a 10R resistor in series in the circuit. The common power of 0603 package resistors is mainly 100mW. P=UI=I²R. After overcurrent, the resistor burns out to prevent damage to subsequent circuits.
2. Voltage sampling circuit

[1] The common battery voltage sampling circuit is similar to the low-side voltage circuit on the right. It collects the external voltage by dividing the voltage equally between two 10K resistors. U=AD/4096×Vref×2
【2】The high-side voltage sampling circuit uses a 220K+10K resistor to divide the voltage, U=(R/Rtotal)xUsource-->U_ADC=10K/(220K+10K)×Vmeasured. Since the reference voltage is 1.5V, the maximum measurable voltage is 34.5V. U=AD/4096×Vref×(220K+10K)/10K
【3】Through diode forward clamping, when the measured voltage is too large, the pin voltage is forced to clamp to 5V+ voltage drop to prevent chip pin damage. Detailed explanation of diode clamping circuit and limiting circuit
3. Current sampling circuit

【1】The current is collected through a 100mR sampling resistor. The project design range is 0-3A, P=I²R-->9×100mR=900mW, so the power should be selected from the common 1W package resistor.
[2] The circuit uses direct pin connection and does not use a current sensing amplifier, so the voltage amplification factor is 1. I=U/R, and the measured current is calculated from the value collected by the ADC pin: I=AD value/collection range×reference voltage/sampling resistor-->I=AD/4096×Vref×10
[3] A 1K resistor is connected in series to limit the current and prevent damage to the ADC pin, and it forms an RC low-pass filter with the back-end capacitor to reduce high-frequency noise.
[4] The sampling resistor should be connected in Kelvin during layout.
4. The TL431 reference voltage

is provided by using the TL431 circuit to provide a 2.5V reference voltage (approximately 2.48V in actual measurement). According to the chip datasheet, when pins 1 and 2 of the chip are connected, VKA=VREF.
The recommended maximum current for IKA is 1mA, and the current limiting resistor R=(5V-2.5V)/0.001A=2.5K. However, the chip sink current can reach 100mA with little damage.
*For example, P=UI=2.5V100mA=0.25W, so the current limiting resistor should be a power resistor with a power greater than 0.25W. **

5. Display and operation circuit

[1] Since the chip I/O often has a sinking current capability greater than a pulling current capability, the LED is designed to be active low level (bright). In order to reduce the current consumption of the LED, some LED brightness is abandoned, the types of device parameters are reduced, and the current limiting resistor of the LED is selected as 10K. The maximum forward current of the red LED is 20mA, and the minimum resistance is R=(5V-1.5V)/I=175Ω; I=U/R->3.5V/10K=0.35mA LED current limiting resistor analysis
[2] Two 0.28-inch three-digit common cathode digital tubes are used for data display. According to the datasheet, the maximum driving current of the digital tube is 35mA, the driving voltage is 2.7V-2.9V, the microcontroller IO port can output 3.3V level, the maximum sink current input is 25mA, R=U/I-->3.3V/0.025A=132Ω. Therefore, a 300R resistor->3.3V/300R=11mA can be used to light up the digital tube.



!! After searching around, it seems that only this chip with a relatively small current was found. (rough search) !!

III. Physical Production
[1] Most of the circuit uses 0603 package. First, solder the surface mount part, and then solder the through part.
[2] If you want to use the 3.96mm×2P wire-to-board pin header for convenience, you can replace it with a 2.54mm×2P header to connect the commonly used DuPont wires, but the overcurrent capacity will affect the measurement range. (This time, DuPont wire was directly wrapped around the terminal block for easy measurement)

IV. Software Part
1. Compiler Part
[1] The most common question in the exchange group during this training camp was about software installation. The new version of KEIL has reached version 5.40 in May 2024. The download link is no longer provided in the new version, and CMSIS has also been updated to 6.1.0. This makes it impossible to compile most official routines normally. These two parts need to be modified before compiling. (Only when installing version 5.39 is there a problem with compiler mismatch)
[2] At the same time, I recommend an official link for chip support package with a relatively fast download speed. From now on, you don't have to wait half a day to download in KEIL PACK Installer.


2. Program Part
Since it is the first time to come into contact with measurement programs, you must write programs yourself to understand them. After studying for so long, I feel that CV is the eternal god. Using the official routines, you can quickly implement the configuration of peripheral registers. I just learned about CW32's BLDC before, so I have some understanding of the chip.
[1] The layout of the digital tube was modified to facilitate wiring. As a result, the segment selection bits of the digital tube do not correspond exactly to the lower eight IO ports of the microcontroller. Therefore, the display code of the segment selection of the digital tube cannot directly display the data. So the common cathode digital tube segment selection array needs to be rearranged.
/*Original common cathode digital tube segment selection array*/
const unsigned char duanma[]={0X3F,0X06,0X5B,0X4F,0X66,0X6D,0X7D,0X07,0X7F,0X6F,0X77,0X7C,0X39,0X5E,0X79,0X71,
/*0-15*//* 0 1 2 3 4 5 6 7 8 9 10:A 11:B 12:C 13:D 14:E 15:F*/
0X00,0x40,0x09,0x6f,0x76,0x1e,0x38,0x54,0X3F,0x73,0X6D,0x78,0x3e,0x58};
/*16-29*//*16 empty 17:- 18 two 19:G 20:H 21:J 22:L 23:N 24:O 25:P 26:S 27:T 28:U 29:c*/ /
*New common cathode digital tube segment selection array*/
const uint8_t duanma[]={0XF5,0X05,0XB3,0X97,0X47,0XD6,0XF6,0X85,0XF7,0XC7,0XE7,0X76,0XF0,0X37,0XF2,0XE2,0X00,0x75};
//Common cathode digital tube segment code 0 1 2 3 4 5 6 7 8 9 ABCDEF empty V

[2] Hardware Error: Due to the use of a 220K resistor with a 5% error, there is always a significant error when measuring voltage. Therefore, the error can only be reduced through software calculation.
① The initial error solution was similar to the method of a linear equation in one variable. By calculating the actual value and the measured value for each segment, the error slope and zero point were calculated.
Below is a step-by-step measurement of the printed actual value and measured value through the serial port. It was found that within the measurement range of the 0-3V low-side voltage detection terminal, the data error of the high-side voltage detection terminal increases with the increase of the voltage value. (This may be a program calculation problem. If there is any error, please point it out.)
The slope calculated for each measurement point was used to back-calculate the actual value for each data point Y=KX+B. However, the workload was a bit large, so the average value of the slope was used for testing first. However, as shown in the figure below, there is still an error of tens of millivolts between the low-side voltage measurement and the high-side voltage measurement.
/*Directly calculate data (no calibration)*/
V = (float)Mean_Value_Filter(Volt_Buffer,ADC_MAXSIZE)/4096*ADC_REF_VALUE*23*100;//Uo=R2/(R1+R2)*U
V_low = (float)Mean_Value_Filter(Volt_low_Buffer,ADC_MAXSIZE)/4096*ADC_REF_VALUE*2*100;
Curr = (float)Mean_Value_Filter(Curr_Buffer,ADC_MAXSIZE)/4096*ADC_REF_VALUE*Sample_R*100;
TL431 = (float)Mean_Value_Filter(Volt_TL431_Buffer,ADC_MAXSIZE)/4096*ADC_REF_VALUE*100;


② Finally, I ported the official example program and found that it still relies on algorithms. Learning more methods is the best way to solve the problem, and it's not an insurmountable hardware error. After intermittently staring at the code for two days, I finally understood the implementation principle of the program. Therefore, I upgraded the original two-point calibration of 5V, 15V, 0.5A, and 1.5A to a step-by-step calibration of 0V-30V and 0A-3A.
I switch between three interfaces—voltage and current display, voltage calibration, and current calibration—using button 1. In the calibration interface, the digital tube displays the current calibration value at the top, and the AD measurement value is displayed below. I use button 2 to calibrate the current data. After calibration, it returns to the data display interface. Button 3 immediately returns to the data display interface. Voltage calibration requires 30 levels, and current calibration requires 6 levels. The calibration process is a bit complex, but the effect is still there. The error of 0.01V in the example program can be reduced to 0.01V error at several volts. (The accuracy can likely be further improved; further learning is needed.)



③ Export the calibration data via serial port. The data can be stored in an array and calibrated directly using buttons, avoiding accidental modification of the reference value.

V. Demonstration of Results
This beginner's training camp project teaches how to use the CW32 development board to collect and display voltage and current data.
1. For the hardware part, watching the videos from experienced programmers and following the schematics, along with the BOM components, to design the board was very helpful, especially in component selection and circuit routing. I initially wanted to directly use chips to replace the development board, but I followed the training camp's requirements and used the development board. 2. The software part was too difficult for a beginner; setting up the Keil environment took two days, and I only managed to get it working with remote support from an experienced programmer. However, learning how to program the ST microcontroller for CW32 was quite helpful.
I directly programmed Experiment Nine, but I still don't understand calibration. I'll submit it as open source first and continue learning.
Finally, here's a power-on video.
The core board was designed using the Aisinco AI-BS21 Star Flash module, with I/O pins for easy functional testing.
Based on the link [Taobao] https://m.tb.cn/h.5uDm2xSNlWCnj1w?tk=uH5hWlALoDM CZ3452 "Disassembled 1.2-inch 240x240 color IPS screen with silicone protective case, refurbished, no information available". Clicking the link or searching on Taobao will open the page directly.
This screen has slight color distortion; it's not recommended.
Revision history:
20240815 - Moved the stand one millimeter to the left.