motorcontroldemo_028/Vinclude/V_SSI_Encoder.h
2019-07-29 08:18:57 +03:00

120 lines
4.5 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_SSI_Encoder.h
\brief Ìîäóëü îöåíêè ñêîðîñòè è ïîëîæåíèÿ ïðè ïîìîùè öèôðîâîãî ýíêîäåðà, ðàáîòàþùåãî ïî èíòåðôåéñó SSI (ñì. TSSI_Encoder)
\author ÎÎÎ "ÍÏÔ Âåêòîð". http://motorcontrol.ru
\version v 1.0 25/04/2016
\defgroup V_SSI_Encoder Ìîäóëü îöåíêè ñêîðîñòè è ïîëîæåíèÿ ïðè ïîìîùè SSI Encoder (ñì. TSSI_Encoder)
\addtogroup V_SSI_Encoder
@{*/
#include "V_IQmath.h"
#include "filter.h"
#ifndef V_SSI_ENCODER_H
#define V_SSI_ENCODER_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \class TSSI_Encoder
\brief Ìîäóëü îáðàáîòêè ýíêîäåðà, ðàáîòàþùåãî ïî SSI (óïðîùåííûé SPI). À èìåííî äëÿ äàò÷èêà HENGSTLER absolute encoder AC 58.
Êëàññ \a TSSI_Encoder, îñíîâàííûé íà ñòðóêòóðå SSI_Encoder,
ÿâëÿåòñÿ ìîäóëåì äëÿ îïðåäåëåíèÿ óãëîâîãî ïîëîæåíèÿ è ñêîðîñòè ðîòîðà
äâèãàòåëÿ ïî äàííûì îò ýíêîäåðà, ðàáîòàþùåãî ïî SSI.
Äàò÷èê ïðåäïîëàãàåòñÿ ïîäêëþ÷àòü íà ðàçúåì J8 ïëàòû èç êîìïëåêòà DRV8301-HC-EVM.
Âîò òîëüêî ìèêðîñõåìó ãàëüâàíè÷åñêîé ðàçâÿçêè (U5) Texas òóäà ïîñòàâèëè ïî÷åìó-òî òàêîé ñòîðîíîé, ÷òî ìèêðîêîíòðîëåð
ðàáîòàåò êàê slave ñòðîéñòâî. ×òîáû ñäåëàòü åãî ìàñòåðîì, íóæíî ïîñòàâèòü äðóãóþ àíàëîãè÷íóþ ìèêðîñõåìó, èëè...
ïåðåâåðíóòü U5 ââåðõ íîãàìè, ïîñòàâèâ ìàðêèðîâêîé âíèç, ëàïêàìè ê âåðõó :)
*/
//! ñì. TSSI_Encoder
struct S_SSI_Encoder {
Uint32 resol; //!<INPUT: ðàçðåøåíèå äàò÷èêà â ìåòêàõ/îáîðîò;
float resol_inv; //!<îáðàòíàÿ âåëè÷èíà ê ðàçðåøåíèþ äàò÷èêà resol
Uint16 pole_pairs; //!<INPUT: ÷èñëî ïàð ïîëþñîâ;
Uint16 rotation_dir; //!<INPUT: íàïðàâëåíèå âðàùåíèÿ
float speed_nom; //!<INPUT: íîìèíàëüíàÿ ñêîðîñòü â îá/ìèí;
_iq speed_elec; //!<OUTPUT: ýëåêòðè÷åñêàÿ ñêîðîñòü â Q24(îòíîñèòåëüíûå åäèíèöû)
_iq theta_elec; //!<OUTPUT: ýëåêòðè÷åñêèé óãîë â Q24(îòíîñèòåëüíûå åäèíèöû)
Uint16 Poscnt_res; //!<Ìåõàíè÷åñê.óãîë â ìåòêàõ;
Uint16 Poscnt_resPrev; //!<Ìåõàíè÷åñê.óãîë â ìåòêàõ ïðåäûäóùåå çíà÷åíèå;
_iq theta_mech; //!<Ìåõàíè÷åñêèé óãîë;
_iq prevThetaMech; //!<Ìåõàíè÷åñêèé óãîë ïðåäûäóùåå çíà÷åíèå;
_iq theta_el_tmp; //!<TEMPORARY: ýëåêòðè÷åñêèé óãîë;
_iq theta_mech_filtered; //!<Ìåõàíè÷åñêèé óãîë ôèëüòðîâàííûé;
_iq theta_mech_filterK; //!<Êîýôôèöèåíò ôèëüòðà ìåõ. óãëà;
_iq AngleOffset;//!< Ñìåùåíèå ýëåêòðè÷åñêîãî óãëà â ãðàäóñàõ
int16 RevolutionCounter; // Êîëè÷åñòâî ìåõàíè÷åñêèõ îáîðîòîâ;
int16 Poscnt_resContinouosInt8;//!<Ìåõàíè÷åñê.óãîë â ìåòêàõ c ó÷åòîì êîë-âà îáîðîòîâ (ïåðåìåííàÿ 8 ðàçðÿäîâ îòñåêàåòñÿ)
int16 Poscnt_resContinouosInt;//!<Ìåõàíè÷åñê.óãîë â ìåòêàõ c ó÷åòîì êîë-âà îáîðîòîâ (ïåðåìåííàÿ 16 ðàçðÿäîâ)
long Poscnt_resContinouosLong;//!<Ìåõàíè÷åñê.óãîë â ìåòêàõ c ó÷åòîì êîë-âà îáîðîòîâ (ïåðåìåííàÿ 32 ðàçðÿäîâ)
_iq theta_mechContinouos; //!<Ìåõàíè÷åñêèé óãîë â ãðàäóñàõ àáñîëþòíûé;
_iq theta_elecContinouos; //!<Ýëåêòðè÷åñêèé óãîë â ãðàäóñàõ àáñîëþòíûé;
void (*init)(volatile struct S_SSI_Encoder*);
void (*calc)(volatile struct S_SSI_Encoder*);
void (*read)(volatile struct S_SSI_Encoder*);
};
typedef volatile struct S_SSI_Encoder TSSI_Encoder;
//! Èíèöèàëèçàòîð ïî-óìîë÷àíèþ.
#define SSI_ENCODER_DEFAULTS {0,0,0,0, 0,0,0,0, 0,0,0,0,0,0, 0,0, 0,0,0,0,0,\
SSI_Encoder_init,\
SSI_Encoder_Calc,\
SSI_Encoder_Read,\
}
//! \memberof TSSI_Encoder
void SSI_Encoder_init(TSSI_Encoder*);
//! \memberof TSSI_Encoder
void SSI_Encoder_Calc(TSSI_Encoder*);
//! \memberof TSSI_Encoder
void SSI_Encoder_Read(TSSI_Encoder*);
#ifdef __cplusplus
}
#endif
#endif
/*@}*/