基于STM32F103C8T6的充电桩计费系统
本设计包含程序代码+原理图+PCB,仅供学习参考
📚开发环境
原理图:Altium Designer
程序编译器:keil 5
编程语言:C语言
设计编号:C0019
📚设计介绍
本设计采用单相互感式计量模块检测交流用电量,利用 RC522 射频模块完 成刷卡计费系统设计。STM32F103C8T6 通过 Modbus 串行传输通信协议与计量 模块进行通信,获得实时电压,实时电流和累计用电量。整个电量检测模块使用电流互感器和光耦隔离,对使用者和控制电路板进行保护。利用 RC522 射频 模块对不同 IC 卡进行读写操作,完成充值,查询和扣费操作,HMI 串口触摸 屏同步显示操作步骤信息。IC 卡号可以储存在 EEPROM 中,保留用户信息。 电参数信息可通过蓝牙发送到其他蓝牙设备上,通过跳线选择 RS232 通信将信 息传输到串行设备上。系统完成硬件电路和程序设计,适合在汽车充电桩上作 为计费系统使用。
STM32F103C8T6 作为中央控制芯片,其它模块包括:AMS1117- 3.3V 稳压电源、、HMI 串口显示屏、晶振与复位电路、RS232 通信模块、RFID-RC522 射频模块、LED 显示、EEPROM 模块和隔离模块。
📚原理图

📚PCB

📚部分程序代码
c
int main(void)
{
char showBuff[80];
GPIO_InitTypeDef GPIO_InitStructure;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);// ÉèÖÃÖжÏÓÅÏȼ¶·Ö×é2
delay_init(); //ÑÓʱº¯Êý³õʼ>>¯
uart1_init(9600);
uart2_init(9600);
uart3_init(4800);
LED_Init(); //³õʼ>>¯ÓëLEDÁ¬½ÓµÄÓ²¼þ½Ó¿Ú
KEY_Init(); //°´¼ü³õʼ>>¯
// TIM2_Int_Init(4999,71); //(1000*72/72(Mhz))us=1ms
// TIM3_Int_Init(999,71);
AT24CXX_Init(); //IIC³õʼ>>¯
InitRc522();
power_ClearValue();
while(1)
{
Charge_GetValue();
memset(showBuff,0,sizeof(showBuff));
snprintf(showBuff,sizeof(showBuff),"V:%.2fV,I:%.2fA,E:%.2fkW-h\r\n", control.V,control.I,control.E);
UsartPrintf(USART2,showBuff);
switch(TFT_Command)
{
case TFT_CommandMain:
memset(showBuff,0,sizeof(showBuff));
snprintf(showBuff,sizeof(showBuff),"main.t0.txt=\"µçѹ:%.2fV\"", control.V);
UsartPrintf(USART1,showBuff);
UsartPrintf(USART1,sendEnd);
memset(showBuff,0,sizeof(showBuff));
snprintf(showBuff,sizeof(showBuff),"main.t1.txt=\"µçÁ÷:%.2fA\"", control.I);
UsartPrintf(USART1,showBuff);
UsartPrintf(USART1,sendEnd);
getRFID=0;
break;
case TFT_CommandStart:
memset(showBuff,0,sizeof(showBuff));
snprintf(showBuff,sizeof(showBuff),"start.t0.txt=\"µçѹ:%.2fV\"", control.V);
UsartPrintf(USART1,showBuff);
UsartPrintf(USART1,sendEnd);
memset(showBuff,0,sizeof(showBuff));
snprintf(showBuff,sizeof(showBuff),"start.t1.txt=\"µçÁ÷:%.2fA\"", control.I);
UsartPrintf(USART1,showBuff);
UsartPrintf(USART1,sendEnd);
memset(showBuff,0,sizeof(showBuff));
snprintf(showBuff,sizeof(showBuff),"start.t2.txt=\"µçÁ¿:%.2fkW-h\"", control.E);
UsartPrintf(USART1,showBuff);
UsartPrintf(USART1,sendEnd);
memset(showBuff,0,sizeof(showBuff));
snprintf(showBuff,sizeof(showBuff),"start.t3.txt=\"½ð¶î:%.1fÔª\"", control.E*Unit_price);
UsartPrintf(USART1,showBuff);
UsartPrintf(USART1,sendEnd);
break;
case TFT_CommandQuery:
if(!RFID_find())
{
UsartPrintf(USART1,"vis g0,0");//¹Ø±Õ¹ö¶¯Îı¾
UsartPrintf(USART1,sendEnd);
temp_money=Read_overage();
memset(showBuff,0,sizeof(showBuff));
snprintf(showBuff,sizeof(showBuff),"query.t0.txt=\"Óà¶î:%.1lfÔª\"", temp_money);
UsartPrintf(USART1,showBuff);
UsartPrintf(USART1,sendEnd);
}
break;
case TFT_CommandRecharge:
if(!RFID_find() && getRFID==0)
{
UsartPrintf(USART1,"page recharge");
UsartPrintf(USART1,sendEnd);
getRFID=1;
}
if(alterInfo.rev_idle)
{
temp_money=alterInfo.alterBuf[4]+Read_overage();
RFID_find();
write_overage(temp_money);
UsartPrintf(USART1,"page main");
UsartPrintf(USART1,sendEnd);
TFT_Command=TFT_CommandMain;
alterInfo.rev_idle=0;
}
break;
case TFT_CommandConsume:
if(!RFID_find())
{
UsartPrintf(USART1,"vis g0,0");//¹Ø±Õ¹ö¶¯Îı¾
UsartPrintf(USART1,sendEnd);
//µ÷ÊÔ temp_money=Read_overage()-control.E*Unit_price;
test=(Read_overage()-control.E*Unit_price)*10;
temp_money=(double)test/10;
memset(showBuff,0,sizeof(showBuff));
snprintf(showBuff,sizeof(showBuff),"consume.t0.txt=\"Óà¶î:%.1lfÔª\"", temp_money-10);
UsartPrintf(USART1,showBuff);
UsartPrintf(USART1,sendEnd);
delay_ms(1000);
RFID_find();
write_overage(temp_money-10);
power_ClearValue();// Çå³ýµçÁ¿
TFT_Command=TFT_CommandMain;//±ÜÃâÖØ¸´¿Û·Ñ
}
break;
default:break;
}
}
}

📚设计报告

📚资料清单
