![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
forkd
Fork of LGstaandart by
Command.c
- Committer:
- Kovalev_D
- Date:
- 2018-01-31
- Revision:
- 232:130a2b5003e6
- Parent:
- 231:079835d508ef
File content as of revision 232:130a2b5003e6:
#include "stdlib.h" //#include "math.h" #include "LPC17xx.h" #include "Global.h" int tempNH,tempNL; unsigned int Rate_Flag; unsigned int CountBuFFIn; unsigned int N=0,CRC_N; unsigned int Rate_7=0; int iRate_7=0; unsigned int Param1=0; unsigned int Param2=0; unsigned int Param3=0; unsigned int Param4=0; ///unsigned int Consol=123; unsigned int TempParam=1; unsigned int CountParam=0; unsigned int OldCuruAngle; unsigned int OldCaunPlus=0; unsigned int OldCaunMin=0; unsigned int OutDeltaPS; int IntOutDeltaPS; int ttemp,temp5=1; int OLDDAC=0; int rr = 123; unsigned int pDestT; GyroParam *Flash; //int q; ///////////////flah and boot/////////// void GoBoot(void) { /* Prepare Sectors to be flashed */ NVIC_DisableIRQ(TIMER1_IRQn); NVIC_DisableIRQ(TIMER2_IRQn); NVIC_DisableIRQ(TIMER3_IRQn); NVIC_DisableIRQ(EINT3_IRQn); SystemInitDef(); vIAP_ReinvokeISP(); } void DropDelay(void) { Gyro.DropDelayGLD = DropDelayGLD_0; switch(Gyro.My_Addres) { case 1: Gyro.DropDelayGLD = DropDelayGLD_1; break; case 2: Gyro.DropDelayGLD = DropDelayGLD_2; break; case 3: Gyro.DropDelayGLD = DropDelayGLD_3; break; } } void EraseFlash(void) { rr = u32IAP_PrepareSectors(19, 21); rr = u32IAP_EraseSectors(19, 21); } void WriteFlash(void) { Gyro.FlashMod = 0; //SystemInitDef(); NVIC_DisableIRQ(TIMER1_IRQn); NVIC_DisableIRQ(TIMER2_IRQn); NVIC_DisableIRQ(TIMER3_IRQn); NVIC_DisableIRQ(EINT3_IRQn); // unsigned int start_address = (unsigned int) & GyroP; rr = u32IAP_PrepareSectors(19, 21); rr = u32IAP_EraseSectors (19, 21); rr = u32IAP_PrepareSectors(19, 21); rr = u32IAP_CopyRAMToFlash(0x030000, &GyroP , 1024); // SystemInit1(); // Инициализация контроллера: установка тактовых частот //SystemCoreClockUpdate1(); // расчет тактовой частоты процессора перед инициализацией UART - 103MHz NVIC_EnableIRQ(TIMER1_IRQn); NVIC_EnableIRQ(TIMER2_IRQn); NVIC_EnableIRQ(TIMER3_IRQn); NVIC_EnableIRQ(EINT3_IRQn); //SystemCoreClockUpdate1(); } void ReadFlash ( void) { NVIC_DisableIRQ(TIMER1_IRQn); NVIC_DisableIRQ(TIMER2_IRQn); NVIC_DisableIRQ(TIMER3_IRQn); NVIC_DisableIRQ(EINT3_IRQn); Gyro.FlashMod = 0; pDestT= (unsigned int) (0x030000); Flash = (GyroParam*) pDestT; GyroP = *(Flash); NVIC_EnableIRQ(TIMER1_IRQn); NVIC_EnableIRQ(TIMER2_IRQn); NVIC_EnableIRQ(TIMER3_IRQn); NVIC_EnableIRQ(EINT3_IRQn); } ///////////////end flah and boot/////////// void M_RateA(void) { if(Gyro.ModeOut==3) { if (Gyro.Device_Mode) Gyro.ModeOut=4; } switch(Gyro.ModeOut) { 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 ){ Gyro.EXT_Latch=0; LoopOn LoopOn LoopOn LoopOn LoopOn LoopOn LoopOn LoopOn LoopOn LoopOn LoopOn CMD_Delta_PS(); LoopOff //NVIC_EnableIRQ(EINT3_IRQn); } 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; case 8: if(Gyro.Rate3_Event ) CMD_Rate3(); break; case 9: if(Gyro.Reper_Event ){ CMD_Rate2(); Gyro.ModeOut=0;} break; case 10: CMD_Rate7();Gyro.ModeOut=0;break;//if(Gyro.EvenRate7 ){ CMD_Rate7(); Gyro.EvenRate7=0;} break; case 11: if(Gyro.EvenRate5K ){ M_Rate5K(); Gyro.EvenRate5K--;} break; } } void BuffClear(void) { for(int q=0; q<60; q++) { BuffTemp[q]=0; } } void CMD_Rate7(void) { BuffClear(); unsigned int Temp; int ADC_Worm[70]; int Temp1; float Temp2; static unsigned int t=0; BuffTemp[0] = Gyro.SOC_Out; BuffTemp[1] = Gyro.My_Addres; for(int q=0; q<64; q++) { Temp = (WormFilt2[q]>>6) + 128; BuffTemp[q+2] = (Temp) & 0xff;//младший байт разности счетчиков } iRate_7 = ((Spi.DAC_B-0x7fff)&0xffff); BuffTemp[66]=(iRate_7 >> 8) & 0xff;//младший байт разности счетчиков BuffTemp[67]=(iRate_7 >> 0) & 0xff;//младший байт разности счетчиков; Rate_7 = Gyro.PLC_Eror_count>>3; BuffTemp[68]=(Rate_7 >> 8) & 0xff;//младший байт разности счетчиков BuffTemp[69]=(Rate_7 >> 0) & 0xff;//младший байт разности счетчиков; Gyro.PLC_Eror_count=0; switch(Gyro.LG_Type) { case 1: iRate_7 = 0xffff-Spi.DAC_A; break; case 0: Temp2 = (Spi.DAC_A*1.538) - 0xd80f; iRate_7 = (int)Temp2; break; } Rate_7 = (unsigned int)(iRate_7&0xffff); BuffTemp[70]= (iRate_7 >> 8) & 0xff;//младший байт разности счетчиков BuffTemp[71]= (iRate_7 >> 0) & 0xff;//младший байт разности счетчиков; Check(BuffTemp,74); WriteConN (BuffTemp,74); } void CMD_M_Param_R(void) { unsigned int NP=0; unsigned int Param; NP = BuffTemp[3]; for (int i=0;i<8;i++) {BuffTemp[i]=0;} BuffTemp[0] = Gyro.SOC_Out; BuffTemp[1] = Gyro.My_Addres; /* sprintf((Time),"%d = %d \r\n",NP, GyroP.Array[NP]); WriteCon(Time);*/ Param = GyroP.Array[NP]; BuffTemp[2] =(GyroP.Array[NP] >> 8) & 0xff;//старший байт требуемого параметра BuffTemp[3] =(GyroP.Array[NP] >> 0) & 0xff;//младший байт требуемого параметра Check(BuffTemp, 6); WriteConN (BuffTemp,6); /*sprintf((Time),"READ Param = <%07d> GyroP.Array[NP] = <%07d> NP= <%07d> Gyro.CaunPlus+Gyro.CaunMin-5000 <%07d> \r\n",Param, GyroP.Array[NP], NP, GyroP.Str.PLC_Lern); WriteCon(Time);*/ NP=0; } float Float(unsigned int TermoHi,unsigned int TermoLo) { char Data[4]; int SecDelta; int TempTD; union { float num; char byte[4]; } SimpleFloat; Data[0]=TermoLo&0xfff; Data[1]=TermoLo>>8; Data[2]=TermoHi&0xfff; Data[3]=TermoHi>>8; for(int i = 0; i < 4; i++) { SimpleFloat.byte[i] = Data[i]; } return SimpleFloat.num; } void CMD_M_Param_W(void) { unsigned int NP=0; unsigned int Param,temp,flash; unsigned int TempTermodataHi, TempTermodataLo; float Ttemp; NP = BuffTemp[3]; Param = (BuffTemp[4]<<8); Param |= BuffTemp[5]; GyroP.Array[NP] = Param; flash=GyroP.Array[115]; Gyro.NP=NP; WriteCon(Time); switch(NP) { case 63: if(GyroP.Str.TStatic_0&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_0 = GyroP.Str.TStatic_0 - 65536; else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_0 = GyroP.Str.TStatic_0; break; case 64: if(GyroP.Str.TStatic_1&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_1 = GyroP.Str.TStatic_1 - 65536; else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_1 = GyroP.Str.TStatic_1; break; case 65: if(GyroP.Str.TStatic_2&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_2 = GyroP.Str.TStatic_2 - 65536; else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_2 = GyroP.Str.TStatic_2; break; case 66: if(GyroP.Str.TStatic_3&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_3 = GyroP.Str.TStatic_3 - 65536; else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_3 = GyroP.Str.TStatic_3; break; case 67: if(GyroP.Str.TStatic_4&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_4 = GyroP.Str.TStatic_4 - 65536; else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_4 = GyroP.Str.TStatic_4; break; case 68: if(GyroP.Str.TStatic_5&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_5 = GyroP.Str.TStatic_5 - 65536; else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_5 = GyroP.Str.TStatic_5; break; case 69: if(GyroP.Str.TStatic_6&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_6 = GyroP.Str.TStatic_6 - 65536; else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_6 = GyroP.Str.TStatic_6; break; case 70: if(GyroP.Str.TStatic_7&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_7 = GyroP.Str.TStatic_7 - 65536; else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_7 = GyroP.Str.TStatic_7; break; case 71: if(GyroP.Str.TStatic_8&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_8 = GyroP.Str.TStatic_8 - 65536; else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_8 = GyroP.Str.TStatic_8; break; case 72: if(GyroP.Str.TStatic_9&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_9 = GyroP.Str.TStatic_9 - 65536; else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_9 = GyroP.Str.TStatic_9; break; case 73: if(GyroP.Str.TStatic_10&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_10 = GyroP.Str.TStatic_10 - 65536; else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_10 = GyroP.Str.TStatic_10; break; case 74: if(GyroP.Str.TStatic_11&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_11 = GyroP.Str.TStatic_11 - 65536; else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_11 = GyroP.Str.TStatic_11; break; case 75: if(GyroP.Str.TStatic_12&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_12 = GyroP.Str.TStatic_12 - 65536; else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_12 = GyroP.Str.TStatic_12; break; case 76: if(GyroP.Str.TStatic_13&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_13 = GyroP.Str.TStatic_13 - 65536; else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_13 = GyroP.Str.TStatic_13; break; case 160: if(GyroP.Str.TDCool_0&0x8000)TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_0 = GyroP.Str.TDCool_0 - 65536; else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_0 = GyroP.Str.TDCool_0; break; case 161: if(GyroP.Str.TDCool_1&0x8000)TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_1 = GyroP.Str.TDCool_1 - 65536; else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_1 = GyroP.Str.TDCool_1; break; case 162: if(GyroP.Str.TDCool_2&0x8000)TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_2 = GyroP.Str.TDCool_2 - 65536; else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_2 = GyroP.Str.TDCool_2; break; case 163: if(GyroP.Str.TDCool_3&0x8000)TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_3 = GyroP.Str.TDCool_3 - 65536; else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_3 = GyroP.Str.TDCool_3; break; case 164: if(GyroP.Str.TDCool_4&0x8000)TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_4 = GyroP.Str.TDCool_4 - 65536; else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_4 = GyroP.Str.TDCool_4; break; case 165: if(GyroP.Str.TDCool_5&0x8000)TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_5 = GyroP.Str.TDCool_5 - 65536; else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_5 = GyroP.Str.TDCool_5; break; case 166: if(GyroP.Str.TDCool_6&0x8000)TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_6 = GyroP.Str.TDCool_6 - 65536; else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_6 = GyroP.Str.TDCool_6; break; case 167: if(GyroP.Str.TDCool_7&0x8000)TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_7 = GyroP.Str.TDCool_7 - 65536; else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_7 = GyroP.Str.TDCool_7; break; case 168: if(GyroP.Str.TDCool_8&0x8000)TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_8 = GyroP.Str.TDCool_8 - 65536; else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_8 = GyroP.Str.TDCool_8; break; case 169: if(GyroP.Str.TDCool_9&0x8000)TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_9 = GyroP.Str.TDCool_9 - 65536; else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_9 = GyroP.Str.TDCool_9; break; case 170: if(GyroP.Str.TDCool_10&0x8000)TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_10 = GyroP.Str.TDCool_10 - 65536; else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_10 = GyroP.Str.TDCool_10; break; case 171: if(GyroP.Str.TDCool_11&0x8000)TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_11 = GyroP.Str.TDCool_11 - 65536; else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_11 = GyroP.Str.TDCool_11; break; case 172: if(GyroP.Str.TDCool_12&0x8000)TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_12 = GyroP.Str.TDCool_12 - 65536; else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_12 = GyroP.Str.TDCool_12; break; case 173: if(GyroP.Str.TDCool_13&0x8000)TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_13 = GyroP.Str.TDCool_13 - 65536; else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_13 = GyroP.Str.TDCool_13; break; case 78: TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_0 = Float(GyroP.Str.TermoDeltaStatic_0, GyroP.Str.TermoDeltaStatic_1 ); break; case 80: TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_1 = Float(GyroP.Str.TermoDeltaStatic_2, GyroP.Str.TermoDeltaStatic_3 ); break; case 82: TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_2 = Float(GyroP.Str.TermoDeltaStatic_4, GyroP.Str.TermoDeltaStatic_5 ); break; case 84: TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_3 = Float(GyroP.Str.TermoDeltaStatic_6, GyroP.Str.TermoDeltaStatic_7 ); break; case 86: TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_4 = Float(GyroP.Str.TermoDeltaStatic_8, GyroP.Str.TermoDeltaStatic_9 ); break; case 88: TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_5 = Float(GyroP.Str.TermoDeltaStatic_10,GyroP.Str.TermoDeltaStatic_11); break; case 90: TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_6 = Float(GyroP.Str.TermoDeltaStatic_12,GyroP.Str.TermoDeltaStatic_13); break; case 92: TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_7 = Float(GyroP.Str.TermoDeltaStatic_14,GyroP.Str.TermoDeltaStatic_15); break; case 94: TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_8 = Float(GyroP.Str.TermoDeltaStatic_16,GyroP.Str.TermoDeltaStatic_17); break; case 96: TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_9 = Float(GyroP.Str.TermoDeltaStatic_18,GyroP.Str.TermoDeltaStatic_19); break; case 98: TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_10 = Float(GyroP.Str.TermoDeltaStatic_20,GyroP.Str.TermoDeltaStatic_21); break; case 100: TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_11 = Float(GyroP.Str.TermoDeltaStatic_22,GyroP.Str.TermoDeltaStatic_23); break; case 102: TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_12 = Float(GyroP.Str.TermoDeltaStatic_24,GyroP.Str.TermoDeltaStatic_25); break; case 104: TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_13 = Float(GyroP.Str.TermoDeltaStatic_26,GyroP.Str.TermoDeltaStatic_27); break; case 175: TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_0 = Float(GyroP.Str.TermoDynamicData_0, GyroP.Str.TermoDynamicData_1 ); break; case 177: TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_1 = Float(GyroP.Str.TermoDynamicData_2, GyroP.Str.TermoDynamicData_3 ); break; case 179: TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_2 = Float(GyroP.Str.TermoDynamicData_4, GyroP.Str.TermoDynamicData_5 ); break; case 181: TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_3 = Float(GyroP.Str.TermoDynamicData_6, GyroP.Str.TermoDynamicData_7 ); break; case 183: TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_4 = Float(GyroP.Str.TermoDynamicData_8, GyroP.Str.TermoDynamicData_9 ); break; case 185: TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_5 = Float(GyroP.Str.TermoDynamicData_10, GyroP.Str.TermoDynamicData_11); break; case 187: TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_6 = Float(GyroP.Str.TermoDynamicData_12, GyroP.Str.TermoDynamicData_13); break; case 189: TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_7 = Float(GyroP.Str.TermoDynamicData_14, GyroP.Str.TermoDynamicData_15); break; case 191: TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_8 = Float(GyroP.Str.TermoDynamicData_16, GyroP.Str.TermoDynamicData_17); break; case 193: TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_9 = Float(GyroP.Str.TermoDynamicData_18, GyroP.Str.TermoDynamicData_19); break; case 195: TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_10 = Float(GyroP.Str.TermoDynamicData_20, GyroP.Str.TermoDynamicData_21); break; case 197: TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_11 = Float(GyroP.Str.TermoDynamicData_22, GyroP.Str.TermoDynamicData_23); break; case 199: TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_12 = Float(GyroP.Str.TermoDynamicData_24, GyroP.Str.TermoDynamicData_25); break; case 201: TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_13 = Float(GyroP.Str.TermoDynamicData_26, GyroP.Str.TermoDynamicData_27); break; //case 0: Gyro.My_Addres = GyroP.Str.My_Addres; break; case 159: Gyro.step = GyroP.Str.Step; 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); else Spi.DAC_A = ((((int)(GyroP.Str.DAC_current_Work+ 0x7fff)&0xffff)+22544)*0.65); break; case 4: if(Gyro.LG_Type) Gyro.HFO_Min=0xffff-GyroP.Str.DAC_current_Start; break; //((int)(GyroP.Str.DAC_current_Start*0.67)-2000); break; case 5: Gyro.TimeToJump = GyroP.Str.TimeToJump; break; case 6: Gyro.JumpDelta = GyroP.Str.JumpDelta; break; case 7: Gyro.PLC_Phase = GyroP.Str.PLC_Phase; break; case 8: Gyro.PLC_Gain = GyroP.Str.PLC_Gain; break; case 12: Gyro.FrqPhase = GyroP.Str.FrqPhase; break; case 13: Gyro.FrqChengSpeed = GyroP.Str.FrqChengSpeed; break; case 14: Gyro.FrqHZ = (7680000 / GyroP.Str.FrqHZ); Gyro.Frq = (7680000 / GyroP.Str.FrqHZ)<<16; break; case 15: Gyro.FrqHZmin = (7680000 / GyroP.Str.FrqHZmin)<<16; break; case 16: Gyro.FrqHZmax = (7680000 / GyroP.Str.FrqHZmax)<<16; break; case 18: temp=((GyroP.Str.VB_Fdf_Hi<<16) | GyroP.Str.VB_Fdf_Lo); temp=temp*20; Gyro.AmpTarget=(unsigned int)(temp); break; case 19: Gyro.AmpSpeed = GyroP.Str.AmpSpeed; break; case 20: Gyro.AmpPerMin = GyroP.Str.AmpPerMin; break; case 21: Gyro.AmpPerMax = GyroP.Str.AmpPerMax; break; case 22: Gyro.AmpPer = GyroP.Str.AmpPer; Gyro.Amp = GyroP.Str.AmpPer<<16; break; case 23: Gyro.AmpMin = GyroP.Str.AmpMin; break; case 24: Gyro.AmpTD = GyroP.Str.AmpTD; break; case 25: Gyro.AmpPerDel = GyroP.Str.AmpPerDel; break; case 33: Gyro.ShiftMod = GyroP.Str.ShiftMod; break; case 34: Gyro.ModAmp = GyroP.Str.ModAmp; break; case 56: Gyro.Gain_Sin = GyroP.Str.Gain_Sin; Out_G_photo(Gyro.Gain_Sin, Gyro.Gain_Cos); break; case 57: Gyro.Gain_Cos = GyroP.Str.Gain_Cos; Out_G_photo(Gyro.Gain_Sin, Gyro.Gain_Cos); break; case 60: Gyro.GLD_Serial = GyroP.Str.GLD_Serial; break; // case 62: Gyro.TermoMod = GyroP.Str.TermoMode; break; case 10: Gyro.DownTreshold = (unsigned int)((GyroP.Str.DownTreshold-0x7fff)&0xffff); break; case 11: Gyro.HighTreshold = (unsigned int)((GyroP.Str.HighTreshold-0x7fff)&0xffff); break; case 9: Gyro.PLCDelay = GyroP.Str.PLCDelay; break; case 105:Gyro.ResetLevelCool = (unsigned int)((GyroP.Str.ResetLevelCool-0x7fff)&0xffff); break; case 116:Gyro.HFO_Gain_Reset_PLC = GyroP.Str.HFO_Gain_Reset_PLC; break; case 55: Gyro.ResetLevelHeat = (unsigned int)((GyroP.Str.ResetLevelHeat-0x7fff)&0xffff); break; case 47: if(GyroP.Str.Tmp_OffsetT4&0x8000) Gyro.Tmp_OffsetT4 = GyroP.Str.Tmp_OffsetT4 - 65536; else Gyro.Tmp_OffsetT4 = GyroP.Str.Tmp_OffsetT4; break; case 48: if(GyroP.Str.Tmp_OffsetT5&0x8000) Gyro.Tmp_OffsetT5 = GyroP.Str.Tmp_OffsetT5 - 65536; else Gyro.Tmp_OffsetT5 = GyroP.Str.Tmp_OffsetT5; break; } NP=0; BuffTemp[0] = Gyro.SOC_Out; BuffTemp[1] = Gyro.My_Addres; BuffTemp[2] = Gyro.CMD_In; BuffTemp[3] =0; //(//GyroP.Array[NP]>> 8) & 0xff;//старший байт требуемого параметра Check(BuffTemp, 6); WriteConN (BuffTemp,6); if(flash){GyroP.Array[115]=0; flash=0; WriteFlash(); ReadFlash ();} } void CMD_Maintenance(void) { unsigned int Temp; sprintf((Time),"%d %d\r\n", Spi.DAC_B, PlcWormDeltaout); WriteCon(Time); /* sprintf((Time),"%d\r\n",convertStrToTime(__DATE__)); WriteCon(Time);*/ 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; Temp = Gyro.Firmware_Version;//17543; //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); WriteConN (BuffTemp,8); } void CMD_B_Delta(void) { Gyro.Event_500Hz=0; Gyro.EXT_Latch=0; unsigned int Temp; BuffTemp[ 0] = Gyro.SOC_Out; BuffTemp[ 1] = Gyro.My_Addres; Temp = Gyro.CuruAngle; Gyro.CuruAngle = 0; BuffTemp[ 2] =(Temp >> 16) & 0xff;//младший байт разности счетчиков BuffTemp[ 3] =(Temp >> 8) & 0xff;//младший байт разности счетчиков BuffTemp[ 4] =(Temp >> 0) & 0xff;//младший байт разности счетчиков BuffTemp[ 5] = 0x00000000; Check(BuffTemp, 8); WriteConN (BuffTemp,8); } void CMD_Delta_Bins(void) { Gyro.Event_500Hz=0; unsigned int Temp; BuffTemp[ 0] = Gyro.SOC_Out; BuffTemp[ 1] = Gyro.My_Addres; Temp = Gyro.CuruAngle; Gyro.CuruAngle = 0; BuffTemp[ 2] =(Temp >> 24) & 0xff;//старший байт разности счетчиков BuffTemp[ 3] =(Temp >> 16) & 0xff;//младший байт разности счетчиков BuffTemp[ 4] =(Temp >> 8) & 0xff;//младший байт разности счетчиков BuffTemp[ 5] =(Temp >> 0) & 0xff;//младший байт разности счетчиков BuffTemp[ 6] = 0x0000; Check(BuffTemp, 9); WriteConN (BuffTemp,9); } void CMD_Delta_PS(void) { int drob,Temp1; float Temp2=0; unsigned int Temp; Gyro.Event_500Hz=0; BuffTemp[ 0] = Gyro.SOC_Out; BuffTemp[ 1] = Gyro.My_Addres; Gyro.CuruAngle = Gyro.CuruAngle + OldCuruAngle + Gyro.AngelCompens; Gyro.AngelCompens=0; OldCuruAngle=Gyro.CuruAngle & 0xf; //сохраняем 3 бит для след измирений Temp=Gyro.CuruAngle>>4; //приводим к форме вывода Gyro.CuruAngle = 0; //Temp=200; BuffTemp[ 2] =(Temp >> 8) & 0xff;//старший байт разности счетчиков BuffTemp[ 3] =(Temp >> 0) & 0xff;//младший байт разности счетчиков BuffTemp[ 4] = CountParam; switch(CountParam) { //F_ras case 0: OutDeltaPS = Gyro.F_ras; BuffTemp[5] = (OutDeltaPS >> 8) & 0xff; break; case 1: BuffTemp[5] = (OutDeltaPS >> 0) & 0xff; break; //HFO case 2: OutDeltaPS = 0xffff - Spi.DAC_A; BuffTemp[5] = (OutDeltaPS >> 8) & 0xff; break; case 3: BuffTemp[5] = (OutDeltaPS >> 0) & 0xff; break; //T_Vibro case 4: OutDeltaPS = Gyro.Frq>>12;//(unsigned int)(7680000/(Gyro.Frq>>16)); BuffTemp[5] = (OutDeltaPS >> 8) & 0xff; break; case 5: BuffTemp[5] = (OutDeltaPS >> 0) & 0xff; break; //L_Vibro case 6: //Temp = Gyro.L_vibro>>1; OutDeltaPS = Gyro.AmpPer; BuffTemp[5] = (OutDeltaPS >> 8) & 0xff; break; case 7: BuffTemp[5] = (OutDeltaPS >> 0) & 0xff; break; //Напряжение на регуляторе периметра case 8: OutDeltaPS = ((Spi.DAC_B-0x7fff)&0xffff); BuffTemp[5] = (OutDeltaPS >> 8) & 0xff; break; case 9: BuffTemp[5] = (OutDeltaPS >> 0) & 0xff; break; //темпкратурный канал 0 case 10: OutDeltaPS = 0; BuffTemp[5] = (OutDeltaPS >> 8) & 0xff; break; case 11: BuffTemp[5] = (OutDeltaPS >> 0) & 0xff; break; //f case 12: OutDeltaPS =0;//(unsigned int)(0x7fff-Spi.ADC5)*0.79; // Temp = Gyro.AD_Slow >> 16; BuffTemp[5] = (OutDeltaPS >> 8) & 0xff; break; case 13: BuffTemp[5] = (OutDeltaPS >> 0) & 0xff; break; //ток 1 case 14: //Temp = Gyro.In1; IntOutDeltaPS = 0;//((Gyro.In1>>1)*0.800875)-0x3e0b; BuffTemp[5] = (IntOutDeltaPS >> 8) & 0xff;//in1//2 break; case 15: BuffTemp[5] = (IntOutDeltaPS >> 0) & 0xff; break; //ток 2 case 16: // Temp = Gyro.In2; IntOutDeltaPS =0;// ((Gyro.In2>>1)*0.800875)-0x3e0b; BuffTemp[5] = (IntOutDeltaPS >> 8) & 0xff; break; case 17: BuffTemp[5] = (IntOutDeltaPS >> 0) & 0xff;//in2//3 break; //разностный температурный канал Delta Temp case 18: OutDeltaPS = 0; OutDeltaPS = Gyro.DeltaT; BuffTemp[5] = (OutDeltaPS >> 8) & 0xff;//дельта break; case 19: BuffTemp[5] = (OutDeltaPS >> 0) & 0xff; break; //температурный канал 5 case 20: OutDeltaPS = 0; OutDeltaPS = Gyro.Termo; BuffTemp[5] =(OutDeltaPS >> 8) & 0xff;//температура break; case 21: BuffTemp[5] =(OutDeltaPS >> 0) & 0xff;//ADC6 sesnsor 5 /* sprintf((Time),"%d %d \r\n", Spi.ADC1, Spi.ADC5 ); WriteCon(Time);*/ break; } Check(BuffTemp, CRC_N); WriteConN (BuffTemp,CRC_N); if(CountParam>20)CountParam=0;//зацикливания буфера от 0 до 21 else CountParam++; } void M_Rate5K(void) { unsigned int Temp; //Temp=Gyro.CuruAngle; //приводим к форме вывода BuffTemp[ 3] =(Gyro.CuruAngle >> 8) & 0xff;//старший байт разности счетчиков 7 --младший байт разности счетчиков BuffTemp[ 2] =(Gyro.CuruAngle >> 0) & 0xff;//младший байт разности счетчиков 8 --старший байт разности счетчиков Gyro.CuruAngle=0; Temp = ((Spi.DAC_B-0x7fff)&0xffff); BuffTemp[5] = (Spi.DAC_B >> 8) & 0xff; //23 Выход регулятора рабочего периметра BuffTemp[4] = (Spi.DAC_B >> 0) & 0xff; Temp = 0xffff - Spi.DAC_A; BuffTemp[7] =(Temp >> 8) & 0xff;//выход регулятора гвч; 11 --выход регулятора ГВЧ BuffTemp[6] =(Temp >> 0) & 0xff; /* sprintf((Time),"%d %d %d\r\n",Gyro.CuruAngle,(Spi.DAC_B-0x7fff),Temp); WriteCon(Time);*/ //Check(BuffTemp, 7); WriteConN (BuffTemp,8); Gyro.EvenRate5K++; } void CMD_Rate(void) { Gyro.Rate1_Event=0; unsigned int Temp; int Temp1; float Temp2; BuffTemp[ 0] = Gyro.SOC_Out; //1 --старт данных BuffTemp[ 1] = Gyro.My_Addres; //2 --адрес отвечающего устройствва BuffTemp[ 2] =( Gyro.CaunPlusReper >> 8) & 0xff;//старший байт счетчика +. 3 --сарший байт счентчика + BuffTemp[ 3] =( Gyro.CaunPlusReper >> 0) & 0xff;//младший байт счетчика +. 4 --младший байт счетчика + BuffTemp[ 4] =( Gyro.CaunMinReper >> 8) & 0xff;//старший байт счетчика -. 5 --сарший байт счентчика - BuffTemp[ 5] =( Gyro.CaunMinReper >> 0) & 0xff;//младший байт счетчика -. 6 --младший байт счетчика - Gyro.CuruAngle = Gyro.CuruAngle + OldCuruAngle + Gyro.AngelCompens; //(72 град/с) OldCuruAngle=Gyro.CuruAngle & 0x3f; //сохраняем 5 бит для след измирений Temp=Gyro.CuruAngle>>6; //приводим к форме вывода Gyro.AngelCompens=0; Gyro.CuruAngle = 0; BuffTemp[ 6] =(Temp >> 8) & 0xff;//старший байт разности счетчиков 7 --младший байт разности счетчиков BuffTemp[ 7] =(Temp >> 0) & 0xff;//младший байт разности счетчиков 8 --старший байт разности счетчиков BuffTemp[38] =(Temp >> 24) & 0xff;; //39 приращение угла BuffTemp[39] =(Temp >> 16) & 0xff;; //40 формат 22.10 BuffTemp[40] =(Temp >> 8) & 0xff;; //41 1бит знак BuffTemp[41] =(Temp >> 0) & 0xff;; //42 Temp = Gyro.F_ras; //Gyro.F_ras=0; BuffTemp[ 8] = (Temp >> 8) & 0xff;//расщипление частота 9 --частота расщипления BuffTemp[ 9] = (Temp >> 0) & 0xff;// 10 --частота расщипления //(unsigned int)((Gyro.DacIn+30000)*0.6667); Temp1 = 0xffff - Spi.DAC_A; BuffTemp[10] = (Temp1 >> 8) & 0xff;//выход регулятора гвч; 11 --выход регулятора ГВЧ BuffTemp[11] = (Temp1 >> 0) & 0xff; //12 --выход регулятора ГВЧ Temp =(int)(tempDeltaRegul); //для призмы tempDeltaRegul=0; BuffTemp[12]=(Temp >> 8) & 0xff;//// HFO 13 --сигнал ошибки регулятора ГВЧ BuffTemp[13]=(Temp >> 0) & 0xff;//// 14 --сигнал ошибки регулятора ГВЧ //Temp = (unsigned int)((7675000*16/(Gyro.Frq>>12))); Temp = Gyro.Frq>>12;//(unsigned int)(7680000/(Gyro.Frq>>16)); BuffTemp[14] = (Temp >> 8) & 0xff; //15 период вибропривода.(частота) T_Vibro BuffTemp[15] = (Temp >> 0) & 0xff; //16 период вибропривода. Temp = Gyro.FrqPhaseEror<<2;//Spi.DAC_A-0x7fff; BuffTemp[16] = (Temp >> 8) & 0xff; //17 старший байт ФД регулятора периода вибропривода BuffTemp[17] = (Temp >> 0) & 0xff; /*sprintf((Time),"%d %d\r\n",Gyro.FrqPhaseEror, Gyro.FrqPhaseEror<<2); WriteCon(Time); */ //18 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 Temp = 0x0;//Gyro.L_vibro<<2; BuffTemp[20] = (Temp >> 8) & 0xff;//регулятор датчика угла поворота //21 старший байт регулятора датчика угла поворота BuffTemp[21] = (Temp >> 0) & 0xff; //22 Temp1 =((Spi.DAC_B-0x7fff)&0xffff);///(3300+(0x7fff+(Spi.DAC_B*1.083))); BuffTemp[22] = (Temp1 >> 8) & 0xff; //23 Выход регулятора рабочего периметра BuffTemp[23] = (Temp1 >> 0) & 0xff; //24 Temp = PLC_EROR; PLC_EROR=0; BuffTemp[24] = (Temp >> 8) & 0xff;// //25 ФД СРП BuffTemp[25] = (Temp >> 0) & 0xff;// //26 ФД СРП Temp =0;/* Gyro.AD_Slow >> 16*/; BuffTemp[26] = (Temp >> 8) & 0xff; //27 ADC 0 BuffTemp[27] = (Temp >> 0) & 0xff; //28 Temp = 0; /*Gyro.AD_Slow >> 16*/; BuffTemp[28] = (Temp >> 8) & 0xff; //29 ADC 1 BuffTemp[29] = (Temp >> 0) & 0xff; //30 Temp1 =Gyro.DeltaTRate;//((Gyro.In1>>1)*0.800875)-0x3e0b; BuffTemp[30] = (Temp1 >> 8) & 0xff;//in1//2 //31 ADC 2 BuffTemp[31] = (Temp1 >> 0) & 0xff; //32 Temp1 =Gyro.DeltaTRate/163;//((Gyro.In2>>1)*0.800875)-0x3e0b;// - 0x4FFF; BuffTemp[32] = (Temp1 >> 8) & 0xff; //33 ADC 3 BuffTemp[33] = (Temp1 >> 0) & 0xff;//in2//3 //34 Temp = Gyro.Termo; BuffTemp[34] = (Temp >> 8) & 0xff;//дельта //35 ADC 4 BuffTemp[35] = (Temp >> 0) & 0xff; //36 // Temp = 000; Temp = (Gyro.DeltaT); BuffTemp[36] =(Temp >> 8) & 0xff;//температура //37 ADC 5 BuffTemp[37] =(Temp >> 0) & 0xff;//ADC6 sesnsor 5 //38 Check(BuffTemp, 44); WriteConN (BuffTemp,44); for(int i=0; i<45;i++) {BuffTemp[i]=0;} } void CMD_Rate2(void) { unsigned int Temp; //float y = 52646.45 Gyro.Reper_Event=0; for(int q=0; q<64; q++) { BuffTemp[q]=0; } BuffTemp[ 0] = Gyro.SOC_Out; BuffTemp[ 1] = Gyro.My_Addres; Temp=Gyro.CaunPlusReper; BuffTemp[ 2] =(Temp >> 8) & 0xff;//старший байт счетчика +. BuffTemp[ 3] =(Temp >> 0) & 0xff;//младший байт счетчика +. //сохраняем 5 бит для след измирений Temp= Gyro.CaunMinReper; BuffTemp[ 4] =(Temp >> 8) & 0xff;//старший байт счетчика -. BuffTemp[ 5] =(Temp >> 0) & 0xff;//младший байт счетчика -. Check(BuffTemp, 8); WriteConN (BuffTemp,8); } void CMD_Rate3(void) { Gyro.Rate3_Event=0; BuffTemp[ 0] = Gyro.SOC_Out; BuffTemp[ 1] = Gyro.My_Addres; BuffTemp[ 2] = 0xcc;//старший байт счетчика +. BuffTemp[ 3] = 0xcc;//младший байт счетчика +. BuffTemp[ 4] =0xBB;//старший байт счетчика -. BuffTemp[ 5] =0xBB;//младший байт счетчика -. Check(BuffTemp, 8); WriteConN (BuffTemp,8); } void CMD_M_Stymul() { int temp,Consol=0,HFO,b4; float Temp1; temp=BuffTemp[3]; b4 = temp; Consol = temp>>7; HFO = temp&0x3;// // (номер (код) ЦАПа 0...3, HFO - 3dac, PLC - 0DAC temp = (((BuffTemp[4]<<8) | BuffTemp[5])&0xFFFF); if(HFO) { Gyro.DacIn=temp; if(Gyro.LG_Type==1) Spi.DAC_A = 0xffff-Gyro.DacIn; //((unsigned int)((Gyro.DacIn+0x7011)*0.6667)); else Spi.DAC_A = (unsigned int)(0xffff-Gyro.DacIn); //Spi.DAC_A = ((unsigned int)((Gyro.DacIn+23200)*0.64)); } else Spi.DAC_B = (unsigned int)((temp-0x7fff)&0xffff); /*sprintf((Time),"%d %d \r\n", Spi.DAC_B, temp); WriteCon(Time); */ for(int q=0; q<64; q++) { BuffTemp[q]=0; } BuffTemp[0] = Gyro.SOC_Out; //DD BuffTemp[1] = Gyro.My_Addres; //00 BuffTemp[2] = Gyro.CMD_In; //D9 BuffTemp[3] =0; Check(BuffTemp, CRC_N); WriteConN (BuffTemp,CRC_N); } void CMD_M_vib() { unsigned int temp1,temp2,anser; temp1 = (((BuffTemp[4]<<8) | BuffTemp[5])&0xFFFF); 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; BuffTemp[2] = Gyro.CMD_In; BuffTemp[3] = 0x0; BuffTemp[4] = 0x0; Check(BuffTemp, CRC_N); WriteConN (BuffTemp,CRC_N); } void CMD_M_Control_D8()///установка\сброс регистров управления { unsigned int bit=0,Pa=0; unsigned int SR=0,V=0,Bit_num=0,A=0; Pa = BuffTemp[3]; SR = Pa >> 7; V = (Pa>>5)&0x3; A = (Pa>>4)&0x1; Bit_num = Pa & 0xf; switch (SR) { case 0: switch (A) { case 0: switch (Bit_num) { case 0x06: FrqOFF break; case 0x05: AVibOFF break; case 0x01: HFOOFF break; case 0x03: PlcOFF break; case 0x02: Gyro.RgConA &= ~(1<<2); break; } break; case 1: switch (Bit_num) { case 0x00: Gyro.RgConB &= ~(1<<0); break; case 0x01: Gyro.RgConB &= ~(1<<1); break; case 0x02: Gyro.RgConB &= ~(1<<2); break; } break; } break; case 1: switch (A) { case 0: switch (Bit_num) { case 0x06: FrqON break; case 0x05: AVibON break; case 0x01: HFOON break; case 0x03: PlcON break; case 0x02: Gyro.RgConA |= (1<<2); break; } break; case 1: switch (Bit_num) { case 0x00: Gyro.RgConB |= (1<<0); break; case 0x01: Gyro.RgConB |= (1<<1); break; case 0x02: Gyro.RgConB |= (1<<2); break; } break; } break; } BuffTemp[0] = Gyro.SOC_Out; //DD BuffTemp[1] = Gyro.My_Addres; //00 BuffTemp[2] = Gyro.CMD_In; //D8 switch (A) { case 0: BuffTemp[ 4] =(Gyro.RgConA >> 8) & 0xff; BuffTemp[ 5] =(Gyro.RgConA >> 0) & 0xff; break; case 1: BuffTemp[ 4] =(Gyro.RgConB >> 8) & 0xff; BuffTemp[ 5] =(Gyro.RgConB >> 0) & 0xff; break; } Check(BuffTemp, CRC_N); WriteConN (BuffTemp,CRC_N); } void CMD_M_Control_D9()///чтение регистров управления { int bit,NReg,param=0; BuffTemp[0] = Gyro.SOC_Out; //DD BuffTemp[1] = Gyro.My_Addres; //00 BuffTemp[2] = Gyro.CMD_In; //D9 param = BuffTemp[3]; if (param) { BuffTemp[3]=1<<4; BuffTemp[4] = (Gyro.RgConB>>8 ) & 0xff; BuffTemp[5] = Gyro.RgConB & 0xff; } else { BuffTemp[3]=0<<4; BuffTemp[4] = (Gyro.RgConA>>8 )& 0xff; BuffTemp[5] = Gyro.RgConA & 0xff; } Check(BuffTemp, CRC_N); WriteConN (BuffTemp,CRC_N); } // (номер (код) ЦАПа 0...3, старший байт требуемого ЦАПа, младший байт треб ЦАПа) void GLDStartDischarg(void) { TimeDischarg=0; Try=0; switch(Gyro.My_Addres) {//смещение поджига и подсветки в зависимости от адреса ГЛД case 0: Gyro.Discharg = StartDischarg << ShiftStart0; Gyro.BackLight = StartBackLight << ShiftStart0; break; case 1: Gyro.Discharg = StartDischarg << ShiftStart1; Gyro.BackLight = StartBackLight << ShiftStart1; break; case 2: Gyro.Discharg = StartDischarg << ShiftStart2; Gyro.BackLight = StartBackLight << ShiftStart2; break; case 3: Gyro.Discharg = StartDischarg << ShiftStart3; Gyro.BackLight = StartBackLight << ShiftStart3; break; } } void Gph_W() { //Gyro.flagGph_W=3; Out_G_photo(BuffTemp[4],BuffTemp[5]); BuffTemp[0] = Gyro.SOC_Out; //DD BuffTemp[1] = Gyro.My_Addres; //00 BuffTemp[2] = Gyro.CMD_In; //D9 BuffTemp[3] = 0; Check(BuffTemp, CRC_N); WriteConN (BuffTemp,CRC_N); } void DeviceMode() { int TempMod=1; BuffTemp[0] = Gyro.SOC_Out; //DD BuffTemp[1] = Gyro.My_Addres; //00 BuffTemp[2] = Gyro.CMD_In; //D9 TempMod = BuffTemp[3] & 0xf; Gyro.Device_Mode = TempMod; sprintf((Time)," Comand - DeviceMode(); Gyro.Device_Mode = %d Gyro.ModeOut = %d\r\n",Gyro.Device_Mode,Gyro.ModeOut); WriteCon(Time); /* sprintf((Time),"%d\r\n",Gyro.Device_Mode); WriteCon(Time);*/ BuffTemp[3]=Gyro.Device_Mode & 0xff; BuffTemp[4]=0; BuffTemp[5]=0; Check(BuffTemp, CRC_N); WriteConN (BuffTemp,CRC_N); } unsigned int Check(char *c, unsigned int Count) { int i=1; unsigned int temp,CRC; temp=1; CRC=0; for(; i<Count-2; i++) { CRC+=c[i]; } if(c[Count-2]!=((CRC>>8)&0xFF)) { temp=0; Gyro.RsErrLine = (Gyro.RsErrLine)&=0x2; } if(c[Count-1]!=((CRC>>0)&0xFF)) { temp=0; // Gyro.RsErrLine= (Gyro.RsErrLine)=0x2; } c[Count-2]=(CRC>>8)&0xFF; c[Count-1]=(CRC>>0)&0xFF; return temp; } int Getlengf(void) { unsigned int lengf; lengf = 1; switch(Gyro.CMD_In) { case 0x99: lengf=6; CRC_N=8; break; //Mintainance case 0xB0: lengf=6; CRC_N=9; break; //Delta_Bins case 0x0F: lengf=6; CRC_N=8; break; //Delta_Bins case 0xA0: lengf=6; CRC_N=8; break; //Delta_PS case 0xDD: lengf=6; CRC_N=44; break; //m_rate case 0x0A: lengf=8; CRC_N=6; break; //m_stymul case 0xE9: lengf=6; CRC_N=8; break; //DeviceMode case 0xE8: lengf=6; CRC_N=8; break; //DeviceMode case 0xA5: lengf=6; CRC_N=8; break; //DeviceMode case 0xD8: lengf=6; CRC_N=8; break; //m_control case 0xD9: lengf=6; CRC_N=8; break; //m_control case 0xE4: lengf=8; CRC_N=6; break; //M_VIB_W case 0xE6: lengf=8; CRC_N=6; break; //M_Gph_W } return lengf; } void Read_CMD(void) { Gyro.RsErrLine = (Gyro.RsErrLine)& 0xffff;//для сброса ошибки CountBuFFIn=ReadChekCon1(BuffTemp); // чтение данных из консоли if(CountBuFFIn==1) { // если есть первый байт if (BuffTemp[0] != SOC_In) { ReadCon1(BuffTemp); Gyro.RsErrLine += 0x100; //BuffTemp[99]=Gyro.RsErrLine; ReadCon1(BuffTemp); } } else if(CountBuFFIn==2) //если второй байт { // широковещаительный if (BuffTemp[1] != Gyro.My_Addres /*|| BuffTemp[1] !=0x1f*/) { ReadCon1(BuffTemp); Gyro.RsErrLine += 0x1; ReadCon1(BuffTemp); } } else if(CountBuFFIn==3) // если третий байт { Gyro.CMD_In=BuffTemp[2]; N=Getlengf(); } else if(CountBuFFIn==4 && (N==6)) { // N - длина посылки аскглд(для записи параметров). определяется по коду команды в Getlengf(); Param1=BuffTemp[3]; } else if((CountBuFFIn==5)&&(N==7)) { Param1=BuffTemp[3]; Param2=BuffTemp[4]; } else if((CountBuFFIn==6)&&(N==8)) { Param1=BuffTemp[3]; Param2=BuffTemp[4]; Param3=BuffTemp[5]; } else if((CountBuFFIn==8)&&(N==10)) { Param1=BuffTemp[4]; Param2=BuffTemp[5]; Param3=BuffTemp[6]; Param4=BuffTemp[7]; } else if(CountBuFFIn > (N-1)) { ReadCon1(BuffTemp); //if(SA)CMD_M_Stymul_Answer(); // if(d8_anser)D8_Answer(); switch(Gyro.CMD_In) { // case 0xA5: DeviceMode() ; break; case 0x99: /*Gyro.ModeOut=0;*/CMD_Maintenance(); break; case 0xD8: CMD_M_Control_D8(); break; case 0xE9: CMD_M_Param_R(); break; //чтение параметров case 0xE8: CMD_M_Param_W(); break; //запись параметра case 0xDA: GLDStartDischarg(); break; case 0xD9: CMD_M_Control_D9(); break; case 0x0A: CMD_M_Stymul(); break; case 0xDD: TempParam=(BuffTemp[3]) & 0x9f; //Rate switch(TempParam) { case Rate1 : CMD_Rate(); break; //case Rate2 : Gyro.ModeOut=9; break; case Rate3 : CMD_Rate3(); break; case PRate1 : Gyro.ModeOut=1; break; case PRate2 : Gyro.ModeOut=2; break; case PRate3 : Gyro.ModeOut=8; break; case Rate7 : CMD_Rate7(); break; case PRate7 : Gyro.ModeOut=10; break; case Rate5K : M_Rate5K(); break; case PRate5K: if(Gyro.ModeOut){} else Gyro.ModeOut=11; break; } break; //DropDelay(); выставка задержки для мультидропа сбрасывается в команде CMD_Maintenance() на () микросекунд; case 0xA0: /*DropDelay();*/ // TempParam=(BuffTemp[3]) & 0x80; //Delta_PS switch(Gyro.Device_Mode) { case 0: Gyro.ModeOut=3; Gyro.Event_500Hz=0; break; case 4: Gyro.ModeOut=4; break; } sprintf((Time)," Comand - B_Delta_PS(); Gyro.Device_Mode = %d Gyro.ModeOut = %d\r\n", Gyro.Device_Mode, Gyro.ModeOut); WriteCon(Time); break; case 0xB0: DropDelay(); TempParam = TempParam=(BuffTemp[3]>>7); //Delta_Bins switch(TempParam) { case PDelta_Bins: Gyro.ModeOut=5; Gyro.Event_500Hz=0; break; case Delta_Bins : CMD_Delta_Bins(); break; } break; case 0x0F: DropDelay(); TempParam = (((BuffTemp[3])>>4) & 0x9); //B_Delta switch(TempParam) { case PB_Delta_EXT: Gyro.ModeOut=6; break; case PB_Delta_INT: Gyro.ModeOut=7; Gyro.Event_500Hz=0; break; case B_Delta_EXT: CMD_B_Delta(); break; case B_Delta_INT: CMD_B_Delta(); break; } break; case 0xE4: CMD_M_vib(); break; case 0xA5: DeviceMode(); break; case 0xE6: Gph_W(); break; Gyro.RsErrLine = 0; } } } void TechLog(void) { unsigned int temp=0; if (ReadCon (Time)) { int a=0; if (Time[0] == 'r') { //Mod 250 Hz PLCRegul250(); // InitPlcFilt () ; } if (Time[0] == 'y') { //Mod 250 Hz PLCRegul250(); if( Gyro.Debag) Gyro.Debag=0; else Gyro.Debag=1; } if (Time[0] == 'u') { //Mod 250 Hz PLCRegul250(); if( Gyro.Debag2) Gyro.Debag2=0; else Gyro.Debag2=1; } if (Time[0] == 'C') Spi.DAC_A+=32; if (Time[0] == 'c') Spi.DAC_A-=32; if (Time[0] == 'V') Spi.DAC_A+=160; if (Time[0] == 'v') Spi.DAC_A-=160; if (Time[0] == 'X') Spi.DAC_B+=1653; if (Time[0] == 'x') Spi.DAC_B-=1653; if (Time[0] == 'Z') Spi.DAC_B+=3306; if (Time[0] == 'z') Spi.DAC_B-=3306; ///////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// //////////////////////Выбор FlashMod/////////////////////////// //////////////////////////////////////////////////////////////// } }