![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
forkd
Fork of LGstaandart by
main.c@133:90d0bf0e2996, 2016-04-13 (annotated)
- Committer:
- Kovalev_D
- Date:
- Wed Apr 13 16:49:22 2016 +0000
- Revision:
- 133:90d0bf0e2996
- Parent:
- 132:2c7bec5cf6fe
- Child:
- 134:caf4c9cd5052
1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
igor_v | 8:5188b1448d34 | 1 | //ssdfwewedfsfds |
igor_v | 0:8ad47e2b6f00 | 2 | /****************************************Copyright (c)**************************************************** |
igor_v | 0:8ad47e2b6f00 | 3 | **--------------File Info--------------------------------------------------------------------------------- |
igor_v | 0:8ad47e2b6f00 | 4 | ** File name: main.c |
igor_v | 0:8ad47e2b6f00 | 5 | ** Last modified Date: 2011-10-24 |
igor_v | 0:8ad47e2b6f00 | 6 | ** Last Version: V1.00 |
igor_v | 0:8ad47e2b6f00 | 7 | ** Descriptions: The main() function |
igor_v | 0:8ad47e2b6f00 | 8 | ** |
igor_v | 0:8ad47e2b6f00 | 9 | **-------------------------------------------------------------------------------------------------------- |
igor_v | 0:8ad47e2b6f00 | 10 | ** Created by: Electrooptica Incorp. |
igor_v | 0:8ad47e2b6f00 | 11 | ** Created date: 2011-08-22 |
igor_v | 0:8ad47e2b6f00 | 12 | ** Version: V1.00 |
igor_v | 3:ed8744c5f67a | 13 | ** Descriptions: |
igor_v | 3:ed8744c5f67a | 14 | **-------------------------------------------------------------------------------------------------------- |
igor_v | 30:17c84ed091b3 | 15 | последнии изменения |
igor_v | 30:17c84ed091b3 | 16 | //2016_02_03_17_47 |
igor_v | 31:c783288001b5 | 17 | //2016_02_06 igor |
igor_v | 37:bdd52117b56e | 18 | //2016_06 Dima |
Kovalev_D | 41:70d12776d1ef | 19 | //2016_02_06 21:20 Kovalev_D |
igor_v | 0:8ad47e2b6f00 | 20 | *********************************************************************************************************/ |
igor_v | 21:bc8c1cec3da6 | 21 | |
igor_v | 0:8ad47e2b6f00 | 22 | |
igor_v | 0:8ad47e2b6f00 | 23 | #include "Global.h" |
igor_v | 0:8ad47e2b6f00 | 24 | //#include <math.h> |
Diletant | 74:f4d9c3403578 | 25 | #include "Device.h" |
Kovalev_D | 130:1421dda4d7e7 | 26 | //#include "IAP.h" |
igor_v | 0:8ad47e2b6f00 | 27 | /****************************************************************************** |
igor_v | 0:8ad47e2b6f00 | 28 | ** Main Function main() |
igor_v | 0:8ad47e2b6f00 | 29 | ******************************************************************************/ |
Diletant | 75:cc1942179a2f | 30 | Device device; //Single global for all device hardware-independent algorithm |
Kovalev_D | 132:2c7bec5cf6fe | 31 | #define IMG_START_SECTOR 0x00010000 /* Sector 16 */ |
Kovalev_D | 132:2c7bec5cf6fe | 32 | #define IMG_END_SECTOR 0x00037FFF /* Sector 20 */ |
Kovalev_D | 132:2c7bec5cf6fe | 33 | /* |
Kovalev_D | 132:2c7bec5cf6fe | 34 | #define IMG_START_SECTOR 0x00030000//0x00010000 /* Sector 16 |
Kovalev_D | 132:2c7bec5cf6fe | 35 | #define IMG_END_SECTOR 0x00037FFF */ |
Diletant | 74:f4d9c3403578 | 36 | |
igor_v | 0:8ad47e2b6f00 | 37 | extern uint32_t CMD_Mode; |
igor_v | 52:30f2e52a493f | 38 | unsigned int secPuls; |
igor_v | 52:30f2e52a493f | 39 | float DACF, K_DAC; |
Kovalev_D | 107:4d178bcc9d8a | 40 | int tempAMP; |
igor_v | 52:30f2e52a493f | 41 | int main (void) |
igor_v | 52:30f2e52a493f | 42 | { |
igor_v | 110:6406b7ac0442 | 43 | int ttemp; |
igor_v | 110:6406b7ac0442 | 44 | unsigned int TempA; |
Kovalev_D | 92:c892f0311aa7 | 45 | |
Kovalev_D | 88:b5c1d9d338d1 | 46 | //DMA_Init(); // Инициализация DMA не используем |
Kovalev_D | 88:b5c1d9d338d1 | 47 | //DACInit(); // инициализация ЦАП. |
Kovalev_D | 92:c892f0311aa7 | 48 | //UART_DMA_Init(); //инициализация DMA для UART.//не используем |
Kovalev_D | 89:a0d344db227e | 49 | //WDTInit(); |
Kovalev_D | 99:3d8f206ceac2 | 50 | // G_Photo_Init(); //инициализация интерфейса I2C для фотодетектора. |
Kovalev_D | 86:398da56ef751 | 51 | //инициализация |
Kovalev_D | 92:c892f0311aa7 | 52 | |
Kovalev_D | 92:c892f0311aa7 | 53 | |
Kovalev_D | 133:90d0bf0e2996 | 54 | //SystemInitDef(); |
Kovalev_D | 133:90d0bf0e2996 | 55 | //vIAP_ReinvokeISP(); |
Kovalev_D | 133:90d0bf0e2996 | 56 | |
Kovalev_D | 133:90d0bf0e2996 | 57 | SystemInit1(); // Инициализация контроллера: установка тактовых частот |
Kovalev_D | 92:c892f0311aa7 | 58 | |
Kovalev_D | 133:90d0bf0e2996 | 59 | |
Kovalev_D | 133:90d0bf0e2996 | 60 | |
Kovalev_D | 86:398da56ef751 | 61 | FlashDMA_Init(); // Загрузка параметров с флэш |
Kovalev_D | 86:398da56ef751 | 62 | SystemCoreClockUpdate1(); // расчет тактовой частоты процессора перед инициализацией UART - 100MHz |
Kovalev_D | 88:b5c1d9d338d1 | 63 | |
Kovalev_D | 86:398da56ef751 | 64 | GLD_Init(); |
Kovalev_D | 92:c892f0311aa7 | 65 | ///////////старый UART |
igor_v | 91:a2bb81eaa183 | 66 | // UARTInit(); // инициализация UART0 на скорость 38400. |
igor_v | 91:a2bb81eaa183 | 67 | // UART1_Init(); // инициализация UART1 на скорость 38400. |
Kovalev_D | 88:b5c1d9d338d1 | 68 | |
igor_v | 91:a2bb81eaa183 | 69 | |
Kovalev_D | 119:4d7fcece9e8e | 70 | UART_InitSet (0, 921600, 0x03); // надо проверить, мож чо с ногам |
Kovalev_D | 129:406995a91322 | 71 | // UART_InitSet (1, 921600, 0x03); |
Kovalev_D | 129:406995a91322 | 72 | UART_InitSet (1, 115200, 0x03); |
Kovalev_D | 99:3d8f206ceac2 | 73 | |
Kovalev_D | 86:398da56ef751 | 74 | //////////// |
Kovalev_D | 90:d9b6a4bc5065 | 75 | //DAC_ADC_Exchange_Init(); // инициализация обмена АЦП и ЦАП. |
Kovalev_D | 88:b5c1d9d338d1 | 76 | |
Diletant | 46:2670fa0fcebc | 77 | IntLatch_Init(); // инициализация внутренней защелки. |
Diletant | 46:2670fa0fcebc | 78 | ExtLatch_Init(); // инициализация внешней защелки. |
igor_v | 21:bc8c1cec3da6 | 79 | LoadFlashParam(FromFLASH); //загрузка параметров. |
Kovalev_D | 89:a0d344db227e | 80 | |
Kovalev_D | 112:4a96133a1311 | 81 | // open_all_loops(); //#define open_all_loops() RgConA = 0 (Основной регистр управления устройства (0 - включить, 1 - отключить)). |
Kovalev_D | 129:406995a91322 | 82 | // Output.Str.HF_reg = Device_blk.Str.HF_min; //HFO output voltage = максивальное напряжение на ГВЧ. |
igor_v | 30:17c84ed091b3 | 83 | init_PLC(); //Инициализация СРП(регулировка периметра) |
igor_v | 30:17c84ed091b3 | 84 | init_Dither_reg(); //инициализация вибропривода |
Kovalev_D | 112:4a96133a1311 | 85 | // RgConB = RATE_VIBRO_1; // дополнительный регистр управления = разность вибросчетчиков после фильтра скольз.среднего(#define RATE_VIBRO_1 0x0001) |
Kovalev_D | 112:4a96133a1311 | 86 | // close_all_loops(); |
igor_v | 51:81f47b817071 | 87 | |
Kovalev_D | 105:bd01d8d20fb6 | 88 | Out_G_photo(200,200); //запись в буфер мастера принятые от функции данные (60,60) и установка флага старта передачи и занятой шины. |
Kovalev_D | 105:bd01d8d20fb6 | 89 | |
Kovalev_D | 47:d902ef6f7564 | 90 | WriteCon1("\n\r ...GL start programm uart ACK.... "); |
Kovalev_D | 47:d902ef6f7564 | 91 | WriteCon("\n\r ...GL start programm uart Tech.... "); |
igor_v | 15:f5191a1c3805 | 92 | sprintf(Time,"\r\nCompiled: %s %s.",__DATE__, __TIME__ ); //Подготовка даты и времени компиляции |
igor_v | 13:e2a1d18677b8 | 93 | WriteCon(Time); |
igor_v | 11:af609f6dee46 | 94 | |
igor_v | 127:6a7472d67804 | 95 | Gyro.PLC_Error2Mode = 10; // начальная задержка (неработает СРП) |
igor_v | 11:af609f6dee46 | 96 | |
Kovalev_D | 50:0e3d47f18a50 | 97 | while ( 1 ) { //основной цикл. |
Kovalev_D | 107:4d178bcc9d8a | 98 | |
Kovalev_D | 108:030cdde08314 | 99 | G_Photo_Exchange(); |
Kovalev_D | 108:030cdde08314 | 100 | Concol (); // Проврка 0 консоли (вход и выход) |
Kovalev_D | 93:b3803774f110 | 101 | Concol1 (); // Проврка 0 консоли (вход и выход) |
Kovalev_D | 99:3d8f206ceac2 | 102 | Read_CMD(); |
igor_v | 3:ed8744c5f67a | 103 | if (OutBufConCount) OutBufConCount--; |
Kovalev_D | 108:030cdde08314 | 104 | if (OutBufCon1Count) OutBufCon1Count--; |
Kovalev_D | 121:bbae560cdd43 | 105 | |
Kovalev_D | 95:dd51e577e114 | 106 | if (ReadCon (Time)) { |
Kovalev_D | 132:2c7bec5cf6fe | 107 | ///////////////////////////////////////////////////////////////// |
Kovalev_D | 132:2c7bec5cf6fe | 108 | //////////////////////////////////////////////////////////////// |
Kovalev_D | 132:2c7bec5cf6fe | 109 | //////////////////////Выбор FlashMod/////////////////////////// |
Kovalev_D | 132:2c7bec5cf6fe | 110 | //////////////////////////////////////////////////////////////// |
Kovalev_D | 132:2c7bec5cf6fe | 111 | |
Kovalev_D | 132:2c7bec5cf6fe | 112 | if (Time[0] == 'W') { |
Kovalev_D | 132:2c7bec5cf6fe | 113 | Gyro.FlashMod=1; |
Kovalev_D | 132:2c7bec5cf6fe | 114 | } |
Kovalev_D | 132:2c7bec5cf6fe | 115 | if (Time[0] == 'R') { |
Kovalev_D | 132:2c7bec5cf6fe | 116 | Gyro.FlashMod=2; |
Kovalev_D | 132:2c7bec5cf6fe | 117 | } |
Kovalev_D | 132:2c7bec5cf6fe | 118 | |
Kovalev_D | 132:2c7bec5cf6fe | 119 | /////////////////////////////////////////////////////////////// |
Kovalev_D | 132:2c7bec5cf6fe | 120 | /////////////////////////////////////////////////////////////// |
Kovalev_D | 132:2c7bec5cf6fe | 121 | //////////////////////////////////////////////////////////////// |
igor_v | 48:8697dfe679b9 | 122 | |
igor_v | 16:18e3fd7b92d0 | 123 | if (Time[0] == 'h') { // если ввели буквц h то выдать подсказку. сделанно через принф ОЧЕНЬ плохо в работе не использовать |
igor_v | 15:f5191a1c3805 | 124 | sprintf(Time,"\r\nCompiled: %s %s.",__DATE__, __TIME__ ); //Подготовка даты и времени компиляции |
igor_v | 15:f5191a1c3805 | 125 | WriteCon(Time); |
igor_v | 52:30f2e52a493f | 126 | sprintf(Time,"--%d.%3.d.%2.d.",Time1Hz,Time1K,Time100K); //Временно выдачпа временни из трех чисел |
igor_v | 15:f5191a1c3805 | 127 | WriteCon(Time); |
igor_v | 52:30f2e52a493f | 128 | } |
igor_v | 52:30f2e52a493f | 129 | if (Time[0] == 'D') { |
igor_v | 52:30f2e52a493f | 130 | Gyro.Discharg = StartDischarg; |
igor_v | 15:f5191a1c3805 | 131 | } |
igor_v | 52:30f2e52a493f | 132 | if (Time[0] == 'L') { |
igor_v | 52:30f2e52a493f | 133 | Gyro.BackLight = StartBackLight; |
igor_v | 52:30f2e52a493f | 134 | } |
Kovalev_D | 98:95b8e79f13e1 | 135 | |
Kovalev_D | 108:030cdde08314 | 136 | if (Time[0] == 'F') { // выдача технологическая |
Kovalev_D | 105:bd01d8d20fb6 | 137 | sprintf(Time,"\r\n"); |
Kovalev_D | 105:bd01d8d20fb6 | 138 | WriteCon(Time); |
Kovalev_D | 105:bd01d8d20fb6 | 139 | sprintf((Time)," <%07d> <%07d>",Gyro.F_ras,Param2); |
Kovalev_D | 105:bd01d8d20fb6 | 140 | WriteCon(Time); |
Kovalev_D | 105:bd01d8d20fb6 | 141 | } |
Kovalev_D | 128:1e4675a36c93 | 142 | |
Kovalev_D | 128:1e4675a36c93 | 143 | if (Time[0] == 'q') { // внешняя защелка |
Kovalev_D | 128:1e4675a36c93 | 144 | Gyro.EXT_Latch=1; |
Kovalev_D | 128:1e4675a36c93 | 145 | } |
Kovalev_D | 98:95b8e79f13e1 | 146 | if (Time[0] == '1') { // выдача технологическая |
Kovalev_D | 88:b5c1d9d338d1 | 147 | sprintf(Time,"\r\n"); |
Kovalev_D | 95:dd51e577e114 | 148 | WriteCon(Time); |
Kovalev_D | 96:1c8536458119 | 149 | for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%05d> ",Buff_1Point[i]); |
igor_v | 52:30f2e52a493f | 150 | WriteCon(Time); |
igor_v | 52:30f2e52a493f | 151 | } |
Kovalev_D | 98:95b8e79f13e1 | 152 | |
Kovalev_D | 98:95b8e79f13e1 | 153 | if (Time[0] == '2') { // выдача технологическая |
Kovalev_D | 98:95b8e79f13e1 | 154 | sprintf(Time,"\r\n"); |
Kovalev_D | 98:95b8e79f13e1 | 155 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 156 | for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%05d> ", Buff_8Point[i]); |
Kovalev_D | 98:95b8e79f13e1 | 157 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 158 | } |
Kovalev_D | 98:95b8e79f13e1 | 159 | if (Time[0] == '3') { // выдача технологическая |
Kovalev_D | 98:95b8e79f13e1 | 160 | sprintf(Time,"\r\n"); |
Kovalev_D | 98:95b8e79f13e1 | 161 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 162 | for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%05d> ", Buff_16Point[i]); |
Kovalev_D | 98:95b8e79f13e1 | 163 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 164 | } |
Kovalev_D | 98:95b8e79f13e1 | 165 | |
Kovalev_D | 98:95b8e79f13e1 | 166 | if (Time[0] == '4') { // выдача технологическая |
Kovalev_D | 98:95b8e79f13e1 | 167 | sprintf(Time,"\r\n"); |
Kovalev_D | 98:95b8e79f13e1 | 168 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 169 | for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%05d> ", Buff_16PointD[i]); |
Kovalev_D | 98:95b8e79f13e1 | 170 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 171 | } |
Kovalev_D | 108:030cdde08314 | 172 | |
Kovalev_D | 108:030cdde08314 | 173 | |
Kovalev_D | 108:030cdde08314 | 174 | |
Kovalev_D | 104:ab1cb4ff56b2 | 175 | if (Time[0] == 'z') { // выдача технологическая |
Kovalev_D | 104:ab1cb4ff56b2 | 176 | sprintf(Time,"\r\n"); |
Kovalev_D | 104:ab1cb4ff56b2 | 177 | WriteCon(Time); |
Kovalev_D | 104:ab1cb4ff56b2 | 178 | |
Kovalev_D | 104:ab1cb4ff56b2 | 179 | for (int i = 0; i < 32; i++ ) |
Kovalev_D | 104:ab1cb4ff56b2 | 180 | { |
Kovalev_D | 104:ab1cb4ff56b2 | 181 | ttemp=(Buff_16PointD[i]); |
Kovalev_D | 104:ab1cb4ff56b2 | 182 | if (ttemp < 0) WriteCon("1"); else WriteCon("0"); |
Kovalev_D | 104:ab1cb4ff56b2 | 183 | } |
Kovalev_D | 104:ab1cb4ff56b2 | 184 | |
Kovalev_D | 104:ab1cb4ff56b2 | 185 | } |
Kovalev_D | 104:ab1cb4ff56b2 | 186 | |
Kovalev_D | 104:ab1cb4ff56b2 | 187 | |
Kovalev_D | 98:95b8e79f13e1 | 188 | if (Time[0] == '5') { // выдача технологическая |
Kovalev_D | 98:95b8e79f13e1 | 189 | sprintf(Time,"\r\n"); |
Kovalev_D | 98:95b8e79f13e1 | 190 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 191 | for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%05d> ",Buff_32Point[i]); |
Kovalev_D | 98:95b8e79f13e1 | 192 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 193 | } |
Kovalev_D | 98:95b8e79f13e1 | 194 | |
Kovalev_D | 98:95b8e79f13e1 | 195 | if (Time[0] == '6') { // выдача технологическая |
Kovalev_D | 98:95b8e79f13e1 | 196 | sprintf(Time,"\r\n"); |
Kovalev_D | 98:95b8e79f13e1 | 197 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 198 | for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%05d> ",Buff_Restored_sin[i]); |
Kovalev_D | 98:95b8e79f13e1 | 199 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 200 | } |
Kovalev_D | 95:dd51e577e114 | 201 | |
Kovalev_D | 95:dd51e577e114 | 202 | |
Kovalev_D | 104:ab1cb4ff56b2 | 203 | |
Kovalev_D | 104:ab1cb4ff56b2 | 204 | if (Time[0] == 'c') { // выдача технологическая |
Kovalev_D | 104:ab1cb4ff56b2 | 205 | sprintf(Time,"\r\n"); |
Kovalev_D | 104:ab1cb4ff56b2 | 206 | WriteCon(Time); |
Kovalev_D | 106:250ddd8629c6 | 207 | sprintf((Time)," <%07d> <%07d> <%07d> <%07d>", Gyro.F_ras,Gyro.F_ras/16, Gyro.Cnt_Pls, Gyro.Cnt_Mns); |
Kovalev_D | 104:ab1cb4ff56b2 | 208 | WriteCon(Time); |
Kovalev_D | 104:ab1cb4ff56b2 | 209 | } |
Kovalev_D | 104:ab1cb4ff56b2 | 210 | |
Kovalev_D | 104:ab1cb4ff56b2 | 211 | |
Kovalev_D | 104:ab1cb4ff56b2 | 212 | |
Kovalev_D | 98:95b8e79f13e1 | 213 | if (Time[0] == '7') { // выдача технологическая |
Kovalev_D | 95:dd51e577e114 | 214 | sprintf(Time,"\r\n"); |
Kovalev_D | 95:dd51e577e114 | 215 | WriteCon(Time); |
Kovalev_D | 96:1c8536458119 | 216 | for (int i = 0; i < 32; i++ )sprintf((Time + i * 10)," <%07d> ",Buff_AMP64P[i]-(Buff_AMP[i])); |
Kovalev_D | 95:dd51e577e114 | 217 | WriteCon(Time); |
Kovalev_D | 95:dd51e577e114 | 218 | } |
Kovalev_D | 98:95b8e79f13e1 | 219 | if (Time[0] == '9') { // выдача технологическая |
Kovalev_D | 98:95b8e79f13e1 | 220 | sprintf(Time,"\r\n"); |
Kovalev_D | 98:95b8e79f13e1 | 221 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 222 | for (int i = 0; i < 32; i++ )sprintf((Time)," <%07d> ",Gyro.Frq); |
Kovalev_D | 98:95b8e79f13e1 | 223 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 224 | } |
Kovalev_D | 98:95b8e79f13e1 | 225 | |
Kovalev_D | 98:95b8e79f13e1 | 226 | if (Time[0] == 'p') { // выдача технологическая |
Kovalev_D | 98:95b8e79f13e1 | 227 | sprintf(Time,"\r\n"); |
Kovalev_D | 98:95b8e79f13e1 | 228 | WriteCon(Time); |
Kovalev_D | 99:3d8f206ceac2 | 229 | for (int i = 0; i < 32; i++ )sprintf((Time)," <%07d> ",Cur_Amp); |
Kovalev_D | 98:95b8e79f13e1 | 230 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 231 | } |
Kovalev_D | 99:3d8f206ceac2 | 232 | if (Time[0] == 'm') { // выдача технологическая |
Kovalev_D | 99:3d8f206ceac2 | 233 | sprintf(Time,"\r\n"); |
Kovalev_D | 99:3d8f206ceac2 | 234 | WriteCon(Time); |
Kovalev_D | 128:1e4675a36c93 | 235 | // sprintf((Time),"Cur_Amp <%07d> ", Cur_Amp); WriteCon(Time); |
Kovalev_D | 128:1e4675a36c93 | 236 | // sprintf((Time),"Znak_Amp <%07d> ", Znak_Amp); WriteCon(Time); |
Kovalev_D | 128:1e4675a36c93 | 237 | // sprintf((Time),"AD_Regul <%07d> ", AD_Regul); WriteCon(Time); |
Kovalev_D | 128:1e4675a36c93 | 238 | |
Kovalev_D | 128:1e4675a36c93 | 239 | sprintf((Time),"PLC_Delta <%07d> ", Gyro.PLC_Delta); WriteCon(Time); |
Kovalev_D | 128:1e4675a36c93 | 240 | sprintf((Time),"PLC_DeltaADD <%07d> ", Gyro.PLC_DeltaADD); WriteCon(Time); |
Kovalev_D | 109:ee0cff33ad3b | 241 | // printf((Time),"AD_Regul <%07d> ", Delta); WriteCon(Time); |
Kovalev_D | 109:ee0cff33ad3b | 242 | |
Kovalev_D | 109:ee0cff33ad3b | 243 | // sprintf((Time),"Spi.DAC_B <%07d> ",Spi.DAC_B); WriteCon(Time);*/ |
Kovalev_D | 109:ee0cff33ad3b | 244 | // sprintf((Time),"MaxAmp <%07d> ", MaxAmp); WriteCon(Time); |
Kovalev_D | 109:ee0cff33ad3b | 245 | // sprintf((Time),"CaunAddPlus <%07d> ", CaunAddPlus); WriteCon(Time); |
Kovalev_D | 109:ee0cff33ad3b | 246 | // sprintf((Time),"CaunAddMin <%07d> ", CaunAddMin); WriteCon(Time); |
Kovalev_D | 109:ee0cff33ad3b | 247 | // sprintf((Time)," Gyro.Amp <%07d> ",amp); WriteCon(Time); |
Kovalev_D | 108:030cdde08314 | 248 | |
Kovalev_D | 99:3d8f206ceac2 | 249 | } |
Kovalev_D | 98:95b8e79f13e1 | 250 | if (Time[0] == 'V') { // выдача технологическая |
Kovalev_D | 109:ee0cff33ad3b | 251 | // Gyro.Frq+=65000; |
Kovalev_D | 121:bbae560cdd43 | 252 | Spi.DAC_B += 200; |
Kovalev_D | 109:ee0cff33ad3b | 253 | |
Kovalev_D | 98:95b8e79f13e1 | 254 | } |
Kovalev_D | 98:95b8e79f13e1 | 255 | if (Time[0] == 'v') { // выдача технологическая |
Kovalev_D | 109:ee0cff33ad3b | 256 | //Gyro.Frq-=65000; |
Kovalev_D | 121:bbae560cdd43 | 257 | Spi.DAC_B -= 200; |
Kovalev_D | 98:95b8e79f13e1 | 258 | } |
Kovalev_D | 96:1c8536458119 | 259 | |
Kovalev_D | 98:95b8e79f13e1 | 260 | if (Time[0] == '8') { // выдача технологическая |
Kovalev_D | 96:1c8536458119 | 261 | sprintf(Time,"\r\n"); |
Kovalev_D | 96:1c8536458119 | 262 | WriteCon(Time); |
Kovalev_D | 96:1c8536458119 | 263 | // for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%05d> ",Buff_AMP64P[i]-(Buff_AMP[i]*2)); |
Kovalev_D | 96:1c8536458119 | 264 | for (int i = 0; i < 32; i++ ) |
Kovalev_D | 96:1c8536458119 | 265 | { |
Kovalev_D | 96:1c8536458119 | 266 | ttemp=(Buff_AMP64P[i]-(Buff_AMP[i])); |
Kovalev_D | 96:1c8536458119 | 267 | if (ttemp < 0) WriteCon("1"); else WriteCon("0"); |
Kovalev_D | 96:1c8536458119 | 268 | } |
Kovalev_D | 96:1c8536458119 | 269 | // WriteCon(Time); |
Kovalev_D | 96:1c8536458119 | 270 | } |
Kovalev_D | 95:dd51e577e114 | 271 | |
Kovalev_D | 98:95b8e79f13e1 | 272 | if (Time[0] == 'b') { // выдача технологическая |
Kovalev_D | 92:c892f0311aa7 | 273 | sprintf(Time,"\r\n"); |
Kovalev_D | 95:dd51e577e114 | 274 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 275 | |
Kovalev_D | 98:95b8e79f13e1 | 276 | for (int i = 0; i < 32; i++ ) |
Kovalev_D | 98:95b8e79f13e1 | 277 | { |
Kovalev_D | 98:95b8e79f13e1 | 278 | ttemp=(Buff_Restored_sin[i]); |
Kovalev_D | 98:95b8e79f13e1 | 279 | if (ttemp < 0) WriteCon("1"); else WriteCon("0"); |
Kovalev_D | 98:95b8e79f13e1 | 280 | } |
Kovalev_D | 98:95b8e79f13e1 | 281 | |
Kovalev_D | 92:c892f0311aa7 | 282 | } |
Kovalev_D | 98:95b8e79f13e1 | 283 | |
Kovalev_D | 128:1e4675a36c93 | 284 | if (Gyro.PLC_Error2Mode) { // выдача технологическая |
Kovalev_D | 128:1e4675a36c93 | 285 | sprintf(Time,"\r\nPLC_Error2Mode"); |
Kovalev_D | 128:1e4675a36c93 | 286 | WriteCon(Time); |
Kovalev_D | 128:1e4675a36c93 | 287 | } |
Kovalev_D | 121:bbae560cdd43 | 288 | |
Kovalev_D | 95:dd51e577e114 | 289 | } |
Kovalev_D | 108:030cdde08314 | 290 | |
Kovalev_D | 112:4a96133a1311 | 291 | // Read_CMD(); |
igor_v | 114:5cc38a53d8a7 | 292 | //ДИМА== посмотри пожалуйста нармално ли работуют все таймеры аппаратные и програмные, то есть нет ли где затыком по времени |
igor_v | 114:5cc38a53d8a7 | 293 | // с помошью ссветодиода например помаргай в разные временна, почему в режиме "рейт" передача от гироскопа идет с разной частотой |
igor_v | 114:5cc38a53d8a7 | 294 | // попробуй сделать "рейт M4" посмотри в протоколе как вклбчается и на кокой скорости работает |
Kovalev_D | 116:66f1f0ff2dab | 295 | |
Kovalev_D | 116:66f1f0ff2dab | 296 | |
Kovalev_D | 116:66f1f0ff2dab | 297 | Event_100KHz(); |
Kovalev_D | 88:b5c1d9d338d1 | 298 | Event_1KHz(); |
Kovalev_D | 124:9ae09249f842 | 299 | Event_500Hz(); |
Kovalev_D | 116:66f1f0ff2dab | 300 | Event_1Hz(); |
Kovalev_D | 124:9ae09249f842 | 301 | |
Kovalev_D | 88:b5c1d9d338d1 | 302 | Event_Vibro(); |
Kovalev_D | 124:9ae09249f842 | 303 | |
Kovalev_D | 124:9ae09249f842 | 304 | switch(Gyro.ModeOut) { |
Kovalev_D | 124:9ae09249f842 | 305 | case 1: |
Kovalev_D | 124:9ae09249f842 | 306 | if(Gyro.Rate1_Event==1)CMD_Rate(); |
Kovalev_D | 124:9ae09249f842 | 307 | break; |
Kovalev_D | 124:9ae09249f842 | 308 | case 2: |
Kovalev_D | 124:9ae09249f842 | 309 | if(Gyro.Rate2_Event==1)CMD_Rate2(); |
Kovalev_D | 124:9ae09249f842 | 310 | break; |
Kovalev_D | 124:9ae09249f842 | 311 | case 3: |
Kovalev_D | 124:9ae09249f842 | 312 | if(Gyro.Delta500_Event==1)CMD_Delta_500Hz(); |
Kovalev_D | 128:1e4675a36c93 | 313 | break; |
Kovalev_D | 128:1e4675a36c93 | 314 | case 4: |
Kovalev_D | 128:1e4675a36c93 | 315 | if(Gyro.EXT_Latch==1){CMD_Delta_Ext();} |
Kovalev_D | 128:1e4675a36c93 | 316 | break; |
Kovalev_D | 124:9ae09249f842 | 317 | } |
igor_v | 111:8ee1ef722ba7 | 318 | if (Spi.ADC_NewData == 1) // был приход новых данных по ацп сдесь сделать обработку информации и подготовку для выдачи делается 1 раз за вибро |
igor_v | 110:6406b7ac0442 | 319 | { |
igor_v | 114:5cc38a53d8a7 | 320 | // можно апихнкть в функцию |
igor_v | 110:6406b7ac0442 | 321 | Spi.ADC_NewData = 0; |
Kovalev_D | 113:8be429494918 | 322 | Gyro.Termo = Spi.ADC1; |
Kovalev_D | 113:8be429494918 | 323 | Gyro.In1 = Spi.ADC2; |
Kovalev_D | 113:8be429494918 | 324 | Gyro.In2 = Spi.ADC3; |
Kovalev_D | 113:8be429494918 | 325 | Gyro.DeltaT = Spi.ADC4; |
igor_v | 114:5cc38a53d8a7 | 326 | TempA = (0x7fff - Spi.ADC5) << 1; // перевернем знак и умножим на два (бало 32000...0 стало 0 ...64000) |
Kovalev_D | 112:4a96133a1311 | 327 | |
igor_v | 110:6406b7ac0442 | 328 | Gyro.ADF_Accum += TempA; |
igor_v | 110:6406b7ac0442 | 329 | Gyro.ADS_Accum += TempA; |
igor_v | 110:6406b7ac0442 | 330 | Gyro.ADF_Count ++; |
igor_v | 110:6406b7ac0442 | 331 | Gyro.ADS_Count ++; |
igor_v | 110:6406b7ac0442 | 332 | |
igor_v | 111:8ee1ef722ba7 | 333 | if (Gyro.ADF_Count > 15) // если прошло 16 тактов виброподвеса |
igor_v | 110:6406b7ac0442 | 334 | { |
igor_v | 111:8ee1ef722ba7 | 335 | Gyro.AD_Fast = Gyro.ADF_Accum << 12; //обновляем данные и приводим в один масштаб |
igor_v | 110:6406b7ac0442 | 336 | Gyro.ADF_Count = 0; |
igor_v | 110:6406b7ac0442 | 337 | Gyro.ADF_Accum = 0; |
igor_v | 110:6406b7ac0442 | 338 | Gyro.ADF_NewData = 1; |
igor_v | 110:6406b7ac0442 | 339 | } |
igor_v | 111:8ee1ef722ba7 | 340 | if (Gyro.ADS_Count > 255) // если прошло 256 тактов виброподвеса |
igor_v | 110:6406b7ac0442 | 341 | { |
igor_v | 111:8ee1ef722ba7 | 342 | Gyro.AD_Slow = Gyro.ADS_Accum << 8; //обновляем данные и приводим в один масштаб |
igor_v | 110:6406b7ac0442 | 343 | Gyro.ADS_Count = 0; |
igor_v | 110:6406b7ac0442 | 344 | Gyro.ADS_Accum = 0; |
igor_v | 110:6406b7ac0442 | 345 | Gyro.ADS_NewData = 1; |
igor_v | 110:6406b7ac0442 | 346 | } |
igor_v | 110:6406b7ac0442 | 347 | } |
Kovalev_D | 112:4a96133a1311 | 348 | |
Kovalev_D | 113:8be429494918 | 349 | |
Kovalev_D | 113:8be429494918 | 350 | |
Kovalev_D | 113:8be429494918 | 351 | |
igor_v | 111:8ee1ef722ba7 | 352 | if (Gyro.ADF_NewData == 1) // был приход новых данных После быстрого фильтра AD |
igor_v | 111:8ee1ef722ba7 | 353 | { |
Kovalev_D | 112:4a96133a1311 | 354 | Gyro.ADF_NewData = 0; |
igor_v | 114:5cc38a53d8a7 | 355 | }// можно запихнкть в функцию |
igor_v | 114:5cc38a53d8a7 | 356 | |
igor_v | 114:5cc38a53d8a7 | 357 | if (Gyro.ADS_NewData == 1) // был приход новых данных После Медленного фильтра AD |
igor_v | 114:5cc38a53d8a7 | 358 | { |
Kovalev_D | 116:66f1f0ff2dab | 359 | |
igor_v | 114:5cc38a53d8a7 | 360 | Gyro.ADS_NewData = 0; |
igor_v | 114:5cc38a53d8a7 | 361 | PlcRegul();//Расчет |
Kovalev_D | 113:8be429494918 | 362 | |
Kovalev_D | 112:4a96133a1311 | 363 | }// можно запихнкть в функцию |
Kovalev_D | 112:4a96133a1311 | 364 | |
igor_v | 114:5cc38a53d8a7 | 365 | if(Gyro.VibroFrqRegulF == 1) //Регулеровка частоты виброподвеса |
Kovalev_D | 112:4a96133a1311 | 366 | { |
Kovalev_D | 112:4a96133a1311 | 367 | Gyro.VibroFrqRegulF = 0; |
Kovalev_D | 112:4a96133a1311 | 368 | VibroFrqRegul(); |
Kovalev_D | 112:4a96133a1311 | 369 | } |
igor_v | 114:5cc38a53d8a7 | 370 | |
igor_v | 114:5cc38a53d8a7 | 371 | if(Gyro.VibroAMPRegulF == 1) //Регулеровка Амплитуды виброподвеса |
Kovalev_D | 112:4a96133a1311 | 372 | { |
Kovalev_D | 112:4a96133a1311 | 373 | Gyro.VibroAMPRegulF = 0; |
Kovalev_D | 112:4a96133a1311 | 374 | VibroAMPRegul(); |
Kovalev_D | 112:4a96133a1311 | 375 | } |
igor_v | 114:5cc38a53d8a7 | 376 | if(Gyro.VibroNoiseF == 1) //регулеровка ошумления, наверно нужно объеденить с регулеровкой ампитуды |
Kovalev_D | 112:4a96133a1311 | 377 | { |
Kovalev_D | 112:4a96133a1311 | 378 | Gyro.VibroNoiseF = 0; |
Kovalev_D | 112:4a96133a1311 | 379 | CalcAmpN(); |
Kovalev_D | 112:4a96133a1311 | 380 | } |
Kovalev_D | 113:8be429494918 | 381 | |
igor_v | 114:5cc38a53d8a7 | 382 | if(Gyro.VibroOutF== 1) // установка ног в регисторе тоже подумать , зачем отделный флаг? наверно |
Kovalev_D | 112:4a96133a1311 | 383 | { |
Kovalev_D | 112:4a96133a1311 | 384 | Gyro.VibroOutF = 0; |
Kovalev_D | 112:4a96133a1311 | 385 | VibroOut(); //Чтение ADS_SPI |
Kovalev_D | 112:4a96133a1311 | 386 | } |
Kovalev_D | 132:2c7bec5cf6fe | 387 | //&Gyro.Firmware_Version |
Kovalev_D | 132:2c7bec5cf6fe | 388 | ///////////////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 132:2c7bec5cf6fe | 389 | ///////////////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 132:2c7bec5cf6fe | 390 | /////////////////////////Работа с Flash////////////////////////////////////////////////////////////////// |
Kovalev_D | 132:2c7bec5cf6fe | 391 | ///////////////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 132:2c7bec5cf6fe | 392 | if(Gyro.FlashMod == 1) |
Kovalev_D | 132:2c7bec5cf6fe | 393 | { |
Kovalev_D | 132:2c7bec5cf6fe | 394 | |
Kovalev_D | 133:90d0bf0e2996 | 395 | vIAP_ReinvokeISP(); |
Kovalev_D | 132:2c7bec5cf6fe | 396 | /* Prepare Sectors to be flashed */ |
Kovalev_D | 133:90d0bf0e2996 | 397 | |
Kovalev_D | 133:90d0bf0e2996 | 398 | |
Kovalev_D | 132:2c7bec5cf6fe | 399 | if(u32IAP_PrepareSectors(19, 21) == IAP_STA_CMD_SUCCESS) |
Kovalev_D | 133:90d0bf0e2996 | 400 | |
Kovalev_D | 132:2c7bec5cf6fe | 401 | { |
Kovalev_D | 132:2c7bec5cf6fe | 402 | WriteCon("\r\nPrepare Sector OK"); |
Kovalev_D | 132:2c7bec5cf6fe | 403 | |
Kovalev_D | 132:2c7bec5cf6fe | 404 | /* Copy data (already) located in RAM to flash */ |
Kovalev_D | 132:2c7bec5cf6fe | 405 | if(u32IAP_CopyRAMToFlash(IMG_START_SECTOR, &TempA, 256) == IAP_STA_CMD_SUCCESS) |
Kovalev_D | 132:2c7bec5cf6fe | 406 | {WriteCon("\r\nWrite"); |
Kovalev_D | 132:2c7bec5cf6fe | 407 | |
Kovalev_D | 132:2c7bec5cf6fe | 408 | /* Verify the flash contents with the contents in RAM */ |
Kovalev_D | 132:2c7bec5cf6fe | 409 | if(u32IAP_Compare(IMG_START_SECTOR, &TempA, 256, 0) == IAP_STA_CMD_SUCCESS){WriteCon("\r\nCompare"); |
Kovalev_D | 132:2c7bec5cf6fe | 410 | |
Kovalev_D | 132:2c7bec5cf6fe | 411 | }else{WriteCon("\r\n error Compare");} |
Kovalev_D | 132:2c7bec5cf6fe | 412 | |
Kovalev_D | 132:2c7bec5cf6fe | 413 | }else{WriteCon("\r\n error Write");} |
Kovalev_D | 132:2c7bec5cf6fe | 414 | |
Kovalev_D | 132:2c7bec5cf6fe | 415 | }else{WriteCon("\r\n error prepare");} |
Kovalev_D | 132:2c7bec5cf6fe | 416 | Gyro.FlashMod = 0; |
Kovalev_D | 132:2c7bec5cf6fe | 417 | } |
Kovalev_D | 132:2c7bec5cf6fe | 418 | |
Kovalev_D | 132:2c7bec5cf6fe | 419 | if(Gyro.FlashMod == 2) // установка ног в регисторе тоже подумать , зачем отделный флаг? наверно |
Kovalev_D | 132:2c7bec5cf6fe | 420 | { |
Kovalev_D | 132:2c7bec5cf6fe | 421 | Gyro.FlashMod = 0; |
Kovalev_D | 132:2c7bec5cf6fe | 422 | WriteCon("\r\Rnead from Flash"); |
Kovalev_D | 132:2c7bec5cf6fe | 423 | } |
Kovalev_D | 132:2c7bec5cf6fe | 424 | |
Kovalev_D | 132:2c7bec5cf6fe | 425 | |
Kovalev_D | 132:2c7bec5cf6fe | 426 | |
igor_v | 114:5cc38a53d8a7 | 427 | |
igor_v | 114:5cc38a53d8a7 | 428 | |
igor_v | 110:6406b7ac0442 | 429 | }//while |
Kovalev_D | 132:2c7bec5cf6fe | 430 | }//main |
igor_v | 0:8ad47e2b6f00 | 431 | |
igor_v | 0:8ad47e2b6f00 | 432 | /****************************************************************************** |
igor_v | 0:8ad47e2b6f00 | 433 | ** End Of File |
igor_v | 0:8ad47e2b6f00 | 434 | ******************************************************************************/ |
igor_v | 0:8ad47e2b6f00 | 435 | |
igor_v | 0:8ad47e2b6f00 | 436 |