forkd

Dependencies:   mbed

Fork of LG2 by Dmitry Kovalev

Committer:
Kovalev_D
Date:
Fri Jan 05 08:14:38 2018 +0000
Revision:
227:2774b56bfab0
Parent:
226:4a4d5bd5fcd7
05.01.2018

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 227:2774b56bfab0 138 case 4: if(Gyro.EXT_Latch ) CMD_Delta_PS(); Gyro.EXT_Latch=0; 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 227:2774b56bfab0 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 227:2774b56bfab0 368 unsigned int Temp;
Kovalev_D 227:2774b56bfab0 369 Gyro.ModeOut = 0;
Kovalev_D 227:2774b56bfab0 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 124:9ae09249f842 377 BuffTemp[1] = Gyro.My_Addres;
Kovalev_D 209:224e7331a061 378
Kovalev_D 227:2774b56bfab0 379 Temp = 0xfff; //Gyro.Firmware_Version;
Kovalev_D 227:2774b56bfab0 380 BuffTemp[2] = (Temp >> 0) & 0xff;
Kovalev_D 227:2774b56bfab0 381 BuffTemp[3] = (Temp >> 8) & 0xff;
Kovalev_D 227:2774b56bfab0 382
Kovalev_D 227:2774b56bfab0 383 Temp = Gyro.GLD_Serial;
Kovalev_D 227:2774b56bfab0 384 BuffTemp[4]=(Temp >> 0) & 0xff;
Kovalev_D 227:2774b56bfab0 385 BuffTemp[5]=(Temp >> 8) & 0xff;
Kovalev_D 209:224e7331a061 386
igor_v 21:bc8c1cec3da6 387 Check(BuffTemp, 8);
igor_v 21:bc8c1cec3da6 388 WriteConN (BuffTemp,8);
Kovalev_D 121:bbae560cdd43 389
igor_v 0:8ad47e2b6f00 390 }
Kovalev_D 193:a0fe8bfc97e4 391 void CMD_B_Delta(void)
Kovalev_D 193:a0fe8bfc97e4 392 {
Kovalev_D 196:f76dbc081e63 393 Gyro.Event_500Hz=0;
Kovalev_D 205:775d54fdf646 394 Gyro.EXT_Latch=0;
Kovalev_D 193:a0fe8bfc97e4 395 unsigned int Temp;
Kovalev_D 193:a0fe8bfc97e4 396 BuffTemp[ 0] = Gyro.SOC_Out;
Kovalev_D 193:a0fe8bfc97e4 397 BuffTemp[ 1] = Gyro.My_Addres;
Kovalev_D 193:a0fe8bfc97e4 398
Kovalev_D 193:a0fe8bfc97e4 399 Temp = Gyro.CuruAngle;
Kovalev_D 193:a0fe8bfc97e4 400 Gyro.CuruAngle = 0;
Kovalev_D 193:a0fe8bfc97e4 401 BuffTemp[ 2] =(Temp >> 16) & 0xff;//младший байт разности счетчиков
Kovalev_D 193:a0fe8bfc97e4 402 BuffTemp[ 3] =(Temp >> 8) & 0xff;//младший байт разности счетчиков
Kovalev_D 193:a0fe8bfc97e4 403 BuffTemp[ 4] =(Temp >> 0) & 0xff;//младший байт разности счетчиков
Kovalev_D 193:a0fe8bfc97e4 404 BuffTemp[ 5] = 0x00000000;
Kovalev_D 193:a0fe8bfc97e4 405 Check(BuffTemp, 8);
Kovalev_D 193:a0fe8bfc97e4 406 WriteConN (BuffTemp,8);
Kovalev_D 193:a0fe8bfc97e4 407 }
Kovalev_D 165:b2bd0c810a4f 408
Kovalev_D 193:a0fe8bfc97e4 409 void CMD_Delta_Bins(void)
Kovalev_D 196:f76dbc081e63 410 { Gyro.Event_500Hz=0;
Kovalev_D 193:a0fe8bfc97e4 411 unsigned int Temp;
Kovalev_D 193:a0fe8bfc97e4 412 BuffTemp[ 0] = Gyro.SOC_Out;
Kovalev_D 193:a0fe8bfc97e4 413 BuffTemp[ 1] = Gyro.My_Addres;
Kovalev_D 193:a0fe8bfc97e4 414
Kovalev_D 193:a0fe8bfc97e4 415 Temp = Gyro.CuruAngle;
Kovalev_D 193:a0fe8bfc97e4 416 Gyro.CuruAngle = 0;
Kovalev_D 193:a0fe8bfc97e4 417
Kovalev_D 193:a0fe8bfc97e4 418 BuffTemp[ 2] =(Temp >> 24) & 0xff;//старший байт разности счетчиков
Kovalev_D 193:a0fe8bfc97e4 419 BuffTemp[ 3] =(Temp >> 16) & 0xff;//младший байт разности счетчиков
Kovalev_D 193:a0fe8bfc97e4 420 BuffTemp[ 4] =(Temp >> 8) & 0xff;//младший байт разности счетчиков
Kovalev_D 193:a0fe8bfc97e4 421 BuffTemp[ 5] =(Temp >> 0) & 0xff;//младший байт разности счетчиков
Kovalev_D 193:a0fe8bfc97e4 422 BuffTemp[ 6] = 0x0000;
Kovalev_D 193:a0fe8bfc97e4 423 Check(BuffTemp, 9);
Kovalev_D 193:a0fe8bfc97e4 424 WriteConN (BuffTemp,9);
Kovalev_D 193:a0fe8bfc97e4 425 }
Kovalev_D 193:a0fe8bfc97e4 426 void CMD_Delta_PS(void)
Kovalev_D 210:b02fa166315d 427 { int drob,Temp1;
Kovalev_D 210:b02fa166315d 428 float Temp2=0;
Kovalev_D 193:a0fe8bfc97e4 429 Gyro.EXT_Latch=0;
Kovalev_D 196:f76dbc081e63 430 Gyro.Event_500Hz=0;
Kovalev_D 122:fbacb932a30b 431 unsigned int Temp;
Kovalev_D 218:b4067cac75c0 432
Kovalev_D 218:b4067cac75c0 433
Kovalev_D 218:b4067cac75c0 434
Kovalev_D 124:9ae09249f842 435 BuffTemp[ 0] = Gyro.SOC_Out;
Kovalev_D 122:fbacb932a30b 436 BuffTemp[ 1] = Gyro.My_Addres;
Kovalev_D 208:19150d2b528f 437
Kovalev_D 209:224e7331a061 438 Gyro.CuruAngle = Gyro.CuruAngle + OldCuruAngle; //(72 град/с)
Kovalev_D 227:2774b56bfab0 439
Kovalev_D 214:4c70e452c491 440 OldCuruAngle=Gyro.CuruAngle & 0xf; //сохраняем 3 бит для след измирений
Kovalev_D 227:2774b56bfab0 441 Temp=Gyro.CuruAngle>>4;
Kovalev_D 227:2774b56bfab0 442 //приводим к форме вывода
Kovalev_D 209:224e7331a061 443 Gyro.CuruAngle = 0;
Kovalev_D 227:2774b56bfab0 444 //Temp=200;
Kovalev_D 124:9ae09249f842 445 BuffTemp[ 2] =(Temp >> 8) & 0xff;//старший байт разности счетчиков
Kovalev_D 124:9ae09249f842 446 BuffTemp[ 3] =(Temp >> 0) & 0xff;//младший байт разности счетчиков
Kovalev_D 124:9ae09249f842 447
Kovalev_D 124:9ae09249f842 448 BuffTemp[ 4] = CountParam;
Kovalev_D 124:9ae09249f842 449 switch(CountParam) {
Kovalev_D 182:ebcd2bc3be8f 450
Kovalev_D 124:9ae09249f842 451 //F_ras
Kovalev_D 124:9ae09249f842 452 case 0:
Kovalev_D 211:ac8251b067d2 453 OutDeltaPS = Gyro.F_ras;
Kovalev_D 211:ac8251b067d2 454 BuffTemp[5] = (OutDeltaPS >> 8) & 0xff;
Kovalev_D 124:9ae09249f842 455 break;
Kovalev_D 124:9ae09249f842 456
Kovalev_D 124:9ae09249f842 457 case 1:
Kovalev_D 211:ac8251b067d2 458 BuffTemp[5] = (OutDeltaPS >> 0) & 0xff;
Kovalev_D 124:9ae09249f842 459 break;
Kovalev_D 208:19150d2b528f 460
Kovalev_D 124:9ae09249f842 461
Kovalev_D 124:9ae09249f842 462 //HFO
Kovalev_D 124:9ae09249f842 463 case 2:
Kovalev_D 227:2774b56bfab0 464
Kovalev_D 227:2774b56bfab0 465 OutDeltaPS = 0xffff - Spi.DAC_A;
Kovalev_D 211:ac8251b067d2 466 BuffTemp[5] = (OutDeltaPS >> 8) & 0xff;
Kovalev_D 124:9ae09249f842 467 break;
Kovalev_D 124:9ae09249f842 468
Kovalev_D 124:9ae09249f842 469 case 3:
Kovalev_D 211:ac8251b067d2 470 BuffTemp[5] = (OutDeltaPS >> 0) & 0xff;
Kovalev_D 124:9ae09249f842 471 break;
Kovalev_D 124:9ae09249f842 472
Kovalev_D 124:9ae09249f842 473
Kovalev_D 124:9ae09249f842 474
Kovalev_D 124:9ae09249f842 475 //T_Vibro
Kovalev_D 124:9ae09249f842 476 case 4:
Kovalev_D 211:ac8251b067d2 477 OutDeltaPS = (unsigned int)(7680000/(Gyro.Frq>>16));
Kovalev_D 211:ac8251b067d2 478 BuffTemp[5] = (OutDeltaPS >> 8) & 0xff;
Kovalev_D 124:9ae09249f842 479 break;
Kovalev_D 124:9ae09249f842 480
Kovalev_D 124:9ae09249f842 481 case 5:
Kovalev_D 211:ac8251b067d2 482 BuffTemp[5] = (OutDeltaPS >> 0) & 0xff;
Kovalev_D 124:9ae09249f842 483 break;
Kovalev_D 124:9ae09249f842 484
Kovalev_D 124:9ae09249f842 485
Kovalev_D 124:9ae09249f842 486
Kovalev_D 124:9ae09249f842 487 //L_Vibro
Kovalev_D 124:9ae09249f842 488 case 6:
Kovalev_D 210:b02fa166315d 489 //Temp = Gyro.L_vibro>>1;
Kovalev_D 211:ac8251b067d2 490 OutDeltaPS = Gyro.L_vibro;
Kovalev_D 211:ac8251b067d2 491 BuffTemp[5] = (OutDeltaPS >> 8) & 0xff;
Kovalev_D 124:9ae09249f842 492
Kovalev_D 124:9ae09249f842 493 break;
Kovalev_D 124:9ae09249f842 494
Kovalev_D 124:9ae09249f842 495 case 7:
Kovalev_D 211:ac8251b067d2 496 BuffTemp[5] = (OutDeltaPS >> 0) & 0xff;
Kovalev_D 124:9ae09249f842 497 break;
Kovalev_D 124:9ae09249f842 498
Kovalev_D 124:9ae09249f842 499
Kovalev_D 124:9ae09249f842 500
Kovalev_D 124:9ae09249f842 501 //Напряжение на регуляторе периметра
Kovalev_D 124:9ae09249f842 502 case 8:
Kovalev_D 227:2774b56bfab0 503 OutDeltaPS = ((Spi.DAC_B-0x7fff)&0xffff);
Kovalev_D 211:ac8251b067d2 504 BuffTemp[5] = (OutDeltaPS >> 8) & 0xff;
Kovalev_D 124:9ae09249f842 505
Kovalev_D 124:9ae09249f842 506 break;
Kovalev_D 124:9ae09249f842 507
Kovalev_D 124:9ae09249f842 508 case 9:
Kovalev_D 211:ac8251b067d2 509 BuffTemp[5] = (OutDeltaPS >> 0) & 0xff;
Kovalev_D 124:9ae09249f842 510 break;
Kovalev_D 124:9ae09249f842 511
Kovalev_D 124:9ae09249f842 512
Kovalev_D 124:9ae09249f842 513
Kovalev_D 124:9ae09249f842 514 //темпкратурный канал 0
Kovalev_D 124:9ae09249f842 515 case 10:
Kovalev_D 211:ac8251b067d2 516 OutDeltaPS = 0;
Kovalev_D 211:ac8251b067d2 517 BuffTemp[5] = (OutDeltaPS >> 8) & 0xff;
igor_v 0:8ad47e2b6f00 518
Kovalev_D 124:9ae09249f842 519 break;
Kovalev_D 124:9ae09249f842 520
Kovalev_D 124:9ae09249f842 521 case 11:
Kovalev_D 211:ac8251b067d2 522 BuffTemp[5] = (OutDeltaPS >> 0) & 0xff;
Kovalev_D 124:9ae09249f842 523 break;
Kovalev_D 124:9ae09249f842 524
Kovalev_D 124:9ae09249f842 525
Kovalev_D 124:9ae09249f842 526
Kovalev_D 177:1666a83d88a5 527 //f
Kovalev_D 124:9ae09249f842 528 case 12:
Kovalev_D 211:ac8251b067d2 529 OutDeltaPS =0;//(unsigned int)(0x7fff-Spi.ADC5)*0.79;
Kovalev_D 210:b02fa166315d 530 // Temp = Gyro.AD_Slow >> 16;
Kovalev_D 211:ac8251b067d2 531 BuffTemp[5] = (OutDeltaPS >> 8) & 0xff;
Kovalev_D 124:9ae09249f842 532
Kovalev_D 124:9ae09249f842 533 break;
Kovalev_D 124:9ae09249f842 534
Kovalev_D 124:9ae09249f842 535 case 13:
Kovalev_D 211:ac8251b067d2 536 BuffTemp[5] = (OutDeltaPS >> 0) & 0xff;
Kovalev_D 124:9ae09249f842 537 break;
Kovalev_D 124:9ae09249f842 538
Kovalev_D 124:9ae09249f842 539
Kovalev_D 124:9ae09249f842 540
Kovalev_D 124:9ae09249f842 541 //ток 1
Kovalev_D 124:9ae09249f842 542 case 14:
Kovalev_D 210:b02fa166315d 543 //Temp = Gyro.In1;
Kovalev_D 227:2774b56bfab0 544 IntOutDeltaPS = 0;//((Gyro.In1>>1)*0.800875)-0x3e0b;
Kovalev_D 211:ac8251b067d2 545 BuffTemp[5] = (IntOutDeltaPS >> 8) & 0xff;//in1//2
Kovalev_D 124:9ae09249f842 546
Kovalev_D 124:9ae09249f842 547 break;
Kovalev_D 124:9ae09249f842 548
Kovalev_D 124:9ae09249f842 549 case 15:
Kovalev_D 211:ac8251b067d2 550 BuffTemp[5] = (IntOutDeltaPS >> 0) & 0xff;
Kovalev_D 124:9ae09249f842 551 break;
Kovalev_D 124:9ae09249f842 552
Kovalev_D 124:9ae09249f842 553
Kovalev_D 124:9ae09249f842 554
Kovalev_D 124:9ae09249f842 555 //ток 2
Kovalev_D 124:9ae09249f842 556 case 16:
Kovalev_D 210:b02fa166315d 557 // Temp = Gyro.In2;
Kovalev_D 227:2774b56bfab0 558 IntOutDeltaPS =0;// ((Gyro.In2>>1)*0.800875)-0x3e0b;
Kovalev_D 211:ac8251b067d2 559 BuffTemp[5] = (IntOutDeltaPS >> 8) & 0xff;
Kovalev_D 124:9ae09249f842 560 break;
Kovalev_D 124:9ae09249f842 561
Kovalev_D 124:9ae09249f842 562 case 17:
Kovalev_D 211:ac8251b067d2 563 BuffTemp[5] = (IntOutDeltaPS >> 0) & 0xff;//in2//3
Kovalev_D 124:9ae09249f842 564 break;
Kovalev_D 124:9ae09249f842 565
Kovalev_D 124:9ae09249f842 566
Kovalev_D 124:9ae09249f842 567
Kovalev_D 124:9ae09249f842 568 //разностный температурный канал Delta Temp
Kovalev_D 124:9ae09249f842 569 case 18:
Kovalev_D 211:ac8251b067d2 570 OutDeltaPS = 0;
Kovalev_D 211:ac8251b067d2 571 OutDeltaPS = Gyro.DeltaT;
Kovalev_D 211:ac8251b067d2 572 BuffTemp[5] = (OutDeltaPS >> 8) & 0xff;//дельта
Kovalev_D 124:9ae09249f842 573 break;
Kovalev_D 124:9ae09249f842 574
Kovalev_D 124:9ae09249f842 575 case 19:
Kovalev_D 211:ac8251b067d2 576 BuffTemp[5] = (OutDeltaPS >> 0) & 0xff;
Kovalev_D 124:9ae09249f842 577 break;
Kovalev_D 124:9ae09249f842 578
Kovalev_D 124:9ae09249f842 579
Kovalev_D 124:9ae09249f842 580
Kovalev_D 124:9ae09249f842 581 //температурный канал 5
Kovalev_D 124:9ae09249f842 582 case 20:
Kovalev_D 211:ac8251b067d2 583 OutDeltaPS = 0;
Kovalev_D 227:2774b56bfab0 584 OutDeltaPS = Gyro.Termo;
Kovalev_D 211:ac8251b067d2 585 BuffTemp[5] =(OutDeltaPS >> 8) & 0xff;//температура
Kovalev_D 124:9ae09249f842 586 break;
Kovalev_D 124:9ae09249f842 587
Kovalev_D 124:9ae09249f842 588 case 21:
Kovalev_D 211:ac8251b067d2 589 BuffTemp[5] =(OutDeltaPS >> 0) & 0xff;//ADC6 sesnsor 5
Kovalev_D 211:ac8251b067d2 590 /* sprintf((Time),"%d %d \r\n", Spi.ADC1, Spi.ADC5 );
Kovalev_D 211:ac8251b067d2 591 WriteCon(Time);*/
Kovalev_D 124:9ae09249f842 592 break;
Kovalev_D 124:9ae09249f842 593 }
Kovalev_D 162:44e4ded32c6a 594 Check(BuffTemp, CRC_N);
Kovalev_D 162:44e4ded32c6a 595 WriteConN (BuffTemp,CRC_N);
Kovalev_D 128:1e4675a36c93 596
Kovalev_D 165:b2bd0c810a4f 597
Kovalev_D 165:b2bd0c810a4f 598 if(CountParam>20)CountParam=0;//зацикливания буфера от 0 до 21
Kovalev_D 165:b2bd0c810a4f 599 else CountParam++;
Kovalev_D 124:9ae09249f842 600
Kovalev_D 124:9ae09249f842 601 }
Kovalev_D 124:9ae09249f842 602
Kovalev_D 222:7de7b3bf3a1d 603
Kovalev_D 222:7de7b3bf3a1d 604 void M_Rate5K(void)
Kovalev_D 222:7de7b3bf3a1d 605 {
Kovalev_D 222:7de7b3bf3a1d 606
Kovalev_D 225:f8fee6c586cc 607 unsigned int Temp;
Kovalev_D 222:7de7b3bf3a1d 608 //Temp=Gyro.CuruAngle; //приводим к форме вывода
Kovalev_D 222:7de7b3bf3a1d 609 BuffTemp[ 3] =(Gyro.CuruAngle >> 8) & 0xff;//старший байт разности счетчиков 7 --младший байт разности счетчиков
Kovalev_D 222:7de7b3bf3a1d 610 BuffTemp[ 2] =(Gyro.CuruAngle >> 0) & 0xff;//младший байт разности счетчиков 8 --старший байт разности счетчиков
Kovalev_D 222:7de7b3bf3a1d 611 Gyro.CuruAngle=0;
Kovalev_D 222:7de7b3bf3a1d 612
Kovalev_D 222:7de7b3bf3a1d 613
Kovalev_D 225:f8fee6c586cc 614 Temp = ((Spi.DAC_B-0x7fff)&0xffff);
Kovalev_D 222:7de7b3bf3a1d 615 BuffTemp[5] = (Spi.DAC_B >> 8) & 0xff; //23 Выход регулятора рабочего периметра
Kovalev_D 222:7de7b3bf3a1d 616 BuffTemp[4] = (Spi.DAC_B >> 0) & 0xff;
Kovalev_D 222:7de7b3bf3a1d 617
Kovalev_D 225:f8fee6c586cc 618
Kovalev_D 225:f8fee6c586cc 619 Temp = 0xffff - Spi.DAC_A;
Kovalev_D 222:7de7b3bf3a1d 620 BuffTemp[7] =(Temp >> 8) & 0xff;//выход регулятора гвч; 11 --выход регулятора ГВЧ
Kovalev_D 222:7de7b3bf3a1d 621 BuffTemp[6] =(Temp >> 0) & 0xff;
Kovalev_D 222:7de7b3bf3a1d 622
Kovalev_D 222:7de7b3bf3a1d 623 /* sprintf((Time),"%d %d %d\r\n",Gyro.CuruAngle,(Spi.DAC_B-0x7fff),Temp);
Kovalev_D 222:7de7b3bf3a1d 624 WriteCon(Time);*/
Kovalev_D 222:7de7b3bf3a1d 625
Kovalev_D 222:7de7b3bf3a1d 626 //Check(BuffTemp, 7);
Kovalev_D 222:7de7b3bf3a1d 627 WriteConN (BuffTemp,8);
Kovalev_D 222:7de7b3bf3a1d 628 Gyro.EvenRate5K++;
Kovalev_D 222:7de7b3bf3a1d 629 }
Kovalev_D 222:7de7b3bf3a1d 630
Kovalev_D 222:7de7b3bf3a1d 631
igor_v 0:8ad47e2b6f00 632 void CMD_Rate(void)
Kovalev_D 190:289514f730ee 633 {
Kovalev_D 124:9ae09249f842 634 Gyro.Rate1_Event=0;
Kovalev_D 108:030cdde08314 635 unsigned int Temp;
Kovalev_D 208:19150d2b528f 636 int Temp1;
Kovalev_D 209:224e7331a061 637 float Temp2;
Kovalev_D 122:fbacb932a30b 638
Kovalev_D 208:19150d2b528f 639 BuffTemp[ 0] = Gyro.SOC_Out; //1 --старт данных
Kovalev_D 208:19150d2b528f 640 BuffTemp[ 1] = Gyro.My_Addres; //2 --адрес отвечающего устройствва
igor_v 21:bc8c1cec3da6 641
Kovalev_D 209:224e7331a061 642 BuffTemp[ 2] =( Gyro.CaunPlusReper >> 8) & 0xff;//старший байт счетчика +. 3 --сарший байт счентчика +
Kovalev_D 209:224e7331a061 643 BuffTemp[ 3] =( Gyro.CaunPlusReper >> 0) & 0xff;//младший байт счетчика +. 4 --младший байт счетчика +
Kovalev_D 211:ac8251b067d2 644
Kovalev_D 209:224e7331a061 645 BuffTemp[ 4] =( Gyro.CaunMinReper >> 8) & 0xff;//старший байт счетчика -. 5 --сарший байт счентчика -
Kovalev_D 209:224e7331a061 646 BuffTemp[ 5] =( Gyro.CaunMinReper >> 0) & 0xff;//младший байт счетчика -. 6 --младший байт счетчика -
Kovalev_D 211:ac8251b067d2 647
Kovalev_D 209:224e7331a061 648
Kovalev_D 209:224e7331a061 649 Gyro.CuruAngle = Gyro.CuruAngle + OldCuruAngle; //(72 град/с)
Kovalev_D 214:4c70e452c491 650 OldCuruAngle=Gyro.CuruAngle & 0x3f; //сохраняем 5 бит для след измирений
Kovalev_D 214:4c70e452c491 651 Temp=Gyro.CuruAngle>>6; //приводим к форме вывода
Kovalev_D 211:ac8251b067d2 652
Kovalev_D 209:224e7331a061 653
Kovalev_D 208:19150d2b528f 654 Gyro.CuruAngle = 0;
Kovalev_D 208:19150d2b528f 655 BuffTemp[ 6] =(Temp >> 8) & 0xff;//старший байт разности счетчиков 7 --младший байт разности счетчиков
Kovalev_D 208:19150d2b528f 656 BuffTemp[ 7] =(Temp >> 0) & 0xff;//младший байт разности счетчиков 8 --старший байт разности счетчиков
Kovalev_D 108:030cdde08314 657
Kovalev_D 108:030cdde08314 658
Kovalev_D 208:19150d2b528f 659 BuffTemp[38] =(Temp >> 24) & 0xff;; //39 приращение угла
Kovalev_D 208:19150d2b528f 660 BuffTemp[39] =(Temp >> 16) & 0xff;; //40 формат 22.10
Kovalev_D 208:19150d2b528f 661 BuffTemp[40] =(Temp >> 8) & 0xff;; //41 1бит знак
Kovalev_D 208:19150d2b528f 662 BuffTemp[41] =(Temp >> 0) & 0xff;; //42
Kovalev_D 209:224e7331a061 663
Kovalev_D 208:19150d2b528f 664 Temp = Gyro.F_ras;
Kovalev_D 209:224e7331a061 665 //Gyro.F_ras=0;
Kovalev_D 208:19150d2b528f 666 BuffTemp[ 8] = (Temp >> 8) & 0xff;//расщипление частота 9 --частота расщипления
Kovalev_D 209:224e7331a061 667 BuffTemp[ 9] = (Temp >> 0) & 0xff;// 10 --частота расщипления
Kovalev_D 208:19150d2b528f 668
Kovalev_D 211:ac8251b067d2 669 //(unsigned int)((Gyro.DacIn+30000)*0.6667);
Kovalev_D 226:4a4d5bd5fcd7 670 Temp1 = 0xffff - Spi.DAC_A;
Kovalev_D 226:4a4d5bd5fcd7 671 BuffTemp[10] = (Temp1 >> 8) & 0xff;//выход регулятора гвч; 11 --выход регулятора ГВЧ
Kovalev_D 209:224e7331a061 672 BuffTemp[11] = (Temp1 >> 0) & 0xff; //12 --выход регулятора ГВЧ
Kovalev_D 209:224e7331a061 673
Kovalev_D 211:ac8251b067d2 674
Kovalev_D 226:4a4d5bd5fcd7 675 /*
Kovalev_D 213:9953db9543d6 676 if(Gyro.LG_Type) Temp =(int)(tempDeltaRegul);
Kovalev_D 226:4a4d5bd5fcd7 677 else Temp =(unsigned int)((0x7fff-Spi.ADC5)*0.79)<<1;*/
Kovalev_D 226:4a4d5bd5fcd7 678
Kovalev_D 226:4a4d5bd5fcd7 679 Temp =(int)(tempDeltaRegul); //для призмы
Kovalev_D 225:f8fee6c586cc 680 tempDeltaRegul=0;
Kovalev_D 208:19150d2b528f 681 BuffTemp[12]=(Temp >> 8) & 0xff;//// HFO 13 --сигнал ошибки регулятора ГВЧ
Kovalev_D 208:19150d2b528f 682 BuffTemp[13]=(Temp >> 0) & 0xff;//// 14 --сигнал ошибки регулятора ГВЧ
Kovalev_D 209:224e7331a061 683
Kovalev_D 209:224e7331a061 684 //Temp = (unsigned int)((7675000*16/(Gyro.Frq>>12)));
Kovalev_D 227:2774b56bfab0 685 Temp = Gyro.Frq>>12;//(unsigned int)(7680000/(Gyro.Frq>>16));
Kovalev_D 208:19150d2b528f 686 BuffTemp[14] = (Temp >> 8) & 0xff; //15 период вибропривода.(частота) T_Vibro
Kovalev_D 208:19150d2b528f 687 BuffTemp[15] = (Temp >> 0) & 0xff; //16 период вибропривода.
Kovalev_D 208:19150d2b528f 688
Kovalev_D 209:224e7331a061 689 Temp = Gyro.FrqPhaseEror<<2;//Spi.DAC_A-0x7fff;
Kovalev_D 209:224e7331a061 690 BuffTemp[16] = (Temp >> 8) & 0xff; //17 старший байт ФД регулятора периода вибропривода
Kovalev_D 209:224e7331a061 691 BuffTemp[17] = (Temp >> 0) & 0xff;
Kovalev_D 209:224e7331a061 692 /*sprintf((Time),"%d %d\r\n",Gyro.FrqPhaseEror, Gyro.FrqPhaseEror<<2);
Kovalev_D 209:224e7331a061 693 WriteCon(Time); */ //18
igor_v 21:bc8c1cec3da6 694
Kovalev_D 227:2774b56bfab0 695 Temp = Gyro.AmpPer/*>>1*/;//(unsigned int)(((7675000*16/200) * Gyro.AmpPer /(Gyro.Frq>>12)));
Kovalev_D 208:19150d2b528f 696 BuffTemp[18] = (Temp >> 8) & 0xff; //19 длительность импулься вибропривода(амплитуда)
Kovalev_D 208:19150d2b528f 697 BuffTemp[19] = (Temp >> 0) & 0xff; //20
Kovalev_D 210:b02fa166315d 698
Kovalev_D 208:19150d2b528f 699
Kovalev_D 208:19150d2b528f 700 Temp = 0x0;//Gyro.L_vibro<<2;
Kovalev_D 208:19150d2b528f 701 BuffTemp[20] = (Temp >> 8) & 0xff;//регулятор датчика угла поворота //21 старший байт регулятора датчика угла поворота
Kovalev_D 208:19150d2b528f 702 BuffTemp[21] = (Temp >> 0) & 0xff; //22
Kovalev_D 208:19150d2b528f 703
Kovalev_D 225:f8fee6c586cc 704 Temp1 =((Spi.DAC_B-0x7fff)&0xffff);///(3300+(0x7fff+(Spi.DAC_B*1.083)));
Kovalev_D 209:224e7331a061 705 BuffTemp[22] = (Temp1 >> 8) & 0xff; //23 Выход регулятора рабочего периметра
Kovalev_D 209:224e7331a061 706 BuffTemp[23] = (Temp1 >> 0) & 0xff;
Kovalev_D 209:224e7331a061 707 //24
Kovalev_D 211:ac8251b067d2 708
Kovalev_D 220:04c54405b82d 709 Temp = PLC_EROR;
Kovalev_D 220:04c54405b82d 710 PLC_EROR=0;
Kovalev_D 220:04c54405b82d 711
Kovalev_D 208:19150d2b528f 712 BuffTemp[24] = (Temp >> 8) & 0xff;// //25 ФД СРП
Kovalev_D 208:19150d2b528f 713 BuffTemp[25] = (Temp >> 0) & 0xff;// //26 ФД СРП
Kovalev_D 209:224e7331a061 714
Kovalev_D 209:224e7331a061 715 Temp =0;/* Gyro.AD_Slow >> 16*/;
Kovalev_D 208:19150d2b528f 716 BuffTemp[26] = (Temp >> 8) & 0xff; //27 ADC 0
Kovalev_D 208:19150d2b528f 717 BuffTemp[27] = (Temp >> 0) & 0xff; //28
Kovalev_D 113:8be429494918 718
Kovalev_D 209:224e7331a061 719 Temp =0; /*Gyro.AD_Slow >> 16*/;
Kovalev_D 208:19150d2b528f 720 BuffTemp[28] = (Temp >> 8) & 0xff; //29 ADC 1
Kovalev_D 208:19150d2b528f 721 BuffTemp[29] = (Temp >> 0) & 0xff; //30
Kovalev_D 113:8be429494918 722
Kovalev_D 220:04c54405b82d 723 Temp1 = 0;//((Gyro.In1>>1)*0.800875)-0x3e0b;
Kovalev_D 209:224e7331a061 724 BuffTemp[30] = (Temp1 >> 8) & 0xff;//in1//2 //31 ADC 2
Kovalev_D 209:224e7331a061 725 BuffTemp[31] = (Temp1 >> 0) & 0xff; //32
Kovalev_D 208:19150d2b528f 726
Kovalev_D 220:04c54405b82d 727 Temp1 =0;//((Gyro.In2>>1)*0.800875)-0x3e0b;// - 0x4FFF;
Kovalev_D 209:224e7331a061 728 BuffTemp[32] = (Temp1 >> 8) & 0xff; //33 ADC 3
Kovalev_D 209:224e7331a061 729 BuffTemp[33] = (Temp1 >> 0) & 0xff;//in2//3 //34
Kovalev_D 209:224e7331a061 730
Kovalev_D 208:19150d2b528f 731 Temp = (Gyro.DeltaT);
Kovalev_D 208:19150d2b528f 732 BuffTemp[34] = (Temp >> 8) & 0xff;//дельта //35 ADC 4
Kovalev_D 208:19150d2b528f 733 BuffTemp[35] = (Temp >> 0) & 0xff; //36
Kovalev_D 208:19150d2b528f 734 // Temp = 000;
Kovalev_D 208:19150d2b528f 735
Kovalev_D 208:19150d2b528f 736 Temp = Gyro.Termo;
Kovalev_D 208:19150d2b528f 737 BuffTemp[36] =(Temp >> 8) & 0xff;//температура //37 ADC 5
Kovalev_D 208:19150d2b528f 738 BuffTemp[37] =(Temp >> 0) & 0xff;//ADC6 sesnsor 5 //38
igor_v 21:bc8c1cec3da6 739
igor_v 21:bc8c1cec3da6 740 Check(BuffTemp, 44);
igor_v 21:bc8c1cec3da6 741 WriteConN (BuffTemp,44);
Kovalev_D 209:224e7331a061 742 for(int i=0; i<45;i++) {BuffTemp[i]=0;}
Kovalev_D 209:224e7331a061 743 }
Kovalev_D 209:224e7331a061 744
Kovalev_D 210:b02fa166315d 745 void CMD_Rate2(void)
Kovalev_D 210:b02fa166315d 746 {
Kovalev_D 210:b02fa166315d 747 unsigned int Temp;
Kovalev_D 225:f8fee6c586cc 748 //float y = 52646.45
Kovalev_D 210:b02fa166315d 749 Gyro.Reper_Event=0;
Kovalev_D 214:4c70e452c491 750 for(int q=0; q<64; q++)
Kovalev_D 214:4c70e452c491 751 {
Kovalev_D 214:4c70e452c491 752 BuffTemp[q]=0;
Kovalev_D 214:4c70e452c491 753 }
Kovalev_D 210:b02fa166315d 754 BuffTemp[ 0] = Gyro.SOC_Out;
Kovalev_D 210:b02fa166315d 755 BuffTemp[ 1] = Gyro.My_Addres;
Kovalev_D 216:189b0ea1dc38 756
Kovalev_D 211:ac8251b067d2 757 Temp=Gyro.CaunPlusReper;
Kovalev_D 211:ac8251b067d2 758
Kovalev_D 210:b02fa166315d 759 BuffTemp[ 2] =(Temp >> 8) & 0xff;//старший байт счетчика +.
Kovalev_D 210:b02fa166315d 760 BuffTemp[ 3] =(Temp >> 0) & 0xff;//младший байт счетчика +.
Kovalev_D 211:ac8251b067d2 761 //сохраняем 5 бит для след измирений
Kovalev_D 210:b02fa166315d 762
Kovalev_D 211:ac8251b067d2 763 Temp= Gyro.CaunMinReper;
Kovalev_D 211:ac8251b067d2 764
Kovalev_D 210:b02fa166315d 765 BuffTemp[ 4] =(Temp >> 8) & 0xff;//старший байт счетчика -.
Kovalev_D 210:b02fa166315d 766 BuffTemp[ 5] =(Temp >> 0) & 0xff;//младший байт счетчика -.
Kovalev_D 216:189b0ea1dc38 767
Kovalev_D 211:ac8251b067d2 768
Kovalev_D 210:b02fa166315d 769 Check(BuffTemp, 8);
Kovalev_D 210:b02fa166315d 770 WriteConN (BuffTemp,8);
Kovalev_D 210:b02fa166315d 771 }
Kovalev_D 210:b02fa166315d 772
Kovalev_D 210:b02fa166315d 773 void CMD_Rate3(void)
Kovalev_D 210:b02fa166315d 774 {
Kovalev_D 210:b02fa166315d 775 Gyro.Rate3_Event=0;
Kovalev_D 210:b02fa166315d 776 BuffTemp[ 0] = Gyro.SOC_Out;
Kovalev_D 210:b02fa166315d 777 BuffTemp[ 1] = Gyro.My_Addres;
Kovalev_D 210:b02fa166315d 778 BuffTemp[ 2] = 0xcc;//старший байт счетчика +.
Kovalev_D 210:b02fa166315d 779 BuffTemp[ 3] = 0xcc;//младший байт счетчика +.
Kovalev_D 210:b02fa166315d 780
Kovalev_D 210:b02fa166315d 781 BuffTemp[ 4] =0xBB;//старший байт счетчика -.
Kovalev_D 210:b02fa166315d 782 BuffTemp[ 5] =0xBB;//младший байт счетчика -.
Kovalev_D 210:b02fa166315d 783
Kovalev_D 210:b02fa166315d 784 Check(BuffTemp, 8);
Kovalev_D 210:b02fa166315d 785 WriteConN (BuffTemp,8);
Kovalev_D 210:b02fa166315d 786 }
Kovalev_D 210:b02fa166315d 787
Kovalev_D 209:224e7331a061 788 void CMD_M_Stymul()
Kovalev_D 209:224e7331a061 789 {
Kovalev_D 209:224e7331a061 790 int temp,Consol=0,HFO,b4;
Kovalev_D 209:224e7331a061 791 float Temp1;
Kovalev_D 209:224e7331a061 792 temp=BuffTemp[3];
Kovalev_D 209:224e7331a061 793
Kovalev_D 209:224e7331a061 794 b4 = temp;
Kovalev_D 209:224e7331a061 795 Consol = temp>>7;
Kovalev_D 209:224e7331a061 796 HFO = temp&0x3;// // (номер (код) ЦАПа 0...3, HFO - 3dac, PLC - 0DAC
Kovalev_D 209:224e7331a061 797
Kovalev_D 209:224e7331a061 798 temp = (((BuffTemp[4]<<8) | BuffTemp[5])&0xFFFF);
Kovalev_D 209:224e7331a061 799 if(HFO)
Kovalev_D 209:224e7331a061 800 {
Kovalev_D 209:224e7331a061 801 Gyro.DacIn=temp;
Kovalev_D 225:f8fee6c586cc 802 if(Gyro.LG_Type==1) Spi.DAC_A = 0xffff-Gyro.DacIn; //((unsigned int)((Gyro.DacIn+0x7011)*0.6667));
Kovalev_D 222:7de7b3bf3a1d 803 else Spi.DAC_A = (unsigned int)(0xffff-Gyro.DacIn); //Spi.DAC_A = ((unsigned int)((Gyro.DacIn+23200)*0.64));
Kovalev_D 209:224e7331a061 804 }
Kovalev_D 225:f8fee6c586cc 805
Kovalev_D 225:f8fee6c586cc 806 else Spi.DAC_B = (unsigned int)((temp-0x7fff)&0xffff);
Kovalev_D 227:2774b56bfab0 807 /*sprintf((Time),"%d %d \r\n", Spi.DAC_B, temp);
Kovalev_D 227:2774b56bfab0 808 WriteCon(Time); */
Kovalev_D 225:f8fee6c586cc 809 for(int q=0; q<64; q++)
Kovalev_D 218:b4067cac75c0 810 {
Kovalev_D 218:b4067cac75c0 811 BuffTemp[q]=0;
Kovalev_D 218:b4067cac75c0 812 }
Kovalev_D 209:224e7331a061 813 BuffTemp[0] = Gyro.SOC_Out; //DD
Kovalev_D 209:224e7331a061 814 BuffTemp[1] = Gyro.My_Addres; //00
Kovalev_D 209:224e7331a061 815 BuffTemp[2] = Gyro.CMD_In; //D9
Kovalev_D 209:224e7331a061 816 BuffTemp[3] =0;
Kovalev_D 209:224e7331a061 817 Check(BuffTemp, CRC_N);
Kovalev_D 209:224e7331a061 818 WriteConN (BuffTemp,CRC_N);
igor_v 0:8ad47e2b6f00 819 }
Kovalev_D 209:224e7331a061 820
Kovalev_D 179:2b4e6bc277df 821 void CMD_M_vib()
Kovalev_D 179:2b4e6bc277df 822 {
Kovalev_D 209:224e7331a061 823 unsigned int temp1,temp2,anser;
Kovalev_D 209:224e7331a061 824 temp1 = (((BuffTemp[4]<<8) | BuffTemp[5])&0xFFFF);
Kovalev_D 227:2774b56bfab0 825 Gyro.Frq = (temp1<<12);
Kovalev_D 227:2774b56bfab0 826 // Gyro.Frq = (122780000/temp1)<<12;
Kovalev_D 227:2774b56bfab0 827
Kovalev_D 227:2774b56bfab0 828 F_vib= (unsigned int)(825600000 / temp1);
Kovalev_D 227:2774b56bfab0 829 temp2 = (((BuffTemp[6]<<8) | BuffTemp[7])&0xFFFF);
Kovalev_D 227:2774b56bfab0 830
Kovalev_D 227:2774b56bfab0 831 sprintf((Time),"%d %d \r\n",temp1, temp2);
Kovalev_D 227:2774b56bfab0 832 WriteCon(Time);
Kovalev_D 227:2774b56bfab0 833 Gyro.AmpPer = temp2;
Kovalev_D 227:2774b56bfab0 834 Gyro.Amp = (Gyro.AmpPer<<17)/100;
Kovalev_D 227:2774b56bfab0 835 /* Gyro.AmpPer = ((((((Gyro.Frq>>12)*200)/16)*temp2)/7680000)/2);
Kovalev_D 227:2774b56bfab0 836 Gyro.Amp = (Gyro.AmpPer)<<17;*/
Kovalev_D 225:f8fee6c586cc 837
Kovalev_D 209:224e7331a061 838 BuffTemp[0] = Gyro.SOC_Out;
Kovalev_D 209:224e7331a061 839 BuffTemp[1] = Gyro.My_Addres;
Kovalev_D 209:224e7331a061 840 BuffTemp[2] = Gyro.CMD_In;
Kovalev_D 209:224e7331a061 841 BuffTemp[3] = 0x0;
Kovalev_D 209:224e7331a061 842 BuffTemp[4] = 0x0;
Kovalev_D 209:224e7331a061 843 Check(BuffTemp, CRC_N);
Kovalev_D 209:224e7331a061 844 WriteConN (BuffTemp,CRC_N);
Kovalev_D 179:2b4e6bc277df 845 }
igor_v 21:bc8c1cec3da6 846 void CMD_M_Control_D8()///установка\сброс регистров управления
igor_v 21:bc8c1cec3da6 847 {
Kovalev_D 209:224e7331a061 848 unsigned int bit=0,Pa=0;
Kovalev_D 209:224e7331a061 849 unsigned int SR=0,V=0,Bit_num=0,A=0;
Kovalev_D 209:224e7331a061 850 Pa = BuffTemp[3];
Kovalev_D 209:224e7331a061 851 SR = Pa >> 7;
Kovalev_D 209:224e7331a061 852 V = (Pa>>5)&0x3;
Kovalev_D 209:224e7331a061 853 A = (Pa>>4)&0x1;
Kovalev_D 209:224e7331a061 854 Bit_num = Pa & 0xf;
Kovalev_D 104:ab1cb4ff56b2 855
Kovalev_D 209:224e7331a061 856 switch (SR)
Kovalev_D 209:224e7331a061 857 {
Kovalev_D 209:224e7331a061 858 case 0:
Kovalev_D 209:224e7331a061 859 switch (A)
Kovalev_D 209:224e7331a061 860 {
Kovalev_D 209:224e7331a061 861 case 0:
Kovalev_D 209:224e7331a061 862 switch (Bit_num)
Kovalev_D 209:224e7331a061 863 {
Kovalev_D 209:224e7331a061 864 case 0x06: FrqOFF break;
Kovalev_D 209:224e7331a061 865 case 0x05: AVibOFF break;
Kovalev_D 209:224e7331a061 866 case 0x01: HFOOFF break;
Kovalev_D 209:224e7331a061 867 case 0x03: PlcOFF break;
Kovalev_D 222:7de7b3bf3a1d 868 case 0x02: Gyro.RgConA &= ~(1<<2); break;
Kovalev_D 209:224e7331a061 869 }
Kovalev_D 209:224e7331a061 870 break;
Kovalev_D 209:224e7331a061 871 case 1:
Kovalev_D 209:224e7331a061 872 switch (Bit_num)
Kovalev_D 209:224e7331a061 873 {
Kovalev_D 209:224e7331a061 874 case 0x00: Gyro.RgConB &= ~(1<<0); break;
Kovalev_D 209:224e7331a061 875 case 0x01: Gyro.RgConB &= ~(1<<1); break;
Kovalev_D 209:224e7331a061 876 case 0x02: Gyro.RgConB &= ~(1<<2); break;
Kovalev_D 209:224e7331a061 877 }
Kovalev_D 209:224e7331a061 878 break;
Kovalev_D 209:224e7331a061 879 }
Kovalev_D 209:224e7331a061 880
Kovalev_D 209:224e7331a061 881
Kovalev_D 209:224e7331a061 882 break;
Kovalev_D 209:224e7331a061 883 case 1:
Kovalev_D 209:224e7331a061 884 switch (A)
Kovalev_D 209:224e7331a061 885 {
Kovalev_D 209:224e7331a061 886 case 0:
Kovalev_D 209:224e7331a061 887 switch (Bit_num)
Kovalev_D 209:224e7331a061 888 {
Kovalev_D 222:7de7b3bf3a1d 889 case 0x06: FrqON break;
Kovalev_D 222:7de7b3bf3a1d 890 case 0x05: AVibON break;
Kovalev_D 222:7de7b3bf3a1d 891 case 0x01: HFOON break;
Kovalev_D 222:7de7b3bf3a1d 892 case 0x03: PlcON break;
Kovalev_D 222:7de7b3bf3a1d 893 case 0x02: Gyro.RgConA |= (1<<2); break;
Kovalev_D 209:224e7331a061 894 }
Kovalev_D 209:224e7331a061 895 break;
Kovalev_D 209:224e7331a061 896 case 1:
Kovalev_D 209:224e7331a061 897 switch (Bit_num)
Kovalev_D 209:224e7331a061 898 {
Kovalev_D 209:224e7331a061 899 case 0x00: Gyro.RgConB |= (1<<0); break;
Kovalev_D 209:224e7331a061 900 case 0x01: Gyro.RgConB |= (1<<1); break;
Kovalev_D 209:224e7331a061 901 case 0x02: Gyro.RgConB |= (1<<2); break;
Kovalev_D 209:224e7331a061 902 }
Kovalev_D 209:224e7331a061 903 break;
Kovalev_D 209:224e7331a061 904 }
Kovalev_D 209:224e7331a061 905 break;
Kovalev_D 209:224e7331a061 906 }
igor_v 30:17c84ed091b3 907 BuffTemp[0] = Gyro.SOC_Out; //DD
igor_v 30:17c84ed091b3 908 BuffTemp[1] = Gyro.My_Addres; //00
igor_v 30:17c84ed091b3 909 BuffTemp[2] = Gyro.CMD_In; //D8
Kovalev_D 209:224e7331a061 910 switch (A)
Kovalev_D 209:224e7331a061 911 {
Kovalev_D 209:224e7331a061 912 case 0:
Kovalev_D 209:224e7331a061 913 BuffTemp[ 4] =(Gyro.RgConA >> 8) & 0xff;
Kovalev_D 209:224e7331a061 914 BuffTemp[ 5] =(Gyro.RgConA >> 0) & 0xff;
Kovalev_D 209:224e7331a061 915 break;
Kovalev_D 209:224e7331a061 916
Kovalev_D 209:224e7331a061 917 case 1:
Kovalev_D 209:224e7331a061 918 BuffTemp[ 4] =(Gyro.RgConB >> 8) & 0xff;
Kovalev_D 209:224e7331a061 919 BuffTemp[ 5] =(Gyro.RgConB >> 0) & 0xff;
Kovalev_D 209:224e7331a061 920 break;
Kovalev_D 209:224e7331a061 921 }
Kovalev_D 209:224e7331a061 922 Check(BuffTemp, CRC_N);
Kovalev_D 209:224e7331a061 923 WriteConN (BuffTemp,CRC_N);
Kovalev_D 209:224e7331a061 924 }
Kovalev_D 208:19150d2b528f 925
igor_v 21:bc8c1cec3da6 926 void CMD_M_Control_D9()///чтение регистров управления
igor_v 21:bc8c1cec3da6 927 {
Kovalev_D 209:224e7331a061 928 int bit,NReg,param=0;
igor_v 30:17c84ed091b3 929 BuffTemp[0] = Gyro.SOC_Out; //DD
igor_v 30:17c84ed091b3 930 BuffTemp[1] = Gyro.My_Addres; //00
igor_v 30:17c84ed091b3 931 BuffTemp[2] = Gyro.CMD_In; //D9
Kovalev_D 209:224e7331a061 932 param = BuffTemp[3];
Kovalev_D 209:224e7331a061 933 if (param)
Kovalev_D 209:224e7331a061 934 {
igor_v 21:bc8c1cec3da6 935 BuffTemp[3]=1<<4;
igor_v 30:17c84ed091b3 936 BuffTemp[4] = (Gyro.RgConB>>8 ) & 0xff;
igor_v 30:17c84ed091b3 937 BuffTemp[5] = Gyro.RgConB & 0xff;
igor_v 21:bc8c1cec3da6 938 }
Kovalev_D 209:224e7331a061 939 else
Kovalev_D 209:224e7331a061 940 {
Kovalev_D 209:224e7331a061 941 BuffTemp[3]=0<<4;
Kovalev_D 209:224e7331a061 942 BuffTemp[4] = (Gyro.RgConA>>8 )& 0xff;
Kovalev_D 209:224e7331a061 943 BuffTemp[5] = Gyro.RgConA & 0xff;
Kovalev_D 209:224e7331a061 944 }
igor_v 21:bc8c1cec3da6 945 Check(BuffTemp, CRC_N);
igor_v 21:bc8c1cec3da6 946 WriteConN (BuffTemp,CRC_N);
igor_v 21:bc8c1cec3da6 947 }
igor_v 21:bc8c1cec3da6 948 // (номер (код) ЦАПа 0...3, старший байт требуемого ЦАПа, младший байт треб ЦАПа)
Kovalev_D 209:224e7331a061 949
Kovalev_D 209:224e7331a061 950
Kovalev_D 194:8f3cb37a5541 951
Kovalev_D 194:8f3cb37a5541 952 void GLDStartDischarg(void)
Kovalev_D 208:19150d2b528f 953 { TimeDischarg=0;
Kovalev_D 208:19150d2b528f 954 Try=0;
Kovalev_D 194:8f3cb37a5541 955 switch(Gyro.My_Addres)
Kovalev_D 194:8f3cb37a5541 956 {//смещение поджига и подсветки в зависимости от адреса ГЛД
Kovalev_D 194:8f3cb37a5541 957 case 0:
Kovalev_D 194:8f3cb37a5541 958 Gyro.Discharg = StartDischarg << ShiftStart0;
Kovalev_D 194:8f3cb37a5541 959 Gyro.BackLight = StartBackLight << ShiftStart0;
Kovalev_D 194:8f3cb37a5541 960 break;
Kovalev_D 194:8f3cb37a5541 961 case 1:
Kovalev_D 194:8f3cb37a5541 962 Gyro.Discharg = StartDischarg << ShiftStart1;
Kovalev_D 194:8f3cb37a5541 963 Gyro.BackLight = StartBackLight << ShiftStart1;
Kovalev_D 194:8f3cb37a5541 964 break;
Kovalev_D 194:8f3cb37a5541 965 case 2:
Kovalev_D 194:8f3cb37a5541 966 Gyro.Discharg = StartDischarg << ShiftStart2;
Kovalev_D 194:8f3cb37a5541 967 Gyro.BackLight = StartBackLight << ShiftStart2;
Kovalev_D 194:8f3cb37a5541 968 break;
Kovalev_D 194:8f3cb37a5541 969 case 3:
Kovalev_D 194:8f3cb37a5541 970 Gyro.Discharg = StartDischarg << ShiftStart3;
Kovalev_D 194:8f3cb37a5541 971 Gyro.BackLight = StartBackLight << ShiftStart3;
Kovalev_D 194:8f3cb37a5541 972 break;
Kovalev_D 194:8f3cb37a5541 973 }
Kovalev_D 194:8f3cb37a5541 974 }
Kovalev_D 194:8f3cb37a5541 975
Kovalev_D 103:e96f08947def 976 void Gph_W()
Kovalev_D 103:e96f08947def 977 {
Kovalev_D 205:775d54fdf646 978 //Gyro.flagGph_W=3;
Kovalev_D 208:19150d2b528f 979
Kovalev_D 172:ef7bf1663645 980 Out_G_photo(BuffTemp[4],BuffTemp[5]);
Kovalev_D 209:224e7331a061 981 BuffTemp[0] = Gyro.SOC_Out; //DD
Kovalev_D 209:224e7331a061 982 BuffTemp[1] = Gyro.My_Addres; //00
Kovalev_D 209:224e7331a061 983 BuffTemp[2] = Gyro.CMD_In; //D9
Kovalev_D 209:224e7331a061 984 BuffTemp[3] = 0;
Kovalev_D 209:224e7331a061 985 Check(BuffTemp, CRC_N);
Kovalev_D 209:224e7331a061 986 WriteConN (BuffTemp,CRC_N);
Kovalev_D 103:e96f08947def 987 }
Kovalev_D 209:224e7331a061 988 void DeviceMode()
Kovalev_D 209:224e7331a061 989 {
Kovalev_D 209:224e7331a061 990 int TempMod=1;
Kovalev_D 209:224e7331a061 991 BuffTemp[0] = Gyro.SOC_Out; //DD
Kovalev_D 209:224e7331a061 992 BuffTemp[1] = Gyro.My_Addres; //00
Kovalev_D 209:224e7331a061 993 BuffTemp[2] = Gyro.CMD_In; //D9
Kovalev_D 209:224e7331a061 994 TempMod = BuffTemp[3] & 0xf;
Kovalev_D 226:4a4d5bd5fcd7 995 Gyro.Device_Mode = TempMod;
Kovalev_D 226:4a4d5bd5fcd7 996
Kovalev_D 226:4a4d5bd5fcd7 997 sprintf((Time)," Comand - DeviceMode(); Gyro.Device_Mode = %d Gyro.ModeOut = %d\r\n",Gyro.Device_Mode,Gyro.ModeOut);
Kovalev_D 226:4a4d5bd5fcd7 998 WriteCon(Time);
Kovalev_D 226:4a4d5bd5fcd7 999 /*
Kovalev_D 226:4a4d5bd5fcd7 1000 sprintf((Time),"%d\r\n",Gyro.Device_Mode);
Kovalev_D 226:4a4d5bd5fcd7 1001 WriteCon(Time);*/
Kovalev_D 226:4a4d5bd5fcd7 1002 BuffTemp[3]=Gyro.Device_Mode & 0xff;
Kovalev_D 209:224e7331a061 1003 BuffTemp[4]=0;
Kovalev_D 209:224e7331a061 1004 BuffTemp[5]=0;
Kovalev_D 209:224e7331a061 1005 Check(BuffTemp, CRC_N);
Kovalev_D 209:224e7331a061 1006 WriteConN (BuffTemp,CRC_N);
Kovalev_D 209:224e7331a061 1007 }
Kovalev_D 102:4270092be987 1008
igor_v 0:8ad47e2b6f00 1009 unsigned int Check(char *c, unsigned int Count)
igor_v 0:8ad47e2b6f00 1010 {
igor_v 21:bc8c1cec3da6 1011 int i=1;
igor_v 21:bc8c1cec3da6 1012 unsigned int temp,CRC;
igor_v 21:bc8c1cec3da6 1013
igor_v 21:bc8c1cec3da6 1014
igor_v 21:bc8c1cec3da6 1015 temp=1;
igor_v 21:bc8c1cec3da6 1016 CRC=0;
igor_v 21:bc8c1cec3da6 1017
igor_v 21:bc8c1cec3da6 1018
igor_v 21:bc8c1cec3da6 1019 for(; i<Count-2; i++) {
igor_v 21:bc8c1cec3da6 1020 CRC+=c[i];
igor_v 21:bc8c1cec3da6 1021 }
igor_v 0:8ad47e2b6f00 1022
igor_v 21:bc8c1cec3da6 1023 if(c[Count-2]!=((CRC>>8)&0xFF)) {
igor_v 21:bc8c1cec3da6 1024 temp=0;
igor_v 30:17c84ed091b3 1025 Gyro.RsErrLine = (Gyro.RsErrLine)&=0x2;
igor_v 21:bc8c1cec3da6 1026 }
igor_v 0:8ad47e2b6f00 1027
igor_v 21:bc8c1cec3da6 1028 if(c[Count-1]!=((CRC>>0)&0xFF)) {
igor_v 21:bc8c1cec3da6 1029 temp=0;
igor_v 30:17c84ed091b3 1030 // Gyro.RsErrLine= (Gyro.RsErrLine)=0x2;
igor_v 21:bc8c1cec3da6 1031 }
igor_v 21:bc8c1cec3da6 1032
igor_v 21:bc8c1cec3da6 1033 c[Count-2]=(CRC>>8)&0xFF;
igor_v 21:bc8c1cec3da6 1034 c[Count-1]=(CRC>>0)&0xFF;
igor_v 21:bc8c1cec3da6 1035
igor_v 21:bc8c1cec3da6 1036 return temp;
igor_v 0:8ad47e2b6f00 1037 }
igor_v 0:8ad47e2b6f00 1038
igor_v 0:8ad47e2b6f00 1039 int Getlengf(void)
igor_v 0:8ad47e2b6f00 1040 {
Kovalev_D 121:bbae560cdd43 1041 unsigned int lengf;
Kovalev_D 121:bbae560cdd43 1042 lengf = 1;
Kovalev_D 194:8f3cb37a5541 1043 switch(Gyro.CMD_In)
Kovalev_D 194:8f3cb37a5541 1044 {
Kovalev_D 194:8f3cb37a5541 1045 case 0x99: lengf=6; CRC_N=8; break; //Mintainance
Kovalev_D 194:8f3cb37a5541 1046 case 0xB0: lengf=6; CRC_N=9; break; //Delta_Bins
Kovalev_D 194:8f3cb37a5541 1047 case 0x0F: lengf=6; CRC_N=8; break; //Delta_Bins
Kovalev_D 194:8f3cb37a5541 1048 case 0xA0: lengf=6; CRC_N=8; break; //Delta_PS
Kovalev_D 194:8f3cb37a5541 1049 case 0xDD: lengf=6; CRC_N=44; break; //m_rate
Kovalev_D 209:224e7331a061 1050 case 0x0A: lengf=8; CRC_N=6; break; //m_stymul
Kovalev_D 194:8f3cb37a5541 1051 case 0xE9: lengf=6; CRC_N=8; break; //DeviceMode
Kovalev_D 194:8f3cb37a5541 1052 case 0xE8: lengf=6; CRC_N=8; break; //DeviceMode
Kovalev_D 194:8f3cb37a5541 1053 case 0xA5: lengf=6; CRC_N=8; break; //DeviceMode
Kovalev_D 209:224e7331a061 1054 case 0xD8: lengf=6; CRC_N=8; break; //m_control
Kovalev_D 194:8f3cb37a5541 1055 case 0xD9: lengf=6; CRC_N=8; break; //m_control
Kovalev_D 209:224e7331a061 1056 case 0xE4: lengf=8; CRC_N=6; break; //M_VIB_W
Kovalev_D 209:224e7331a061 1057 case 0xE6: lengf=8; CRC_N=6; break; //M_Gph_W
Kovalev_D 209:224e7331a061 1058
Kovalev_D 194:8f3cb37a5541 1059 } return lengf;
igor_v 0:8ad47e2b6f00 1060 }
igor_v 0:8ad47e2b6f00 1061
igor_v 0:8ad47e2b6f00 1062 void Read_CMD(void)
igor_v 21:bc8c1cec3da6 1063 {
Kovalev_D 188:4c523cc373cc 1064
Kovalev_D 147:1aed74f19a8f 1065 Gyro.RsErrLine = (Gyro.RsErrLine)& 0xffff;//для сброса ошибки
Kovalev_D 188:4c523cc373cc 1066 CountBuFFIn=ReadChekCon1(BuffTemp);
Kovalev_D 188:4c523cc373cc 1067 // чтение данных из консоли
Kovalev_D 188:4c523cc373cc 1068 if(CountBuFFIn==1) {
Kovalev_D 190:289514f730ee 1069 // если есть первый байт
Kovalev_D 209:224e7331a061 1070 if (BuffTemp[0] != SOC_In)
Kovalev_D 209:224e7331a061 1071 {
Kovalev_D 147:1aed74f19a8f 1072 ReadCon1(BuffTemp);
Kovalev_D 194:8f3cb37a5541 1073 Gyro.RsErrLine += 0x100;
Kovalev_D 209:224e7331a061 1074 //BuffTemp[99]=Gyro.RsErrLine;
Kovalev_D 209:224e7331a061 1075 ReadCon1(BuffTemp);
Kovalev_D 209:224e7331a061 1076 }
Kovalev_D 147:1aed74f19a8f 1077 }
Kovalev_D 190:289514f730ee 1078 else if(CountBuFFIn==2) //если второй байт
Kovalev_D 194:8f3cb37a5541 1079 { // широковещаительный
Kovalev_D 209:224e7331a061 1080 if (BuffTemp[1] != Gyro.My_Addres /*|| BuffTemp[1] !=0x1f*/)
Kovalev_D 209:224e7331a061 1081 {
Kovalev_D 93:b3803774f110 1082 ReadCon1(BuffTemp);
Kovalev_D 194:8f3cb37a5541 1083 Gyro.RsErrLine += 0x1;
Kovalev_D 209:224e7331a061 1084 ReadCon1(BuffTemp);
Kovalev_D 188:4c523cc373cc 1085 }
Kovalev_D 147:1aed74f19a8f 1086 }
Kovalev_D 190:289514f730ee 1087 else if(CountBuFFIn==3) // если третий байт
Kovalev_D 147:1aed74f19a8f 1088 {
igor_v 30:17c84ed091b3 1089 Gyro.CMD_In=BuffTemp[2];
Kovalev_D 92:c892f0311aa7 1090 N=Getlengf();
Kovalev_D 92:c892f0311aa7 1091 }
Kovalev_D 92:c892f0311aa7 1092 else if(CountBuFFIn==4 && (N==6))
Kovalev_D 92:c892f0311aa7 1093 { // N - длина посылки аскглд(для записи параметров). определяется по коду команды в Getlengf();
igor_v 21:bc8c1cec3da6 1094 Param1=BuffTemp[3];
Kovalev_D 92:c892f0311aa7 1095 }
Kovalev_D 92:c892f0311aa7 1096 else if((CountBuFFIn==5)&&(N==7))
Kovalev_D 92:c892f0311aa7 1097 {
igor_v 21:bc8c1cec3da6 1098 Param1=BuffTemp[3];
igor_v 21:bc8c1cec3da6 1099 Param2=BuffTemp[4];
igor_v 0:8ad47e2b6f00 1100
Kovalev_D 92:c892f0311aa7 1101 }
Kovalev_D 92:c892f0311aa7 1102 else if((CountBuFFIn==6)&&(N==8))
Kovalev_D 147:1aed74f19a8f 1103 {
igor_v 21:bc8c1cec3da6 1104 Param1=BuffTemp[3];
igor_v 21:bc8c1cec3da6 1105 Param2=BuffTemp[4];
igor_v 21:bc8c1cec3da6 1106 Param3=BuffTemp[5];
Kovalev_D 92:c892f0311aa7 1107 }
Kovalev_D 102:4270092be987 1108 else if((CountBuFFIn==8)&&(N==10))
Kovalev_D 147:1aed74f19a8f 1109 {
Kovalev_D 102:4270092be987 1110 Param1=BuffTemp[4];
Kovalev_D 102:4270092be987 1111 Param2=BuffTemp[5];
Kovalev_D 102:4270092be987 1112 Param3=BuffTemp[6];
Kovalev_D 102:4270092be987 1113 Param4=BuffTemp[7];
Kovalev_D 102:4270092be987 1114 }
Kovalev_D 98:95b8e79f13e1 1115
Kovalev_D 92:c892f0311aa7 1116 else if(CountBuFFIn > (N-1))
Kovalev_D 92:c892f0311aa7 1117 {
Kovalev_D 147:1aed74f19a8f 1118 ReadCon1(BuffTemp);
Kovalev_D 208:19150d2b528f 1119
Kovalev_D 209:224e7331a061 1120 //if(SA)CMD_M_Stymul_Answer();
Kovalev_D 208:19150d2b528f 1121 // if(d8_anser)D8_Answer();
Kovalev_D 208:19150d2b528f 1122
Kovalev_D 147:1aed74f19a8f 1123 switch(Gyro.CMD_In) {
Kovalev_D 226:4a4d5bd5fcd7 1124 // case 0xA5: DeviceMode() ; break;
Kovalev_D 209:224e7331a061 1125 case 0x99: /*Gyro.ModeOut=0;*/CMD_Maintenance(); break;
Kovalev_D 209:224e7331a061 1126 case 0xD8: CMD_M_Control_D8(); break;
Kovalev_D 194:8f3cb37a5541 1127 case 0xE9: CMD_M_Param_R(); break; //чтение параметров
Kovalev_D 194:8f3cb37a5541 1128 case 0xE8: CMD_M_Param_W(); break; //запись параметра
Kovalev_D 194:8f3cb37a5541 1129 case 0xDA: GLDStartDischarg(); break;
Kovalev_D 194:8f3cb37a5541 1130 case 0xD9: CMD_M_Control_D9(); break;
Kovalev_D 208:19150d2b528f 1131 case 0x0A: CMD_M_Stymul(); break;
Kovalev_D 209:224e7331a061 1132 case 0xDD: TempParam=(BuffTemp[3]) & 0x9f; //Rate
Kovalev_D 193:a0fe8bfc97e4 1133 switch(TempParam) {
Kovalev_D 209:224e7331a061 1134 case Rate1 : CMD_Rate(); break;
Kovalev_D 226:4a4d5bd5fcd7 1135 //case Rate2 : Gyro.ModeOut=9; break;
Kovalev_D 209:224e7331a061 1136 case Rate3 : CMD_Rate3(); break;
Kovalev_D 194:8f3cb37a5541 1137 case PRate1 : Gyro.ModeOut=1; break;
Kovalev_D 214:4c70e452c491 1138 case PRate2 : Gyro.ModeOut=2; break;
Kovalev_D 214:4c70e452c491 1139 case PRate3 : Gyro.ModeOut=8; break;
Kovalev_D 214:4c70e452c491 1140 case Rate7 : CMD_Rate7(); break;
Kovalev_D 226:4a4d5bd5fcd7 1141 case PRate7 : Gyro.ModeOut=10; break;
Kovalev_D 222:7de7b3bf3a1d 1142 case Rate5K : M_Rate5K(); break;
Kovalev_D 222:7de7b3bf3a1d 1143 case PRate5K:
Kovalev_D 222:7de7b3bf3a1d 1144 if(Gyro.ModeOut){}
Kovalev_D 222:7de7b3bf3a1d 1145 else Gyro.ModeOut=11;
Kovalev_D 222:7de7b3bf3a1d 1146 break;
Kovalev_D 214:4c70e452c491 1147
Kovalev_D 193:a0fe8bfc97e4 1148 }
Kovalev_D 194:8f3cb37a5541 1149 break; //DropDelay(); выставка задержки для мультидропа сбрасывается в команде CMD_Maintenance() на () микросекунд;
Kovalev_D 226:4a4d5bd5fcd7 1150
Kovalev_D 226:4a4d5bd5fcd7 1151 case 0xA0: /*DropDelay();*/
Kovalev_D 226:4a4d5bd5fcd7 1152 // TempParam=(BuffTemp[3]) & 0x80; //Delta_PS
Kovalev_D 226:4a4d5bd5fcd7 1153
Kovalev_D 226:4a4d5bd5fcd7 1154 switch(Gyro.Device_Mode)
Kovalev_D 226:4a4d5bd5fcd7 1155 {
Kovalev_D 226:4a4d5bd5fcd7 1156 case 0: Gyro.ModeOut=3; Gyro.Event_500Hz=0; break;
Kovalev_D 226:4a4d5bd5fcd7 1157 case 4: Gyro.ModeOut=4; break;
Kovalev_D 226:4a4d5bd5fcd7 1158 }
Kovalev_D 226:4a4d5bd5fcd7 1159 sprintf((Time)," Comand - B_Delta_PS(); Gyro.Device_Mode = %d Gyro.ModeOut = %d\r\n", Gyro.Device_Mode, Gyro.ModeOut);
Kovalev_D 226:4a4d5bd5fcd7 1160 WriteCon(Time);
Kovalev_D 194:8f3cb37a5541 1161 break;
Kovalev_D 226:4a4d5bd5fcd7 1162
Kovalev_D 194:8f3cb37a5541 1163 case 0xB0: DropDelay(); TempParam = TempParam=(BuffTemp[3]>>7); //Delta_Bins
Kovalev_D 193:a0fe8bfc97e4 1164 switch(TempParam) {
Kovalev_D 196:f76dbc081e63 1165 case PDelta_Bins: Gyro.ModeOut=5; Gyro.Event_500Hz=0; break;
Kovalev_D 193:a0fe8bfc97e4 1166 case Delta_Bins : CMD_Delta_Bins(); break;
Kovalev_D 193:a0fe8bfc97e4 1167 }
Kovalev_D 194:8f3cb37a5541 1168 break;
Kovalev_D 194:8f3cb37a5541 1169 case 0x0F: DropDelay(); TempParam = (((BuffTemp[3])>>4) & 0x9); //B_Delta
Kovalev_D 193:a0fe8bfc97e4 1170 switch(TempParam) {
Kovalev_D 193:a0fe8bfc97e4 1171 case PB_Delta_EXT: Gyro.ModeOut=6; break;
Kovalev_D 196:f76dbc081e63 1172 case PB_Delta_INT: Gyro.ModeOut=7; Gyro.Event_500Hz=0; break;
Kovalev_D 193:a0fe8bfc97e4 1173 case B_Delta_EXT: CMD_B_Delta(); break;
Kovalev_D 193:a0fe8bfc97e4 1174 case B_Delta_INT: CMD_B_Delta(); break;
Kovalev_D 193:a0fe8bfc97e4 1175 }
Kovalev_D 194:8f3cb37a5541 1176 break;
Kovalev_D 194:8f3cb37a5541 1177 case 0xE4: CMD_M_vib(); break;
Kovalev_D 209:224e7331a061 1178 case 0xA5: DeviceMode(); break;
Kovalev_D 194:8f3cb37a5541 1179 case 0xE6: Gph_W(); break;
Kovalev_D 194:8f3cb37a5541 1180 Gyro.RsErrLine = 0;
Kovalev_D 194:8f3cb37a5541 1181 }
Kovalev_D 194:8f3cb37a5541 1182 }
Kovalev_D 147:1aed74f19a8f 1183 }
Kovalev_D 193:a0fe8bfc97e4 1184
Kovalev_D 193:a0fe8bfc97e4 1185
Kovalev_D 147:1aed74f19a8f 1186 void TechLog(void)
Kovalev_D 147:1aed74f19a8f 1187 {
Kovalev_D 208:19150d2b528f 1188 unsigned int temp=0;
Kovalev_D 225:f8fee6c586cc 1189 if (ReadCon (Time))
Kovalev_D 208:19150d2b528f 1190 {
Kovalev_D 214:4c70e452c491 1191 int a=0;
Kovalev_D 225:f8fee6c586cc 1192
Kovalev_D 225:f8fee6c586cc 1193
Kovalev_D 225:f8fee6c586cc 1194
Kovalev_D 225:f8fee6c586cc 1195
Kovalev_D 225:f8fee6c586cc 1196 if (Time[0] == 'y')
Kovalev_D 225:f8fee6c586cc 1197 { //Mod 250 Hz PLCRegul250();
Kovalev_D 225:f8fee6c586cc 1198 if( Gyro.Debag) Gyro.Debag=0;
Kovalev_D 225:f8fee6c586cc 1199 else Gyro.Debag=1;
Kovalev_D 225:f8fee6c586cc 1200 }
Kovalev_D 225:f8fee6c586cc 1201 if (Time[0] == 'u')
Kovalev_D 225:f8fee6c586cc 1202 { //Mod 250 Hz PLCRegul250();
Kovalev_D 225:f8fee6c586cc 1203 if( Gyro.Debag2) Gyro.Debag2=0;
Kovalev_D 225:f8fee6c586cc 1204 else Gyro.Debag2=1;
Kovalev_D 225:f8fee6c586cc 1205 }
Kovalev_D 227:2774b56bfab0 1206 if (Time[0] == 'C') Spi.DAC_A+=32;
Kovalev_D 227:2774b56bfab0 1207 if (Time[0] == 'c') Spi.DAC_A-=32;
Kovalev_D 227:2774b56bfab0 1208
Kovalev_D 227:2774b56bfab0 1209 if (Time[0] == 'k') PLC_ERR_DAC_F = 0;
Kovalev_D 227:2774b56bfab0 1210
Kovalev_D 227:2774b56bfab0 1211 if (Time[0] == 'V') Spi.DAC_A+=160;
Kovalev_D 227:2774b56bfab0 1212 if (Time[0] == 'v') Spi.DAC_A-=160;
Kovalev_D 227:2774b56bfab0 1213
Kovalev_D 225:f8fee6c586cc 1214 if (Time[0] == 'X') Spi.DAC_B+=2000;
Kovalev_D 225:f8fee6c586cc 1215 if (Time[0] == 'x') Spi.DAC_B-=2000;
Kovalev_D 147:1aed74f19a8f 1216 /////////////////////////////////////////////////////////////////
Kovalev_D 147:1aed74f19a8f 1217 ////////////////////////////////////////////////////////////////
Kovalev_D 147:1aed74f19a8f 1218 //////////////////////Выбор FlashMod///////////////////////////
Kovalev_D 147:1aed74f19a8f 1219 ////////////////////////////////////////////////////////////////
Kovalev_D 225:f8fee6c586cc 1220 /*
Kovalev_D 205:775d54fdf646 1221 if (Time[0] == 'B') Gyro.FlashMod=1;
Kovalev_D 147:1aed74f19a8f 1222 if (Time[0] == 'R') {Gyro.FlashMod=3;}
Kovalev_D 205:775d54fdf646 1223 if (Time[0] == 'E') {Gyro.FlashMod=4;}
Kovalev_D 147:1aed74f19a8f 1224 ///////////////////////////////////////////////////////////////
Kovalev_D 147:1aed74f19a8f 1225 ///////////////////////////////////////////////////////////////
Kovalev_D 147:1aed74f19a8f 1226 ////////////////////////////////////////////////////////////////
Kovalev_D 209:224e7331a061 1227
Kovalev_D 209:224e7331a061 1228
Kovalev_D 209:224e7331a061 1229
Kovalev_D 209:224e7331a061 1230
Kovalev_D 222:7de7b3bf3a1d 1231 if (Time[0] == 'f') { // выдача технологическая
Kovalev_D 209:224e7331a061 1232 Gyro.ModAmp += 1;
Kovalev_D 209:224e7331a061 1233 sprintf((Time),"%d \r\n", Gyro.ModAmp);
Kovalev_D 209:224e7331a061 1234 WriteCon(Time);
Kovalev_D 222:7de7b3bf3a1d 1235 }
Kovalev_D 222:7de7b3bf3a1d 1236 if (Time[0] == 'd') { // выдача технологическая
Kovalev_D 209:224e7331a061 1237 Gyro.ModAmp -= 1;
Kovalev_D 209:224e7331a061 1238 sprintf((Time),"%d \r\n", Gyro.ModAmp);
Kovalev_D 209:224e7331a061 1239 WriteCon(Time);
Kovalev_D 222:7de7b3bf3a1d 1240 }
Kovalev_D 147:1aed74f19a8f 1241 if (Time[0] == 'V') { // выдача технологическая
Kovalev_D 214:4c70e452c491 1242 F_vib += 1;
Kovalev_D 214:4c70e452c491 1243 LPC_MCPWM->LIM1 = F_vib;
Kovalev_D 214:4c70e452c491 1244 LPC_MCPWM->LIM2 = F_vib;
Kovalev_D 214:4c70e452c491 1245 sprintf((Time),"%d \r\n", F_vib);
Kovalev_D 214:4c70e452c491 1246 WriteCon(Time);
Kovalev_D 214:4c70e452c491 1247 }
Kovalev_D 147:1aed74f19a8f 1248 if (Time[0] == 'v') { // выдача технологическая
Kovalev_D 214:4c70e452c491 1249 F_vib -= 1;
Kovalev_D 214:4c70e452c491 1250 LPC_MCPWM->LIM1 = F_vib;
Kovalev_D 214:4c70e452c491 1251 LPC_MCPWM->LIM2 = F_vib;
Kovalev_D 214:4c70e452c491 1252
Kovalev_D 209:224e7331a061 1253 }
Kovalev_D 220:04c54405b82d 1254
Kovalev_D 220:04c54405b82d 1255
Kovalev_D 220:04c54405b82d 1256
Kovalev_D 225:f8fee6c586cc 1257
Kovalev_D 220:04c54405b82d 1258
Kovalev_D 220:04c54405b82d 1259
Kovalev_D 220:04c54405b82d 1260
Kovalev_D 209:224e7331a061 1261 if (Time[0] == 'p') { // выдача технологическая
Kovalev_D 214:4c70e452c491 1262 // PlcOFF //Gyro.RgConA&0x8=0;
Kovalev_D 214:4c70e452c491 1263
Kovalev_D 214:4c70e452c491 1264 if(Gyro.LogMod) Gyro.LogMod=0;
Kovalev_D 214:4c70e452c491 1265 else Gyro.LogMod=5;
Kovalev_D 211:ac8251b067d2 1266 // MODFlag=1;
Kovalev_D 214:4c70e452c491 1267 // Spi.DAC_B = 32767;
Kovalev_D 209:224e7331a061 1268 }
Kovalev_D 209:224e7331a061 1269 if (Time[0] == 'o') { // выдача технологическая
Kovalev_D 220:04c54405b82d 1270 if(TypeMod==0)TypeMod=5;
Kovalev_D 220:04c54405b82d 1271 else TypeMod=0;
Kovalev_D 213:9953db9543d6 1272
Kovalev_D 211:ac8251b067d2 1273 // Spi.DAC_B = 32000;
Kovalev_D 209:224e7331a061 1274 }
Kovalev_D 215:b58b887fd367 1275 if (Time[0] == 'h')
Kovalev_D 215:b58b887fd367 1276 { // выдача технологическая
Kovalev_D 215:b58b887fd367 1277 for(int q=0; q<64; q++)
Kovalev_D 215:b58b887fd367 1278 {
Kovalev_D 216:189b0ea1dc38 1279 sprintf((Time),"%i \r\n",(BuffADC_znak[q]));
Kovalev_D 215:b58b887fd367 1280 WriteCon(Time);
Kovalev_D 215:b58b887fd367 1281 }
Kovalev_D 215:b58b887fd367 1282
Kovalev_D 215:b58b887fd367 1283 }
Kovalev_D 214:4c70e452c491 1284
Kovalev_D 220:04c54405b82d 1285
Kovalev_D 220:04c54405b82d 1286 if (Time[0] == 'b')
Kovalev_D 211:ac8251b067d2 1287 { // выдача технологическая
Kovalev_D 220:04c54405b82d 1288 sprintf((Time),"10000 \r\n");
Kovalev_D 220:04c54405b82d 1289 WriteCon(Time);
Kovalev_D 214:4c70e452c491 1290 for(int q=0; q<64; q++)
Kovalev_D 215:b58b887fd367 1291 {
Kovalev_D 220:04c54405b82d 1292
Kovalev_D 220:04c54405b82d 1293 if(((CountV255+q)&0xff)==0)
Kovalev_D 220:04c54405b82d 1294 {
Kovalev_D 220:04c54405b82d 1295 sprintf((Time),"12000 \r\n");
Kovalev_D 220:04c54405b82d 1296 WriteCon(Time);
Kovalev_D 220:04c54405b82d 1297 }
Kovalev_D 220:04c54405b82d 1298 else
Kovalev_D 220:04c54405b82d 1299 {
Kovalev_D 220:04c54405b82d 1300 sprintf((Time),"%d \r\n", BuffADC_1Point[(CountV64+q)&0xff] );
Kovalev_D 220:04c54405b82d 1301 WriteCon(Time);
Kovalev_D 220:04c54405b82d 1302 }
Kovalev_D 220:04c54405b82d 1303
Kovalev_D 220:04c54405b82d 1304
Kovalev_D 220:04c54405b82d 1305 }
Kovalev_D 214:4c70e452c491 1306 }
Kovalev_D 225:f8fee6c586cc 1307
Kovalev_D 220:04c54405b82d 1308 if (Time[0] == 'n')
Kovalev_D 214:4c70e452c491 1309 { // выдача технологическая
Kovalev_D 214:4c70e452c491 1310 for(int q=0; q<64; q++)
Kovalev_D 215:b58b887fd367 1311 {
Kovalev_D 222:7de7b3bf3a1d 1312 sprintf((Time),"%d ", Buff_OUT[q]);
Kovalev_D 220:04c54405b82d 1313 WriteCon(Time);
Kovalev_D 222:7de7b3bf3a1d 1314 sprintf((Time),"%d \r\n",ModArraySin[(q+Gyro.PLC_Phase)&0x3f]);
Kovalev_D 222:7de7b3bf3a1d 1315 WriteCon(Time);
Kovalev_D 220:04c54405b82d 1316
Kovalev_D 220:04c54405b82d 1317 }
Kovalev_D 220:04c54405b82d 1318 Spi.DAC_B+=500;
Kovalev_D 220:04c54405b82d 1319 }
Kovalev_D 220:04c54405b82d 1320 if (Time[0] == 'm')
Kovalev_D 220:04c54405b82d 1321 { // выдача технологическая
Kovalev_D 220:04c54405b82d 1322 for(int q=0; q<64; q++)
Kovalev_D 220:04c54405b82d 1323 {
Kovalev_D 220:04c54405b82d 1324 sprintf((Time),"%d \r\n", BuffADC_64Point[q] );
Kovalev_D 216:189b0ea1dc38 1325 WriteCon(Time);
Kovalev_D 215:b58b887fd367 1326 }
Kovalev_D 214:4c70e452c491 1327 }
Kovalev_D 215:b58b887fd367 1328
Kovalev_D 220:04c54405b82d 1329
Kovalev_D 214:4c70e452c491 1330
Kovalev_D 214:4c70e452c491 1331
Kovalev_D 214:4c70e452c491 1332
Kovalev_D 214:4c70e452c491 1333
Kovalev_D 225:f8fee6c586cc 1334
Kovalev_D 214:4c70e452c491 1335
Kovalev_D 209:224e7331a061 1336 if (Time[0] == 'u')
Kovalev_D 209:224e7331a061 1337 { // выдача технологическая
Kovalev_D 220:04c54405b82d 1338 Gyro.ShowMod2=1; //Mod vibro Hz
Kovalev_D 211:ac8251b067d2 1339 }
Kovalev_D 220:04c54405b82d 1340 if (Time[0] == 'U')
Kovalev_D 220:04c54405b82d 1341 { // выдача технологическая
Kovalev_D 220:04c54405b82d 1342 Gyro.ShowMod2=0; //Mod vibro Hz
Kovalev_D 220:04c54405b82d 1343 }
Kovalev_D 211:ac8251b067d2 1344
Kovalev_D 225:f8fee6c586cc 1345
Kovalev_D 211:ac8251b067d2 1346 if (Time[0] == 'f')
Kovalev_D 211:ac8251b067d2 1347 { // выдача технологическая
Kovalev_D 211:ac8251b067d2 1348 Gyro.CuruAngleLog = 0; //Mod vibro Hz
Kovalev_D 211:ac8251b067d2 1349 }
Kovalev_D 211:ac8251b067d2 1350 if (Time[0] == 'd')
Kovalev_D 211:ac8251b067d2 1351 { // выдача технологическая
Kovalev_D 211:ac8251b067d2 1352 Gyro.CuruAngleLog = 1; //Mod vibro Hz
Kovalev_D 211:ac8251b067d2 1353 }
Kovalev_D 208:19150d2b528f 1354 if (Time[0] == 'l')
Kovalev_D 208:19150d2b528f 1355 { // выдача технологическая
Kovalev_D 206:00341a03e05c 1356 Gyro.My_Addres = GyroP.Str.My_Addres; // Gyro.My_Addres = 0;
Kovalev_D 208:19150d2b528f 1357 Gyro.GLD_Serial = GyroP.Str.GLD_Serial;
Kovalev_D 208:19150d2b528f 1358 Gyro.FrqHZ = GyroP.Str.FrqHZ;
Kovalev_D 206:00341a03e05c 1359 Gyro.Frq = GyroP.Str.FrqHZ<<16;
Kovalev_D 206:00341a03e05c 1360 Gyro.FrqHZmin = GyroP.Str.FrqHZmin<<16;
Kovalev_D 206:00341a03e05c 1361 Gyro.FrqHZmax = GyroP.Str.FrqHZmax<<16;
Kovalev_D 206:00341a03e05c 1362 Gyro.FrqChengSpeed = GyroP.Str.FrqChengSpeed;
Kovalev_D 208:19150d2b528f 1363 Gyro.PLC_Gain = GyroP.Str.PLC_Gain;
Kovalev_D 208:19150d2b528f 1364 Gyro.PLC_Phase = GyroP.Str.PLC_Phase;
Kovalev_D 206:00341a03e05c 1365 Gyro.ModAmp = GyroP.Str.ModAmp;
Kovalev_D 208:19150d2b528f 1366 Gyro.FrqPhase = GyroP.Str.FrqPhase;
Kovalev_D 206:00341a03e05c 1367 Gyro.AmpPer = GyroP.Str.AmpPer;
Kovalev_D 206:00341a03e05c 1368 Gyro.Amp = GyroP.Str.AmpPer<<16;
Kovalev_D 208:19150d2b528f 1369 Gyro.AmpSpeed = GyroP.Str.AmpSpeed;
Kovalev_D 206:00341a03e05c 1370 Gyro.AmpPerDel = GyroP.Str.AmpPerDel;
Kovalev_D 208:19150d2b528f 1371 temp=((GyroP.Str.VB_Fdf_Hi<<16) | GyroP.Str.VB_Fdf_Lo);
Kovalev_D 208:19150d2b528f 1372 temp=temp/18.2;
Kovalev_D 208:19150d2b528f 1373 Gyro.AmpTarget=(unsigned int)(temp);
Kovalev_D 206:00341a03e05c 1374 Gyro.AmpPerMin = GyroP.Str.AmpPerMin;
Kovalev_D 206:00341a03e05c 1375 Gyro.AmpPerMax = GyroP.Str.AmpPerMax;
Kovalev_D 206:00341a03e05c 1376 Gyro.AmpMin = GyroP.Str.AmpMin;
Kovalev_D 206:00341a03e05c 1377 Gyro.AmpTD = GyroP.Str.AmpTD;
Kovalev_D 208:19150d2b528f 1378 Spi.DAC_A = GyroP.Str.DAC_current_Work;
Kovalev_D 206:00341a03e05c 1379 Gyro.Gain_Sin = GyroP.Str.Gain_Sin;
Kovalev_D 206:00341a03e05c 1380 Gyro.Gain_Cos = GyroP.Str.Gain_Cos;
Kovalev_D 207:d1ce992f5d17 1381 Out_G_photo(Gyro.Gain_Sin, Gyro.Gain_Cos);
Kovalev_D 206:00341a03e05c 1382 }
Kovalev_D 225:f8fee6c586cc 1383 */
Kovalev_D 208:19150d2b528f 1384
Kovalev_D 225:f8fee6c586cc 1385 }
igor_v 0:8ad47e2b6f00 1386 }
igor_v 0:8ad47e2b6f00 1387
igor_v 0:8ad47e2b6f00 1388