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

164 lines
4.4 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_adc.h
\brief Ìîäóëü îáðàáîòêè ÀÖÏ (ñì. TAdcDrv)
\author ÎÎÎ "ÍÏÔ Âåêòîð". http://motorcontrol.ru
\version v 2.0 25/03/2016
\defgroup V_adc Ìîäóëü îáðàáîòêè ÀÖÏ (ñì. TAdcDrv)
@{
*/
#ifndef V_ADC_H
#define V_ADC_H
#ifdef __cplusplus
extern "C"
{
#endif
/*! \class TAdcDrv
\brief Ìîäóëü îáðàáîòêè ÀÖÏ
Êëàññ \a TAdcDrv, îñíîâàííûé íà ñòðóêòóðå SAdcDrv, ñîäåðæèò â ñåáå
ìåòîäû äëÿ îáðàáîòêè ðåçóëüòàòîâ ÀÖÏ. À èìåííî: ñ÷èòûâàíèå, íîðìèðîâêó è
ïðèâåäåíèå ê îòíîñèòåëüíûì åäèíèöàì, ôèëüòðàöèþ. Ó êàæäîãî èçìåðÿåìîãî ñèãíàëà
åñòü êàê ìèíèìóì äâà ïàðàìåòðà äëÿ íàñòðîéêè: êîýôôèöèåíò óñèëåíèÿ è ñìåùåíèå.
Íàñòðîéêó äàò÷èêîâ æåëàòåëüíî ïðîèçâîäèòü òàê: ïîäàòü íóëåâîé ñèãíàë è íàñòðîèòü
ñìåùåíèå, ÷òîáû èçìåðÿåìîå çíà÷åíèå ïîêàçûâàëî íîëü. Ïîäàòü óðîâåíü ñèãíàëà, áëèçêèé
ê íîìèíàëüíîìó è íàñòðîèòü êîýôôèöèåíò óñèëåíèÿ, ÷òîáû èçìåðåííîå çíà÷åíèå ñîîòâåòñòâîâàëî
äåéñòâèòåëüíîñòè.*/
//! ñì. TAdcDrv
struct SAdcDrv
{
int16 Imeas_a_gain; //!< Êîýôôèöèåíò óñèëåíèÿ.
int16 Imeas_a_offset; //!< Ñìåùåíèå íóëÿ.
int32 Imeas_a; //!< Èçìåðåííîå çíà÷åíèå óñðåäíåííîå.
int32 IaGainNom; //!< Âñïîìîãàòåëüíûé êîýôô. óñèëåíèÿ.
int32 IA_temp; //!<Âðåìåííàÿ ïåðåìåííàÿ
int16 IASampleLength; //äëèíà âûáîðêè (êîë-âî òî÷åê íà ïåðèîäå ØÈÌ)
int16 IAPointer; //íîìåð ïîñëåäíåé âûáîðêè
int16 IABuf[4]; //ìàññèâ òî÷åê äëÿ óñðåäíåíèÿ
int16 Imeas_b_gain;
int16 Imeas_b_offset;
int32 Imeas_b;
int32 IbGainNom;
int32 IB_temp;
int16 IBSampleLength; //äëèíà âûáîðêè (êîë-âî òî÷åê íà ïåðèîäå ØÈÌ)
int16 IBPointer; //íîìåð ïîñëåäíåé âûáîðêè
int16 IBBuf[4]; //ìàññèâ òî÷åê äëÿ óñðåäíåíèÿ
int16 Imeas_c_gain;
int16 Imeas_c_offset;
int32 Imeas_c;
int32 IcGainNom;
int32 IC_temp;
int16 ICSampleLength; //äëèíà âûáîðêè (êîë-âî òî÷åê íà ïåðèîäå ØÈÌ)
int16 ICPointer; //íîìåð ïîñëåäíåé âûáîðêè
int16 ICBuf[4]; //ìàññèâ òî÷åê äëÿ óñðåäíåíèÿ
int16 Imeas_d_gain;
int16 Imeas_d_offset;
int32 Imeas_d;
int32 IdGainNom;
int16 ID_temp;
int16 IDSampleLength; //äëèíà âûáîðêè (êîë-âî òî÷åê íà ïåðèîäå ØÈÌ)
int16 IDPointer; //íîìåð ïîñëåäíåé âûáîðêè
int16 IDBuf[4]; //ìàññèâ òî÷åê äëÿ óñðåäíåíèÿ
int16 Udc_meas_gain;
int16 Udc_meas_offset;
int32 Udc_meas;
int32 UdcGainNom;
int16 Udc_temp;
int16 UdcSampleLength; //äëèíà âûáîðêè (êîë-âî òî÷åê íà ïåðèîäå ØÈÌ)
int16 UdcPointer; //íîìåð ïîñëåäíåé âûáîðêè
int16 UdcBuf[4]; //ìàññèâ òî÷åê äëÿ óñðåäíåíèÿ
int16 T_meas_gain; //!< Êîýôôèöèåíò óñèëåíèÿ.
int32 T_meas; //!< Èçìåðåííîå çíà÷åíèå óñðåäíåííîå.
int32 TGainNom; //!< Âñïîìîãàòåëüíûé êîýôô. óñèëåíèÿ.
int16 T_temp; //!<Âðåìåííàÿ ïåðåìåííàÿ
int16 ref_meas_gain;
int16 ref_meas_offset;
int32 ref_meas;
int32 refGainNom;
int16 ref_temp;
void (*init)(struct SAdcDrv *);
void (*fast_calc)(struct SAdcDrv*);
void (*ms_calc)(struct SAdcDrv*);
void (*slow_calc)(struct SAdcDrv*);
};
typedef struct SAdcDrv TAdcDrv;
//!Èíèöèàëèçàòîð ïî óìîë÷àíèþ.
#define ADC_DRV_DEFAULTS {\
54,0,0,0,0, \
4,0,{0}, \
54,0,0,0,0, \
4,0,{0}, \
54,0,0,0,0, \
4,0,{0}, \
54,0,0,0,0, \
4,0,{0}, \
800,0,0,0,0, \
4,0,{0}, \
100,0,0,0, \
54,0,0,0,0, \
AdcDrv_init,\
AdcDrv_fast_calc,\
AdcDrv_ms_calc,\
AdcDrv_slow_calc,\
}
//! \memberof TAdcDrv
void AdcDrv_init(TAdcDrv*);
//! \memberof TAdcDrv
void AdcDrv_slow_calc(TAdcDrv*);
//! \memberof TAdcDrv
void AdcDrv_fast_calc(TAdcDrv*);
//! \memberof TAdcDrv
void AdcDrv_ms_calc(TAdcDrv*);
#ifdef __cplusplus
}
#endif
#endif
/*@}*/