109 lines
3.0 KiB
C
109 lines
3.0 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_UdControl.h
|
|
\brief Ìîäóëü ïëàâíîãî çàðÿäà ÇÏÒ
|
|
\author ÎÎÎ "ÍÏÔ Âåêòîð". http://motorcontrol.ru
|
|
\version v 1.0 25/08/2017
|
|
|
|
\addtogroup
|
|
@{*/
|
|
|
|
|
|
#ifndef V_UD_CONTROL_H
|
|
#define V_UD_CONTROL_H
|
|
|
|
|
|
#include "build.h"
|
|
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
//! ñîñòîÿíèå âûêëþ÷åíî
|
|
#define UD_CONTROL_STATE_OFF 0
|
|
//! ñîñòîÿíèå îæèäàíèÿ âêëþ÷åíèÿ
|
|
#define UD_CONTROL_STATE_WAIT 1
|
|
//! ñîñòîÿíèå âêëþ÷åíî
|
|
#define UD_CONTROL_STATE_ON 2
|
|
|
|
#define UD_CONTROL_OFF GPIOB->DATAOUTCLR = GPIO_PIN_14;
|
|
#define UD_CONTROL_ON GPIOB->DATAOUTSET = GPIO_PIN_14;
|
|
|
|
|
|
|
|
/*! \class TUdControl
|
|
\brief Óïðàâëåíèå öåïüþ çàðÿäà çâåíà ïîñòîÿííîãî òîêà
|
|
|
|
Êëàññ \a TUdControl, îñíîâàííûé íà ñòðóêòóðå SUdControl, ñëóæèò
|
|
äëÿ óïðàâëåíèÿ äèñêðåòíûì âûõîäîì, êîòîðûé çàìûêàåò öåïü çàðÿäà
|
|
çâåíà ïîñòîÿííîãî òîêà. Ïåðåä âêëþ÷åíèåì ñëåäóþò òðè ïðîâåðêè:
|
|
âûäåðæêà òàéìàóòà, ïðåâûøåíèå íàïðÿæåíèÿ âûøå çàäàííîé óñòàâêè è
|
|
âûïîëàæèâàíèå êðèâîé íàïðÿæåíèÿ (ïðîèçâîäíàÿ ñòðåìèòñÿ ê íóëþ).
|
|
*/
|
|
|
|
//!ñì. TUdControl
|
|
struct SUdControl{
|
|
Uint16 Enabled;
|
|
int fault_start; //!<ïîïûòêà ïóñêà ïðè íåçàøóíòèðîâàííîì ðåëå
|
|
int state; //!<ñîñòîÿíèå
|
|
int state_shadow;//!< ñîñòîÿíèå òåíåâîå
|
|
int state_prev;//!<ñîñòîÿíèå ïðåäûäóùåå
|
|
int E;//!<ôëàã ïåðâîãî âõîæäåíèÿ
|
|
int StateCounter;//!<ñ÷åò÷èê âðåìåíè íàõîæäåíèÿ â ñîñòîÿíèè
|
|
long fUdc_output_prev;//!<çíà÷åíèÿ íàïðÿæåíèÿ ïðåäûäóùåå
|
|
long U_on;//!<íàïðÿæåíèå âêëþ÷åíèÿ
|
|
long U_off;//!<íàïðÿæåíèå âûêëþ÷åíèÿ
|
|
long Timeout_on;//!<òàéìàóò âêëþ÷åíèÿ â ìñ.
|
|
long deriv_time_ZPT; //!<ïðîèçâîäíàÿ ïî íàïðÿæåíèþ íà ìèëëèñåêóíäå
|
|
long deriv_const; //!<êîíñòàíòà óñòàâêè ñðàâíåíèÿ ïðîèçâîäíîé
|
|
int StateOn;//!<äâîè÷íîå ñîñòîÿíèå: âêëþ÷åí/íå âêëþ÷åí
|
|
TFilter fUdc;//!<ôèëüòð íàïðÿæåíèÿ íà ÇÏÒ
|
|
Uint16 ExternCheckKey;//!<Âõîä áëîê-êîíòàêòà
|
|
Uint16 ExternCheckKeyEnabled;//!<Íàäî ëè àíàëèçèðîâàòü áëîê-êîíòàêòà
|
|
void (*init)(volatile struct SUdControl*);
|
|
void (*calc)(volatile struct SUdControl*);
|
|
};
|
|
|
|
typedef volatile struct SUdControl TUdControl;
|
|
|
|
|
|
|
|
//! \memberof TUdControl
|
|
void UdControl_init(TUdControl*);
|
|
//! \memberof TUdControl
|
|
void UdControl_calc(TUdControl*);
|
|
|
|
|
|
#define UD_CONTROL_DEFAULTS {0,0,UD_CONTROL_STATE_OFF,UD_CONTROL_STATE_OFF,UD_CONTROL_STATE_OFF,\
|
|
0,0,0,\
|
|
_IQ(0.8),_IQ(0.5),3000,0,\
|
|
0,0, FILTER_DEFAULTS,\
|
|
0,0,\
|
|
UdControl_init,\
|
|
UdControl_calc}
|
|
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
/*@}*/
|
|
|