![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
forkd
Fork of LG2 by
Revision 227:2774b56bfab0, committed 2018-01-05
- Comitter:
- Kovalev_D
- Date:
- Fri Jan 05 08:14:38 2018 +0000
- Parent:
- 226:4a4d5bd5fcd7
- Commit message:
- 05.01.2018
Changed in this revision
--- a/Command.c Tue Dec 26 05:14:09 2017 +0000 +++ b/Command.c Fri Jan 05 08:14:38 2018 +0000 @@ -135,7 +135,7 @@ case 1: if(Gyro.Rate1_Event ) CMD_Rate(); break; case 2: if(Gyro.Reper_Event ) CMD_Rate2(); break; case 3: if(Gyro.Event_500Hz ) CMD_Delta_PS(); break; - case 4: if(Gyro.EXT_Latch ) CMD_Delta_PS(); Gyro.EXT_Latch=0; LoopOff break; + case 4: if(Gyro.EXT_Latch ) CMD_Delta_PS(); Gyro.EXT_Latch=0; break; case 5: if(Gyro.Event_500Hz ) CMD_Delta_Bins(); break; case 6: if(Gyro.EXT_Latch ) CMD_B_Delta(); Gyro.EXT_Latch=0; break; case 7: if(Gyro.Event_500Hz ) CMD_B_Delta(); break; @@ -274,7 +274,7 @@ switch(NP) { - case 0: Gyro.My_Addres = GyroP.Str.My_Addres; break; + //case 0: Gyro.My_Addres = GyroP.Str.My_Addres; break; case 1: Gyro.HFO_ref = (unsigned int)(GyroP.Str.HFO_ref) ; break; case 2: Gyro.HFO_Gain = GyroP.Str.HFO_Gain; break; case 3: if(Gyro.LG_Type) Gyro.HFO_Max=0xffff-GyroP.Str.DAC_current_Work; //((int)(GyroP.Str.DAC_current_Work*0.67)-2000); @@ -365,30 +365,26 @@ } void CMD_Maintenance(void) { - - Gyro.ModeOut=0; - Gyro.Device_Mode = 0; + unsigned int Temp; + Gyro.ModeOut = 0; + Gyro.Device_Mode = 0; for(int q=0; q<64; q++) { BuffTemp[q]=0; } //Gyro.DropDelayGLD = DropDelayGLD_0;//задержка на выдачу 45 микросекунд для любого адреса ГЛД BuffTemp[0] = Gyro.SOC_Out; - BuffTemp[1] = Gyro.My_Addres; - BuffTemp[2] = Gyro.Firmware_Version; - /* sprintf((Time),"%d \r\n", Gyro.Firmware_Version); - WriteCon(Time);*/ - BuffTemp[3] = Gyro.GLD_Serial; - - BuffTemp[4]=0x00; - - BuffTemp[5]=0x00; + Temp = 0xfff; //Gyro.Firmware_Version; + BuffTemp[2] = (Temp >> 0) & 0xff; + BuffTemp[3] = (Temp >> 8) & 0xff; + + Temp = Gyro.GLD_Serial; + BuffTemp[4]=(Temp >> 0) & 0xff; + BuffTemp[5]=(Temp >> 8) & 0xff; Check(BuffTemp, 8); - /* sprintf((Time),"%d %d %d %d %d %d %d %d\r\n",BuffTemp[0], BuffTemp[1],BuffTemp[2],BuffTemp[3],BuffTemp[4],BuffTemp[5],BuffTemp[6],BuffTemp[7]); - WriteCon(Time);*/ WriteConN (BuffTemp,8); } @@ -440,11 +436,12 @@ BuffTemp[ 1] = Gyro.My_Addres; Gyro.CuruAngle = Gyro.CuruAngle + OldCuruAngle; //(72 град/с) - + OldCuruAngle=Gyro.CuruAngle & 0xf; //сохраняем 3 бит для след измирений - Temp=Gyro.CuruAngle>>4; //приводим к форме вывода + Temp=Gyro.CuruAngle>>4; + //приводим к форме вывода Gyro.CuruAngle = 0; - + //Temp=200; BuffTemp[ 2] =(Temp >> 8) & 0xff;//старший байт разности счетчиков BuffTemp[ 3] =(Temp >> 0) & 0xff;//младший байт разности счетчиков @@ -464,14 +461,8 @@ //HFO case 2: - /* Temp2 = ((Spi.DAC_A/0.65)-22544)-0x7fff; - Temp1= (int)Temp2;*/ - //2930 - if(Gyro.LG_Type) {OutDeltaPS =(int)(((Spi.DAC_A-0x84bf))* 2); - } - else {OutDeltaPS =(unsigned int)(0x7fff-Spi.ADC5)*0.79; - } - // Temp = Spi.DAC_A-0x7fff; + + OutDeltaPS = 0xffff - Spi.DAC_A; BuffTemp[5] = (OutDeltaPS >> 8) & 0xff; break; @@ -509,7 +500,7 @@ //Напряжение на регуляторе периметра case 8: - OutDeltaPS =(int)(3300+(0x7fff+(Spi.DAC_B*1.083)));// (Spi.DAC_B - 0x7fff); + OutDeltaPS = ((Spi.DAC_B-0x7fff)&0xffff); BuffTemp[5] = (OutDeltaPS >> 8) & 0xff; break; @@ -550,7 +541,7 @@ //ток 1 case 14: //Temp = Gyro.In1; - IntOutDeltaPS = ((Gyro.In1>>1)*0.800875)-0x3e0b; + IntOutDeltaPS = 0;//((Gyro.In1>>1)*0.800875)-0x3e0b; BuffTemp[5] = (IntOutDeltaPS >> 8) & 0xff;//in1//2 break; @@ -564,7 +555,7 @@ //ток 2 case 16: // Temp = Gyro.In2; - IntOutDeltaPS = ((Gyro.In2>>1)*0.800875)-0x3e0b; + IntOutDeltaPS =0;// ((Gyro.In2>>1)*0.800875)-0x3e0b; BuffTemp[5] = (IntOutDeltaPS >> 8) & 0xff; break; @@ -590,7 +581,7 @@ //температурный канал 5 case 20: OutDeltaPS = 0; - OutDeltaPS = Gyro.Termo;//Spi.ADC1;// //Gyro.Termo;//0xa4=164 + OutDeltaPS = Gyro.Termo; BuffTemp[5] =(OutDeltaPS >> 8) & 0xff;//температура break; @@ -691,7 +682,7 @@ BuffTemp[13]=(Temp >> 0) & 0xff;//// 14 --сигнал ошибки регулятора ГВЧ //Temp = (unsigned int)((7675000*16/(Gyro.Frq>>12))); - Temp = (unsigned int)(7680000/(Gyro.Frq>>16)); + Temp = Gyro.Frq>>12;//(unsigned int)(7680000/(Gyro.Frq>>16)); BuffTemp[14] = (Temp >> 8) & 0xff; //15 период вибропривода.(частота) T_Vibro BuffTemp[15] = (Temp >> 0) & 0xff; //16 период вибропривода. @@ -701,7 +692,7 @@ /*sprintf((Time),"%d %d\r\n",Gyro.FrqPhaseEror, Gyro.FrqPhaseEror<<2); WriteCon(Time); */ //18 - Temp =Gyro.L_vibro/*>>1*/;//(unsigned int)(((7675000*16/200) * Gyro.AmpPer /(Gyro.Frq>>12))); + Temp = Gyro.AmpPer/*>>1*/;//(unsigned int)(((7675000*16/200) * Gyro.AmpPer /(Gyro.Frq>>12))); BuffTemp[18] = (Temp >> 8) & 0xff; //19 длительность импулься вибропривода(амплитуда) BuffTemp[19] = (Temp >> 0) & 0xff; //20 @@ -813,8 +804,8 @@ } else Spi.DAC_B = (unsigned int)((temp-0x7fff)&0xffff); - sprintf((Time),"%d %d \r\n", Spi.DAC_B, temp); - WriteCon(Time); + /*sprintf((Time),"%d %d \r\n", Spi.DAC_B, temp); + WriteCon(Time); */ for(int q=0; q<64; q++) { BuffTemp[q]=0; @@ -831,11 +822,18 @@ { unsigned int temp1,temp2,anser; temp1 = (((BuffTemp[4]<<8) | BuffTemp[5])&0xFFFF); - Gyro.Frq = (122780000/temp1)<<12; - F_vib=103200000/((Gyro.Frq>>16)*2); - temp2 = (((BuffTemp[6]<<8) | BuffTemp[7])&0xFFFF); - Gyro.AmpPer = ((((((Gyro.Frq>>12)*200)/16)*temp2)/7680000)/2); - Gyro.Amp = (Gyro.AmpPer)<<15; + Gyro.Frq = (temp1<<12); + // Gyro.Frq = (122780000/temp1)<<12; + + F_vib= (unsigned int)(825600000 / temp1); + temp2 = (((BuffTemp[6]<<8) | BuffTemp[7])&0xFFFF); + + sprintf((Time),"%d %d \r\n",temp1, temp2); + WriteCon(Time); + Gyro.AmpPer = temp2; + Gyro.Amp = (Gyro.AmpPer<<17)/100; + /* Gyro.AmpPer = ((((((Gyro.Frq>>12)*200)/16)*temp2)/7680000)/2); + Gyro.Amp = (Gyro.AmpPer)<<17;*/ BuffTemp[0] = Gyro.SOC_Out; BuffTemp[1] = Gyro.My_Addres; @@ -1205,8 +1203,14 @@ if( Gyro.Debag2) Gyro.Debag2=0; else Gyro.Debag2=1; } - if (Time[0] == 'C') Spi.DAC_A+=200; - if (Time[0] == 'c') Spi.DAC_A-=200; + if (Time[0] == 'C') Spi.DAC_A+=32; + if (Time[0] == 'c') Spi.DAC_A-=32; + + if (Time[0] == 'k') PLC_ERR_DAC_F = 0; + + if (Time[0] == 'V') Spi.DAC_A+=160; + if (Time[0] == 'v') Spi.DAC_A-=160; + if (Time[0] == 'X') Spi.DAC_B+=2000; if (Time[0] == 'x') Spi.DAC_B-=2000; /////////////////////////////////////////////////////////////////
--- a/Global.c Tue Dec 26 05:14:09 2017 +0000 +++ b/Global.c Fri Jan 05 08:14:38 2018 +0000 @@ -40,8 +40,11 @@ int BuffADC_128Point [100]; int BuffADC_64Point [100]; + + int BuffPLC_FILT [20]; + unsigned int C_PLC_F=0; + int BuffADC_32Point [100]; - int BuffADC_16Point [100]; int BuffADC_10HFO [100]; @@ -76,7 +79,10 @@ int temp=0; InitMOD(); - + for(int q=0; q<20; q++) + { + BuffPLC_FILT [q] = 0; + } Gyro.CuruAngleLog=0; Global_Time = 0; Time_UART = 0;
--- a/Global.h Tue Dec 26 05:14:09 2017 +0000 +++ b/Global.h Fri Jan 05 08:14:38 2018 +0000 @@ -47,7 +47,8 @@ extern unsigned int secPuls; extern unsigned char BuffTemp[]; extern unsigned char Time[]; - +extern int BuffPLC_FILT[]; +extern unsigned int C_PLC_F; extern unsigned int MODFlag; extern unsigned int Time250Hz; extern unsigned int Event250Hz;
--- a/MCPWM.c Tue Dec 26 05:14:09 2017 +0000 +++ b/MCPWM.c Fri Jan 05 08:14:38 2018 +0000 @@ -25,7 +25,9 @@ } void ReVib(void) -{ Gyro.AmpPer = ((Gyro.Amp*100)>>17); +{ + + Gyro.AmpPer = ((Gyro.Amp*100)>>17); F_vib=(103200000<<5)/((Gyro.Frq)>>10);//периуд вибро. T_vibP = F_vib/10000;
--- a/MTimer.c Tue Dec 26 05:14:09 2017 +0000 +++ b/MTimer.c Fri Jan 05 08:14:38 2018 +0000 @@ -61,10 +61,7 @@ if (Event1Hz) { - - /* sprintf((Time),"%d \r\n",Gyro.EXT_Latch); - WriteCon(Time);*/ - + if(Gyro.RgConA&0x4) JumpTimer=0; else @@ -81,20 +78,14 @@ } - /*if(Gyro.ShowMod2) - { - sprintf((Time),"%d %d %d\r\n",Spi.DAC_B,AMPSUM_DESP,Spi.DAC_A); - WriteCon(Time); - Spi.DAC_B+=200; - }*/ Discharg(); BackLight(); Gyro.Rate1_Event = 1; Event1Hz--; Time1Hz++; - // sprintf((Time),"%d \r\n",Gyro.ModeOut ); - // WriteCon(Time); + sprintf((Time),"%d \r\n",GyroP.Str.GLD_Serial ); + WriteCon(Time); } } @@ -132,8 +123,9 @@ { if(Gyro.Debag2) { - sprintf((Time),"%d %d \r\n", (0xffff-Spi.DAC_A)-30000, ((Spi.DAC_B-0x7fff)&0xffff)); + sprintf((Time),"%d %d %d\r\n", (0xffff-Spi.DAC_A), ((Spi.DAC_B-0x7fff)&0xffff), BuffADC_128Point[CountV64]); WriteCon(Time); + } Event500Hz--; Gyro.Event_500Hz=1;// Event 500Гц выдачи данных для постройки графика управления вибро
--- a/SPI.c Tue Dec 26 05:14:09 2017 +0000 +++ b/SPI.c Fri Jan 05 08:14:38 2018 +0000 @@ -14,6 +14,9 @@ int start=10; int dispersion=0,side=1,tempstrafe=15000; int ADC_5_T; +int PLC_ERR_DAC,PLC_ERR_DAC_F; + + unsigned int TempA; unsigned int TempTermLM; unsigned int conuntPLS; @@ -32,7 +35,7 @@ int Buff_OUT1 [64]; int Buff_OUT [64]; int RegulADC,DeltaRegul,tempDeltaRegul; -int count10HFO=0, count10v=0, AmpWorms,MinWorms,MaxWorms,AMPSUM,AMPSUMP,AMPSUMM,AMPSUM_DESP,AMPSUMPout,AMPSUMMout,AMPSUMout,SumDelta,PLC_EROR,PLC_Flag,HFO_Flag,HFOdelta,HFOregul,HFOSumDelta; +int count10HFO=0, count10v=0, AmpWorms,MinWorms,MaxWorms,AMPSUM,AMPSUMP,AMPSUMM,AMPSUMPout,AMPSUMMout,AMPSUMout,SumDelta,PLC_EROR,PLC_Flag,HFO_Flag,HFOdelta,HFOregul,HFOSumDelta; //int BuffADC_32Point [64]; @@ -57,7 +60,7 @@ unsigned int ModArraySaw [64]; unsigned int Mod=0; int znak; - +unsigned int HFO_AVR; void InitMOD(void) { for (int i = 0; i < 64; i++ ) @@ -125,13 +128,14 @@ { Spi.ADC_NewData = 0; // Gyro.Termo = (unsigned int)(((Spi.ADC1>>1) + Gyro.Tmp_OffsetT4) * Gyro.Tmp_scaleT4); - Gyro.Termo = (unsigned int)(Spi.ADC1>>1); + Gyro.Termo = (unsigned int)((((Spi.ADC1>>1)*100)*0.0122)-27300); + //Gyro.Termo = Gyro.IN1_Accum += Spi.ADC2; Gyro.IN2_Accum += Spi.ADC3; // Gyro.DeltaT = (unsigned int)(((Spi.ADC4>>1) + Gyro.Tmp_OffsetT5) * Gyro.Tmp_scaleT5); switch(Gyro.LG_Type) { - case 1: Gyro.DeltaT = (unsigned int)(Spi.ADC2>>1); break; + case 1: Gyro.DeltaT = (unsigned int)((((Spi.ADC2>>1)*100)*0.0122)-27300); break; case 0: Gyro.DeltaT = (unsigned int)(Spi.ADC4>>1); break; } @@ -172,31 +176,21 @@ void HFOFilt(void) { - if (count10HFO>=64*8) - { - count10HFO=0; - for(int q=0; q<64; q++) - { - AMPSUM+=BuffADC_10v[q]; - } - AMPSUM=AMPSUM>>6; - AMPSUM=AMPSUM>>3; - //AMPSUM=AMPSUM>>3; - - AMPSUM_DESP=AMPSUM; - HFOdelta=(int)((Gyro.HFO_ref)-AMPSUM); - - + + + /* HFO_AVR+=(BuffADC_10v[CountV64]>>4); + HFO_AVR-=(BuffADC_10v[CountV64 - 32]>>4); + */ + HFOdelta=(int)((Gyro.HFO_ref)-(BuffADC_128Point[CountV64]>>7)); + HFOSumDelta+=HFOdelta; HFOregul=HFOSumDelta/(int)(Gyro.HFO_Gain); - + HFOSumDelta-=Gyro.HFO_Gain*HFOregul; - - // tempDeltaRegul = HFOregul; tempDeltaRegul += HFOregul; AMPSUM=0; HFO_Flag=1; - } + } void PLCFilt(void) @@ -205,7 +199,8 @@ if (count10v>=64*32) { - + C_PLC_F++; + C_PLC_F = C_PLC_F & 0xf; count10v=0; for(int q=0; q<32; q++) @@ -227,7 +222,7 @@ for(int q=0; q<64; q++) { - // AMPSUM+=BuffADC_10v[q]; + AMPSUM+=BuffADC_10v[q]; AMPSUMout+=BuffADC_10v_F[q]; BuffADC_10v_OLD[q]= BuffADC_10v[q]; BuffADC_10v[q] =0; @@ -239,7 +234,11 @@ /*sprintf((Time),"%d \r\n", Spi.DAC_A); WriteCon(Time);*/ - + + AMPSUM=AMPSUM>>6; + AMPSUM=AMPSUM>>3; + AMPSUM=AMPSUM>>3; + AMPSUMPout=AMPSUMP>>1; AMPSUMMout=AMPSUMM>>1; AMPSUMout=AMPSUM; @@ -255,6 +254,13 @@ PLC_EROR+=Gyro.PLC_Eror_count; + BuffPLC_FILT[C_PLC_F] = Gyro.PLC_Eror_count; + if(Time1Hz>10) + { + PLC_ERR_DAC_F += BuffPLC_FILT[C_PLC_F]; + PLC_ERR_DAC_F -= BuffPLC_FILT[(C_PLC_F-8)&0xf]; + } + PLC_ERR_DAC = PLC_ERR_DAC_F>>3; PLC_Flag=1; AMPSUMM=0; AMPSUMP=0; @@ -315,9 +321,9 @@ BuffADC_1Point[CountV255] = (0x7fff-ADC5New)&0x7fff; BuffADC_1Point_64[CountV31]=(0x7fff-ADC5New)&0x7fff; - /* ADC_128Point += BuffADC_1Point[CountV255]; + ADC_128Point += BuffADC_1Point[CountV255]; ADC_128Point -= BuffADC_1Point[(CountV255 - 128) & 0xff]; // заполнение буфера накопленых приращений за 64 тактов - BuffADC_128Point[CountV64] = ADC_128Point;*/ + BuffADC_128Point[CountV64] = ADC_128Point; // Buff_Restored_Mod[CountV31] =(int)(BuffADC_1Point_64[CountV31] - ((BuffADC_128Point[CountV64])>>7)); @@ -372,30 +378,35 @@ { } - else Spi.DAC_B+=(Gyro.PLC_Eror_count); + else + { + /* if(Gyro.PLC_Eror_count>600) Gyro.PLC_Eror_count=0; + else if(Gyro.PLC_Eror_count<(-600)) Gyro.PLC_Eror_count=0;*/ + + Spi.DAC_B+=PLC_ERR_DAC; + + } } - } - Gyro.PLC_Eror_count=0; - if(Gyro.LG_Type==1) - { - if(Spi.DAC_B > Gyro.HighTreshold ) - { + if(Spi.DAC_B > Gyro.HighTreshold ) + { Spi.DAC_B = (Gyro.ResetLevelCool); Gyro.PLCDelay = GyroP.Str.PLCDelay; - } - else if(Spi.DAC_B < Gyro.DownTreshold ) - { + } + else if(Spi.DAC_B < Gyro.DownTreshold ) + { Spi.DAC_B = (Gyro.ResetLevelHeat); Gyro.PLCDelay = GyroP.Str.PLCDelay; - } - } - else - { - if ( Spi.DAC_B < 10300 ) Spi.DAC_B = 32000; //проверка на переваливание за границу. - else if ( Spi.DAC_B > 57000 ) Spi.DAC_B = 32000; - } + } + } + + + + if(PLC_Flag) { + /*sprintf((Time),"%d %d %d\r\n", PLC_ERR_DAC, Spi.DAC_B, Spi.DAC_A); + WriteCon(Time);*/ + PLC_ERR_DAC=0; PLC_Flag=0; } }
--- a/SPI.h Tue Dec 26 05:14:09 2017 +0000 +++ b/SPI.h Fri Jan 05 08:14:38 2018 +0000 @@ -37,6 +37,7 @@ extern unsigned int Cur_Amp,faza; extern int Znak_Amp; extern int AD_Regul ; +extern int PLC_ERR_DAC,PLC_ERR_DAC_F; extern unsigned int SinPLC[]; //extern unsigned int Temp_AMP; @@ -72,8 +73,8 @@ extern int BuffADC_10v []; extern int BuffADC_10v_OLD []; extern int BuffADC_10v_F []; -extern int count10v,AmpWorms,MinWorms,MaxWorms,PLC_Flag,AMPSUM,AMPSUM_DESP,AMPSUMP,AMPSUMM,AMPSUMPout,AMPSUMMout,AMPSUMout,SumDelta, PLC_EROR; - +extern int count10v,AmpWorms,MinWorms,MaxWorms,PLC_Flag,AMPSUM,AMPSUMP,AMPSUMM,AMPSUMPout,AMPSUMMout,AMPSUMout,SumDelta, PLC_EROR; +extern unsigned int HFO_AVR; extern int Buff_Restored_Mod []; extern int Buff_PLC_Eror []; extern int BSinMns [];
--- a/vibro.c Tue Dec 26 05:14:09 2017 +0000 +++ b/vibro.c Fri Jan 05 08:14:38 2018 +0000 @@ -14,54 +14,6 @@ Gyro.EXT_Latch=1; LPC_GPIOINT->IO0IntClr |= (1<<1); - LoopOn - LoopOn - LoopOn - LoopOn - LoopOn - - LoopOn - LoopOn - LoopOn - LoopOn - LoopOn - LoopOn - LoopOn - LoopOn - LoopOn - LoopOn - LoopOn - - LoopOn - LoopOn - LoopOn - LoopOn - LoopOn - LoopOn - LoopOn - LoopOn - LoopOn - LoopOn - LoopOn - - LoopOn - LoopOn - LoopOn - LoopOn - LoopOn - LoopOn - LoopOn - LoopOn - LoopOn - LoopOn - LoopOn - - LoopOn - LoopOn - LoopOn - LoopOn - LoopOn - LoopOn } @@ -211,9 +163,9 @@ temp=temp>>6; LowDZ = ((Gyro.AmpSpeed<<3)*(-1)); HiDZ = (Gyro.AmpSpeed<<3); - Gyro.Amp -= temp>>4; // расчет амплитуды ВП с учетом разници - if((Gyro.Amp>>16) > (Gyro.AmpPerMax)) {Gyro.Amp = (Gyro.AmpPerMax << 16);} // временное ограничение роста амплитуды ВП в случае неподоженного гироскопа////////// - if((Gyro.Amp>>16) < (Gyro.AmpPerMin)) {Gyro.Amp = (Gyro.AmpPerMin << 16);} // временное ограничение роста амплитуды ВП в случае неподоженного гироскопа////////// + Gyro.Amp -= temp>>4; // расчет амплитуды ВП с учетом разници(Gyro.AmpPer<<17)/100; + if((Gyro.AmpPer) > (Gyro.AmpPerMax)) {Gyro.Amp = ((Gyro.AmpPerMax<<17)/100);} // временное ограничение роста амплитуды ВП в случае неподоженного гироскопа////////// + if((Gyro.AmpPer) < (Gyro.AmpPerMin)) {Gyro.Amp = ((Gyro.AmpPerMin<<17)/100);} // временное ограничение роста амплитуды ВП в случае неподоженного гироскопа////////// // Gyro.AmpPer = (Gyro.Amp)>>16; //приведение амплитуды ВП к виду 0%-100% } LPC_MCPWM->MAT1 = T_vib_1;