资源描述:
《3943.水温控制系统 程序附件》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、附:系统程序主函数文件#include"LPC23xx.h"/*LPC23xx/24xxPeripheralRegisters*/#include"type.h"#include"irq.h"#include"target.h"#include"timer.h"#include"rtc.h"#include"define.h"#include"Coefficient.h"#include"KeyLED_Define.h"#include"LCD_Menu_Resource.h"#include"math.h"#incl
2、ude"string.h"#include"stdio.h"#defineSampleCycleNum5#definePi3.#defineSqrt_21.#definePointsNumber64extern_ARMABIfloatroundf(float/*x*/);doubleCaculate_Frequency(intpiont[],doubleFrequency_0);voidDelay_for_AD(void);voidADGPIO_Initial(void);enumSystem_StateSystemS
3、tate;//系统状态,分为测频阶段和参量计算两个状态intAD0_Value[512],AD1_Value[512];//采样值WORDTotalPointsNumber;DWORDADC_TimerInterval;BYTETimesCount_for_Frequency;//测频状态时记录采集周期数BYTENewValueCreated_Flag;//新菜了一个周期波形的标志BYTEFrequnecyStateEnter_Flag;//进入频率测试状态的标志BYTEElseStateEnter_Flag;//点入
4、电参量计算的标志DWORDFILE_DATA_BUF_BYTE_Count=0;BYTEUSBConnect_Flag=0;//U盘连接标志,当U盘连接时,标志置1intU[PointsNumber*3+1];intI[PointsNumber*3+1];floata_for_U[11];floatb_for_U[11];//傅氏分解的实部、虚部floata_for_I[11];floatb_for_I[11];//傅氏分解的实部、虚部structVoltage_CoeU_Coe_Temp[10],U_Coe_Valu
5、e,I_Coe_Temp[10],I_Coe_Value;//各谐波的有效值,记录十次取平均值floatU_Value=0,I_Value=0,PF_Value=0,Power_Value=0,Q_Value=0,S_Value=0;//分别为电压、电流、有功、无功和视在功率floatUmax_Value=0,Imax_Value=0,Powermax_Value=0,Qmax_Value=0,Smax_Value=0;//分别为电压、电流、有功、无功和视在功率最大值floatUmin_Value=0,Imin_Val
6、ue=0,Powermin_Value=0,Qmin_Value=0,Smin_Value=0;//分别为电压、电流、有功、无功和视在功率最小值doubleFrequency_Value;//频率floatU_Temp[10],I_Temp[10],Power_Temp[10],Q_Temp[10],S_Temp[10];//分别为电压、电流、有功、无功和视在功率BYTEValueTempCount=0;intmain(void){WORDi=0;BYTEj;BYTEKeyNumber;WORDtemp;SCS
7、=1;
8、InitKeyLEDRelay_Pin();LCD_init();//初始化clearscreen();//清屏Menu_pageID=PageID_MainPage;Key_databuf=0x3f;Enter_flag=1;Esc_flag=0;KeyLCD_Deal(NoKey);BackPara(PageID_VrefAdj);/*RTC时钟初始化*/SystemTime.RTC_Sec=0;SystemTime.RTC_Min=0;SystemTime.RTC_Hour=0;SystemTime.RTC_Md
9、ay=1;SystemTime.RTC_Mon=6;SystemTime.RTC_Year=2008;BackPara(PageID_TimeSet);RTCInit();/*Initializetimer0,forsamplePF*/init_timer(0,Fpclk);//起动定时器0,作为测功率因数用enable_time