forkd

Dependencies:   mbed

Fork of LG2 by Dmitry Kovalev

Committer:
Kovalev_D
Date:
Tue Dec 26 05:14:09 2017 +0000
Revision:
226:4a4d5bd5fcd7
Parent:
225:f8fee6c586cc
Child:
227:2774b56bfab0
4hfo_1plc

Who changed what in which revision?

UserRevisionLine numberNew contents of line
igor_v 0:8ad47e2b6f00 1 #include "stdlib.h"
Kovalev_D 197:7a05523bf588 2 //#include "math.h"
igor_v 0:8ad47e2b6f00 3 #include "LPC17xx.h"
igor_v 0:8ad47e2b6f00 4 #include "Global.h"
Kovalev_D 106:250ddd8629c6 5 int tempNH,tempNL;
igor_v 0:8ad47e2b6f00 6 unsigned int Rate_Flag;
igor_v 0:8ad47e2b6f00 7 unsigned int CountBuFFIn;
igor_v 21:bc8c1cec3da6 8 unsigned int N=0,CRC_N;
Kovalev_D 214:4c70e452c491 9 unsigned int Rate_7=0;
Kovalev_D 214:4c70e452c491 10 int iRate_7=0;
igor_v 21:bc8c1cec3da6 11 unsigned int Param1=0;
igor_v 21:bc8c1cec3da6 12 unsigned int Param2=0;
igor_v 21:bc8c1cec3da6 13 unsigned int Param3=0;
igor_v 21:bc8c1cec3da6 14 unsigned int Param4=0;
Kovalev_D 209:224e7331a061 15 ///unsigned int Consol=123;
Kovalev_D 121:bbae560cdd43 16 unsigned int TempParam=1;
Kovalev_D 124:9ae09249f842 17 unsigned int CountParam=0;
Kovalev_D 209:224e7331a061 18 unsigned int OldCuruAngle;
Kovalev_D 209:224e7331a061 19 unsigned int OldCaunPlus=0;
Kovalev_D 209:224e7331a061 20 unsigned int OldCaunMin=0;
Kovalev_D 211:ac8251b067d2 21 unsigned int OutDeltaPS;
Kovalev_D 211:ac8251b067d2 22 int IntOutDeltaPS;
Kovalev_D 209:224e7331a061 23 int ttemp,temp5=1;
Kovalev_D 197:7a05523bf588 24 int OLDDAC=0;
Kovalev_D 205:775d54fdf646 25 int rr = 123;
Kovalev_D 209:224e7331a061 26 unsigned int pDestT;
Kovalev_D 136:19b9e6abb86f 27 GyroParam *Flash;
Kovalev_D 211:ac8251b067d2 28 //int q;
Kovalev_D 147:1aed74f19a8f 29 ///////////////flah and boot///////////
Kovalev_D 147:1aed74f19a8f 30 void GoBoot(void)
Kovalev_D 147:1aed74f19a8f 31 {
Kovalev_D 147:1aed74f19a8f 32 /* Prepare Sectors to be flashed */
Kovalev_D 147:1aed74f19a8f 33 NVIC_DisableIRQ(TIMER1_IRQn);
Kovalev_D 147:1aed74f19a8f 34 NVIC_DisableIRQ(TIMER2_IRQn);
Kovalev_D 147:1aed74f19a8f 35 NVIC_DisableIRQ(TIMER3_IRQn);
Kovalev_D 147:1aed74f19a8f 36 NVIC_DisableIRQ(EINT3_IRQn);
Kovalev_D 147:1aed74f19a8f 37 SystemInitDef();
Kovalev_D 147:1aed74f19a8f 38 vIAP_ReinvokeISP();
Kovalev_D 147:1aed74f19a8f 39 }
Kovalev_D 181:0b022246c43c 40
Kovalev_D 181:0b022246c43c 41 void DropDelay(void)
Kovalev_D 225:f8fee6c586cc 42 {
Kovalev_D 225:f8fee6c586cc 43 Gyro.DropDelayGLD = DropDelayGLD_0;
Kovalev_D 225:f8fee6c586cc 44 switch(Gyro.My_Addres) {
Kovalev_D 225:f8fee6c586cc 45 case 1: Gyro.DropDelayGLD = DropDelayGLD_1; break;
Kovalev_D 225:f8fee6c586cc 46 case 2: Gyro.DropDelayGLD = DropDelayGLD_2; break;
Kovalev_D 225:f8fee6c586cc 47 case 3: Gyro.DropDelayGLD = DropDelayGLD_3; break;
Kovalev_D 225:f8fee6c586cc 48 }
Kovalev_D 194:8f3cb37a5541 49
Kovalev_D 181:0b022246c43c 50 }
Kovalev_D 205:775d54fdf646 51 /*
Kovalev_D 147:1aed74f19a8f 52 void WriteFlash(void)
Kovalev_D 147:1aed74f19a8f 53 {
Kovalev_D 205:775d54fdf646 54
Kovalev_D 147:1aed74f19a8f 55 SystemInitDef();
Kovalev_D 147:1aed74f19a8f 56 WriteCon("\r\n Start Prepare Sectors");
Kovalev_D 205:775d54fdf646 57 if(u32IAP_PrepareSectors(5, 5) == IAP_STA_CMD_SUCCESS)
Kovalev_D 147:1aed74f19a8f 58 {
Kovalev_D 147:1aed74f19a8f 59 WriteCon("\r\nPrepare Sectors OK");
Kovalev_D 147:1aed74f19a8f 60 WriteCon("\r\n Start Erase");
Kovalev_D 147:1aed74f19a8f 61 u32IAP_EraseSectors(IMG_START_SECTOR, IMG_END_SECTOR);
Kovalev_D 147:1aed74f19a8f 62 WriteCon("\r\n AND Erase");
Kovalev_D 147:1aed74f19a8f 63 }
Kovalev_D 205:775d54fdf646 64 else WriteCon("\r\nPrepare Sectors ERROR ");
Kovalev_D 147:1aed74f19a8f 65 SystemInit1();
Kovalev_D 147:1aed74f19a8f 66 Gyro.FlashMod = 0;
Kovalev_D 169:140743e3bb96 67 }
Kovalev_D 205:775d54fdf646 68 */
Kovalev_D 205:775d54fdf646 69 void EraseFlash(void)
Kovalev_D 205:775d54fdf646 70 {
Kovalev_D 207:d1ce992f5d17 71 rr = u32IAP_PrepareSectors(19, 21);
Kovalev_D 209:224e7331a061 72 /*sprintf((Time)," dffddfd <%07d> ",rr);
Kovalev_D 209:224e7331a061 73 WriteCon(Time);*/
Kovalev_D 207:d1ce992f5d17 74 rr = u32IAP_EraseSectors(19, 21);
Kovalev_D 209:224e7331a061 75 /* sprintf((Time)," dffddfd <%07d> ",rr);
Kovalev_D 209:224e7331a061 76 WriteCon(Time);*/
Kovalev_D 205:775d54fdf646 77 }
Kovalev_D 205:775d54fdf646 78
Kovalev_D 205:775d54fdf646 79 void WriteFlash(void)
Kovalev_D 205:775d54fdf646 80
Kovalev_D 208:19150d2b528f 81 {
Kovalev_D 208:19150d2b528f 82 Gyro.FlashMod = 0;
Kovalev_D 205:775d54fdf646 83
Kovalev_D 205:775d54fdf646 84 //SystemInitDef();
Kovalev_D 205:775d54fdf646 85 NVIC_DisableIRQ(TIMER1_IRQn);
Kovalev_D 205:775d54fdf646 86 NVIC_DisableIRQ(TIMER2_IRQn);
Kovalev_D 205:775d54fdf646 87 NVIC_DisableIRQ(TIMER3_IRQn);
Kovalev_D 205:775d54fdf646 88 NVIC_DisableIRQ(EINT3_IRQn);
Kovalev_D 205:775d54fdf646 89
Kovalev_D 208:19150d2b528f 90 // unsigned int start_address = (unsigned int) & GyroP;
Kovalev_D 207:d1ce992f5d17 91 rr = u32IAP_PrepareSectors(19, 21);
Kovalev_D 208:19150d2b528f 92 rr = u32IAP_EraseSectors (19, 21);
Kovalev_D 207:d1ce992f5d17 93 rr = u32IAP_PrepareSectors(19, 21);
Kovalev_D 208:19150d2b528f 94 rr = u32IAP_CopyRAMToFlash(0x030000, &GyroP , 1024);
Kovalev_D 205:775d54fdf646 95 // SystemInit1(); // Инициализация контроллера: установка тактовых частот
Kovalev_D 205:775d54fdf646 96 //SystemCoreClockUpdate1(); // расчет тактовой частоты процессора перед инициализацией UART - 103MHz
Kovalev_D 205:775d54fdf646 97
Kovalev_D 205:775d54fdf646 98 NVIC_EnableIRQ(TIMER1_IRQn);
Kovalev_D 205:775d54fdf646 99 NVIC_EnableIRQ(TIMER2_IRQn);
Kovalev_D 205:775d54fdf646 100 NVIC_EnableIRQ(TIMER3_IRQn);
Kovalev_D 205:775d54fdf646 101 NVIC_EnableIRQ(EINT3_IRQn);
Kovalev_D 208:19150d2b528f 102 //SystemCoreClockUpdate1();
Kovalev_D 205:775d54fdf646 103
Kovalev_D 205:775d54fdf646 104 }
Kovalev_D 136:19b9e6abb86f 105 void ReadFlash ( void)
Kovalev_D 136:19b9e6abb86f 106 {
Kovalev_D 205:775d54fdf646 107 NVIC_DisableIRQ(TIMER1_IRQn);
Kovalev_D 205:775d54fdf646 108 NVIC_DisableIRQ(TIMER2_IRQn);
Kovalev_D 205:775d54fdf646 109 NVIC_DisableIRQ(TIMER3_IRQn);
Kovalev_D 205:775d54fdf646 110 NVIC_DisableIRQ(EINT3_IRQn);
Kovalev_D 147:1aed74f19a8f 111 Gyro.FlashMod = 0;
Kovalev_D 136:19b9e6abb86f 112 WriteCon("\r\n Pirivet Flash");
Kovalev_D 205:775d54fdf646 113
Kovalev_D 207:d1ce992f5d17 114 pDestT= (unsigned int) (0x030000);
Kovalev_D 136:19b9e6abb86f 115 Flash = (GyroParam*) pDestT;
Kovalev_D 136:19b9e6abb86f 116 GyroP = *(Flash);
Kovalev_D 205:775d54fdf646 117
Kovalev_D 205:775d54fdf646 118 NVIC_EnableIRQ(TIMER1_IRQn);
Kovalev_D 205:775d54fdf646 119 NVIC_EnableIRQ(TIMER2_IRQn);
Kovalev_D 205:775d54fdf646 120 NVIC_EnableIRQ(TIMER3_IRQn);
Kovalev_D 205:775d54fdf646 121 NVIC_EnableIRQ(EINT3_IRQn);
Kovalev_D 208:19150d2b528f 122 }
Kovalev_D 169:140743e3bb96 123 ///////////////end flah and boot///////////
Kovalev_D 222:7de7b3bf3a1d 124
Kovalev_D 191:40028201ddad 125 void M_RateA(void)
Kovalev_D 226:4a4d5bd5fcd7 126 {
Kovalev_D 226:4a4d5bd5fcd7 127
Kovalev_D 226:4a4d5bd5fcd7 128 if(Gyro.ModeOut==3)
Kovalev_D 226:4a4d5bd5fcd7 129 {
Kovalev_D 226:4a4d5bd5fcd7 130 if (Gyro.Device_Mode) Gyro.ModeOut=4;
Kovalev_D 226:4a4d5bd5fcd7 131 }
Kovalev_D 226:4a4d5bd5fcd7 132
Kovalev_D 209:224e7331a061 133 switch(Gyro.ModeOut)
Kovalev_D 209:224e7331a061 134 {
Kovalev_D 226:4a4d5bd5fcd7 135 case 1: if(Gyro.Rate1_Event ) CMD_Rate(); break;
Kovalev_D 226:4a4d5bd5fcd7 136 case 2: if(Gyro.Reper_Event ) CMD_Rate2(); break;
Kovalev_D 226:4a4d5bd5fcd7 137 case 3: if(Gyro.Event_500Hz ) CMD_Delta_PS(); break;
Kovalev_D 226:4a4d5bd5fcd7 138 case 4: if(Gyro.EXT_Latch ) CMD_Delta_PS(); Gyro.EXT_Latch=0; LoopOff break;
Kovalev_D 226:4a4d5bd5fcd7 139 case 5: if(Gyro.Event_500Hz ) CMD_Delta_Bins(); break;
Kovalev_D 226:4a4d5bd5fcd7 140 case 6: if(Gyro.EXT_Latch ) CMD_B_Delta(); Gyro.EXT_Latch=0; break;
Kovalev_D 226:4a4d5bd5fcd7 141 case 7: if(Gyro.Event_500Hz ) CMD_B_Delta(); break;
Kovalev_D 226:4a4d5bd5fcd7 142 case 8: if(Gyro.Rate3_Event ) CMD_Rate3(); break;
Kovalev_D 226:4a4d5bd5fcd7 143 case 9: if(Gyro.Reper_Event ){ CMD_Rate2(); Gyro.ModeOut=0;} break;
Kovalev_D 225:f8fee6c586cc 144 case 10: CMD_Rate7();Gyro.ModeOut=0;break;//if(Gyro.EvenRate7 ){ CMD_Rate7(); Gyro.EvenRate7=0;} break;
Kovalev_D 222:7de7b3bf3a1d 145 case 11: if(Gyro.EvenRate5K ){ M_Rate5K(); Gyro.EvenRate5K--;} break;
Kovalev_D 196:f76dbc081e63 146 }
Kovalev_D 191:40028201ddad 147 }
Kovalev_D 136:19b9e6abb86f 148
Kovalev_D 214:4c70e452c491 149 void BuffClear(void)
Kovalev_D 214:4c70e452c491 150 {
Kovalev_D 214:4c70e452c491 151 for(int q=0; q<60; q++)
Kovalev_D 214:4c70e452c491 152 {
Kovalev_D 214:4c70e452c491 153 BuffTemp[q]=0;
Kovalev_D 214:4c70e452c491 154 }
Kovalev_D 214:4c70e452c491 155 }
Kovalev_D 222:7de7b3bf3a1d 156
Kovalev_D 222:7de7b3bf3a1d 157
Kovalev_D 222:7de7b3bf3a1d 158
Kovalev_D 222:7de7b3bf3a1d 159
Kovalev_D 222:7de7b3bf3a1d 160
Kovalev_D 222:7de7b3bf3a1d 161
Kovalev_D 214:4c70e452c491 162 void CMD_Rate7(void)
Kovalev_D 214:4c70e452c491 163 {
Kovalev_D 218:b4067cac75c0 164 //Buff_Restored_Mod[CountV31] BuffADC_znak[q]
Kovalev_D 214:4c70e452c491 165 // (CountV64)&0x3f]*Gyro.ModAmp туды
Kovalev_D 214:4c70e452c491 166 //BuffADC_64Point[ (CountFaza + Gyro.PLC_Phase) & 0x3f]
Kovalev_D 214:4c70e452c491 167 BuffClear();
Kovalev_D 214:4c70e452c491 168
Kovalev_D 225:f8fee6c586cc 169 unsigned int Temp;
Kovalev_D 225:f8fee6c586cc 170 int ADC_Worm[70];
Kovalev_D 214:4c70e452c491 171 int Temp1;
Kovalev_D 214:4c70e452c491 172 float Temp2;
Kovalev_D 222:7de7b3bf3a1d 173 static unsigned int t=0;
Kovalev_D 214:4c70e452c491 174
Kovalev_D 214:4c70e452c491 175 BuffTemp[0] = Gyro.SOC_Out;
Kovalev_D 214:4c70e452c491 176 BuffTemp[1] = Gyro.My_Addres;
Kovalev_D 225:f8fee6c586cc 177 MinWorms=BuffADC_10v_F[10];
Kovalev_D 225:f8fee6c586cc 178 MaxWorms=BuffADC_10v_F[10];
Kovalev_D 225:f8fee6c586cc 179 for(int q=0; q<64; q++)
Kovalev_D 225:f8fee6c586cc 180 {
Kovalev_D 225:f8fee6c586cc 181 if(MinWorms > BuffADC_10v_F[q]) MinWorms = (BuffADC_10v_F[q]);
Kovalev_D 225:f8fee6c586cc 182 if(MaxWorms < BuffADC_10v_F[q]) MaxWorms = (BuffADC_10v_F[q]);
Kovalev_D 225:f8fee6c586cc 183 }
Kovalev_D 225:f8fee6c586cc 184 AmpWorms = (MaxWorms-MinWorms)>>1;
Kovalev_D 225:f8fee6c586cc 185
Kovalev_D 225:f8fee6c586cc 186 for(int q=0; q<64; q++)
Kovalev_D 225:f8fee6c586cc 187 {
Kovalev_D 225:f8fee6c586cc 188 ADC_Worm[q] = (BuffADC_10v_F[q] - (MinWorms+AmpWorms));// от -128 до 128
Kovalev_D 225:f8fee6c586cc 189 }
Kovalev_D 214:4c70e452c491 190
Kovalev_D 225:f8fee6c586cc 191 for(int q=32; q<64; q++)
Kovalev_D 225:f8fee6c586cc 192 {
Kovalev_D 225:f8fee6c586cc 193 ADC_Worm[q] = ADC_Worm[q] * (-1);
Kovalev_D 225:f8fee6c586cc 194 }
Kovalev_D 225:f8fee6c586cc 195
Kovalev_D 225:f8fee6c586cc 196 for(int q=0; q<64; q++)
Kovalev_D 225:f8fee6c586cc 197 {
Kovalev_D 225:f8fee6c586cc 198 ADC_Worm[q] = ADC_Worm[q] + AmpWorms+1;
Kovalev_D 225:f8fee6c586cc 199 Temp = (ADC_Worm[q])>>9;
Kovalev_D 225:f8fee6c586cc 200 BuffTemp[q+2] = (Temp) & 0xff;//младший байт разности счетчиков
Kovalev_D 225:f8fee6c586cc 201 }
Kovalev_D 214:4c70e452c491 202
Kovalev_D 214:4c70e452c491 203
Kovalev_D 225:f8fee6c586cc 204
Kovalev_D 225:f8fee6c586cc 205 iRate_7 = ((Spi.DAC_B-0x7fff)&0xffff);
Kovalev_D 225:f8fee6c586cc 206 BuffTemp[66]=(iRate_7 >> 8) & 0xff;//младший байт разности счетчиков
Kovalev_D 225:f8fee6c586cc 207 BuffTemp[67]=(iRate_7 >> 0) & 0xff;//младший байт разности счетчиков;
Kovalev_D 225:f8fee6c586cc 208
Kovalev_D 225:f8fee6c586cc 209 Rate_7 = Gyro.PLC_Eror_count>>3;
Kovalev_D 225:f8fee6c586cc 210 BuffTemp[68]=(Rate_7 >> 8) & 0xff;//младший байт разности счетчиков
Kovalev_D 225:f8fee6c586cc 211 BuffTemp[69]=(Rate_7 >> 0) & 0xff;//младший байт разности счетчиков;
Kovalev_D 214:4c70e452c491 212
Kovalev_D 214:4c70e452c491 213 Gyro.PLC_Eror_count=0;
Kovalev_D 218:b4067cac75c0 214
Kovalev_D 218:b4067cac75c0 215 switch(Gyro.LG_Type)
Kovalev_D 214:4c70e452c491 216 {
Kovalev_D 225:f8fee6c586cc 217 case 1: iRate_7 = 0xffff-Spi.DAC_A; break;
Kovalev_D 218:b4067cac75c0 218
Kovalev_D 214:4c70e452c491 219 case 0: Temp2 = (Spi.DAC_A*1.538) - 0xd80f;
Kovalev_D 218:b4067cac75c0 220 iRate_7 = (int)Temp2;
Kovalev_D 218:b4067cac75c0 221 break;
Kovalev_D 214:4c70e452c491 222 }
Kovalev_D 225:f8fee6c586cc 223 Rate_7 = (unsigned int)(iRate_7&0xffff);
Kovalev_D 225:f8fee6c586cc 224 BuffTemp[70]= (iRate_7 >> 8) & 0xff;//младший байт разности счетчиков
Kovalev_D 225:f8fee6c586cc 225 BuffTemp[71]= (iRate_7 >> 0) & 0xff;//младший байт разности счетчиков;
Kovalev_D 214:4c70e452c491 226
Kovalev_D 225:f8fee6c586cc 227 Check(BuffTemp,74);
Kovalev_D 225:f8fee6c586cc 228 WriteConN (BuffTemp,74);
Kovalev_D 214:4c70e452c491 229 }
Kovalev_D 214:4c70e452c491 230
Kovalev_D 214:4c70e452c491 231
Kovalev_D 214:4c70e452c491 232
Kovalev_D 129:406995a91322 233 void CMD_M_Param_R(void)
igor_v 0:8ad47e2b6f00 234 {
Kovalev_D 208:19150d2b528f 235
Kovalev_D 214:4c70e452c491 236
Kovalev_D 208:19150d2b528f 237 unsigned int NP=0;
Kovalev_D 129:406995a91322 238 unsigned int Param;
Kovalev_D 208:19150d2b528f 239
Kovalev_D 214:4c70e452c491 240
Kovalev_D 208:19150d2b528f 241 NP = BuffTemp[3];
Kovalev_D 208:19150d2b528f 242
Kovalev_D 209:224e7331a061 243 for (int i=0;i<8;i++)
Kovalev_D 209:224e7331a061 244 {BuffTemp[i]=0;}
Kovalev_D 208:19150d2b528f 245
Kovalev_D 208:19150d2b528f 246
Kovalev_D 129:406995a91322 247 BuffTemp[0] = Gyro.SOC_Out;
Kovalev_D 129:406995a91322 248 BuffTemp[1] = Gyro.My_Addres;
Kovalev_D 129:406995a91322 249
Kovalev_D 208:19150d2b528f 250
Kovalev_D 209:224e7331a061 251 /* sprintf((Time),"%d = %d \r\n",NP, GyroP.Array[NP]);
Kovalev_D 209:224e7331a061 252 WriteCon(Time);*/
Kovalev_D 129:406995a91322 253 Param = GyroP.Array[NP];
Kovalev_D 208:19150d2b528f 254 BuffTemp[2] =(GyroP.Array[NP] >> 8) & 0xff;//старший байт требуемого параметра
Kovalev_D 208:19150d2b528f 255 BuffTemp[3] =(GyroP.Array[NP] >> 0) & 0xff;//младший байт требуемого параметра
Kovalev_D 129:406995a91322 256
Kovalev_D 129:406995a91322 257 Check(BuffTemp, 6);
Kovalev_D 129:406995a91322 258 WriteConN (BuffTemp,6);
Kovalev_D 205:775d54fdf646 259 /*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);
Kovalev_D 205:775d54fdf646 260 WriteCon(Time);*/
Kovalev_D 208:19150d2b528f 261 NP=0;
Kovalev_D 129:406995a91322 262 }
Kovalev_D 129:406995a91322 263 void CMD_M_Param_W(void)
Kovalev_D 129:406995a91322 264 {
Kovalev_D 208:19150d2b528f 265 unsigned int NP=0;
Kovalev_D 208:19150d2b528f 266 unsigned int Param,temp,flash;
Kovalev_D 129:406995a91322 267
Kovalev_D 129:406995a91322 268 NP = BuffTemp[3];
Kovalev_D 129:406995a91322 269 Param = (BuffTemp[4]<<8);
Kovalev_D 129:406995a91322 270 Param |= BuffTemp[5];
Kovalev_D 129:406995a91322 271
Kovalev_D 208:19150d2b528f 272 GyroP.Array[NP] = Param;
Kovalev_D 222:7de7b3bf3a1d 273 flash=GyroP.Array[115];
Kovalev_D 209:224e7331a061 274
Kovalev_D 208:19150d2b528f 275 switch(NP)
Kovalev_D 208:19150d2b528f 276 {
Kovalev_D 211:ac8251b067d2 277 case 0: Gyro.My_Addres = GyroP.Str.My_Addres; break;
Kovalev_D 226:4a4d5bd5fcd7 278 case 1: Gyro.HFO_ref = (unsigned int)(GyroP.Str.HFO_ref) ; break;
Kovalev_D 211:ac8251b067d2 279 case 2: Gyro.HFO_Gain = GyroP.Str.HFO_Gain; break;
Kovalev_D 225:f8fee6c586cc 280 case 3: if(Gyro.LG_Type) Gyro.HFO_Max=0xffff-GyroP.Str.DAC_current_Work; //((int)(GyroP.Str.DAC_current_Work*0.67)-2000);
Kovalev_D 211:ac8251b067d2 281 else Spi.DAC_A = ((((int)(GyroP.Str.DAC_current_Work+ 0x7fff)&0xffff)+22544)*0.65); break;
Kovalev_D 211:ac8251b067d2 282
Kovalev_D 225:f8fee6c586cc 283 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;
Kovalev_D 208:19150d2b528f 284
Kovalev_D 222:7de7b3bf3a1d 285 case 5: Gyro.TimeToJump = GyroP.Str.TimeToJump; break;
Kovalev_D 222:7de7b3bf3a1d 286 case 6: Gyro.JumpDelta = GyroP.Str.JumpDelta; break;
Kovalev_D 222:7de7b3bf3a1d 287
Kovalev_D 209:224e7331a061 288 case 7: Gyro.PLC_Phase = GyroP.Str.PLC_Phase; break;
Kovalev_D 209:224e7331a061 289 case 8: Gyro.PLC_Gain = GyroP.Str.PLC_Gain; break;
Kovalev_D 209:224e7331a061 290 case 12: Gyro.FrqPhase = GyroP.Str.FrqPhase; break;
Kovalev_D 209:224e7331a061 291 case 13: Gyro.FrqChengSpeed = GyroP.Str.FrqChengSpeed; break;
Kovalev_D 209:224e7331a061 292
Kovalev_D 209:224e7331a061 293 case 14: Gyro.FrqHZ = (7680000 / GyroP.Str.FrqHZ);
Kovalev_D 209:224e7331a061 294 Gyro.Frq = (7680000 / GyroP.Str.FrqHZ)<<16;
Kovalev_D 208:19150d2b528f 295 break;
Kovalev_D 208:19150d2b528f 296
Kovalev_D 209:224e7331a061 297 case 15: Gyro.FrqHZmin = (7680000 / GyroP.Str.FrqHZmin)<<16; break;
Kovalev_D 209:224e7331a061 298 case 16: Gyro.FrqHZmax = (7680000 / GyroP.Str.FrqHZmax)<<16; break;
Kovalev_D 208:19150d2b528f 299
Kovalev_D 208:19150d2b528f 300 case 18: temp=((GyroP.Str.VB_Fdf_Hi<<16) | GyroP.Str.VB_Fdf_Lo);
Kovalev_D 225:f8fee6c586cc 301
Kovalev_D 218:b4067cac75c0 302 temp=temp*20;
Kovalev_D 218:b4067cac75c0 303 Gyro.AmpTarget=(unsigned int)(temp);
Kovalev_D 208:19150d2b528f 304 break;
Kovalev_D 208:19150d2b528f 305
Kovalev_D 209:224e7331a061 306 case 19: Gyro.AmpSpeed = GyroP.Str.AmpSpeed; break;
Kovalev_D 209:224e7331a061 307 case 20: Gyro.AmpPerMin = GyroP.Str.AmpPerMin; break;
Kovalev_D 209:224e7331a061 308 case 21: Gyro.AmpPerMax = GyroP.Str.AmpPerMax; break;
Kovalev_D 208:19150d2b528f 309
Kovalev_D 208:19150d2b528f 310 case 22: Gyro.AmpPer = GyroP.Str.AmpPer;
Kovalev_D 208:19150d2b528f 311 Gyro.Amp = GyroP.Str.AmpPer<<16;
Kovalev_D 208:19150d2b528f 312 break;
Kovalev_D 208:19150d2b528f 313
Kovalev_D 209:224e7331a061 314 case 23: Gyro.AmpMin = GyroP.Str.AmpMin; break;
Kovalev_D 209:224e7331a061 315 case 24: Gyro.AmpTD = GyroP.Str.AmpTD; break;
Kovalev_D 209:224e7331a061 316 case 25: Gyro.AmpPerDel = GyroP.Str.AmpPerDel; break;
Kovalev_D 220:04c54405b82d 317 case 33: Gyro.ShiftMod = GyroP.Str.ShiftMod; break;
Kovalev_D 209:224e7331a061 318 case 34: Gyro.ModAmp = GyroP.Str.ModAmp; break;
Kovalev_D 208:19150d2b528f 319 case 56: Gyro.Gain_Sin = GyroP.Str.Gain_Sin;
Kovalev_D 208:19150d2b528f 320 Out_G_photo(Gyro.Gain_Sin, Gyro.Gain_Cos);
Kovalev_D 208:19150d2b528f 321 break;
Kovalev_D 208:19150d2b528f 322 case 57: Gyro.Gain_Cos = GyroP.Str.Gain_Cos;
Kovalev_D 208:19150d2b528f 323 Out_G_photo(Gyro.Gain_Sin, Gyro.Gain_Cos);
Kovalev_D 208:19150d2b528f 324 break;
Kovalev_D 209:224e7331a061 325 case 60: Gyro.GLD_Serial = GyroP.Str.GLD_Serial; break;
Kovalev_D 211:ac8251b067d2 326
Kovalev_D 211:ac8251b067d2 327
Kovalev_D 225:f8fee6c586cc 328 case 10: Gyro.DownTreshold = (unsigned int)((GyroP.Str.DownTreshold-0x7fff)&0xffff); break;
Kovalev_D 225:f8fee6c586cc 329 case 11: Gyro.HighTreshold = (unsigned int)((GyroP.Str.HighTreshold-0x7fff)&0xffff); break;
Kovalev_D 225:f8fee6c586cc 330
Kovalev_D 225:f8fee6c586cc 331 case 9: Gyro.PLCDelay = GyroP.Str.PLCDelay; break;
Kovalev_D 225:f8fee6c586cc 332
Kovalev_D 225:f8fee6c586cc 333 case 105:Gyro.ResetLevelCool = (unsigned int)((GyroP.Str.ResetLevelCool-0x7fff)&0xffff); break;
Kovalev_D 225:f8fee6c586cc 334 case 55: Gyro.ResetLevelHeat = (unsigned int)((GyroP.Str.ResetLevelHeat-0x7fff)&0xffff); break;
Kovalev_D 225:f8fee6c586cc 335
Kovalev_D 225:f8fee6c586cc 336
Kovalev_D 225:f8fee6c586cc 337
Kovalev_D 225:f8fee6c586cc 338
Kovalev_D 225:f8fee6c586cc 339 //27
Kovalev_D 225:f8fee6c586cc 340
Kovalev_D 225:f8fee6c586cc 341 /// Gyro.PLCDelay = GyroP.Str.PLCDelay;
Kovalev_D 225:f8fee6c586cc 342 //105
Kovalev_D 225:f8fee6c586cc 343
Kovalev_D 225:f8fee6c586cc 344 /*
Kovalev_D 211:ac8251b067d2 345 case 39: Gyro.ResetLevelCool = 0x7fff+GyroP.Str.ResetLevelCool; break;
Kovalev_D 225:f8fee6c586cc 346 case 31: Gyro.ResetLevelHeat = 0x7fff+GyroP.Str.ResetLevelHeat; break; */ //27
Kovalev_D 211:ac8251b067d2 347
Kovalev_D 211:ac8251b067d2 348
Kovalev_D 211:ac8251b067d2 349 //105
Kovalev_D 211:ac8251b067d2 350
Kovalev_D 208:19150d2b528f 351 }
Kovalev_D 208:19150d2b528f 352
Kovalev_D 208:19150d2b528f 353 NP=0;
Kovalev_D 129:406995a91322 354
Kovalev_D 129:406995a91322 355 BuffTemp[0] = Gyro.SOC_Out;
Kovalev_D 129:406995a91322 356 BuffTemp[1] = Gyro.My_Addres;
Kovalev_D 129:406995a91322 357 BuffTemp[2] = Gyro.CMD_In;
Kovalev_D 208:19150d2b528f 358 BuffTemp[3] =0; //(//GyroP.Array[NP]>> 8) & 0xff;//старший байт требуемого параметра
Kovalev_D 129:406995a91322 359
Kovalev_D 129:406995a91322 360 Check(BuffTemp, 6);
Kovalev_D 129:406995a91322 361 WriteConN (BuffTemp,6);
Kovalev_D 222:7de7b3bf3a1d 362 if(flash){GyroP.Array[115]=0; flash=0; WriteFlash(); ReadFlash ();}
Kovalev_D 208:19150d2b528f 363
Kovalev_D 208:19150d2b528f 364
Kovalev_D 129:406995a91322 365 }
igor_v 0:8ad47e2b6f00 366 void CMD_Maintenance(void)
igor_v 0:8ad47e2b6f00 367 {
Kovalev_D 218:b4067cac75c0 368
Kovalev_D 209:224e7331a061 369 Gyro.ModeOut=0;
Kovalev_D 226:4a4d5bd5fcd7 370 Gyro.Device_Mode = 0;
Kovalev_D 218:b4067cac75c0 371 for(int q=0; q<64; q++)
Kovalev_D 218:b4067cac75c0 372 {
Kovalev_D 218:b4067cac75c0 373 BuffTemp[q]=0;
Kovalev_D 218:b4067cac75c0 374 }
Kovalev_D 208:19150d2b528f 375 //Gyro.DropDelayGLD = DropDelayGLD_0;//задержка на выдачу 45 микросекунд для любого адреса ГЛД
Kovalev_D 122:fbacb932a30b 376 BuffTemp[0] = Gyro.SOC_Out;
Kovalev_D 209:224e7331a061 377
Kovalev_D 124:9ae09249f842 378 BuffTemp[1] = Gyro.My_Addres;
Kovalev_D 209:224e7331a061 379
Kovalev_D 124:9ae09249f842 380 BuffTemp[2] = Gyro.Firmware_Version;
Kovalev_D 209:224e7331a061 381 /* sprintf((Time),"%d \r\n", Gyro.Firmware_Version);
Kovalev_D 209:224e7331a061 382 WriteCon(Time);*/
Kovalev_D 169:140743e3bb96 383 BuffTemp[3] = Gyro.GLD_Serial;
Kovalev_D 209:224e7331a061 384
igor_v 21:bc8c1cec3da6 385 BuffTemp[4]=0x00;
Kovalev_D 209:224e7331a061 386
igor_v 21:bc8c1cec3da6 387 BuffTemp[5]=0x00;
Kovalev_D 209:224e7331a061 388
igor_v 21:bc8c1cec3da6 389 Check(BuffTemp, 8);
Kovalev_D 209:224e7331a061 390 /* 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]);
Kovalev_D 209:224e7331a061 391 WriteCon(Time);*/
igor_v 21:bc8c1cec3da6 392 WriteConN (BuffTemp,8);
Kovalev_D 121:bbae560cdd43 393
igor_v 0:8ad47e2b6f00 394 }
Kovalev_D 193:a0fe8bfc97e4 395 void CMD_B_Delta(void)
Kovalev_D 193:a0fe8bfc97e4 396 {
Kovalev_D 196:f76dbc081e63 397 Gyro.Event_500Hz=0;
Kovalev_D 205:775d54fdf646 398 Gyro.EXT_Latch=0;
Kovalev_D 193:a0fe8bfc97e4 399 unsigned int Temp;
Kovalev_D 193:a0fe8bfc97e4 400 BuffTemp[ 0] = Gyro.SOC_Out;
Kovalev_D 193:a0fe8bfc97e4 401 BuffTemp[ 1] = Gyro.My_Addres;
Kovalev_D 193:a0fe8bfc97e4 402
Kovalev_D 193:a0fe8bfc97e4 403 Temp = Gyro.CuruAngle;
Kovalev_D 193:a0fe8bfc97e4 404 Gyro.CuruAngle = 0;
Kovalev_D 193:a0fe8bfc97e4 405 BuffTemp[ 2] =(Temp >> 16) & 0xff;//младший байт разности счетчиков
Kovalev_D 193:a0fe8bfc97e4 406 BuffTemp[ 3] =(Temp >> 8) & 0xff;//младший байт разности счетчиков
Kovalev_D 193:a0fe8bfc97e4 407 BuffTemp[ 4] =(Temp >> 0) & 0xff;//младший байт разности счетчиков
Kovalev_D 193:a0fe8bfc97e4 408 BuffTemp[ 5] = 0x00000000;
Kovalev_D 193:a0fe8bfc97e4 409 Check(BuffTemp, 8);
Kovalev_D 193:a0fe8bfc97e4 410 WriteConN (BuffTemp,8);
Kovalev_D 193:a0fe8bfc97e4 411 }
Kovalev_D 165:b2bd0c810a4f 412
Kovalev_D 193:a0fe8bfc97e4 413 void CMD_Delta_Bins(void)
Kovalev_D 196:f76dbc081e63 414 { Gyro.Event_500Hz=0;
Kovalev_D 193:a0fe8bfc97e4 415 unsigned int Temp;
Kovalev_D 193:a0fe8bfc97e4 416 BuffTemp[ 0] = Gyro.SOC_Out;
Kovalev_D 193:a0fe8bfc97e4 417 BuffTemp[ 1] = Gyro.My_Addres;
Kovalev_D 193:a0fe8bfc97e4 418
Kovalev_D 193:a0fe8bfc97e4 419 Temp = Gyro.CuruAngle;
Kovalev_D 193:a0fe8bfc97e4 420 Gyro.CuruAngle = 0;
Kovalev_D 193:a0fe8bfc97e4 421
Kovalev_D 193:a0fe8bfc97e4 422 BuffTemp[ 2] =(Temp >> 24) & 0xff;//старший байт разности счетчиков
Kovalev_D 193:a0fe8bfc97e4 423 BuffTemp[ 3] =(Temp >> 16) & 0xff;//младший байт разности счетчиков
Kovalev_D 193:a0fe8bfc97e4 424 BuffTemp[ 4] =(Temp >> 8) & 0xff;//младший байт разности счетчиков
Kovalev_D 193:a0fe8bfc97e4 425 BuffTemp[ 5] =(Temp >> 0) & 0xff;//младший байт разности счетчиков
Kovalev_D 193:a0fe8bfc97e4 426 BuffTemp[ 6] = 0x0000;
Kovalev_D 193:a0fe8bfc97e4 427 Check(BuffTemp, 9);
Kovalev_D 193:a0fe8bfc97e4 428 WriteConN (BuffTemp,9);
Kovalev_D 193:a0fe8bfc97e4 429 }
Kovalev_D 193:a0fe8bfc97e4 430 void CMD_Delta_PS(void)
Kovalev_D 210:b02fa166315d 431 { int drob,Temp1;
Kovalev_D 210:b02fa166315d 432 float Temp2=0;
Kovalev_D 193:a0fe8bfc97e4 433 Gyro.EXT_Latch=0;
Kovalev_D 196:f76dbc081e63 434 Gyro.Event_500Hz=0;
Kovalev_D 122:fbacb932a30b 435 unsigned int Temp;
Kovalev_D 218:b4067cac75c0 436
Kovalev_D 218:b4067cac75c0 437
Kovalev_D 218:b4067cac75c0 438
Kovalev_D 124:9ae09249f842 439 BuffTemp[ 0] = Gyro.SOC_Out;
Kovalev_D 122:fbacb932a30b 440 BuffTemp[ 1] = Gyro.My_Addres;
Kovalev_D 208:19150d2b528f 441
Kovalev_D 209:224e7331a061 442 Gyro.CuruAngle = Gyro.CuruAngle + OldCuruAngle; //(72 град/с)
Kovalev_D 209:224e7331a061 443
Kovalev_D 214:4c70e452c491 444 OldCuruAngle=Gyro.CuruAngle & 0xf; //сохраняем 3 бит для след измирений
Kovalev_D 214:4c70e452c491 445 Temp=Gyro.CuruAngle>>4; //приводим к форме вывода
Kovalev_D 209:224e7331a061 446 Gyro.CuruAngle = 0;
Kovalev_D 124:9ae09249f842 447
Kovalev_D 124:9ae09249f842 448 BuffTemp[ 2] =(Temp >> 8) & 0xff;//старший байт разности счетчиков
Kovalev_D 124:9ae09249f842 449 BuffTemp[ 3] =(Temp >> 0) & 0xff;//младший байт разности счетчиков
Kovalev_D 124:9ae09249f842 450
Kovalev_D 124:9ae09249f842 451 BuffTemp[ 4] = CountParam;
Kovalev_D 124:9ae09249f842 452 switch(CountParam) {
Kovalev_D 182:ebcd2bc3be8f 453
Kovalev_D 124:9ae09249f842 454 //F_ras
Kovalev_D 124:9ae09249f842 455 case 0:
Kovalev_D 211:ac8251b067d2 456 OutDeltaPS = Gyro.F_ras;
Kovalev_D 211:ac8251b067d2 457 BuffTemp[5] = (OutDeltaPS >> 8) & 0xff;
Kovalev_D 124:9ae09249f842 458 break;
Kovalev_D 124:9ae09249f842 459
Kovalev_D 124:9ae09249f842 460 case 1:
Kovalev_D 211:ac8251b067d2 461 BuffTemp[5] = (OutDeltaPS >> 0) & 0xff;
Kovalev_D 124:9ae09249f842 462 break;
Kovalev_D 208:19150d2b528f 463
Kovalev_D 124:9ae09249f842 464
Kovalev_D 124:9ae09249f842 465 //HFO
Kovalev_D 124:9ae09249f842 466 case 2:
Kovalev_D 211:ac8251b067d2 467 /* Temp2 = ((Spi.DAC_A/0.65)-22544)-0x7fff;
Kovalev_D 211:ac8251b067d2 468 Temp1= (int)Temp2;*/
Kovalev_D 218:b4067cac75c0 469 //2930
Kovalev_D 218:b4067cac75c0 470 if(Gyro.LG_Type) {OutDeltaPS =(int)(((Spi.DAC_A-0x84bf))* 2);
Kovalev_D 218:b4067cac75c0 471 }
Kovalev_D 218:b4067cac75c0 472 else {OutDeltaPS =(unsigned int)(0x7fff-Spi.ADC5)*0.79;
Kovalev_D 218:b4067cac75c0 473 }
Kovalev_D 210:b02fa166315d 474 // Temp = Spi.DAC_A-0x7fff;
Kovalev_D 211:ac8251b067d2 475 BuffTemp[5] = (OutDeltaPS >> 8) & 0xff;
Kovalev_D 124:9ae09249f842 476 break;
Kovalev_D 124:9ae09249f842 477
Kovalev_D 124:9ae09249f842 478 case 3:
Kovalev_D 211:ac8251b067d2 479 BuffTemp[5] = (OutDeltaPS >> 0) & 0xff;
Kovalev_D 124:9ae09249f842 480 break;
Kovalev_D 124:9ae09249f842 481
Kovalev_D 124:9ae09249f842 482
Kovalev_D 124:9ae09249f842 483
Kovalev_D 124:9ae09249f842 484 //T_Vibro
Kovalev_D 124:9ae09249f842 485 case 4:
Kovalev_D 211:ac8251b067d2 486 OutDeltaPS = (unsigned int)(7680000/(Gyro.Frq>>16));
Kovalev_D 211:ac8251b067d2 487 BuffTemp[5] = (OutDeltaPS >> 8) & 0xff;
Kovalev_D 124:9ae09249f842 488 break;
Kovalev_D 124:9ae09249f842 489
Kovalev_D 124:9ae09249f842 490 case 5:
Kovalev_D 211:ac8251b067d2 491 BuffTemp[5] = (OutDeltaPS >> 0) & 0xff;
Kovalev_D 124:9ae09249f842 492 break;
Kovalev_D 124:9ae09249f842 493
Kovalev_D 124:9ae09249f842 494
Kovalev_D 124:9ae09249f842 495
Kovalev_D 124:9ae09249f842 496 //L_Vibro
Kovalev_D 124:9ae09249f842 497 case 6:
Kovalev_D 210:b02fa166315d 498 //Temp = Gyro.L_vibro>>1;
Kovalev_D 211:ac8251b067d2 499 OutDeltaPS = Gyro.L_vibro;
Kovalev_D 211:ac8251b067d2 500 BuffTemp[5] = (OutDeltaPS >> 8) & 0xff;
Kovalev_D 124:9ae09249f842 501
Kovalev_D 124:9ae09249f842 502 break;
Kovalev_D 124:9ae09249f842 503
Kovalev_D 124:9ae09249f842 504 case 7:
Kovalev_D 211:ac8251b067d2 505 BuffTemp[5] = (OutDeltaPS >> 0) & 0xff;
Kovalev_D 124:9ae09249f842 506 break;
Kovalev_D 124:9ae09249f842 507
Kovalev_D 124:9ae09249f842 508
Kovalev_D 124:9ae09249f842 509
Kovalev_D 124:9ae09249f842 510 //Напряжение на регуляторе периметра
Kovalev_D 124:9ae09249f842 511 case 8:
Kovalev_D 218:b4067cac75c0 512 OutDeltaPS =(int)(3300+(0x7fff+(Spi.DAC_B*1.083)));// (Spi.DAC_B - 0x7fff);
Kovalev_D 211:ac8251b067d2 513 BuffTemp[5] = (OutDeltaPS >> 8) & 0xff;
Kovalev_D 124:9ae09249f842 514
Kovalev_D 124:9ae09249f842 515 break;
Kovalev_D 124:9ae09249f842 516
Kovalev_D 124:9ae09249f842 517 case 9:
Kovalev_D 211:ac8251b067d2 518 BuffTemp[5] = (OutDeltaPS >> 0) & 0xff;
Kovalev_D 124:9ae09249f842 519 break;
Kovalev_D 124:9ae09249f842 520
Kovalev_D 124:9ae09249f842 521
Kovalev_D 124:9ae09249f842 522
Kovalev_D 124:9ae09249f842 523 //темпкратурный канал 0
Kovalev_D 124:9ae09249f842 524 case 10:
Kovalev_D 211:ac8251b067d2 525 OutDeltaPS = 0;
Kovalev_D 211:ac8251b067d2 526 BuffTemp[5] = (OutDeltaPS >> 8) & 0xff;
igor_v 0:8ad47e2b6f00 527
Kovalev_D 124:9ae09249f842 528 break;
Kovalev_D 124:9ae09249f842 529
Kovalev_D 124:9ae09249f842 530 case 11:
Kovalev_D 211:ac8251b067d2 531 BuffTemp[5] = (OutDeltaPS >> 0) & 0xff;
Kovalev_D 124:9ae09249f842 532 break;
Kovalev_D 124:9ae09249f842 533
Kovalev_D 124:9ae09249f842 534
Kovalev_D 124:9ae09249f842 535
Kovalev_D 177:1666a83d88a5 536 //f
Kovalev_D 124:9ae09249f842 537 case 12:
Kovalev_D 211:ac8251b067d2 538 OutDeltaPS =0;//(unsigned int)(0x7fff-Spi.ADC5)*0.79;
Kovalev_D 210:b02fa166315d 539 // Temp = Gyro.AD_Slow >> 16;
Kovalev_D 211:ac8251b067d2 540 BuffTemp[5] = (OutDeltaPS >> 8) & 0xff;
Kovalev_D 124:9ae09249f842 541
Kovalev_D 124:9ae09249f842 542 break;
Kovalev_D 124:9ae09249f842 543
Kovalev_D 124:9ae09249f842 544 case 13:
Kovalev_D 211:ac8251b067d2 545 BuffTemp[5] = (OutDeltaPS >> 0) & 0xff;
Kovalev_D 124:9ae09249f842 546 break;
Kovalev_D 124:9ae09249f842 547
Kovalev_D 124:9ae09249f842 548
Kovalev_D 124:9ae09249f842 549
Kovalev_D 124:9ae09249f842 550 //ток 1
Kovalev_D 124:9ae09249f842 551 case 14:
Kovalev_D 210:b02fa166315d 552 //Temp = Gyro.In1;
Kovalev_D 211:ac8251b067d2 553 IntOutDeltaPS = ((Gyro.In1>>1)*0.800875)-0x3e0b;
Kovalev_D 211:ac8251b067d2 554 BuffTemp[5] = (IntOutDeltaPS >> 8) & 0xff;//in1//2
Kovalev_D 124:9ae09249f842 555
Kovalev_D 124:9ae09249f842 556 break;
Kovalev_D 124:9ae09249f842 557
Kovalev_D 124:9ae09249f842 558 case 15:
Kovalev_D 211:ac8251b067d2 559 BuffTemp[5] = (IntOutDeltaPS >> 0) & 0xff;
Kovalev_D 124:9ae09249f842 560 break;
Kovalev_D 124:9ae09249f842 561
Kovalev_D 124:9ae09249f842 562
Kovalev_D 124:9ae09249f842 563
Kovalev_D 124:9ae09249f842 564 //ток 2
Kovalev_D 124:9ae09249f842 565 case 16:
Kovalev_D 210:b02fa166315d 566 // Temp = Gyro.In2;
Kovalev_D 211:ac8251b067d2 567 IntOutDeltaPS = ((Gyro.In2>>1)*0.800875)-0x3e0b;
Kovalev_D 211:ac8251b067d2 568 BuffTemp[5] = (IntOutDeltaPS >> 8) & 0xff;
Kovalev_D 124:9ae09249f842 569 break;
Kovalev_D 124:9ae09249f842 570
Kovalev_D 124:9ae09249f842 571 case 17:
Kovalev_D 211:ac8251b067d2 572 BuffTemp[5] = (IntOutDeltaPS >> 0) & 0xff;//in2//3
Kovalev_D 124:9ae09249f842 573 break;
Kovalev_D 124:9ae09249f842 574
Kovalev_D 124:9ae09249f842 575
Kovalev_D 124:9ae09249f842 576
Kovalev_D 124:9ae09249f842 577 //разностный температурный канал Delta Temp
Kovalev_D 124:9ae09249f842 578 case 18:
Kovalev_D 211:ac8251b067d2 579 OutDeltaPS = 0;
Kovalev_D 211:ac8251b067d2 580 OutDeltaPS = Gyro.DeltaT;
Kovalev_D 211:ac8251b067d2 581 BuffTemp[5] = (OutDeltaPS >> 8) & 0xff;//дельта
Kovalev_D 124:9ae09249f842 582 break;
Kovalev_D 124:9ae09249f842 583
Kovalev_D 124:9ae09249f842 584 case 19:
Kovalev_D 211:ac8251b067d2 585 BuffTemp[5] = (OutDeltaPS >> 0) & 0xff;
Kovalev_D 124:9ae09249f842 586 break;
Kovalev_D 124:9ae09249f842 587
Kovalev_D 124:9ae09249f842 588
Kovalev_D 124:9ae09249f842 589
Kovalev_D 124:9ae09249f842 590 //температурный канал 5
Kovalev_D 124:9ae09249f842 591 case 20:
Kovalev_D 211:ac8251b067d2 592 OutDeltaPS = 0;
Kovalev_D 225:f8fee6c586cc 593 OutDeltaPS = Gyro.Termo;//Spi.ADC1;// //Gyro.Termo;//0xa4=164
Kovalev_D 211:ac8251b067d2 594 BuffTemp[5] =(OutDeltaPS >> 8) & 0xff;//температура
Kovalev_D 124:9ae09249f842 595 break;
Kovalev_D 124:9ae09249f842 596
Kovalev_D 124:9ae09249f842 597 case 21:
Kovalev_D 211:ac8251b067d2 598 BuffTemp[5] =(OutDeltaPS >> 0) & 0xff;//ADC6 sesnsor 5
Kovalev_D 211:ac8251b067d2 599 /* sprintf((Time),"%d %d \r\n", Spi.ADC1, Spi.ADC5 );
Kovalev_D 211:ac8251b067d2 600 WriteCon(Time);*/
Kovalev_D 124:9ae09249f842 601 break;
Kovalev_D 124:9ae09249f842 602 }
Kovalev_D 162:44e4ded32c6a 603 Check(BuffTemp, CRC_N);
Kovalev_D 162:44e4ded32c6a 604 WriteConN (BuffTemp,CRC_N);
Kovalev_D 128:1e4675a36c93 605
Kovalev_D 165:b2bd0c810a4f 606
Kovalev_D 165:b2bd0c810a4f 607 if(CountParam>20)CountParam=0;//зацикливания буфера от 0 до 21
Kovalev_D 165:b2bd0c810a4f 608 else CountParam++;
Kovalev_D 124:9ae09249f842 609
Kovalev_D 124:9ae09249f842 610 }
Kovalev_D 124:9ae09249f842 611
Kovalev_D 222:7de7b3bf3a1d 612
Kovalev_D 222:7de7b3bf3a1d 613 void M_Rate5K(void)
Kovalev_D 222:7de7b3bf3a1d 614 {
Kovalev_D 222:7de7b3bf3a1d 615
Kovalev_D 225:f8fee6c586cc 616 unsigned int Temp;
Kovalev_D 222:7de7b3bf3a1d 617 //Temp=Gyro.CuruAngle; //приводим к форме вывода
Kovalev_D 222:7de7b3bf3a1d 618 BuffTemp[ 3] =(Gyro.CuruAngle >> 8) & 0xff;//старший байт разности счетчиков 7 --младший байт разности счетчиков
Kovalev_D 222:7de7b3bf3a1d 619 BuffTemp[ 2] =(Gyro.CuruAngle >> 0) & 0xff;//младший байт разности счетчиков 8 --старший байт разности счетчиков
Kovalev_D 222:7de7b3bf3a1d 620 Gyro.CuruAngle=0;
Kovalev_D 222:7de7b3bf3a1d 621
Kovalev_D 222:7de7b3bf3a1d 622
Kovalev_D 225:f8fee6c586cc 623 Temp = ((Spi.DAC_B-0x7fff)&0xffff);
Kovalev_D 222:7de7b3bf3a1d 624 BuffTemp[5] = (Spi.DAC_B >> 8) & 0xff; //23 Выход регулятора рабочего периметра
Kovalev_D 222:7de7b3bf3a1d 625 BuffTemp[4] = (Spi.DAC_B >> 0) & 0xff;
Kovalev_D 222:7de7b3bf3a1d 626
Kovalev_D 225:f8fee6c586cc 627
Kovalev_D 225:f8fee6c586cc 628 Temp = 0xffff - Spi.DAC_A;
Kovalev_D 222:7de7b3bf3a1d 629 BuffTemp[7] =(Temp >> 8) & 0xff;//выход регулятора гвч; 11 --выход регулятора ГВЧ
Kovalev_D 222:7de7b3bf3a1d 630 BuffTemp[6] =(Temp >> 0) & 0xff;
Kovalev_D 222:7de7b3bf3a1d 631
Kovalev_D 222:7de7b3bf3a1d 632 /* sprintf((Time),"%d %d %d\r\n",Gyro.CuruAngle,(Spi.DAC_B-0x7fff),Temp);
Kovalev_D 222:7de7b3bf3a1d 633 WriteCon(Time);*/
Kovalev_D 222:7de7b3bf3a1d 634
Kovalev_D 222:7de7b3bf3a1d 635 //Check(BuffTemp, 7);
Kovalev_D 222:7de7b3bf3a1d 636 WriteConN (BuffTemp,8);
Kovalev_D 222:7de7b3bf3a1d 637 Gyro.EvenRate5K++;
Kovalev_D 222:7de7b3bf3a1d 638 }
Kovalev_D 222:7de7b3bf3a1d 639
Kovalev_D 222:7de7b3bf3a1d 640
igor_v 0:8ad47e2b6f00 641 void CMD_Rate(void)
Kovalev_D 190:289514f730ee 642 {
Kovalev_D 124:9ae09249f842 643 Gyro.Rate1_Event=0;
Kovalev_D 108:030cdde08314 644 unsigned int Temp;
Kovalev_D 208:19150d2b528f 645 int Temp1;
Kovalev_D 209:224e7331a061 646 float Temp2;
Kovalev_D 122:fbacb932a30b 647
Kovalev_D 208:19150d2b528f 648 BuffTemp[ 0] = Gyro.SOC_Out; //1 --старт данных
Kovalev_D 208:19150d2b528f 649 BuffTemp[ 1] = Gyro.My_Addres; //2 --адрес отвечающего устройствва
igor_v 21:bc8c1cec3da6 650
Kovalev_D 209:224e7331a061 651 BuffTemp[ 2] =( Gyro.CaunPlusReper >> 8) & 0xff;//старший байт счетчика +. 3 --сарший байт счентчика +
Kovalev_D 209:224e7331a061 652 BuffTemp[ 3] =( Gyro.CaunPlusReper >> 0) & 0xff;//младший байт счетчика +. 4 --младший байт счетчика +
Kovalev_D 211:ac8251b067d2 653
Kovalev_D 209:224e7331a061 654 BuffTemp[ 4] =( Gyro.CaunMinReper >> 8) & 0xff;//старший байт счетчика -. 5 --сарший байт счентчика -
Kovalev_D 209:224e7331a061 655 BuffTemp[ 5] =( Gyro.CaunMinReper >> 0) & 0xff;//младший байт счетчика -. 6 --младший байт счетчика -
Kovalev_D 211:ac8251b067d2 656
Kovalev_D 209:224e7331a061 657
Kovalev_D 209:224e7331a061 658 Gyro.CuruAngle = Gyro.CuruAngle + OldCuruAngle; //(72 град/с)
Kovalev_D 214:4c70e452c491 659 OldCuruAngle=Gyro.CuruAngle & 0x3f; //сохраняем 5 бит для след измирений
Kovalev_D 214:4c70e452c491 660 Temp=Gyro.CuruAngle>>6; //приводим к форме вывода
Kovalev_D 211:ac8251b067d2 661
Kovalev_D 209:224e7331a061 662
Kovalev_D 208:19150d2b528f 663 Gyro.CuruAngle = 0;
Kovalev_D 208:19150d2b528f 664 BuffTemp[ 6] =(Temp >> 8) & 0xff;//старший байт разности счетчиков 7 --младший байт разности счетчиков
Kovalev_D 208:19150d2b528f 665 BuffTemp[ 7] =(Temp >> 0) & 0xff;//младший байт разности счетчиков 8 --старший байт разности счетчиков
Kovalev_D 108:030cdde08314 666
Kovalev_D 108:030cdde08314 667
Kovalev_D 208:19150d2b528f 668 BuffTemp[38] =(Temp >> 24) & 0xff;; //39 приращение угла
Kovalev_D 208:19150d2b528f 669 BuffTemp[39] =(Temp >> 16) & 0xff;; //40 формат 22.10
Kovalev_D 208:19150d2b528f 670 BuffTemp[40] =(Temp >> 8) & 0xff;; //41 1бит знак
Kovalev_D 208:19150d2b528f 671 BuffTemp[41] =(Temp >> 0) & 0xff;; //42
Kovalev_D 209:224e7331a061 672
Kovalev_D 208:19150d2b528f 673 Temp = Gyro.F_ras;
Kovalev_D 209:224e7331a061 674 //Gyro.F_ras=0;
Kovalev_D 208:19150d2b528f 675 BuffTemp[ 8] = (Temp >> 8) & 0xff;//расщипление частота 9 --частота расщипления
Kovalev_D 209:224e7331a061 676 BuffTemp[ 9] = (Temp >> 0) & 0xff;// 10 --частота расщипления
Kovalev_D 208:19150d2b528f 677
Kovalev_D 211:ac8251b067d2 678 //(unsigned int)((Gyro.DacIn+30000)*0.6667);
Kovalev_D 226:4a4d5bd5fcd7 679 Temp1 = 0xffff - Spi.DAC_A;
Kovalev_D 226:4a4d5bd5fcd7 680 BuffTemp[10] = (Temp1 >> 8) & 0xff;//выход регулятора гвч; 11 --выход регулятора ГВЧ
Kovalev_D 209:224e7331a061 681 BuffTemp[11] = (Temp1 >> 0) & 0xff; //12 --выход регулятора ГВЧ
Kovalev_D 209:224e7331a061 682
Kovalev_D 211:ac8251b067d2 683
Kovalev_D 226:4a4d5bd5fcd7 684 /*
Kovalev_D 213:9953db9543d6 685 if(Gyro.LG_Type) Temp =(int)(tempDeltaRegul);
Kovalev_D 226:4a4d5bd5fcd7 686 else Temp =(unsigned int)((0x7fff-Spi.ADC5)*0.79)<<1;*/
Kovalev_D 226:4a4d5bd5fcd7 687
Kovalev_D 226:4a4d5bd5fcd7 688 Temp =(int)(tempDeltaRegul); //для призмы
Kovalev_D 225:f8fee6c586cc 689 tempDeltaRegul=0;
Kovalev_D 208:19150d2b528f 690 BuffTemp[12]=(Temp >> 8) & 0xff;//// HFO 13 --сигнал ошибки регулятора ГВЧ
Kovalev_D 208:19150d2b528f 691 BuffTemp[13]=(Temp >> 0) & 0xff;//// 14 --сигнал ошибки регулятора ГВЧ
Kovalev_D 209:224e7331a061 692
Kovalev_D 209:224e7331a061 693 //Temp = (unsigned int)((7675000*16/(Gyro.Frq>>12)));
Kovalev_D 210:b02fa166315d 694 Temp = (unsigned int)(7680000/(Gyro.Frq>>16));
Kovalev_D 208:19150d2b528f 695 BuffTemp[14] = (Temp >> 8) & 0xff; //15 период вибропривода.(частота) T_Vibro
Kovalev_D 208:19150d2b528f 696 BuffTemp[15] = (Temp >> 0) & 0xff; //16 период вибропривода.
Kovalev_D 208:19150d2b528f 697
Kovalev_D 209:224e7331a061 698 Temp = Gyro.FrqPhaseEror<<2;//Spi.DAC_A-0x7fff;
Kovalev_D 209:224e7331a061 699 BuffTemp[16] = (Temp >> 8) & 0xff; //17 старший байт ФД регулятора периода вибропривода
Kovalev_D 209:224e7331a061 700 BuffTemp[17] = (Temp >> 0) & 0xff;
Kovalev_D 209:224e7331a061 701 /*sprintf((Time),"%d %d\r\n",Gyro.FrqPhaseEror, Gyro.FrqPhaseEror<<2);
Kovalev_D 209:224e7331a061 702 WriteCon(Time); */ //18
igor_v 21:bc8c1cec3da6 703
Kovalev_D 209:224e7331a061 704 Temp =Gyro.L_vibro/*>>1*/;//(unsigned int)(((7675000*16/200) * Gyro.AmpPer /(Gyro.Frq>>12)));
Kovalev_D 208:19150d2b528f 705 BuffTemp[18] = (Temp >> 8) & 0xff; //19 длительность импулься вибропривода(амплитуда)
Kovalev_D 208:19150d2b528f 706 BuffTemp[19] = (Temp >> 0) & 0xff; //20
Kovalev_D 210:b02fa166315d 707
Kovalev_D 208:19150d2b528f 708
Kovalev_D 208:19150d2b528f 709 Temp = 0x0;//Gyro.L_vibro<<2;
Kovalev_D 208:19150d2b528f 710 BuffTemp[20] = (Temp >> 8) & 0xff;//регулятор датчика угла поворота //21 старший байт регулятора датчика угла поворота
Kovalev_D 208:19150d2b528f 711 BuffTemp[21] = (Temp >> 0) & 0xff; //22
Kovalev_D 208:19150d2b528f 712
Kovalev_D 225:f8fee6c586cc 713 Temp1 =((Spi.DAC_B-0x7fff)&0xffff);///(3300+(0x7fff+(Spi.DAC_B*1.083)));
Kovalev_D 209:224e7331a061 714 BuffTemp[22] = (Temp1 >> 8) & 0xff; //23 Выход регулятора рабочего периметра
Kovalev_D 209:224e7331a061 715 BuffTemp[23] = (Temp1 >> 0) & 0xff;
Kovalev_D 209:224e7331a061 716 //24
Kovalev_D 211:ac8251b067d2 717
Kovalev_D 220:04c54405b82d 718 Temp = PLC_EROR;
Kovalev_D 220:04c54405b82d 719 PLC_EROR=0;
Kovalev_D 220:04c54405b82d 720
Kovalev_D 208:19150d2b528f 721 BuffTemp[24] = (Temp >> 8) & 0xff;// //25 ФД СРП
Kovalev_D 208:19150d2b528f 722 BuffTemp[25] = (Temp >> 0) & 0xff;// //26 ФД СРП
Kovalev_D 209:224e7331a061 723
Kovalev_D 209:224e7331a061 724 Temp =0;/* Gyro.AD_Slow >> 16*/;
Kovalev_D 208:19150d2b528f 725 BuffTemp[26] = (Temp >> 8) & 0xff; //27 ADC 0
Kovalev_D 208:19150d2b528f 726 BuffTemp[27] = (Temp >> 0) & 0xff; //28
Kovalev_D 113:8be429494918 727
Kovalev_D 209:224e7331a061 728 Temp =0; /*Gyro.AD_Slow >> 16*/;
Kovalev_D 208:19150d2b528f 729 BuffTemp[28] = (Temp >> 8) & 0xff; //29 ADC 1
Kovalev_D 208:19150d2b528f 730 BuffTemp[29] = (Temp >> 0) & 0xff; //30
Kovalev_D 113:8be429494918 731
Kovalev_D 220:04c54405b82d 732 Temp1 = 0;//((Gyro.In1>>1)*0.800875)-0x3e0b;
Kovalev_D 209:224e7331a061 733 BuffTemp[30] = (Temp1 >> 8) & 0xff;//in1//2 //31 ADC 2
Kovalev_D 209:224e7331a061 734 BuffTemp[31] = (Temp1 >> 0) & 0xff; //32
Kovalev_D 208:19150d2b528f 735
Kovalev_D 220:04c54405b82d 736 Temp1 =0;//((Gyro.In2>>1)*0.800875)-0x3e0b;// - 0x4FFF;
Kovalev_D 209:224e7331a061 737 BuffTemp[32] = (Temp1 >> 8) & 0xff; //33 ADC 3
Kovalev_D 209:224e7331a061 738 BuffTemp[33] = (Temp1 >> 0) & 0xff;//in2//3 //34
Kovalev_D 209:224e7331a061 739
Kovalev_D 208:19150d2b528f 740 Temp = (Gyro.DeltaT);
Kovalev_D 208:19150d2b528f 741 BuffTemp[34] = (Temp >> 8) & 0xff;//дельта //35 ADC 4
Kovalev_D 208:19150d2b528f 742 BuffTemp[35] = (Temp >> 0) & 0xff; //36
Kovalev_D 208:19150d2b528f 743 // Temp = 000;
Kovalev_D 208:19150d2b528f 744
Kovalev_D 208:19150d2b528f 745 Temp = Gyro.Termo;
Kovalev_D 208:19150d2b528f 746 BuffTemp[36] =(Temp >> 8) & 0xff;//температура //37 ADC 5
Kovalev_D 208:19150d2b528f 747 BuffTemp[37] =(Temp >> 0) & 0xff;//ADC6 sesnsor 5 //38
igor_v 21:bc8c1cec3da6 748
igor_v 21:bc8c1cec3da6 749 Check(BuffTemp, 44);
igor_v 21:bc8c1cec3da6 750 WriteConN (BuffTemp,44);
Kovalev_D 209:224e7331a061 751 for(int i=0; i<45;i++) {BuffTemp[i]=0;}
Kovalev_D 209:224e7331a061 752 }
Kovalev_D 209:224e7331a061 753
Kovalev_D 210:b02fa166315d 754 void CMD_Rate2(void)
Kovalev_D 210:b02fa166315d 755 {
Kovalev_D 210:b02fa166315d 756 unsigned int Temp;
Kovalev_D 225:f8fee6c586cc 757 //float y = 52646.45
Kovalev_D 210:b02fa166315d 758 Gyro.Reper_Event=0;
Kovalev_D 214:4c70e452c491 759 for(int q=0; q<64; q++)
Kovalev_D 214:4c70e452c491 760 {
Kovalev_D 214:4c70e452c491 761 BuffTemp[q]=0;
Kovalev_D 214:4c70e452c491 762 }
Kovalev_D 210:b02fa166315d 763 BuffTemp[ 0] = Gyro.SOC_Out;
Kovalev_D 210:b02fa166315d 764 BuffTemp[ 1] = Gyro.My_Addres;
Kovalev_D 216:189b0ea1dc38 765
Kovalev_D 211:ac8251b067d2 766 Temp=Gyro.CaunPlusReper;
Kovalev_D 211:ac8251b067d2 767
Kovalev_D 210:b02fa166315d 768 BuffTemp[ 2] =(Temp >> 8) & 0xff;//старший байт счетчика +.
Kovalev_D 210:b02fa166315d 769 BuffTemp[ 3] =(Temp >> 0) & 0xff;//младший байт счетчика +.
Kovalev_D 211:ac8251b067d2 770 //сохраняем 5 бит для след измирений
Kovalev_D 210:b02fa166315d 771
Kovalev_D 211:ac8251b067d2 772 Temp= Gyro.CaunMinReper;
Kovalev_D 211:ac8251b067d2 773
Kovalev_D 210:b02fa166315d 774 BuffTemp[ 4] =(Temp >> 8) & 0xff;//старший байт счетчика -.
Kovalev_D 210:b02fa166315d 775 BuffTemp[ 5] =(Temp >> 0) & 0xff;//младший байт счетчика -.
Kovalev_D 216:189b0ea1dc38 776
Kovalev_D 211:ac8251b067d2 777
Kovalev_D 210:b02fa166315d 778 Check(BuffTemp, 8);
Kovalev_D 210:b02fa166315d 779 WriteConN (BuffTemp,8);
Kovalev_D 210:b02fa166315d 780 }
Kovalev_D 210:b02fa166315d 781
Kovalev_D 210:b02fa166315d 782 void CMD_Rate3(void)
Kovalev_D 210:b02fa166315d 783 {
Kovalev_D 210:b02fa166315d 784 Gyro.Rate3_Event=0;
Kovalev_D 210:b02fa166315d 785 BuffTemp[ 0] = Gyro.SOC_Out;
Kovalev_D 210:b02fa166315d 786 BuffTemp[ 1] = Gyro.My_Addres;
Kovalev_D 210:b02fa166315d 787 BuffTemp[ 2] = 0xcc;//старший байт счетчика +.
Kovalev_D 210:b02fa166315d 788 BuffTemp[ 3] = 0xcc;//младший байт счетчика +.
Kovalev_D 210:b02fa166315d 789
Kovalev_D 210:b02fa166315d 790 BuffTemp[ 4] =0xBB;//старший байт счетчика -.
Kovalev_D 210:b02fa166315d 791 BuffTemp[ 5] =0xBB;//младший байт счетчика -.
Kovalev_D 210:b02fa166315d 792
Kovalev_D 210:b02fa166315d 793 Check(BuffTemp, 8);
Kovalev_D 210:b02fa166315d 794 WriteConN (BuffTemp,8);
Kovalev_D 210:b02fa166315d 795 }
Kovalev_D 210:b02fa166315d 796
Kovalev_D 209:224e7331a061 797 void CMD_M_Stymul()
Kovalev_D 209:224e7331a061 798 {
Kovalev_D 209:224e7331a061 799 int temp,Consol=0,HFO,b4;
Kovalev_D 209:224e7331a061 800 float Temp1;
Kovalev_D 209:224e7331a061 801 temp=BuffTemp[3];
Kovalev_D 209:224e7331a061 802
Kovalev_D 209:224e7331a061 803 b4 = temp;
Kovalev_D 209:224e7331a061 804 Consol = temp>>7;
Kovalev_D 209:224e7331a061 805 HFO = temp&0x3;// // (номер (код) ЦАПа 0...3, HFO - 3dac, PLC - 0DAC
Kovalev_D 209:224e7331a061 806
Kovalev_D 209:224e7331a061 807 temp = (((BuffTemp[4]<<8) | BuffTemp[5])&0xFFFF);
Kovalev_D 209:224e7331a061 808 if(HFO)
Kovalev_D 209:224e7331a061 809 {
Kovalev_D 209:224e7331a061 810 Gyro.DacIn=temp;
Kovalev_D 225:f8fee6c586cc 811 if(Gyro.LG_Type==1) Spi.DAC_A = 0xffff-Gyro.DacIn; //((unsigned int)((Gyro.DacIn+0x7011)*0.6667));
Kovalev_D 222:7de7b3bf3a1d 812 else Spi.DAC_A = (unsigned int)(0xffff-Gyro.DacIn); //Spi.DAC_A = ((unsigned int)((Gyro.DacIn+23200)*0.64));
Kovalev_D 209:224e7331a061 813 }
Kovalev_D 225:f8fee6c586cc 814
Kovalev_D 225:f8fee6c586cc 815 else Spi.DAC_B = (unsigned int)((temp-0x7fff)&0xffff);
Kovalev_D 225:f8fee6c586cc 816 sprintf((Time),"%d %d \r\n", Spi.DAC_B, temp);
Kovalev_D 225:f8fee6c586cc 817 WriteCon(Time);
Kovalev_D 225:f8fee6c586cc 818 for(int q=0; q<64; q++)
Kovalev_D 218:b4067cac75c0 819 {
Kovalev_D 218:b4067cac75c0 820 BuffTemp[q]=0;
Kovalev_D 218:b4067cac75c0 821 }
Kovalev_D 209:224e7331a061 822 BuffTemp[0] = Gyro.SOC_Out; //DD
Kovalev_D 209:224e7331a061 823 BuffTemp[1] = Gyro.My_Addres; //00
Kovalev_D 209:224e7331a061 824 BuffTemp[2] = Gyro.CMD_In; //D9
Kovalev_D 209:224e7331a061 825 BuffTemp[3] =0;
Kovalev_D 209:224e7331a061 826 Check(BuffTemp, CRC_N);
Kovalev_D 209:224e7331a061 827 WriteConN (BuffTemp,CRC_N);
igor_v 0:8ad47e2b6f00 828 }
Kovalev_D 209:224e7331a061 829
Kovalev_D 179:2b4e6bc277df 830 void CMD_M_vib()
Kovalev_D 179:2b4e6bc277df 831 {
Kovalev_D 209:224e7331a061 832 unsigned int temp1,temp2,anser;
Kovalev_D 209:224e7331a061 833 temp1 = (((BuffTemp[4]<<8) | BuffTemp[5])&0xFFFF);
Kovalev_D 225:f8fee6c586cc 834 Gyro.Frq = (122780000/temp1)<<12;
Kovalev_D 214:4c70e452c491 835 F_vib=103200000/((Gyro.Frq>>16)*2);
Kovalev_D 209:224e7331a061 836 temp2 = (((BuffTemp[6]<<8) | BuffTemp[7])&0xFFFF);
Kovalev_D 210:b02fa166315d 837 Gyro.AmpPer = ((((((Gyro.Frq>>12)*200)/16)*temp2)/7680000)/2);
Kovalev_D 214:4c70e452c491 838 Gyro.Amp = (Gyro.AmpPer)<<15;
Kovalev_D 225:f8fee6c586cc 839
Kovalev_D 209:224e7331a061 840 BuffTemp[0] = Gyro.SOC_Out;
Kovalev_D 209:224e7331a061 841 BuffTemp[1] = Gyro.My_Addres;
Kovalev_D 209:224e7331a061 842 BuffTemp[2] = Gyro.CMD_In;
Kovalev_D 209:224e7331a061 843 BuffTemp[3] = 0x0;
Kovalev_D 209:224e7331a061 844 BuffTemp[4] = 0x0;
Kovalev_D 209:224e7331a061 845 Check(BuffTemp, CRC_N);
Kovalev_D 209:224e7331a061 846 WriteConN (BuffTemp,CRC_N);
Kovalev_D 179:2b4e6bc277df 847 }
igor_v 21:bc8c1cec3da6 848 void CMD_M_Control_D8()///установка\сброс регистров управления
igor_v 21:bc8c1cec3da6 849 {
Kovalev_D 209:224e7331a061 850 unsigned int bit=0,Pa=0;
Kovalev_D 209:224e7331a061 851 unsigned int SR=0,V=0,Bit_num=0,A=0;
Kovalev_D 209:224e7331a061 852 Pa = BuffTemp[3];
Kovalev_D 209:224e7331a061 853 SR = Pa >> 7;
Kovalev_D 209:224e7331a061 854 V = (Pa>>5)&0x3;
Kovalev_D 209:224e7331a061 855 A = (Pa>>4)&0x1;
Kovalev_D 209:224e7331a061 856 Bit_num = Pa & 0xf;
Kovalev_D 104:ab1cb4ff56b2 857
Kovalev_D 209:224e7331a061 858 switch (SR)
Kovalev_D 209:224e7331a061 859 {
Kovalev_D 209:224e7331a061 860 case 0:
Kovalev_D 209:224e7331a061 861 switch (A)
Kovalev_D 209:224e7331a061 862 {
Kovalev_D 209:224e7331a061 863 case 0:
Kovalev_D 209:224e7331a061 864 switch (Bit_num)
Kovalev_D 209:224e7331a061 865 {
Kovalev_D 209:224e7331a061 866 case 0x06: FrqOFF break;
Kovalev_D 209:224e7331a061 867 case 0x05: AVibOFF break;
Kovalev_D 209:224e7331a061 868 case 0x01: HFOOFF break;
Kovalev_D 209:224e7331a061 869 case 0x03: PlcOFF break;
Kovalev_D 222:7de7b3bf3a1d 870 case 0x02: Gyro.RgConA &= ~(1<<2); break;
Kovalev_D 209:224e7331a061 871 }
Kovalev_D 209:224e7331a061 872 break;
Kovalev_D 209:224e7331a061 873 case 1:
Kovalev_D 209:224e7331a061 874 switch (Bit_num)
Kovalev_D 209:224e7331a061 875 {
Kovalev_D 209:224e7331a061 876 case 0x00: Gyro.RgConB &= ~(1<<0); break;
Kovalev_D 209:224e7331a061 877 case 0x01: Gyro.RgConB &= ~(1<<1); break;
Kovalev_D 209:224e7331a061 878 case 0x02: Gyro.RgConB &= ~(1<<2); break;
Kovalev_D 209:224e7331a061 879 }
Kovalev_D 209:224e7331a061 880 break;
Kovalev_D 209:224e7331a061 881 }
Kovalev_D 209:224e7331a061 882
Kovalev_D 209:224e7331a061 883
Kovalev_D 209:224e7331a061 884 break;
Kovalev_D 209:224e7331a061 885 case 1:
Kovalev_D 209:224e7331a061 886 switch (A)
Kovalev_D 209:224e7331a061 887 {
Kovalev_D 209:224e7331a061 888 case 0:
Kovalev_D 209:224e7331a061 889 switch (Bit_num)
Kovalev_D 209:224e7331a061 890 {
Kovalev_D 222:7de7b3bf3a1d 891 case 0x06: FrqON break;
Kovalev_D 222:7de7b3bf3a1d 892 case 0x05: AVibON break;
Kovalev_D 222:7de7b3bf3a1d 893 case 0x01: HFOON break;
Kovalev_D 222:7de7b3bf3a1d 894 case 0x03: PlcON break;
Kovalev_D 222:7de7b3bf3a1d 895 case 0x02: Gyro.RgConA |= (1<<2); break;
Kovalev_D 209:224e7331a061 896 }
Kovalev_D 209:224e7331a061 897 break;
Kovalev_D 209:224e7331a061 898 case 1:
Kovalev_D 209:224e7331a061 899 switch (Bit_num)
Kovalev_D 209:224e7331a061 900 {
Kovalev_D 209:224e7331a061 901 case 0x00: Gyro.RgConB |= (1<<0); break;
Kovalev_D 209:224e7331a061 902 case 0x01: Gyro.RgConB |= (1<<1); break;
Kovalev_D 209:224e7331a061 903 case 0x02: Gyro.RgConB |= (1<<2); break;
Kovalev_D 209:224e7331a061 904 }
Kovalev_D 209:224e7331a061 905 break;
Kovalev_D 209:224e7331a061 906 }
Kovalev_D 209:224e7331a061 907 break;
Kovalev_D 209:224e7331a061 908 }
igor_v 30:17c84ed091b3 909 BuffTemp[0] = Gyro.SOC_Out; //DD
igor_v 30:17c84ed091b3 910 BuffTemp[1] = Gyro.My_Addres; //00
igor_v 30:17c84ed091b3 911 BuffTemp[2] = Gyro.CMD_In; //D8
Kovalev_D 209:224e7331a061 912 switch (A)
Kovalev_D 209:224e7331a061 913 {
Kovalev_D 209:224e7331a061 914 case 0:
Kovalev_D 209:224e7331a061 915 BuffTemp[ 4] =(Gyro.RgConA >> 8) & 0xff;
Kovalev_D 209:224e7331a061 916 BuffTemp[ 5] =(Gyro.RgConA >> 0) & 0xff;
Kovalev_D 209:224e7331a061 917 break;
Kovalev_D 209:224e7331a061 918
Kovalev_D 209:224e7331a061 919 case 1:
Kovalev_D 209:224e7331a061 920 BuffTemp[ 4] =(Gyro.RgConB >> 8) & 0xff;
Kovalev_D 209:224e7331a061 921 BuffTemp[ 5] =(Gyro.RgConB >> 0) & 0xff;
Kovalev_D 209:224e7331a061 922 break;
Kovalev_D 209:224e7331a061 923 }
Kovalev_D 209:224e7331a061 924 Check(BuffTemp, CRC_N);
Kovalev_D 209:224e7331a061 925 WriteConN (BuffTemp,CRC_N);
Kovalev_D 209:224e7331a061 926 }
Kovalev_D 208:19150d2b528f 927
igor_v 21:bc8c1cec3da6 928 void CMD_M_Control_D9()///чтение регистров управления
igor_v 21:bc8c1cec3da6 929 {
Kovalev_D 209:224e7331a061 930 int bit,NReg,param=0;
igor_v 30:17c84ed091b3 931 BuffTemp[0] = Gyro.SOC_Out; //DD
igor_v 30:17c84ed091b3 932 BuffTemp[1] = Gyro.My_Addres; //00
igor_v 30:17c84ed091b3 933 BuffTemp[2] = Gyro.CMD_In; //D9
Kovalev_D 209:224e7331a061 934 param = BuffTemp[3];
Kovalev_D 209:224e7331a061 935 if (param)
Kovalev_D 209:224e7331a061 936 {
igor_v 21:bc8c1cec3da6 937 BuffTemp[3]=1<<4;
igor_v 30:17c84ed091b3 938 BuffTemp[4] = (Gyro.RgConB>>8 ) & 0xff;
igor_v 30:17c84ed091b3 939 BuffTemp[5] = Gyro.RgConB & 0xff;
igor_v 21:bc8c1cec3da6 940 }
Kovalev_D 209:224e7331a061 941 else
Kovalev_D 209:224e7331a061 942 {
Kovalev_D 209:224e7331a061 943 BuffTemp[3]=0<<4;
Kovalev_D 209:224e7331a061 944 BuffTemp[4] = (Gyro.RgConA>>8 )& 0xff;
Kovalev_D 209:224e7331a061 945 BuffTemp[5] = Gyro.RgConA & 0xff;
Kovalev_D 209:224e7331a061 946 }
igor_v 21:bc8c1cec3da6 947 Check(BuffTemp, CRC_N);
igor_v 21:bc8c1cec3da6 948 WriteConN (BuffTemp,CRC_N);
igor_v 21:bc8c1cec3da6 949 }
igor_v 21:bc8c1cec3da6 950 // (номер (код) ЦАПа 0...3, старший байт требуемого ЦАПа, младший байт треб ЦАПа)
Kovalev_D 209:224e7331a061 951
Kovalev_D 209:224e7331a061 952
Kovalev_D 194:8f3cb37a5541 953
Kovalev_D 194:8f3cb37a5541 954 void GLDStartDischarg(void)
Kovalev_D 208:19150d2b528f 955 { TimeDischarg=0;
Kovalev_D 208:19150d2b528f 956 Try=0;
Kovalev_D 194:8f3cb37a5541 957 switch(Gyro.My_Addres)
Kovalev_D 194:8f3cb37a5541 958 {//смещение поджига и подсветки в зависимости от адреса ГЛД
Kovalev_D 194:8f3cb37a5541 959 case 0:
Kovalev_D 194:8f3cb37a5541 960 Gyro.Discharg = StartDischarg << ShiftStart0;
Kovalev_D 194:8f3cb37a5541 961 Gyro.BackLight = StartBackLight << ShiftStart0;
Kovalev_D 194:8f3cb37a5541 962 break;
Kovalev_D 194:8f3cb37a5541 963 case 1:
Kovalev_D 194:8f3cb37a5541 964 Gyro.Discharg = StartDischarg << ShiftStart1;
Kovalev_D 194:8f3cb37a5541 965 Gyro.BackLight = StartBackLight << ShiftStart1;
Kovalev_D 194:8f3cb37a5541 966 break;
Kovalev_D 194:8f3cb37a5541 967 case 2:
Kovalev_D 194:8f3cb37a5541 968 Gyro.Discharg = StartDischarg << ShiftStart2;
Kovalev_D 194:8f3cb37a5541 969 Gyro.BackLight = StartBackLight << ShiftStart2;
Kovalev_D 194:8f3cb37a5541 970 break;
Kovalev_D 194:8f3cb37a5541 971 case 3:
Kovalev_D 194:8f3cb37a5541 972 Gyro.Discharg = StartDischarg << ShiftStart3;
Kovalev_D 194:8f3cb37a5541 973 Gyro.BackLight = StartBackLight << ShiftStart3;
Kovalev_D 194:8f3cb37a5541 974 break;
Kovalev_D 194:8f3cb37a5541 975 }
Kovalev_D 194:8f3cb37a5541 976 }
Kovalev_D 194:8f3cb37a5541 977
Kovalev_D 103:e96f08947def 978 void Gph_W()
Kovalev_D 103:e96f08947def 979 {
Kovalev_D 205:775d54fdf646 980 //Gyro.flagGph_W=3;
Kovalev_D 208:19150d2b528f 981
Kovalev_D 172:ef7bf1663645 982 Out_G_photo(BuffTemp[4],BuffTemp[5]);
Kovalev_D 209:224e7331a061 983 BuffTemp[0] = Gyro.SOC_Out; //DD
Kovalev_D 209:224e7331a061 984 BuffTemp[1] = Gyro.My_Addres; //00
Kovalev_D 209:224e7331a061 985 BuffTemp[2] = Gyro.CMD_In; //D9
Kovalev_D 209:224e7331a061 986 BuffTemp[3] = 0;
Kovalev_D 209:224e7331a061 987 Check(BuffTemp, CRC_N);
Kovalev_D 209:224e7331a061 988 WriteConN (BuffTemp,CRC_N);
Kovalev_D 103:e96f08947def 989 }
Kovalev_D 209:224e7331a061 990 void DeviceMode()
Kovalev_D 209:224e7331a061 991 {
Kovalev_D 209:224e7331a061 992 int TempMod=1;
Kovalev_D 209:224e7331a061 993 BuffTemp[0] = Gyro.SOC_Out; //DD
Kovalev_D 209:224e7331a061 994 BuffTemp[1] = Gyro.My_Addres; //00
Kovalev_D 209:224e7331a061 995 BuffTemp[2] = Gyro.CMD_In; //D9
Kovalev_D 209:224e7331a061 996 TempMod = BuffTemp[3] & 0xf;
Kovalev_D 226:4a4d5bd5fcd7 997 Gyro.Device_Mode = TempMod;
Kovalev_D 226:4a4d5bd5fcd7 998
Kovalev_D 226:4a4d5bd5fcd7 999 sprintf((Time)," Comand - DeviceMode(); Gyro.Device_Mode = %d Gyro.ModeOut = %d\r\n",Gyro.Device_Mode,Gyro.ModeOut);
Kovalev_D 226:4a4d5bd5fcd7 1000 WriteCon(Time);
Kovalev_D 226:4a4d5bd5fcd7 1001 /*
Kovalev_D 226:4a4d5bd5fcd7 1002 sprintf((Time),"%d\r\n",Gyro.Device_Mode);
Kovalev_D 226:4a4d5bd5fcd7 1003 WriteCon(Time);*/
Kovalev_D 226:4a4d5bd5fcd7 1004 BuffTemp[3]=Gyro.Device_Mode & 0xff;
Kovalev_D 209:224e7331a061 1005 BuffTemp[4]=0;
Kovalev_D 209:224e7331a061 1006 BuffTemp[5]=0;
Kovalev_D 209:224e7331a061 1007 Check(BuffTemp, CRC_N);
Kovalev_D 209:224e7331a061 1008 WriteConN (BuffTemp,CRC_N);
Kovalev_D 209:224e7331a061 1009 }
Kovalev_D 102:4270092be987 1010
igor_v 0:8ad47e2b6f00 1011 unsigned int Check(char *c, unsigned int Count)
igor_v 0:8ad47e2b6f00 1012 {
igor_v 21:bc8c1cec3da6 1013 int i=1;
igor_v 21:bc8c1cec3da6 1014 unsigned int temp,CRC;
igor_v 21:bc8c1cec3da6 1015
igor_v 21:bc8c1cec3da6 1016
igor_v 21:bc8c1cec3da6 1017 temp=1;
igor_v 21:bc8c1cec3da6 1018 CRC=0;
igor_v 21:bc8c1cec3da6 1019
igor_v 21:bc8c1cec3da6 1020
igor_v 21:bc8c1cec3da6 1021 for(; i<Count-2; i++) {
igor_v 21:bc8c1cec3da6 1022 CRC+=c[i];
igor_v 21:bc8c1cec3da6 1023 }
igor_v 0:8ad47e2b6f00 1024
igor_v 21:bc8c1cec3da6 1025 if(c[Count-2]!=((CRC>>8)&0xFF)) {
igor_v 21:bc8c1cec3da6 1026 temp=0;
igor_v 30:17c84ed091b3 1027 Gyro.RsErrLine = (Gyro.RsErrLine)&=0x2;
igor_v 21:bc8c1cec3da6 1028 }
igor_v 0:8ad47e2b6f00 1029
igor_v 21:bc8c1cec3da6 1030 if(c[Count-1]!=((CRC>>0)&0xFF)) {
igor_v 21:bc8c1cec3da6 1031 temp=0;
igor_v 30:17c84ed091b3 1032 // Gyro.RsErrLine= (Gyro.RsErrLine)=0x2;
igor_v 21:bc8c1cec3da6 1033 }
igor_v 21:bc8c1cec3da6 1034
igor_v 21:bc8c1cec3da6 1035 c[Count-2]=(CRC>>8)&0xFF;
igor_v 21:bc8c1cec3da6 1036 c[Count-1]=(CRC>>0)&0xFF;
igor_v 21:bc8c1cec3da6 1037
igor_v 21:bc8c1cec3da6 1038 return temp;
igor_v 0:8ad47e2b6f00 1039 }
igor_v 0:8ad47e2b6f00 1040
igor_v 0:8ad47e2b6f00 1041 int Getlengf(void)
igor_v 0:8ad47e2b6f00 1042 {
Kovalev_D 121:bbae560cdd43 1043 unsigned int lengf;
Kovalev_D 121:bbae560cdd43 1044 lengf = 1;
Kovalev_D 194:8f3cb37a5541 1045 switch(Gyro.CMD_In)
Kovalev_D 194:8f3cb37a5541 1046 {
Kovalev_D 194:8f3cb37a5541 1047 case 0x99: lengf=6; CRC_N=8; break; //Mintainance
Kovalev_D 194:8f3cb37a5541 1048 case 0xB0: lengf=6; CRC_N=9; break; //Delta_Bins
Kovalev_D 194:8f3cb37a5541 1049 case 0x0F: lengf=6; CRC_N=8; break; //Delta_Bins
Kovalev_D 194:8f3cb37a5541 1050 case 0xA0: lengf=6; CRC_N=8; break; //Delta_PS
Kovalev_D 194:8f3cb37a5541 1051 case 0xDD: lengf=6; CRC_N=44; break; //m_rate
Kovalev_D 209:224e7331a061 1052 case 0x0A: lengf=8; CRC_N=6; break; //m_stymul
Kovalev_D 194:8f3cb37a5541 1053 case 0xE9: lengf=6; CRC_N=8; break; //DeviceMode
Kovalev_D 194:8f3cb37a5541 1054 case 0xE8: lengf=6; CRC_N=8; break; //DeviceMode
Kovalev_D 194:8f3cb37a5541 1055 case 0xA5: lengf=6; CRC_N=8; break; //DeviceMode
Kovalev_D 209:224e7331a061 1056 case 0xD8: lengf=6; CRC_N=8; break; //m_control
Kovalev_D 194:8f3cb37a5541 1057 case 0xD9: lengf=6; CRC_N=8; break; //m_control
Kovalev_D 209:224e7331a061 1058 case 0xE4: lengf=8; CRC_N=6; break; //M_VIB_W
Kovalev_D 209:224e7331a061 1059 case 0xE6: lengf=8; CRC_N=6; break; //M_Gph_W
Kovalev_D 209:224e7331a061 1060
Kovalev_D 194:8f3cb37a5541 1061 } return lengf;
igor_v 0:8ad47e2b6f00 1062 }
igor_v 0:8ad47e2b6f00 1063
igor_v 0:8ad47e2b6f00 1064 void Read_CMD(void)
igor_v 21:bc8c1cec3da6 1065 {
Kovalev_D 188:4c523cc373cc 1066
Kovalev_D 147:1aed74f19a8f 1067 Gyro.RsErrLine = (Gyro.RsErrLine)& 0xffff;//для сброса ошибки
Kovalev_D 188:4c523cc373cc 1068 CountBuFFIn=ReadChekCon1(BuffTemp);
Kovalev_D 188:4c523cc373cc 1069 // чтение данных из консоли
Kovalev_D 188:4c523cc373cc 1070 if(CountBuFFIn==1) {
Kovalev_D 190:289514f730ee 1071 // если есть первый байт
Kovalev_D 209:224e7331a061 1072 if (BuffTemp[0] != SOC_In)
Kovalev_D 209:224e7331a061 1073 {
Kovalev_D 147:1aed74f19a8f 1074 ReadCon1(BuffTemp);
Kovalev_D 194:8f3cb37a5541 1075 Gyro.RsErrLine += 0x100;
Kovalev_D 209:224e7331a061 1076 //BuffTemp[99]=Gyro.RsErrLine;
Kovalev_D 209:224e7331a061 1077 ReadCon1(BuffTemp);
Kovalev_D 209:224e7331a061 1078 }
Kovalev_D 147:1aed74f19a8f 1079 }
Kovalev_D 190:289514f730ee 1080 else if(CountBuFFIn==2) //если второй байт
Kovalev_D 194:8f3cb37a5541 1081 { // широковещаительный
Kovalev_D 209:224e7331a061 1082 if (BuffTemp[1] != Gyro.My_Addres /*|| BuffTemp[1] !=0x1f*/)
Kovalev_D 209:224e7331a061 1083 {
Kovalev_D 93:b3803774f110 1084 ReadCon1(BuffTemp);
Kovalev_D 194:8f3cb37a5541 1085 Gyro.RsErrLine += 0x1;
Kovalev_D 209:224e7331a061 1086 ReadCon1(BuffTemp);
Kovalev_D 188:4c523cc373cc 1087 }
Kovalev_D 147:1aed74f19a8f 1088 }
Kovalev_D 190:289514f730ee 1089 else if(CountBuFFIn==3) // если третий байт
Kovalev_D 147:1aed74f19a8f 1090 {
igor_v 30:17c84ed091b3 1091 Gyro.CMD_In=BuffTemp[2];
Kovalev_D 92:c892f0311aa7 1092 N=Getlengf();
Kovalev_D 92:c892f0311aa7 1093 }
Kovalev_D 92:c892f0311aa7 1094 else if(CountBuFFIn==4 && (N==6))
Kovalev_D 92:c892f0311aa7 1095 { // N - длина посылки аскглд(для записи параметров). определяется по коду команды в Getlengf();
igor_v 21:bc8c1cec3da6 1096 Param1=BuffTemp[3];
Kovalev_D 92:c892f0311aa7 1097 }
Kovalev_D 92:c892f0311aa7 1098 else if((CountBuFFIn==5)&&(N==7))
Kovalev_D 92:c892f0311aa7 1099 {
igor_v 21:bc8c1cec3da6 1100 Param1=BuffTemp[3];
igor_v 21:bc8c1cec3da6 1101 Param2=BuffTemp[4];
igor_v 0:8ad47e2b6f00 1102
Kovalev_D 92:c892f0311aa7 1103 }
Kovalev_D 92:c892f0311aa7 1104 else if((CountBuFFIn==6)&&(N==8))
Kovalev_D 147:1aed74f19a8f 1105 {
igor_v 21:bc8c1cec3da6 1106 Param1=BuffTemp[3];
igor_v 21:bc8c1cec3da6 1107 Param2=BuffTemp[4];
igor_v 21:bc8c1cec3da6 1108 Param3=BuffTemp[5];
Kovalev_D 92:c892f0311aa7 1109 }
Kovalev_D 102:4270092be987 1110 else if((CountBuFFIn==8)&&(N==10))
Kovalev_D 147:1aed74f19a8f 1111 {
Kovalev_D 102:4270092be987 1112 Param1=BuffTemp[4];
Kovalev_D 102:4270092be987 1113 Param2=BuffTemp[5];
Kovalev_D 102:4270092be987 1114 Param3=BuffTemp[6];
Kovalev_D 102:4270092be987 1115 Param4=BuffTemp[7];
Kovalev_D 102:4270092be987 1116 }
Kovalev_D 98:95b8e79f13e1 1117
Kovalev_D 92:c892f0311aa7 1118 else if(CountBuFFIn > (N-1))
Kovalev_D 92:c892f0311aa7 1119 {
Kovalev_D 147:1aed74f19a8f 1120 ReadCon1(BuffTemp);
Kovalev_D 208:19150d2b528f 1121
Kovalev_D 209:224e7331a061 1122 //if(SA)CMD_M_Stymul_Answer();
Kovalev_D 208:19150d2b528f 1123 // if(d8_anser)D8_Answer();
Kovalev_D 208:19150d2b528f 1124
Kovalev_D 147:1aed74f19a8f 1125 switch(Gyro.CMD_In) {
Kovalev_D 226:4a4d5bd5fcd7 1126 // case 0xA5: DeviceMode() ; break;
Kovalev_D 209:224e7331a061 1127 case 0x99: /*Gyro.ModeOut=0;*/CMD_Maintenance(); break;
Kovalev_D 209:224e7331a061 1128 case 0xD8: CMD_M_Control_D8(); break;
Kovalev_D 194:8f3cb37a5541 1129 case 0xE9: CMD_M_Param_R(); break; //чтение параметров
Kovalev_D 194:8f3cb37a5541 1130 case 0xE8: CMD_M_Param_W(); break; //запись параметра
Kovalev_D 194:8f3cb37a5541 1131 case 0xDA: GLDStartDischarg(); break;
Kovalev_D 194:8f3cb37a5541 1132 case 0xD9: CMD_M_Control_D9(); break;
Kovalev_D 208:19150d2b528f 1133 case 0x0A: CMD_M_Stymul(); break;
Kovalev_D 209:224e7331a061 1134 case 0xDD: TempParam=(BuffTemp[3]) & 0x9f; //Rate
Kovalev_D 193:a0fe8bfc97e4 1135 switch(TempParam) {
Kovalev_D 209:224e7331a061 1136 case Rate1 : CMD_Rate(); break;
Kovalev_D 226:4a4d5bd5fcd7 1137 //case Rate2 : Gyro.ModeOut=9; break;
Kovalev_D 209:224e7331a061 1138 case Rate3 : CMD_Rate3(); break;
Kovalev_D 194:8f3cb37a5541 1139 case PRate1 : Gyro.ModeOut=1; break;
Kovalev_D 214:4c70e452c491 1140 case PRate2 : Gyro.ModeOut=2; break;
Kovalev_D 214:4c70e452c491 1141 case PRate3 : Gyro.ModeOut=8; break;
Kovalev_D 214:4c70e452c491 1142 case Rate7 : CMD_Rate7(); break;
Kovalev_D 226:4a4d5bd5fcd7 1143 case PRate7 : Gyro.ModeOut=10; break;
Kovalev_D 222:7de7b3bf3a1d 1144 case Rate5K : M_Rate5K(); break;
Kovalev_D 222:7de7b3bf3a1d 1145 case PRate5K:
Kovalev_D 222:7de7b3bf3a1d 1146 if(Gyro.ModeOut){}
Kovalev_D 222:7de7b3bf3a1d 1147 else Gyro.ModeOut=11;
Kovalev_D 222:7de7b3bf3a1d 1148 break;
Kovalev_D 214:4c70e452c491 1149
Kovalev_D 193:a0fe8bfc97e4 1150 }
Kovalev_D 194:8f3cb37a5541 1151 break; //DropDelay(); выставка задержки для мультидропа сбрасывается в команде CMD_Maintenance() на () микросекунд;
Kovalev_D 226:4a4d5bd5fcd7 1152
Kovalev_D 226:4a4d5bd5fcd7 1153 case 0xA0: /*DropDelay();*/
Kovalev_D 226:4a4d5bd5fcd7 1154 // TempParam=(BuffTemp[3]) & 0x80; //Delta_PS
Kovalev_D 226:4a4d5bd5fcd7 1155
Kovalev_D 226:4a4d5bd5fcd7 1156 switch(Gyro.Device_Mode)
Kovalev_D 226:4a4d5bd5fcd7 1157 {
Kovalev_D 226:4a4d5bd5fcd7 1158 case 0: Gyro.ModeOut=3; Gyro.Event_500Hz=0; break;
Kovalev_D 226:4a4d5bd5fcd7 1159 case 4: Gyro.ModeOut=4; break;
Kovalev_D 226:4a4d5bd5fcd7 1160 }
Kovalev_D 226:4a4d5bd5fcd7 1161 sprintf((Time)," Comand - B_Delta_PS(); Gyro.Device_Mode = %d Gyro.ModeOut = %d\r\n", Gyro.Device_Mode, Gyro.ModeOut);
Kovalev_D 226:4a4d5bd5fcd7 1162 WriteCon(Time);
Kovalev_D 194:8f3cb37a5541 1163 break;
Kovalev_D 226:4a4d5bd5fcd7 1164
Kovalev_D 194:8f3cb37a5541 1165 case 0xB0: DropDelay(); TempParam = TempParam=(BuffTemp[3]>>7); //Delta_Bins
Kovalev_D 193:a0fe8bfc97e4 1166 switch(TempParam) {
Kovalev_D 196:f76dbc081e63 1167 case PDelta_Bins: Gyro.ModeOut=5; Gyro.Event_500Hz=0; break;
Kovalev_D 193:a0fe8bfc97e4 1168 case Delta_Bins : CMD_Delta_Bins(); break;
Kovalev_D 193:a0fe8bfc97e4 1169 }
Kovalev_D 194:8f3cb37a5541 1170 break;
Kovalev_D 194:8f3cb37a5541 1171 case 0x0F: DropDelay(); TempParam = (((BuffTemp[3])>>4) & 0x9); //B_Delta
Kovalev_D 193:a0fe8bfc97e4 1172 switch(TempParam) {
Kovalev_D 193:a0fe8bfc97e4 1173 case PB_Delta_EXT: Gyro.ModeOut=6; break;
Kovalev_D 196:f76dbc081e63 1174 case PB_Delta_INT: Gyro.ModeOut=7; Gyro.Event_500Hz=0; break;
Kovalev_D 193:a0fe8bfc97e4 1175 case B_Delta_EXT: CMD_B_Delta(); break;
Kovalev_D 193:a0fe8bfc97e4 1176 case B_Delta_INT: CMD_B_Delta(); break;
Kovalev_D 193:a0fe8bfc97e4 1177 }
Kovalev_D 194:8f3cb37a5541 1178 break;
Kovalev_D 194:8f3cb37a5541 1179 case 0xE4: CMD_M_vib(); break;
Kovalev_D 209:224e7331a061 1180 case 0xA5: DeviceMode(); break;
Kovalev_D 194:8f3cb37a5541 1181 case 0xE6: Gph_W(); break;
Kovalev_D 194:8f3cb37a5541 1182 Gyro.RsErrLine = 0;
Kovalev_D 194:8f3cb37a5541 1183 }
Kovalev_D 194:8f3cb37a5541 1184 }
Kovalev_D 147:1aed74f19a8f 1185 }
Kovalev_D 193:a0fe8bfc97e4 1186
Kovalev_D 193:a0fe8bfc97e4 1187
Kovalev_D 147:1aed74f19a8f 1188 void TechLog(void)
Kovalev_D 147:1aed74f19a8f 1189 {
Kovalev_D 208:19150d2b528f 1190 unsigned int temp=0;
Kovalev_D 225:f8fee6c586cc 1191 if (ReadCon (Time))
Kovalev_D 208:19150d2b528f 1192 {
Kovalev_D 214:4c70e452c491 1193 int a=0;
Kovalev_D 225:f8fee6c586cc 1194
Kovalev_D 225:f8fee6c586cc 1195
Kovalev_D 225:f8fee6c586cc 1196
Kovalev_D 225:f8fee6c586cc 1197
Kovalev_D 225:f8fee6c586cc 1198 if (Time[0] == 'y')
Kovalev_D 225:f8fee6c586cc 1199 { //Mod 250 Hz PLCRegul250();
Kovalev_D 225:f8fee6c586cc 1200 if( Gyro.Debag) Gyro.Debag=0;
Kovalev_D 225:f8fee6c586cc 1201 else Gyro.Debag=1;
Kovalev_D 225:f8fee6c586cc 1202 }
Kovalev_D 225:f8fee6c586cc 1203 if (Time[0] == 'u')
Kovalev_D 225:f8fee6c586cc 1204 { //Mod 250 Hz PLCRegul250();
Kovalev_D 225:f8fee6c586cc 1205 if( Gyro.Debag2) Gyro.Debag2=0;
Kovalev_D 225:f8fee6c586cc 1206 else Gyro.Debag2=1;
Kovalev_D 225:f8fee6c586cc 1207 }
Kovalev_D 225:f8fee6c586cc 1208 if (Time[0] == 'C') Spi.DAC_A+=200;
Kovalev_D 225:f8fee6c586cc 1209 if (Time[0] == 'c') Spi.DAC_A-=200;
Kovalev_D 225:f8fee6c586cc 1210 if (Time[0] == 'X') Spi.DAC_B+=2000;
Kovalev_D 225:f8fee6c586cc 1211 if (Time[0] == 'x') Spi.DAC_B-=2000;
Kovalev_D 147:1aed74f19a8f 1212 /////////////////////////////////////////////////////////////////
Kovalev_D 147:1aed74f19a8f 1213 ////////////////////////////////////////////////////////////////
Kovalev_D 147:1aed74f19a8f 1214 //////////////////////Выбор FlashMod///////////////////////////
Kovalev_D 147:1aed74f19a8f 1215 ////////////////////////////////////////////////////////////////
Kovalev_D 225:f8fee6c586cc 1216 /*
Kovalev_D 205:775d54fdf646 1217 if (Time[0] == 'B') Gyro.FlashMod=1;
Kovalev_D 147:1aed74f19a8f 1218 if (Time[0] == 'R') {Gyro.FlashMod=3;}
Kovalev_D 205:775d54fdf646 1219 if (Time[0] == 'E') {Gyro.FlashMod=4;}
Kovalev_D 147:1aed74f19a8f 1220 ///////////////////////////////////////////////////////////////
Kovalev_D 147:1aed74f19a8f 1221 ///////////////////////////////////////////////////////////////
Kovalev_D 147:1aed74f19a8f 1222 ////////////////////////////////////////////////////////////////
Kovalev_D 209:224e7331a061 1223
Kovalev_D 209:224e7331a061 1224
Kovalev_D 209:224e7331a061 1225
Kovalev_D 209:224e7331a061 1226
Kovalev_D 222:7de7b3bf3a1d 1227 if (Time[0] == 'f') { // выдача технологическая
Kovalev_D 209:224e7331a061 1228 Gyro.ModAmp += 1;
Kovalev_D 209:224e7331a061 1229 sprintf((Time),"%d \r\n", Gyro.ModAmp);
Kovalev_D 209:224e7331a061 1230 WriteCon(Time);
Kovalev_D 222:7de7b3bf3a1d 1231 }
Kovalev_D 222:7de7b3bf3a1d 1232 if (Time[0] == 'd') { // выдача технологическая
Kovalev_D 209:224e7331a061 1233 Gyro.ModAmp -= 1;
Kovalev_D 209:224e7331a061 1234 sprintf((Time),"%d \r\n", Gyro.ModAmp);
Kovalev_D 209:224e7331a061 1235 WriteCon(Time);
Kovalev_D 222:7de7b3bf3a1d 1236 }
Kovalev_D 147:1aed74f19a8f 1237 if (Time[0] == 'V') { // выдача технологическая
Kovalev_D 214:4c70e452c491 1238 F_vib += 1;
Kovalev_D 214:4c70e452c491 1239 LPC_MCPWM->LIM1 = F_vib;
Kovalev_D 214:4c70e452c491 1240 LPC_MCPWM->LIM2 = F_vib;
Kovalev_D 214:4c70e452c491 1241 sprintf((Time),"%d \r\n", F_vib);
Kovalev_D 214:4c70e452c491 1242 WriteCon(Time);
Kovalev_D 214:4c70e452c491 1243 }
Kovalev_D 147:1aed74f19a8f 1244 if (Time[0] == 'v') { // выдача технологическая
Kovalev_D 214:4c70e452c491 1245 F_vib -= 1;
Kovalev_D 214:4c70e452c491 1246 LPC_MCPWM->LIM1 = F_vib;
Kovalev_D 214:4c70e452c491 1247 LPC_MCPWM->LIM2 = F_vib;
Kovalev_D 214:4c70e452c491 1248
Kovalev_D 209:224e7331a061 1249 }
Kovalev_D 220:04c54405b82d 1250
Kovalev_D 220:04c54405b82d 1251
Kovalev_D 220:04c54405b82d 1252
Kovalev_D 225:f8fee6c586cc 1253
Kovalev_D 220:04c54405b82d 1254
Kovalev_D 220:04c54405b82d 1255
Kovalev_D 220:04c54405b82d 1256
Kovalev_D 209:224e7331a061 1257 if (Time[0] == 'p') { // выдача технологическая
Kovalev_D 214:4c70e452c491 1258 // PlcOFF //Gyro.RgConA&0x8=0;
Kovalev_D 214:4c70e452c491 1259
Kovalev_D 214:4c70e452c491 1260 if(Gyro.LogMod) Gyro.LogMod=0;
Kovalev_D 214:4c70e452c491 1261 else Gyro.LogMod=5;
Kovalev_D 211:ac8251b067d2 1262 // MODFlag=1;
Kovalev_D 214:4c70e452c491 1263 // Spi.DAC_B = 32767;
Kovalev_D 209:224e7331a061 1264 }
Kovalev_D 209:224e7331a061 1265 if (Time[0] == 'o') { // выдача технологическая
Kovalev_D 220:04c54405b82d 1266 if(TypeMod==0)TypeMod=5;
Kovalev_D 220:04c54405b82d 1267 else TypeMod=0;
Kovalev_D 213:9953db9543d6 1268
Kovalev_D 211:ac8251b067d2 1269 // Spi.DAC_B = 32000;
Kovalev_D 209:224e7331a061 1270 }
Kovalev_D 215:b58b887fd367 1271 if (Time[0] == 'h')
Kovalev_D 215:b58b887fd367 1272 { // выдача технологическая
Kovalev_D 215:b58b887fd367 1273 for(int q=0; q<64; q++)
Kovalev_D 215:b58b887fd367 1274 {
Kovalev_D 216:189b0ea1dc38 1275 sprintf((Time),"%i \r\n",(BuffADC_znak[q]));
Kovalev_D 215:b58b887fd367 1276 WriteCon(Time);
Kovalev_D 215:b58b887fd367 1277 }
Kovalev_D 215:b58b887fd367 1278
Kovalev_D 215:b58b887fd367 1279 }
Kovalev_D 214:4c70e452c491 1280
Kovalev_D 220:04c54405b82d 1281
Kovalev_D 220:04c54405b82d 1282 if (Time[0] == 'b')
Kovalev_D 211:ac8251b067d2 1283 { // выдача технологическая
Kovalev_D 220:04c54405b82d 1284 sprintf((Time),"10000 \r\n");
Kovalev_D 220:04c54405b82d 1285 WriteCon(Time);
Kovalev_D 214:4c70e452c491 1286 for(int q=0; q<64; q++)
Kovalev_D 215:b58b887fd367 1287 {
Kovalev_D 220:04c54405b82d 1288
Kovalev_D 220:04c54405b82d 1289 if(((CountV255+q)&0xff)==0)
Kovalev_D 220:04c54405b82d 1290 {
Kovalev_D 220:04c54405b82d 1291 sprintf((Time),"12000 \r\n");
Kovalev_D 220:04c54405b82d 1292 WriteCon(Time);
Kovalev_D 220:04c54405b82d 1293 }
Kovalev_D 220:04c54405b82d 1294 else
Kovalev_D 220:04c54405b82d 1295 {
Kovalev_D 220:04c54405b82d 1296 sprintf((Time),"%d \r\n", BuffADC_1Point[(CountV64+q)&0xff] );
Kovalev_D 220:04c54405b82d 1297 WriteCon(Time);
Kovalev_D 220:04c54405b82d 1298 }
Kovalev_D 220:04c54405b82d 1299
Kovalev_D 220:04c54405b82d 1300
Kovalev_D 220:04c54405b82d 1301 }
Kovalev_D 214:4c70e452c491 1302 }
Kovalev_D 225:f8fee6c586cc 1303
Kovalev_D 220:04c54405b82d 1304 if (Time[0] == 'n')
Kovalev_D 214:4c70e452c491 1305 { // выдача технологическая
Kovalev_D 214:4c70e452c491 1306 for(int q=0; q<64; q++)
Kovalev_D 215:b58b887fd367 1307 {
Kovalev_D 222:7de7b3bf3a1d 1308 sprintf((Time),"%d ", Buff_OUT[q]);
Kovalev_D 220:04c54405b82d 1309 WriteCon(Time);
Kovalev_D 222:7de7b3bf3a1d 1310 sprintf((Time),"%d \r\n",ModArraySin[(q+Gyro.PLC_Phase)&0x3f]);
Kovalev_D 222:7de7b3bf3a1d 1311 WriteCon(Time);
Kovalev_D 220:04c54405b82d 1312
Kovalev_D 220:04c54405b82d 1313 }
Kovalev_D 220:04c54405b82d 1314 Spi.DAC_B+=500;
Kovalev_D 220:04c54405b82d 1315 }
Kovalev_D 220:04c54405b82d 1316 if (Time[0] == 'm')
Kovalev_D 220:04c54405b82d 1317 { // выдача технологическая
Kovalev_D 220:04c54405b82d 1318 for(int q=0; q<64; q++)
Kovalev_D 220:04c54405b82d 1319 {
Kovalev_D 220:04c54405b82d 1320 sprintf((Time),"%d \r\n", BuffADC_64Point[q] );
Kovalev_D 216:189b0ea1dc38 1321 WriteCon(Time);
Kovalev_D 215:b58b887fd367 1322 }
Kovalev_D 214:4c70e452c491 1323 }
Kovalev_D 215:b58b887fd367 1324
Kovalev_D 220:04c54405b82d 1325
Kovalev_D 214:4c70e452c491 1326
Kovalev_D 214:4c70e452c491 1327
Kovalev_D 214:4c70e452c491 1328
Kovalev_D 214:4c70e452c491 1329
Kovalev_D 225:f8fee6c586cc 1330
Kovalev_D 214:4c70e452c491 1331
Kovalev_D 209:224e7331a061 1332 if (Time[0] == 'u')
Kovalev_D 209:224e7331a061 1333 { // выдача технологическая
Kovalev_D 220:04c54405b82d 1334 Gyro.ShowMod2=1; //Mod vibro Hz
Kovalev_D 211:ac8251b067d2 1335 }
Kovalev_D 220:04c54405b82d 1336 if (Time[0] == 'U')
Kovalev_D 220:04c54405b82d 1337 { // выдача технологическая
Kovalev_D 220:04c54405b82d 1338 Gyro.ShowMod2=0; //Mod vibro Hz
Kovalev_D 220:04c54405b82d 1339 }
Kovalev_D 211:ac8251b067d2 1340
Kovalev_D 225:f8fee6c586cc 1341
Kovalev_D 211:ac8251b067d2 1342 if (Time[0] == 'f')
Kovalev_D 211:ac8251b067d2 1343 { // выдача технологическая
Kovalev_D 211:ac8251b067d2 1344 Gyro.CuruAngleLog = 0; //Mod vibro Hz
Kovalev_D 211:ac8251b067d2 1345 }
Kovalev_D 211:ac8251b067d2 1346 if (Time[0] == 'd')
Kovalev_D 211:ac8251b067d2 1347 { // выдача технологическая
Kovalev_D 211:ac8251b067d2 1348 Gyro.CuruAngleLog = 1; //Mod vibro Hz
Kovalev_D 211:ac8251b067d2 1349 }
Kovalev_D 208:19150d2b528f 1350 if (Time[0] == 'l')
Kovalev_D 208:19150d2b528f 1351 { // выдача технологическая
Kovalev_D 206:00341a03e05c 1352 Gyro.My_Addres = GyroP.Str.My_Addres; // Gyro.My_Addres = 0;
Kovalev_D 208:19150d2b528f 1353 Gyro.GLD_Serial = GyroP.Str.GLD_Serial;
Kovalev_D 208:19150d2b528f 1354 Gyro.FrqHZ = GyroP.Str.FrqHZ;
Kovalev_D 206:00341a03e05c 1355 Gyro.Frq = GyroP.Str.FrqHZ<<16;
Kovalev_D 206:00341a03e05c 1356 Gyro.FrqHZmin = GyroP.Str.FrqHZmin<<16;
Kovalev_D 206:00341a03e05c 1357 Gyro.FrqHZmax = GyroP.Str.FrqHZmax<<16;
Kovalev_D 206:00341a03e05c 1358 Gyro.FrqChengSpeed = GyroP.Str.FrqChengSpeed;
Kovalev_D 208:19150d2b528f 1359 Gyro.PLC_Gain = GyroP.Str.PLC_Gain;
Kovalev_D 208:19150d2b528f 1360 Gyro.PLC_Phase = GyroP.Str.PLC_Phase;
Kovalev_D 206:00341a03e05c 1361 Gyro.ModAmp = GyroP.Str.ModAmp;
Kovalev_D 208:19150d2b528f 1362 Gyro.FrqPhase = GyroP.Str.FrqPhase;
Kovalev_D 206:00341a03e05c 1363 Gyro.AmpPer = GyroP.Str.AmpPer;
Kovalev_D 206:00341a03e05c 1364 Gyro.Amp = GyroP.Str.AmpPer<<16;
Kovalev_D 208:19150d2b528f 1365 Gyro.AmpSpeed = GyroP.Str.AmpSpeed;
Kovalev_D 206:00341a03e05c 1366 Gyro.AmpPerDel = GyroP.Str.AmpPerDel;
Kovalev_D 208:19150d2b528f 1367 temp=((GyroP.Str.VB_Fdf_Hi<<16) | GyroP.Str.VB_Fdf_Lo);
Kovalev_D 208:19150d2b528f 1368 temp=temp/18.2;
Kovalev_D 208:19150d2b528f 1369 Gyro.AmpTarget=(unsigned int)(temp);
Kovalev_D 206:00341a03e05c 1370 Gyro.AmpPerMin = GyroP.Str.AmpPerMin;
Kovalev_D 206:00341a03e05c 1371 Gyro.AmpPerMax = GyroP.Str.AmpPerMax;
Kovalev_D 206:00341a03e05c 1372 Gyro.AmpMin = GyroP.Str.AmpMin;
Kovalev_D 206:00341a03e05c 1373 Gyro.AmpTD = GyroP.Str.AmpTD;
Kovalev_D 208:19150d2b528f 1374 Spi.DAC_A = GyroP.Str.DAC_current_Work;
Kovalev_D 206:00341a03e05c 1375 Gyro.Gain_Sin = GyroP.Str.Gain_Sin;
Kovalev_D 206:00341a03e05c 1376 Gyro.Gain_Cos = GyroP.Str.Gain_Cos;
Kovalev_D 207:d1ce992f5d17 1377 Out_G_photo(Gyro.Gain_Sin, Gyro.Gain_Cos);
Kovalev_D 206:00341a03e05c 1378 }
Kovalev_D 225:f8fee6c586cc 1379 */
Kovalev_D 208:19150d2b528f 1380
Kovalev_D 225:f8fee6c586cc 1381 }
igor_v 0:8ad47e2b6f00 1382 }
igor_v 0:8ad47e2b6f00 1383
igor_v 0:8ad47e2b6f00 1384