51 lines
1.6 KiB
C
51 lines
1.6 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_excitation.c
|
|
\brief Ìîäóëü âîçáóäèòåëÿ
|
|
\author ÎÎÎ "ÍÏÔ Âåêòîð". http://motorcontrol.ru
|
|
\version v 1.0 28/03/2017
|
|
|
|
\addtogroup V_excitation
|
|
@{*/
|
|
|
|
#include "V_IQmath.h" // Include header for IQmath library
|
|
#include "V_excitation.h"
|
|
#include "main.h"
|
|
//! Ôóíêöèÿ ðàñ÷åòà ðåëåéíîãî ðåãóëÿòîðà
|
|
|
|
//! \memberof TRelayReg
|
|
void excitation_calc(Texcitation *v)
|
|
{
|
|
//Îáìîòêà âîçáóæäåíèÿ ÑÄ
|
|
//â ìîäóëå ØÈÌ òîëüêî 3 êàíàëà. Ïîýòîìó äëÿ ìîäåëè ÑÄ ñ îáìîòêîé âîçáóæäåíèÿ ïîñ÷èòàåì ñêâàæíîñòü òóò.
|
|
volatile int32 GammaF;
|
|
if (v->ref < _IQ(0))
|
|
v->ref = _IQ(0);
|
|
|
|
if (v->ref > _IQ(1))
|
|
v->ref = _IQ(1);
|
|
|
|
GammaF = v->ref >> 8; // (IQ16) ïåðåâîäèì òî, ÷òî âûøå, â iq16.
|
|
GammaF = _IQ16mpy(GammaF, _IQ16(pwm.k_pwm)); // (IQ16) ïåðåâîäèì ñêâàæíîñòü â âåëè÷èíó äëÿ çàãðóçêè â ðåãèñòð ñðàâíåíèÿ.
|
|
GammaF = pwm.k_pwm - (GammaF >> 16); // (IQ0) Çàãðóæåì öåëóþ ÷àñòü â ðåãèñòð ñðàâíåíèÿ.
|
|
|
|
#if defined(HW_MCB3_SIMULATOR)
|
|
model.cmpr3 = (Uint16) GammaF;
|
|
#endif
|
|
}
|
|
|
|
/*@}*/
|