Project Introduction:
Digital Voltage and Current Meter Based on CW32.
Project Function:
The digital voltage and current meter combines ADC technology with circuit measurement principles, accurately converting analog voltage and current signals into digital displays. This allows electronic engineers to intuitively read and analyze
project parameters.
This project uses the LCSC CW32F030C8T6 development board (core board) as the main controller
and uses a digital tube to display voltage and current values.
Principle Analysis (Hardware Description)
: Here you can fill in the design principle of the project, breaking down and analyzing the design principle. Example:
This project consists of the following parts: power supply, digital tube display, main control, and voltage and current sampling. This project mainly samples voltage and current through an ADC and displays it using a digital tube.
Power supply circuit:

Digital tube display circuit

...
Software
code for digital tube display, controlling the lower 8 bits of GPIO to display on the 8-segment digital tube:
void Seg_Display(uint8_t Pos,uint8_t Num)
{
int i;
uint8_t Dis_Value = Seg_Table[Num];
GPIO_LowByte_Write(CW_GPIOA,Dis_Value);
switch(Pos)
{
case 0:
GPIO_WritePin(CW_GPIOA,GPIO_PIN_8,GPIO_Pin_RESET); //PA8,COM1
break;
case 1:
GPIO_WritePin(CW_GPIOA,GPIO_PIN_11,GPIO_Pin_RESET); //PA9,COM2
break;
case 2:
GPIO_WritePin(CW_GPIOA,GPIO_PIN_12,GPIO_Pin_RESET); //PA10,COM3
break;
case 3:
GPIO_WritePin(CW_GPIOA,GPIO_PIN_15,GPIO_Pin_RESET); //PA11,COM4
break;
case 4:
GPIO_WritePin(CW_GPIOB,GPIO_PIN_3,GPIO_Pin_RESET); //PA12,COM5
break;
case 5:
GPIO_WritePin(CW_GPIOB,GPIO_PIN_4,GPIO_Pin_RESET); //PA15,COM6
break;
default:
break;
}
}
Voltage and current acquisition:
void Volt_Cal(void)
{
float t,KT1;
V_Buffer = Mean_Value_Filter(Volt_Buffer,ADC_SAMPLE_SIZE);//Use mean filtering
I_Buffer = Mean_Value_Filter(Curr_Buffer,ADC_SAMPLE_SIZE); //Use mean filtering
V_Buffer = (V_Buffer * ADC_REF_VALUE >> 12) * (R2 + R1)/R1;
// Rounding
if(V_Buffer % 10 >= 5)
{
V_Buffer = V_Buffer / 10 + 1;
}
else
{
V_Buffer = V_Buffer / 10;
}
ADC_GetSqr1Result(&I_Buffer); ///Display the current acquired value
I_Buffer=I_Buffer * ADC_REF_VALUE >> 12;
/**mv =I_Buffer * ADC_REF_VALUE >> 12,
R = 100mr,
10ma = mv/R/10=mv/0.1/10 = mv
*/
}