![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
test fork
Fork of LG by
HFO_Reg.c@0:8ad47e2b6f00, 2016-01-30 (annotated)
- Committer:
- igor_v
- Date:
- Sat Jan 30 13:00:39 2016 +0000
- Revision:
- 0:8ad47e2b6f00
- Child:
- 1:f2adcae3d304
2016_01_30;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
igor_v | 0:8ad47e2b6f00 | 1 | #include "mathDSP.h" |
igor_v | 0:8ad47e2b6f00 | 2 | #include "InputOutput.h" |
igor_v | 0:8ad47e2b6f00 | 3 | #include "CntrlGLD.h" |
igor_v | 0:8ad47e2b6f00 | 4 | |
igor_v | 0:8ad47e2b6f00 | 5 | #define HFO_NEG_MIN 8738 // -4.5 V |
igor_v | 0:8ad47e2b6f00 | 6 | #define HFO_NEG_MAX 25122 // -10.5 V |
igor_v | 0:8ad47e2b6f00 | 7 | #define HFO_POZ_MIN -32221 // +10.5 V |
igor_v | 0:8ad47e2b6f00 | 8 | #define HFO_POZ_MAX -15837 // +4.5 V |
igor_v | 0:8ad47e2b6f00 | 9 | |
igor_v | 0:8ad47e2b6f00 | 10 | /****************************************************************************** |
igor_v | 0:8ad47e2b6f00 | 11 | ** Function name: clc_HFO |
igor_v | 0:8ad47e2b6f00 | 12 | ** |
igor_v | 0:8ad47e2b6f00 | 13 | ** Descriptions: Procedure of the HFO regulator |
igor_v | 0:8ad47e2b6f00 | 14 | ** |
igor_v | 0:8ad47e2b6f00 | 15 | ** parameters: None |
igor_v | 0:8ad47e2b6f00 | 16 | ** Returned value: None |
igor_v | 0:8ad47e2b6f00 | 17 | ** |
igor_v | 0:8ad47e2b6f00 | 18 | ******************************************************************************/ |
igor_v | 0:8ad47e2b6f00 | 19 | void clc_HFO() // --- HFO regulator --- |
igor_v | 0:8ad47e2b6f00 | 20 | { |
igor_v | 0:8ad47e2b6f00 | 21 | |
igor_v | 0:8ad47e2b6f00 | 22 | static int hf_reg = 0; //r. çíà÷åíèå èíòåãðàòîðà â êîíòóðå ÃÂ× |
igor_v | 0:8ad47e2b6f00 | 23 | |
igor_v | 0:8ad47e2b6f00 | 24 | |
igor_v | 0:8ad47e2b6f00 | 25 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 26 | //r. ôèëüòðàöèÿ âûõîäà àìïë. äåòåêòîðà ïåðåä ïåðåäà÷åé â êîíòóð ÃÂ× |
igor_v | 0:8ad47e2b6f00 | 27 | /*int HFO_MovAverFilt (int Input) |
igor_v | 0:8ad47e2b6f00 | 28 | { |
igor_v | 0:8ad47e2b6f00 | 29 | static __int64 smooth_HF = 0; |
igor_v | 0:8ad47e2b6f00 | 30 | |
igor_v | 0:8ad47e2b6f00 | 31 | static int buffer_HF[BUF_SIZE]; |
igor_v | 0:8ad47e2b6f00 | 32 | |
igor_v | 0:8ad47e2b6f00 | 33 | static unsigned i_HF = 0; |
igor_v | 0:8ad47e2b6f00 | 34 | |
igor_v | 0:8ad47e2b6f00 | 35 | smooth_HF -= buffer_HF[i_HF]; |
igor_v | 0:8ad47e2b6f00 | 36 | buffer_HF[i_HF] = Input; |
igor_v | 0:8ad47e2b6f00 | 37 | smooth_HF += Input; |
igor_v | 0:8ad47e2b6f00 | 38 | |
igor_v | 0:8ad47e2b6f00 | 39 | i_HF++; |
igor_v | 0:8ad47e2b6f00 | 40 | i_HF &= (BUF_SIZE-1); |
igor_v | 0:8ad47e2b6f00 | 41 | |
igor_v | 0:8ad47e2b6f00 | 42 | return (smooth_HF>>22); //shift on additional 6 bits for smoothing 2^6 = 64 |
igor_v | 0:8ad47e2b6f00 | 43 | }*/ |
igor_v | 0:8ad47e2b6f00 | 44 | |
igor_v | 0:8ad47e2b6f00 | 45 | |
igor_v | 0:8ad47e2b6f00 | 46 | // HFO_SHIFT - ÷èñëî ðàçðÿäîâ äðîáíîé ÷àñòè â 32-õáèòîâîé ïåðåìåííîé hf_reg32 |
igor_v | 0:8ad47e2b6f00 | 47 | Input.StrIn.HF_out = HFO_MovAverFilt(Input.StrIn.HF_out<<HFO_SHIFT); |
igor_v | 0:8ad47e2b6f00 | 48 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 49 | |
igor_v | 0:8ad47e2b6f00 | 50 | Output.Str.HF_dif = L_sub(Device_blk.Str.HF_ref, Input.StrIn.HF_out); // HF_dif = HF_out - Device_blk.Str.HF_ref; |
igor_v | 0:8ad47e2b6f00 | 51 | |
igor_v | 0:8ad47e2b6f00 | 52 | if ( loop_is_closed(HF_REG_ON) ) //e. the regulator loop is closed //r. êîíòóð çàìêíóò |
igor_v | 0:8ad47e2b6f00 | 53 | {// êîýôôèöèåíò ïåðåäà÷è |
igor_v | 0:8ad47e2b6f00 | 54 | hf_reg = L_mac( hf_reg, Output.Str.HF_dif, Device_blk.Str.HF_scl ); // hf_reg32 += HFO_error * Device_blk.Str.HF_scl; |
igor_v | 0:8ad47e2b6f00 | 55 | Saturation(hf_reg, Device_blk.Str.HF_max << HFO_SHIFT, Device_blk.Str.HF_min << HFO_SHIFT); //e. checking range //r. ïðîâåðêà äèàïàçîíà if (Uin > UpSat) Uin = UpSat; if (Uin < DownSat) Uin = DownSat; |
igor_v | 0:8ad47e2b6f00 | 56 | Output.Str.HF_reg = (hf_reg >> HFO_SHIFT); // Output.Str.HF_reg - HFO output voltage |
igor_v | 0:8ad47e2b6f00 | 57 | } |
igor_v | 0:8ad47e2b6f00 | 58 | else |
igor_v | 0:8ad47e2b6f00 | 59 | { |
igor_v | 0:8ad47e2b6f00 | 60 | hf_reg = Output.Str.HF_reg << HFO_SHIFT; //r. èíòåãðàòîðó ïðèñâàèâàåì ïðåäûäóùåå çíà÷åíèå HF_reg |
igor_v | 0:8ad47e2b6f00 | 61 | } |
igor_v | 0:8ad47e2b6f00 | 62 | |
igor_v | 0:8ad47e2b6f00 | 63 | // cyclic built-in test |
igor_v | 0:8ad47e2b6f00 | 64 | if (!(((Output.Str.HF_reg < HFO_NEG_MAX)&&(Output.Str.HF_reg > HFO_NEG_MIN))||((Output.Str.HF_reg < HFO_POZ_MAX) && (Output.Str.HF_reg > HFO_POZ_MIN)))) |
igor_v | 0:8ad47e2b6f00 | 65 | { |
igor_v | 0:8ad47e2b6f00 | 66 | Valid_Data |= HFO_VOLT_ERROR; |
igor_v | 0:8ad47e2b6f00 | 67 | } |
igor_v | 0:8ad47e2b6f00 | 68 | } // clc_HFO |
igor_v | 0:8ad47e2b6f00 | 69 |