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