📄 hpf.cpp
字号:
// HPF.cpp: implementation of the CHPF class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Fileter.h"
#include "HPF.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CHPF::CHPF()
{
}
CHPF::~CHPF()
{
}
//////////////////////////////////////////////////////////
// the Butter HPF
CButterHPF::CButterHPF():CButterLPF()
{
}
CButterHPF::CButterHPF(int sectionnum):CButterLPF(sectionnum)
{
}
CButterHPF::~CButterHPF()
{}
void CButterHPF::CountValue() //根据节数,查表得出元件
{
//C1 C2 C3 C4 C5 L2 L4 R2 R4 R6
//INITTION THE COMPNETN
delete [] pCCompnent;
delete [] pLCompnent;
pCCompnent = new CCCompnent[SectionNum/2];
pLCompnent = new CLCompnent[(SectionNum+1)/2];
double Omg=2*PI*PassFreq;
double C=1.0/(Omg*RL);
double L=RL/Omg;
int i;
for(i=0;i<SectionNum;i++)
{
if(i%2==0) // is a L
{
CLCompnent *pL=new CLCompnent(L/ButterData[SectionNum-1][i]);
pLCompnent[(i+1)/2]=*pL;
delete pL;
}
else //is a L
{
CCCompnent *pC=new CCCompnent(C/ButterData[SectionNum-1][i]);
pCCompnent[i/2] =*pC;
delete pC;
}
}
}
void CButterHPF::GetOut(CComplex_num &UL,CComplex_num &IL,double freq) //不同频率下的复数值大小
{//C1 L2 C3 L4 C5 L6 C7 R2 R4 R6
int i;
CComplex_num AllRL(RL,0), Is(1,0), Us(1,0);
for(i=SectionNum-1;i>=0;i--)
{
if(i%2==0) //is a L Compnent
{
CComplex_num L1=pLCompnent[(i+1)/2].GetComplexVal(freq);
Is=(L1+AllRL)/L1 *Is; //IL is 1
AllRL=AllRL%L1;
}
else //is a C Compnent
{
CComplex_num C1=pCCompnent[i/2].GetComplexVal(freq);
Us=(C1+AllRL)/AllRL *Us; //UL is 1
AllRL=AllRL+C1;
}
}
UL=CComplex_num(1,0)/Us;
IL=CComplex_num(1,0)/Is;
}
//////////////////////////////////////////////////////////
// the Cheby HPF
CChebyHPF::CChebyHPF():CChebyLPF()
{ }
CChebyHPF::CChebyHPF(int sectionnum):CChebyLPF(sectionnum)
{}
CChebyHPF:: ~CChebyHPF()
{}
void CChebyHPF::CountValue() //根据节数,查表得出元件
{
//C1 C2 C3 C4 C5 L2 L4 R2 R4 R6
//INITTION THE COMPNETN
delete [] pCCompnent;
delete [] pLCompnent;
pCCompnent = new CCCompnent[SectionNum/2];
pLCompnent = new CLCompnent[(SectionNum+1)/2];
double Omg=2*PI*PassFreq;
double C=1.0/(Omg*RL);
double L=RL/Omg;
int i;
for(i=0;i<SectionNum;i++)
{
if(i%2==0) // is a L
{
CLCompnent *pL=new CLCompnent(L/ChebyData[SectionNum-1][i]);
pLCompnent[(i+1)/2]=*pL;
delete pL;
}
else //is a L
{
CCCompnent *pC=new CCCompnent(C/ChebyData[SectionNum-1][i]);
pCCompnent[i/2] =*pC;
delete pC;
}
}
}
void CChebyHPF::GetOut(CComplex_num &UL,CComplex_num &IL,double freq) //不同频率下的复数值大小
{
//C1 L2 C3 L4 C5 L6 C7 R2 R4 R6
int i;
CComplex_num AllRL(RL,0), Is(1,0), Us(1,0);
for(i=SectionNum-1;i>=0;i--)
{
if(i%2==0) //is a L Compnent
{
CComplex_num L1=pLCompnent[(i+1)/2].GetComplexVal(freq);
Is=(L1+AllRL)/L1 *Is; //IL is 1
AllRL=AllRL%L1;
}
else //is a C Compnent
{
CComplex_num C1=pCCompnent[i/2].GetComplexVal(freq);
Us=(C1+AllRL)/AllRL *Us; //UL is 1
AllRL=AllRL+C1;
}
}
UL=CComplex_num(1,0)/Us;
IL=CComplex_num(1,0)/Is;
}
//////////////////////////////////////////////////////////
// the Cauer HPF
CCauerHPF::CCauerHPF():CCauerLPF()
{ }
CCauerHPF::CCauerHPF(int sectionnum):CCauerLPF(sectionnum)
{}
CCauerHPF::CCauerHPF(int sectionnum,int reflex):CCauerLPF(sectionnum,reflex)
{}
CCauerHPF:: ~CCauerHPF()
{}
void CCauerHPF::CountValue() //根据节数,查表得出元件
{
//C1 C2 C3 C4 C5 L2 L4 R2 R4 R6
//INITTION THE COMPNETN
delete [] pCCompnent;
delete [] pLCompnent;
pCCompnent= new CCCompnent[SectionNum];
pLCompnent= new CLCompnent[SectionNum];
GetDataFromTable();//从表中查到数 放入pCCompnent,pLCompnent中
int i;
//change
for(i=0;i<SectionNum;i++)
{
double value;
value=pCCompnent[i].GetVal();
pCCompnent[i].SetVal(pLCompnent[i].GetVal());
pLCompnent[i].SetVal(value);
}
//count
double Omg=2*PI*PassFreq;
double C=1.0/(Omg*RL);
double L=RL/Omg;
for(i=0;i<SectionNum;i++)
{
if(i%2!=0) // is a C
{
CCCompnent *pC=&pCCompnent[i/2];
pC->SetVal(C/pC->GetVal());
}
CLCompnent *pL=&pLCompnent[i];
pL->SetVal(L/pL->GetVal());
}
}
void CCauerHPF::GetOut(CComplex_num &UL,CComplex_num &IL,double freq) //不同频率下的复数值大小
{//C1 L2 C3 L4 C5 L6 C7 R2 R4 R6
int i;
CComplex_num AllRL(RL,0), Is(1,0), Us(1,0);
for(i=SectionNum-1;i>=0;i--)
{
if(i%2!=0) //is a C Compnent
{
CComplex_num LC1=pCCompnent[i/2].GetComplexVal(freq)%
pLCompnent[i].GetComplexVal(freq);
Us=(LC1+AllRL)/AllRL *Us; //UL is 1
AllRL=AllRL+LC1;
}
else //is a L Compnent
{
CComplex_num L1=pLCompnent[i].GetComplexVal(freq);
Is= (L1+AllRL)/L1 *Is;
AllRL=AllRL%L1;
}
}
UL=CComplex_num(1,0)/Us;
IL=CComplex_num(1,0)/Is;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -