174 lines
6.8 KiB
C
174 lines
6.8 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_PWM_Module.h
|
|
\brief Ìîäóëü ðåàëèçàöèè âåêòîðíîé ØÈÌ (ñì. TPWM_Module)
|
|
\author ÎÎÎ "ÍÏÔ Âåêòîð". http://motorcontrol.ru
|
|
\version v 2.0 25/03/2016
|
|
|
|
\defgroup V_PWM_Module Ìîäóëü ðåàëèçàöèè âåêòîðíîé ØÈÌ (ñì. TPWM_Module)
|
|
@{*/
|
|
|
|
#ifndef _V_PWM_Module_
|
|
#define _V_PWM_Module_
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
#define _1_SQRT3 _IQ(0.5773503)
|
|
#define _2_SQRT3 _IQ(1.1547005)
|
|
|
|
//! Îãðàíè÷åíèÿ ÷àñòîòû ØÈÌ (êÃö) min
|
|
#define PWM_FREQ_MIN _IQ10(2)
|
|
//! Îãðàíè÷åíèÿ ÷àñòîòû ØÈÌ (êÃö) max
|
|
#define PWM_FREQ_MAX _IQ10(100.0)
|
|
|
|
//!Âåêòîðíàÿ 6-òè ñåêòîðíàÿ ØÈÌ
|
|
#define PWM_TYPE_6SECT_NO_SV 0
|
|
//!Ñèíóñîèäàëüíàÿ ØÈÌ
|
|
#define PWM_TYPE_SIN_PWM 1
|
|
//!Âåêòîðíàÿ 12-òè ñåêòîðíàÿ ØÈÌ
|
|
#define PWM_TYPE_12SECT_NO_SV 2
|
|
//!ØÈÌ ìåòîäîì âû÷èñëåíèÿ ôàçíûõ ïîòåíöèàëîâ
|
|
#define PWM_TYPE_FLY_12SECT 3
|
|
//!ØÈÌ äëÿ óïðàâëåíèÿ ÄÏÒ
|
|
#define PWM_TYPE_DC_DRIVE 4
|
|
//!ØÈÌ äëÿ óïðàâëåíèÿ SRM
|
|
#define PWM_TYPE_SRD 5
|
|
|
|
//! Îãðàíè÷åíèÿ âåëè÷èíû "ì¸ðòâîãî âðåìåíè", ìêñ, min
|
|
#define DEAD_BAND_MIN _IQ(0)
|
|
//! Îãðàíè÷åíèÿ âåëè÷èíû "ì¸ðòâîãî âðåìåíè", ìêñ, max
|
|
#define DEAD_BAND_MAX _IQ(10)
|
|
|
|
//! Îãðàíè÷åíèÿ âåëè÷èíû "ìèíèìàëüíîé ñêâàæíîñòè", ìêñ, min
|
|
#define GAMMA_LIMIT_MIN _IQ(0)
|
|
//! Îãðàíè÷åíèÿ âåëè÷èíû "ìèíèìàëüíîé ñêâàæíîñòè", ìêñ, max
|
|
#define GAMMA_LIMIT_MAX _IQ(10)
|
|
|
|
// Êîíñòàíòû çàãðóçêè ðåãèñòðîâ AQCTL# è AQCSFRC (ePWM)
|
|
// (îïðåäåëÿþò íàñòðîéêó ñîáûòèé äëÿ âûõîäîâ ØÈÌ)
|
|
#define AQ_EPWM_DISABLE 0x0000 //!< âñå ñîáûòèÿ çàïðåùåíû
|
|
|
|
//! Ôëàã ðàçðåøåíèÿ âíóòðåííåé ïðèâÿçêè ØÈÌ-âûõîäîâ
|
|
#define ENABLE_PULLUP 0
|
|
|
|
//!÷òî äåëàòü ïðè àïïàðàòíîé àâàðèè ñ íîæêàìè
|
|
#define TZ_STATE TZ_FORCE_LO
|
|
|
|
/*! \class TPWM_Module
|
|
\brief Ìîäóëü ðåàëèçàöèè ØÈÌ
|
|
|
|
Êëàññ \a TPWM_Module, îñíîâàííûé íà ñòðóêòóðå SPWM_Module, ðåàëèçóåò
|
|
âåêòîðíóþ è ñêàëÿðíóþ øèðîòíî-èìïóëüñíóþ ìîäóëÿöèþ äëÿ óïðàâëåíèÿ
|
|
øåñòèêëþ÷åâûì èíâåðòîðîì. Èìååò íàñòðîéêè ìåðòâîãî âðåìåíè,
|
|
÷àñòîòû, êîððåêöèþ â çàâèñèìîñòè îò íàïðÿæåíèÿ ÇÏÒ,
|
|
êîìïåíñàöèþ ìåðòâîãî âðåìåíè.
|
|
Çàäàíèå íàïðÿæåíèÿ ïðîèñõîäèò ïî äâóì ïåðïåíäèêóëÿðíûì îñÿì àëüôà è áåòòà.
|
|
Ïðè ýòîì îñü àëüôà ñîíàïðàâëåíà ñ îñüþ À òðåõôàçíîé ñèñòåìû êîîðäèíàò. Äëÿ çàäàíèÿ íîâîãî íàïðÿæåíèÿ íóæíî
|
|
ïîìåñòèòü çàäàíèå â UalphaRef, UbetaRef è âûçâàòü update. Â çàâèñèìîñòè îò òîãî,
|
|
êàêîé òèï ØÈÌ âûáðàí â íàñòðîéêàõ (íàñòðàèâàåòñÿ ïîëüçîâàòåëåì â ïåðåìåííîé PWM_type),
|
|
ôóíêöèÿ PWM_Module_Update âûçîâåò íóæíóþ ôóíêöèþ, ðåàëèçóþùóþ òðåáóåìûé òèï ØÈÌ.
|
|
 ðåçóëüòàòå ýòîãî íà òðåõ ôàçàõ èíâåðòîðà â ñðåäíåì çà ïåðèîä ØÈÌ áóäåò ðåàëèçîâàí
|
|
òàêîé âåêòîð íàïðÿæåíèÿ, êîòîðûé çàäàí â UalphaRef, UbetaRef. ×òîáû ñîçäàòü ïåðåìåííîå
|
|
ñèíóñîèäàëüíîå íàïðÿæåíèå, òðåáóåòñÿ âðàùàòü âåêòîð çàäàíèÿ âíåøíåé ïî îòíîøåíèþ ê ìîäóëþ ØÈÌ ïðîãðàììîé.
|
|
*/
|
|
|
|
//! ñì. TPWM_Module
|
|
struct SPWM_Module {
|
|
int16 Enabled; //!< Ôëàã äëÿ ÷òåíèÿ - âêëþ÷åí ØÈÌ èëè âûêëþ÷åí.
|
|
int32 UalphaRef; //!<Çàäàíèå ïî îñè àñüôà (çàäàåòñÿ)
|
|
int32 UbetaRef; //!<Çàäàíèå ïî îñè áåòòà (çàäàåòñÿ)
|
|
|
|
int32 UPhARef; //!<Çàäàíèå ïî ôàçå A (çàäàåòñÿ)
|
|
int32 UPhBRef; //!<Çàäàíèå ïî ôàçå B (çàäàåòñÿ)
|
|
int32 UPhCRef; //!<Çàäàíèå ïî ôàçå c (çàäàåòñÿ)
|
|
|
|
int32 k_pwm; //!< Ïåðèîä òàéìåðà ØÈÌ, äëÿ ÷òåíèÿ.
|
|
int32 U_mag; //!< Òåêóùàÿ àìïëèòóäà íàïðÿæåíèÿ, äëÿ ÷òåíèÿ.
|
|
int32 U_lim; //!< Îãðàíè÷åíèå âåêòîðà íàïðÿæåíèÿ, çàäàåòñÿ
|
|
|
|
int32 GammaA; //!< Ñêâàæíîñòü ôàçû À â ðàçìåðíîñòè òàéìåðà ØÈÌ, äëÿ ÷òåíèÿ.
|
|
int32 GammaB; //!< Ñêâàæíîñòü ôàçû B â ðàçìåðíîñòè òàéìåðà ØÈÌ, äëÿ ÷òåíèÿ.
|
|
int32 GammaC; //!< Ñêâàæíîñòü ôàçû C â ðàçìåðíîñòè òàéìåðà ØÈÌ, äëÿ ÷òåíèÿ.
|
|
|
|
int16 PWM_type; //!< Òèï ØÈÌ. Ïðèíèìàåò çíà÷åíèÿ êîíñòàíò ñ ïðåôèêâîì PWM_TYPE_. Çàäàåòñÿ.
|
|
int16 PWM_typeOld; //!< Ïðåäûäóùåå çíà÷åíèÿ òèïà ØÈÌ, ñëóæåáíàÿ ïåðåìåííàÿ.
|
|
int16 sector; //!< Òåêóùèé ñåêòîð â âåêòîðíîì òèïå ØÈÌ. Äëÿ ÷òåíèÿ.
|
|
|
|
int32 UalphaNorm; //!< Íîðìèðîâàííîå çàäàíèå, ñëóæåáíàÿ ïåðåìåííàÿ.
|
|
int32 UbetaNorm; //!< Íîðìèðîâàííîå çàäàíèå, ñëóæåáíàÿ ïåðåìåííàÿ.
|
|
int32 UdCorTmp; //!<Ñëóæåáíàÿ ïåðåìåííàÿ äëÿ êîððåêòèðîâêè âûõîäíîãî íàïðÿæåíèÿ â çàâèñèìîñòè îò íàïðÿæåíèÿ ÇÏÒ
|
|
int32 UdCompK; //!< Êîýôôèöèåíò êîððåêòèðîâêè âûõîäíîãî íàïðÿæåíèÿ èíâåðòîðà â çàâèñèìîñòè îò èçìåíåíèÿ íàïðÿæåíèÿ ÇÏÒ îò íîìèíàëüíîãî. Çàäàåòñÿ.
|
|
int32 UdCompEnable; //!< Ðàçðåøåíèå êîððåêòèðîâêè âûõîäíîãî íàïðÿæåíèÿ èíâåðòîðà â çàâèñèìîñòè îò èçìåíåíèÿ íàïðÿæåíèÿ ÇÏÒ îò íîìèíàëüíîãî. Çàäàåòñÿ.
|
|
int16 ULimitation; //!< ôëàã î òîì, ÷òî èäåò îãðàíè÷åíèå íàïðÿæåíèÿ - âûõîäíîå íàïðÿæåíèå ìåíüøå çàäàííîãî. Äëÿ ÷òåíèÿ.
|
|
_iq Frequency; //!< ×àñòîòà ØÈÌ â êÃö. Ôîðìàò 22.10! Çàäàåòñÿ.
|
|
_iq FreqPrev; //!< Ïðåäóäóùàÿ ÷àñòîòà ØÈÌ, ñëóæåáíàÿ ïåðåìåííàÿ.
|
|
int32 DeadBand; //!< âåëè÷èíà "ì¸ðòâîãî âðåìåíè", ìêñ, çàäàåòñÿ.
|
|
int32 MinGammaLimit; //!< ìèíèìàëüíàÿ ñêâàæíîñòü íà êëþ÷å, çàäàåòñÿ.
|
|
int PDP_Fault; //!< Ôëàã î òîì, ÷òî ìîóäëåì ØÈÌ çàôèêñèðîâàíà àïïàðàòíàÿ àâàðèÿ îò èíâåðòîðà. Äëÿ ÷òåíèÿ. Ïî íåé íåîáõîäèìà ðåàêöèÿ ìîäóëÿ çàùèò!
|
|
int ChargingMode; //!< Ðåæåì çàðÿäà áóäñòðåïíûõ êîíäåíñàòîðîâ. Äîëæåí âûñòàâëÿòüñÿ â åäåíèöó íà âðåìÿ 2-10 ìñ âíåøíåé ïðîãðàììîé ïåðåä çàïóñêîì ØÈÌ.
|
|
void (*init)(volatile struct SPWM_Module*); /* Pointer to the init function */
|
|
void (*update)(volatile struct SPWM_Module*); /* Pointer to the update function */
|
|
void (*slow_calc)(volatile struct SPWM_Module*);
|
|
void (*On)(volatile struct SPWM_Module*); //!< ïðîöåäóðà âêëþ÷åíèÿ (ðàçðåøåíèÿ) ØÈÌ-âûõîäîâ
|
|
void (*Off)(volatile struct SPWM_Module*); //!< ïðîöåäóðà îòêëþ÷åíèÿ (çàïðåùåíèÿ) ØÈÌ-âûõîäîâ
|
|
};
|
|
|
|
typedef volatile struct SPWM_Module TPWM_Module;
|
|
|
|
//! Èíèöèàëèçàòîð ïî-óìîë÷àíèþ.
|
|
#define PWM_Module_DEFAULTS {\
|
|
0,0,0, \
|
|
0,0,0, \
|
|
0, \
|
|
0, \
|
|
_IQ(0.866),0, \
|
|
0,0,\
|
|
0,0,\
|
|
0,\
|
|
0,0,0,0,0,0,0x1400,0,0,0,0,0,\
|
|
PWM_Module_Init, \
|
|
PWM_Module_Update, \
|
|
PWM_Module_SlowCalc, \
|
|
PWM_Module_On, \
|
|
PWM_Module_Off, \
|
|
}
|
|
|
|
//! \memberof TPWM_Module
|
|
void PWM_Module_Init(TPWM_Module *);
|
|
//! \memberof TPWM_Module
|
|
void PWM_Module_Update(TPWM_Module *);
|
|
//! \memberof TPWM_Module
|
|
void PWM_Module_SlowCalc(TPWM_Module *);
|
|
//! \memberof TPWM_Module
|
|
void PWM_Module_On(TPWM_Module *);
|
|
//! \memberof TPWM_Module
|
|
void PWM_Module_Off(TPWM_Module *);
|
|
|
|
//âåêòîðíûå ôóíêöèè èç áèáëèîòåêè
|
|
void PWM_Module_No_SV_Update(TPWM_Module *);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|
|
|
|
/*@}*/
|
|
|