资源简介
用DFT算法和查表的方法实现电力系统各种参数的分析
代码片段和文件信息
#include “DSP28_Device.h“
#if(ADC)
extern Uint16 volatile test_wordtest_byte;
extern STATUS volatile Flags;
extern Uint16 volatile adbuf[6][ADC_PR+ADC_OFFSET]adcbcntClrTimer;
extern Uint16 volatile avarage_pr_cnt; //周期个数计数器
extern Uint16 volatile TdCntTdCntATdCntBTdCntCBdCntBdCntABdCntBBdCntC;//投切延时计数器返回延时计数器
extern int32 volatile VirtVal[7]papbpcqaqbqcthdi0sasbsc;//存放最终计算结果VirtVal缓冲区0单元到6单元分别是uaubuciaibici0
extern Uint16 volatile UCoefUaCoefUbCoefUcCoefIaCoefIbCoefIcCoef; //Ua、Ub、Uc、Ia、Ib、Ic六个模拟输入通道的系数
extern Uint16 volatile UaaUbbUcc;
extern float volatile IaaIbbIcc;
extern float volatile AdrMax[7]AdrMin[7];
extern float volatile paspbspcsqasqbsqcs;
extern float volatile UaSumUbSumUcSumIaSumIbSumIcSumI0Sum;
extern float volatile PaSumPbSumPcSumQaSumQbSumQcSumSaSumSbSumScSum;
extern float volatile cosacosbcoscsaasbbscc; //存放功率因数
extern float volatile UaBuf[AVARAGE_PR_NUM]UbBuf[AVARAGE_PR_NUM]UcBuf[AVARAGE_PR_NUM];
extern float volatile IaBuf[AVARAGE_PR_NUM]IbBuf[AVARAGE_PR_NUM]IcBuf[AVARAGE_PR_NUM];
extern float volatile PaBuf[AVARAGE_PR_NUM]PbBuf[AVARAGE_PR_NUM]PcBuf[AVARAGE_PR_NUM];
extern float volatile QaBuf[AVARAGE_PR_NUM]QbBuf[AVARAGE_PR_NUM]QcBuf[AVARAGE_PR_NUM];
extern float volatile SaBuf[AVARAGE_PR_NUM]SbBuf[AVARAGE_PR_NUM]ScBuf[AVARAGE_PR_NUM];
extern Uint16 volatile inpwpwidctuhuli00; //存放设置的参数:口令、地址、变比、电压上限、电压下限
extern Uint16 volatile thducosskkbdtd; //电压谐波畸变率上限、补偿的功率因数上限、投入门限系数、投切延时
extern OUTPORT volatile outpin[OUTNUM];
extern Uint16 volatile EquAEquBEquCEquT;
extern Uint16 volatile singlecapsrnumtogthercaptrnum;
extern SSTEP volatile sstep;
extern TSTEP volatile tstep;
extern Uint16 volatile frequenceFreCntPerVal;
extern Uint16 volatile FreBuf[AVARAGE_PERIOD];
extern float volatile harm_cos_tab[ADC_PR+ADC_OFFSET];
extern float volatile harm_sin_tab[ADC_PR+ADC_OFFSET];
extern Uint16 volatile harmsca[6][HARM_TIME]; //分别存放6相的谐波总加及3~HARM_TIME次谐波分量比例
extern Uint16 volatile HSS[6][HARM_TIME];
extern Uint16 volatile HarSca[6][HARM_TIME];
extern Uint16 volatile MaxHarm[6][HARM_TIME];
#if(MMI)
Uint32 Taxis(Uint16 *BufUint16 AverageTime) //将Buf内的数据去掉一个最大的和一个最小的
{
Uint32 Temp;
Uint16 CntReg;
if(AverageTime>=4) //只有数据个数较多时才去掉最大值和最小值再求平均
{
Reg=0;
for(Cnt=1;Cnt {
if(*(Buf+Reg)<*(Buf+Cnt))Reg=Cnt;
}
Temp=*(Buf+Reg);
for(Cnt=Reg;Cnt {
*(Buf+Cnt)=*(Buf+Cnt+1);
}
*(Buf+AverageTime-1)=Temp; //最大值放在最后一个单元
Reg=0;
for(Cnt=1;Cnt {
if(*(Buf+Reg)>*(Buf+Cnt))Reg=Cnt;
}
Temp=*(Buf+Reg);
for(Cnt=Reg;Cnt {
*(Buf+Cnt)=*(Buf+Cnt+1);
}
*(Buf+AverageTime-2)=Temp; //最小值放在最后第二个单元
Temp=0;
for(Cnt=0;Cnt
- 上一篇:模拟电子技术课程设计实验报告.doc
- 下一篇:对信号作双谱分析
评论
共有 条评论