旋转变压器做为速度反馈时的计算程序
/*=====================================================================================File name: RESOLVER.C(IQ version)
Originator: Digital Control Systems Group
Texas Instruments
Description:Speed and position measurement computation based resolver
=====================================================================================
History:
-------------------------------------------------------------------------------------
04-15-2005 Version 3.20
-------------------------------------------------------------------------------------*/
#include "IQmathLib.h" // Include header for IQmath library
// Don't forget to set a proper GLOBAL_Q in "IQmathLib.h" file
#include "dmctype.h"
#include "resolver.h"
void resolver_calc(RESOLVER *v)
{
demodulator_calc(v);
filter_calc(v);
position_speed_calc(v);
// angle_comp_calc(v);
}
void demodulator_calc(RESOLVER *v)
{
v->DemodSin = v->SinIn;
v->DemodCos = v->CosIn;
/*
// Inputs: v->SinIn, v->CosIn
// Outputs: v->DemodSin, v->DemodCos
int16 i;
// Pass the previous resolver signals
for(i=v->DemodConst-1;i>0;i--){
v->PreviousDemodSin = v->PreviousDemodSin;
v->PreviousDemodCos = v->PreviousDemodCos;
}
// Index zero in the array keeps the current resolver signals
v->PreviousDemodSin = v->SinIn;
v->PreviousDemodCos = v->CosIn;
// Initialize the demodulated signals
v->DemodSin = 0;
v->DemodCos = 0;
// Demodulate the resolver signals
for(i=0;i<v->DemodConst;i++){
if (_IQabs(v->PreviousDemodSin) > v->DemodSin)
v->DemodSin = _IQabs(v->PreviousDemodSin);
if (_IQabs(v->PreviousDemodCos) > v->DemodCos)
v->DemodCos = _IQabs(v->PreviousDemodCos);
}
*/
}
void filter_calc(RESOLVER *v)
{
// Inputs: v->DemodSin, v->DemodCos
// Outputs: v->FilteredSin, v->FilteredCos
int16 i;
// Initialize the filtered signals
v->FilteredSin = 0;
v->FilteredCos = 0;
for(i=17;i>=0;i--){
if (i>0) {
// Pass the previous demodulated signals
v->PreviousSin = v->PreviousSin;
v->PreviousCos = v->PreviousCos;
}
else{
// Index zero in the array keeps the current demodulated signals
v->PreviousSin = v->DemodSin;
v->PreviousCos = v->DemodCos;
}
// Filtering the signals
v->FilteredSin += _IQmpy(v->FilterGain,v->PreviousSin);
v->FilteredCos += _IQmpy(v->FilterGain,v->PreviousCos);
}
}
void position_speed_calc(RESOLVER *v)
{
// Inputs: v->FilteredSin, v->FilteredCos
// Outputs: v->ElecTheta, v->MechTheta, v->RefTheta, v->Speed
_iq Tmp1,FilterGain;
// Amplify the filtered signals
v->AmplifiedSin = _IQmpy(v->SignalGain,v->FilteredSin);
v->AmplifiedCos = _IQmpy(v->SignalGain,v->FilteredCos);
// v->AmplifiedSin = _IQmpy(v->SignalGain,v->SinIn);
// v->AmplifiedCos = _IQmpy(v->SignalGain,v->CosIn);
// Arctan function
Tmp1 = _IQatan2PU(v->AmplifiedSin,v->AmplifiedCos);
// Low-pass filter for resolver angles
FilterGain = _IQ(0);//_IQ(0.95);
v->FilterTheta1 = _IQmpy(FilterGain,v->FilterTheta1) + _IQmpy((_IQ(1)-FilterGain),Tmp1);
// Rotor speed computation
if ((v->FilterTheta1 > _IQ(0.75))&(v->OldTheta < _IQ(0.25)))
Tmp1 = _IQ21mpy(v->K1,(_IQ(-1)+ v->FilterTheta1 - v->OldTheta));
else if ((v->OldTheta > _IQ(0.75))&(v->FilterTheta1 < _IQ(0.25)))
Tmp1 = _IQ21mpy(v->K1,(_IQ(1)- v->OldTheta + v->FilterTheta1));
else
Tmp1 = _IQ21mpy(v->K1,(v->FilterTheta1 - v->OldTheta));
// Low-pass filter for calculated speed
FilterGain = _IQ(0.95);
v->Speed = _IQmpy(FilterGain,v->Speed) + _IQmpy((_IQ(1)-FilterGain),Tmp1);
// Limit the calculated speed within (-1,1)
if (v->Speed > _IQ(1))
v->Speed = _IQ(1);
else if (v->Speed < _IQ(-1))
v->Speed = _IQ(-1);
// Update the mechanical angle
v->OldTheta = v->FilterTheta1;
v->MechTheta = v->FilterTheta1;
if (v->MechTheta >= _IQ(1))
v->MechTheta = _IQ(1);
if (v->MechTheta < _IQ(0))
v->MechTheta = _IQ(0);
// Low-pass filter
FilterGain = _IQ(0.70);
v->RefTheta = _IQmpy(FilterGain,v->RefTheta) + _IQmpy((_IQ(1)-FilterGain),v->MechTheta);
// Compute electrical angle
v->ElecTheta = v->MechTheta*v->PolePairs;
if (v->ElecTheta >= _IQ(1))
v->ElecTheta -= _IQ(1);
// Change motor speed from pu value to rpm value (Q15 -> Q0)
// Q0 = Q0*GLOBAL_Q => _IQXmpy(), X = GLOBAL_Q
v->SpeedRpm = _IQmpy(v->BaseRpm,v->Speed);
}
void angle_comp_calc(RESOLVER *v)
{
// Inputs: v->RefTheta
// Outputs: v->OutputTheta
// Convert OutputTheta to from mechanical to electrical angle
v->OutputTheta = v->RefTheta*v->PolePairs;
if (v->OutputTheta >= _IQ(1))
v->OutputTheta -= _IQ(1);
// Compensate the mechanical angle between resolver signal and back EMF of winding a
v->OutputTheta += v->CalibratedAngle;
if (v->OutputTheta >= _IQ(1))
v->OutputTheta -= _IQ(1);
// (0.125 pu)*v->PolePairs pu = (45 deg)*v->PolePairselectrical degree
v->OutputTheta += _IQ1mpy(v->PolePairs,_IQ25(0.125));
if (v->OutputTheta >= _IQ(1))
v->OutputTheta -= _IQ(1);
// _IQ(0.171) = Mechanical phase delay at base speed due to low-pass filter (FIR 17-order)
v->OutputTheta += _IQmpy(v->Speed,_IQ1mpy(v->PolePairs,_IQ25(0.171)));
if (v->OutputTheta >= _IQ(1))
v->OutputTheta -= _IQ(1);
// _IQ(0.09) = Mechanical phase delay at base speed due to low-pass filter (1-order)
v->OutputTheta += _IQmpy(v->Speed,_IQ1mpy(v->PolePairs,_IQ25(0.09)));
if (v->OutputTheta >= _IQ(1))
v->OutputTheta -= _IQ(1);
}
有部分不是很理解 可以相互讨论哈 是在cd程序库 里面下的看名字可以看出是ti公司的代码 用编码器做为转速反馈和用旋变做反馈的代码的区别是哪些 有没有
知道
的
交流一下 大家快快讨论下啊,坐等高人 我来尝试说一下。
回3楼:
常规的光电编码器分三种:增量式方波、增量式正弦波和绝对值式的。
旋变和增量式正弦波和绝对值式的解码代码一致。而增量式方波是通过对上升沿或者下降沿计数来做解码的。 在ti代码库没有看到旋转变压器的doc文档啊
电角度与机械角度中间相当于一个变速比
页:
[1]