motorcontroldemo_035/Vsrc/V_CurPar.c
2019-07-29 08:17:46 +03:00

90 lines
2.9 KiB
C

/*!
Copyright 2017 ÀÎ "ÍÈÈÝÒ" è ÎÎÎ "ÍÏÔ ÂÅÊÒÎÐ"
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
\file V_CurPar.c
\brief Ðàñ÷åò íàáëþäàåìûõ òåêóùèõ ïàðàìåòðîâ (ñì. TCurPar)
\author ÎÎÎ "ÍÏÔ Âåêòîð". http://motorcontrol.ru
\version v 2.0 25/03/2016
*/
/** \addtogroup V_CurPar */
/*@{*/
#ifdef __cplusplus
extern "C" {
#endif
#include "DSP.h" // Device Headerfile and Examples Include File
#include "V_IQmath.h" // áèáëèîòåêà IQmath
#include "V_CurPar.h" // çàãîëîâî÷íûé ôàéë
#include "main.h"
#ifdef __cplusplus
}
#endif
//! Èíèöèàëèçàöèÿ ìîäóëÿ
//! Òàê, âñÿèå îáíóëåíèÿ...
//! \memberof TCurPar
void CurPar_init(TCurPar* p) {
//ôèëüòðû
p->fPower.T = _IQ(0.001); //ôèëüòð ìîùíîñòè äëÿ âûâîäà íà ýêðàí
}
//!Ðàñ÷åò ìîùíîñòè èç äàííûõ ôàç
//!Ðàñ÷åò ïðîèñõîäèò â äâóõôàçíîé ñèñòåìå êîîðäèíàò, ïðèâÿçàííîé ê ñòàòîðó
//!Äëÿ ðàñ÷åòà èñïîëüçóþòñÿ ìãíîâàííåûå íàïðÿæåíèÿ ôàç UalphaRef, UbetaRef,
//!ìãíîâàííûå òîêè ôàç Ialpha, Ibeta. Äëÿ êàæäîé èç îñåé íàïðÿæåíèå óìíîæàåòñÿ íà òîê,
//!ïîëó÷åííàÿ ìãíîâåííàÿ ìîùíîñòü ñóììèðóåòñÿ ñ àíàëîãè÷íîé ìîùíîñòüþ ïî äðóãîé îñè,
//!à çàòåì ïîëó÷åííàÿ ñóììàðòíàÿ ìãíîâåííàÿ ìîùíîñòü ôèëüòðóåòñÿ èíåðöèîííûì çâåíîì ïåðâîãî ïîðÿäêà.
//! \memberof TCurPar
void CurPar_PowerCalcUf(TCurPar* p) {
p->Ualpha = pwm.UalphaRef; //Íàïðÿæåíèå çàäàííîå îñè àëüôà
p->Ubeta = pwm.UbetaRef; //Íàïðÿæåíèå çàäàííîå îñè áåòà
//ìãíîâåííàÿ ìîùíîñòü ïî îñÿì àëüôà è áåòà ïîäàåòñÿ íà âõîä ôèëüòðà
p->fPower.input = _IQmpy(p->PowerK,
_IQmpy(p->Ualpha,p->Ialpha)+_IQmpy(p->Ubeta,p->Ibeta));
//ðàñ÷åò ôèëüòðà
p->fPower.calc(&p->fPower);
//ðåçóëüòàò ðàáîòû ôèëüòðà - òåêóùàÿ àêòèâíàÿ ìîùíîñòü.
p->power = p->fPower.output;
}
//!Ðàñ÷åò òåêóùèõ ïàðàìåòðîâ ïðèâîäà
//! \memberof TCurPar
void CurPar_calc(TCurPar* p) {
CurPar_PowerCalcUf(p); //Ðàñ÷åò ìîùíîñòè
}
//! \memberof TCurPar
//Ðàñ÷åò âíóòðåííåãî ìàñøòàáèðóþùåãî êîýôôèöåíòà ìîùíîñòè
//äëÿ ïðèâåäåíèÿ ðàçëè÷íûõ òèïîâ ðàñ÷åòîâ ìîùíîñòè ê áàçîâîé ìîùíîñòè drv_params.power
void CurPar_slow_calc(TCurPar* p) {
float PowerMaxReal;
float PowerMaxScale;
PowerMaxReal = (float) drv_params.I_nom * drv_params.U_nom;
PowerMaxScale = _IQ6toF(drv_params.power);
p->PowerK = _IQmpy(_IQ(PowerMaxReal / PowerMaxScale), _IQ(3.0/2));//äðîáü 3/2 íóæíà äëÿ ïðåîáðàçîâàíèÿ ìîùíîñòè îò 2õ ôàçíîãî ïðåäñòàâëåíèÿ ê 3õ ôàçíîìó
}
/*@}*/