67 lines
1.8 KiB
C
67 lines
1.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_rmp_ctrl.c
|
|
\brief Çàäàò÷èê èíòåíñèâíîñòè (ñì. TRMPCtrl)
|
|
\author ÎÎÎ "ÍÏÔ Âåêòîð". http://motorcontrol.ru
|
|
\version v 2.0 25/03/2016
|
|
|
|
*/
|
|
|
|
/** \addtogroup V_rmp_ctrl */
|
|
/*@{*/
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include "v_rmp_ctrl.h"
|
|
#include "V_IQmath.h"
|
|
#include "stdlib.h"
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
//! Ôóíêöèÿ ðàñ÷åòà çàäàò÷èêà èíòåíñèâíîñòè
|
|
|
|
//!Èçìåíÿåò output ñ çàäàííûì òåìïîì T,
|
|
//!ïîêà output íå äîñòèãíåò input.
|
|
|
|
//! \memberof TRMPCtrl
|
|
void V_RMP_CTRL_calc(TRMPCtrl *p) {
|
|
//âûõîä ìåíüøå âõîäà?
|
|
if (p->output < p->input)
|
|
p->output += p->step;//óâåë÷è÷èâàåì ñ çàäàííûì òåìïîì âûõîä
|
|
if (p->output > p->input)
|
|
p->output -= p->step;
|
|
|
|
if ((labs(p->output - p->input) <= p->step) || (p->T==0)) {//âîøëè â çàäàíèå ñ òî÷íîñòü äî øàãà èëè ÇÈ âîîáùå îòêëþ÷åí
|
|
p->output = p->input;//âûõîä ðàâåí âõîäó
|
|
}
|
|
}
|
|
|
|
//! Âñïîìîãàòåëüíàÿ ôóíêöèÿ çàäàò÷èêà èíòåíñèâíîñòè
|
|
|
|
//!Ïåðåñ÷èòûâàåò òåìï ðàçãîíà T â øàã step c ó÷åòîì ÷àñòîòû
|
|
//!âûçîâà îñíîâíîé ôóíêöèè Ts (äèñêðåòèçàöèÿ, îáû÷íî 10êÃö).
|
|
|
|
//! \memberof TRMPCtrl
|
|
void V_RMP_CTRL_slow_calc(TRMPCtrl *p) {
|
|
p->step = _IQdiv(p->Ts, p->T);//øàã èíòåãðàòîðà ÇÈ
|
|
}
|
|
|
|
/*@}*/
|
|
|