Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of LG2 by
HFO_Reg.c
00001 #include "Global.h" 00002 00003 #define HFO_NEG_MIN 8738 // -4.5 V 00004 #define HFO_NEG_MAX 25122 // -10.5 V 00005 #define HFO_POZ_MIN -32221 // +10.5 V 00006 #define HFO_POZ_MAX -15837 // +4.5 V 00007 00008 /****************************************************************************** 00009 ** Function name: clc_HFO 00010 ** 00011 ** Descriptions: Procedure of the HFO regulator 00012 ** 00013 ** parameters: None 00014 ** Returned value: None 00015 ** 00016 ******************************************************************************/ 00017 /*void clc_HFO() // --- HFO regulator --- 00018 { 00019 00020 static int hf_reg = 0; //r. значение интегратора в контуре ГВЧ 00021 00022 00023 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00024 //r. фильтрация выхода ампл. детектора перед передачей в контур ГВЧ 00025 int HFO_MovAverFilt (int Input) 00026 { 00027 static __int64 smooth_HF = 0; 00028 00029 static int buffer_HF[BUF_SIZE]; 00030 00031 static unsigned i_HF = 0; 00032 00033 smooth_HF -= buffer_HF[i_HF]; 00034 buffer_HF[i_HF] = Input; 00035 smooth_HF += Input; 00036 00037 i_HF++; 00038 i_HF &= (BUF_SIZE-1); 00039 00040 return (smooth_HF>>22); //shift on additional 6 bits for smoothing 2^6 = 64 00041 } 00042 00043 00044 HFO_SHIFT - число разрядов дробной части в 32-хбитовой переменной hf_reg32 00045 Input.StrIn.HF_out = HFO_MovAverFilt(Input.StrIn.HF_out<<HFO_SHIFT); 00046 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00047 00048 Output.Str.HF_dif = L_sub(Device_blk.Str.HF_ref, Input.StrIn.HF_out); // HF_dif = HF_out - Device_blk.Str.HF_ref; 00049 00050 if ( loop_is_closed(HF_REG_ON) ) { //e. the regulator loop is closed //r. контур замкнут 00051 // коэффициент передачи 00052 hf_reg = L_mac( hf_reg, Output.Str.HF_dif, Device_blk.Str.HF_scl ); // hf_reg32 += HFO_error * Device_blk.Str.HF_scl; 00053 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; 00054 Output.Str.HF_reg = (hf_reg >> HFO_SHIFT); // Output.Str.HF_reg - HFO output voltage 00055 } else { 00056 hf_reg = Output.Str.HF_reg << HFO_SHIFT; //r. интегратору присваиваем предыдущее значение HF_reg 00057 } 00058 00059 // cyclic built-in test 00060 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)))) { 00061 Valid_Data |= HFO_VOLT_ERROR; 00062 } 00063 } 00064 */ 00065
Generated on Thu Jul 14 2022 02:34:42 by
 1.7.2
 1.7.2 
    