![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
forkd
Fork of LG2 by
SPI.c@198:fb22ba6aad54, 2016-10-20 (annotated)
- Committer:
- Kovalev_D
- Date:
- Thu Oct 20 09:29:05 2016 +0000
- Revision:
- 198:fb22ba6aad54
- Parent:
- 197:7a05523bf588
- Child:
- 199:2728719cdc64
fork
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
igor_v | 0:8ad47e2b6f00 | 1 | #include "Global.h" |
igor_v | 0:8ad47e2b6f00 | 2 | struct SPI Spi; |
Kovalev_D | 112:4a96133a1311 | 3 | //unsigned int Temp_AMP; |
Kovalev_D | 96:1c8536458119 | 4 | unsigned int Temp_AMP64P; |
Kovalev_D | 196:f76dbc081e63 | 5 | int ttt=1; |
Kovalev_D | 99:3d8f206ceac2 | 6 | unsigned int Count_AMP, ADD_AMP, Cur_Amp; |
Kovalev_D | 99:3d8f206ceac2 | 7 | int Znak_Amp; |
Kovalev_D | 109:ee0cff33ad3b | 8 | int AD_Regul = 0; |
Kovalev_D | 190:289514f730ee | 9 | int temp9,tempADC5; |
Kovalev_D | 148:7ce8c1fd00f7 | 10 | int AD_MAX=0; |
Kovalev_D | 196:f76dbc081e63 | 11 | int k=0,l=0,r=0,n=0;//счетчики для регулировки периметра |
Kovalev_D | 188:4c523cc373cc | 12 | int flagmod=0,Bdelta; |
Kovalev_D | 191:40028201ddad | 13 | int start=10; |
Kovalev_D | 197:7a05523bf588 | 14 | int dispersion=0,side=1,tempstrafe=15000; |
Kovalev_D | 86:398da56ef751 | 15 | unsigned int Temp_ADC_2; |
Kovalev_D | 86:398da56ef751 | 16 | unsigned int Temp_ADC_3; |
Kovalev_D | 86:398da56ef751 | 17 | unsigned int Temp_ADC_4; |
Kovalev_D | 86:398da56ef751 | 18 | unsigned int Temp_ADC_5; |
Kovalev_D | 147:1aed74f19a8f | 19 | unsigned int TempA; |
Kovalev_D | 158:0c8342e1837a | 20 | unsigned int TempTermLM; |
igor_v | 31:c783288001b5 | 21 | |
Kovalev_D | 197:7a05523bf588 | 22 | int ADC5Old,ADCDIF=0; |
Kovalev_D | 197:7a05523bf588 | 23 | int DACModReg; |
Kovalev_D | 197:7a05523bf588 | 24 | int SinPls=0,SinMns=0; |
Kovalev_D | 197:7a05523bf588 | 25 | unsigned int ADC5New; |
Kovalev_D | 95:dd51e577e114 | 26 | unsigned int Buff_ADC_1 [32]; |
Kovalev_D | 95:dd51e577e114 | 27 | unsigned int Buff_ADC_2 [32]; |
Kovalev_D | 95:dd51e577e114 | 28 | unsigned int Buff_ADC_3 [32]; |
Kovalev_D | 95:dd51e577e114 | 29 | unsigned int Buff_ADC_4 [32]; |
igor_v | 51:81f47b817071 | 30 | |
Kovalev_D | 197:7a05523bf588 | 31 | |
Kovalev_D | 197:7a05523bf588 | 32 | unsigned int Buff_ADC_5 [512]; |
Kovalev_D | 197:7a05523bf588 | 33 | unsigned int BuffADC_16Point [64]; |
Kovalev_D | 197:7a05523bf588 | 34 | unsigned int BuffADC_32Point [64]; |
Kovalev_D | 197:7a05523bf588 | 35 | unsigned int BuffADC_64Point [64]; |
Kovalev_D | 197:7a05523bf588 | 36 | unsigned int BuffADC_32PointD [64]; |
Kovalev_D | 197:7a05523bf588 | 37 | unsigned int Buff_Restored_Mod [64]; |
Kovalev_D | 197:7a05523bf588 | 38 | |
Kovalev_D | 197:7a05523bf588 | 39 | unsigned int PulseADC_16Point; |
Kovalev_D | 197:7a05523bf588 | 40 | unsigned int PulseADC_32Point; |
Kovalev_D | 197:7a05523bf588 | 41 | unsigned int PulseADC_64Point; |
Kovalev_D | 197:7a05523bf588 | 42 | unsigned int PulseADC_32PointD; |
Kovalev_D | 197:7a05523bf588 | 43 | |
Kovalev_D | 197:7a05523bf588 | 44 | |
igor_v | 31:c783288001b5 | 45 | unsigned int Buff_AMP [256]; |
Kovalev_D | 96:1c8536458119 | 46 | unsigned int Buff_AMP64P [256]; |
Kovalev_D | 197:7a05523bf588 | 47 | unsigned int TypeMod=0; |
Kovalev_D | 197:7a05523bf588 | 48 | unsigned int ModArraySin [64] = {50,55,59,64,68,73,77,81,85,88,91,94,96,98,99,99,100,99,99,98,96,94,91,88,85,81,77,73,68,64,59,55,50,45,41,36,32,27,23,19,16,12,9,7,4,2,1,1,0,1,1,2,4,7,9,12,16,19,23,27,32,36,41,45}; |
Kovalev_D | 197:7a05523bf588 | 49 | unsigned int ModArrayTriangle [64]; |
Kovalev_D | 197:7a05523bf588 | 50 | unsigned int ModArraySaw [64]; |
Kovalev_D | 197:7a05523bf588 | 51 | unsigned int Mod=0; |
Kovalev_D | 197:7a05523bf588 | 52 | |
Kovalev_D | 197:7a05523bf588 | 53 | void InitMOD(void) |
Kovalev_D | 197:7a05523bf588 | 54 | { |
Kovalev_D | 197:7a05523bf588 | 55 | for (int i = 0; i < 64; i++ ) |
Kovalev_D | 197:7a05523bf588 | 56 | { |
Kovalev_D | 197:7a05523bf588 | 57 | if(i<32) { ModArrayTriangle[i]=Mod; Mod+=3;} |
Kovalev_D | 197:7a05523bf588 | 58 | else { ModArrayTriangle[i]=Mod; Mod-=3;} |
Kovalev_D | 197:7a05523bf588 | 59 | } |
Kovalev_D | 197:7a05523bf588 | 60 | |
Kovalev_D | 197:7a05523bf588 | 61 | for (int i = 0; i < 64; i++ ) |
Kovalev_D | 197:7a05523bf588 | 62 | { |
Kovalev_D | 197:7a05523bf588 | 63 | ModArraySaw[i]=Mod; |
Kovalev_D | 197:7a05523bf588 | 64 | Mod+=2; |
Kovalev_D | 197:7a05523bf588 | 65 | } |
Kovalev_D | 197:7a05523bf588 | 66 | } |
Kovalev_D | 197:7a05523bf588 | 67 | void Modulator(void) |
Kovalev_D | 197:7a05523bf588 | 68 | { |
Kovalev_D | 197:7a05523bf588 | 69 | switch(TypeMod) |
Kovalev_D | 197:7a05523bf588 | 70 | { |
Kovalev_D | 197:7a05523bf588 | 71 | case 0: LPC_DAC->DACR = (ModArraySin [CountV64]*Gyro.ModAmp); break; |
Kovalev_D | 197:7a05523bf588 | 72 | case 1: LPC_DAC->DACR = (ModArraySaw [CountV64]*Gyro.ModAmp); break; |
Kovalev_D | 197:7a05523bf588 | 73 | case 2: LPC_DAC->DACR = (ModArrayTriangle [CountV64]*Gyro.ModAmp); break; |
Kovalev_D | 197:7a05523bf588 | 74 | } |
Kovalev_D | 197:7a05523bf588 | 75 | } |
Kovalev_D | 197:7a05523bf588 | 76 | void PLCRegul(void) |
Kovalev_D | 197:7a05523bf588 | 77 | { |
Kovalev_D | 198:fb22ba6aad54 | 78 | int templm=0; |
Kovalev_D | 198:fb22ba6aad54 | 79 | if (CountV64 == 0) |
Kovalev_D | 197:7a05523bf588 | 80 | { |
Kovalev_D | 198:fb22ba6aad54 | 81 | for (int i = 0; i < 32; i++ ) |
Kovalev_D | 197:7a05523bf588 | 82 | { |
Kovalev_D | 197:7a05523bf588 | 83 | SinPls+= BuffADC_64Point[i]; |
Kovalev_D | 197:7a05523bf588 | 84 | } |
Kovalev_D | 197:7a05523bf588 | 85 | for (int i = 32; i < 64; i++ ) |
Kovalev_D | 197:7a05523bf588 | 86 | { |
Kovalev_D | 197:7a05523bf588 | 87 | SinMns+= BuffADC_64Point[i]; |
Kovalev_D | 197:7a05523bf588 | 88 | } |
Kovalev_D | 197:7a05523bf588 | 89 | ADCDIF = SinPls - SinMns; |
Kovalev_D | 198:fb22ba6aad54 | 90 | Spi.DAC_B-=ADCDIF>>7; |
Kovalev_D | 197:7a05523bf588 | 91 | |
Kovalev_D | 198:fb22ba6aad54 | 92 | /* if(ADCDIF>0) Spi.DAC_B-=3; |
Kovalev_D | 198:fb22ba6aad54 | 93 | else Spi.DAC_B+=3;*/ |
Kovalev_D | 197:7a05523bf588 | 94 | |
Kovalev_D | 197:7a05523bf588 | 95 | if ( Spi.DAC_B < 15300 ) Spi.DAC_B = 32000; //проверка на переваливание за границу. |
Kovalev_D | 197:7a05523bf588 | 96 | else if ( Spi.DAC_B > 53000 ) Spi.DAC_B = 32000; |
Kovalev_D | 198:fb22ba6aad54 | 97 | |
Kovalev_D | 198:fb22ba6aad54 | 98 | sprintf((Time),"%d %d %d \r\n", ADCDIF>>7, Spi.DAC_B, Gyro.test );//выдаем в терминал для постройки граффика регулировки периметра. |
Kovalev_D | 198:fb22ba6aad54 | 99 | WriteCon(Time); |
Kovalev_D | 198:fb22ba6aad54 | 100 | |
Kovalev_D | 197:7a05523bf588 | 101 | SinPls=0; |
Kovalev_D | 197:7a05523bf588 | 102 | SinMns=0; |
Kovalev_D | 197:7a05523bf588 | 103 | } |
Kovalev_D | 197:7a05523bf588 | 104 | } |
Kovalev_D | 197:7a05523bf588 | 105 | |
igor_v | 110:6406b7ac0442 | 106 | |
Kovalev_D | 147:1aed74f19a8f | 107 | void ADS_Acum(void) |
Kovalev_D | 147:1aed74f19a8f | 108 | { |
Kovalev_D | 157:1069c80f4944 | 109 | Spi.ADC_NewData = 0; |
Kovalev_D | 157:1069c80f4944 | 110 | Gyro.Termo = Spi.ADC1; |
Kovalev_D | 157:1069c80f4944 | 111 | Gyro.In1 = Spi.ADC2; |
Kovalev_D | 157:1069c80f4944 | 112 | Gyro.In2 = Spi.ADC3; |
Kovalev_D | 157:1069c80f4944 | 113 | Gyro.DeltaT = Spi.ADC4; |
Kovalev_D | 170:d099c3025f87 | 114 | |
Kovalev_D | 172:ef7bf1663645 | 115 | TempA = (0xffff - Spi.ADC5); // перевернем знак и умножим на два (было 32000...0 стало 0 ...32000 /*сдвиг(<<1) стало 0 ...64000*/) |
Kovalev_D | 170:d099c3025f87 | 116 | |
Kovalev_D | 157:1069c80f4944 | 117 | Gyro.ADF_Accum += TempA; |
Kovalev_D | 157:1069c80f4944 | 118 | Gyro.ADS_Accum += TempA; |
Kovalev_D | 157:1069c80f4944 | 119 | Gyro.ADF_Count ++; |
Kovalev_D | 157:1069c80f4944 | 120 | Gyro.ADS_Count ++; |
Kovalev_D | 147:1aed74f19a8f | 121 | |
Kovalev_D | 157:1069c80f4944 | 122 | if (Gyro.ADF_Count > 15) { // если прошло 16 тактов виброподвеса |
Kovalev_D | 172:ef7bf1663645 | 123 | Gyro.AD_Fast = Gyro.ADF_Accum << 11; //обновляем данные и приводим в один масштаб |
Kovalev_D | 157:1069c80f4944 | 124 | Gyro.ADF_Count = 0;// |
Kovalev_D | 157:1069c80f4944 | 125 | Gyro.ADF_Accum = 0; |
Kovalev_D | 157:1069c80f4944 | 126 | Gyro.ADF_NewData = 1; |
Kovalev_D | 157:1069c80f4944 | 127 | } |
Kovalev_D | 157:1069c80f4944 | 128 | if (Gyro.ADS_Count > 255) { // если прошло 256 тактов виброподвеса |
Kovalev_D | 172:ef7bf1663645 | 129 | Gyro.AD_Slow = Gyro.ADS_Accum << 7; //обновляем данные и приводим в один масштаб |
Kovalev_D | 157:1069c80f4944 | 130 | Gyro.ADS_Count = 0; |
Kovalev_D | 157:1069c80f4944 | 131 | Gyro.ADS_Accum = 0; |
Kovalev_D | 197:7a05523bf588 | 132 | Gyro.ADS_NewData = 1; |
Kovalev_D | 157:1069c80f4944 | 133 | } |
Kovalev_D | 147:1aed74f19a8f | 134 | } |
igor_v | 110:6406b7ac0442 | 135 | |
igor_v | 114:5cc38a53d8a7 | 136 | void SPI_Exchange(void) // новая функция чтения, в нецй не должно быть ничего лишнего |
Kovalev_D | 157:1069c80f4944 | 137 | { |
Kovalev_D | 157:1069c80f4944 | 138 | unsigned int DummySPI; |
Kovalev_D | 197:7a05523bf588 | 139 | |
Kovalev_D | 197:7a05523bf588 | 140 | //unsigned int ADC5Dif; |
Kovalev_D | 197:7a05523bf588 | 141 | |
Kovalev_D | 197:7a05523bf588 | 142 | ADC5New = LPC_SSP0->DR;// Чтение АЦП |
Kovalev_D | 197:7a05523bf588 | 143 | // Spi.ADC5_Accum += LPC_SSP0->DR; |
Kovalev_D | 198:fb22ba6aad54 | 144 | |
Kovalev_D | 198:fb22ba6aad54 | 145 | Spi.ADC5_Accum += ADC5New; |
igor_v | 110:6406b7ac0442 | 146 | Spi.ADC4_Accum += LPC_SSP0->DR; |
igor_v | 110:6406b7ac0442 | 147 | Spi.ADC3_Accum += LPC_SSP0->DR; |
igor_v | 110:6406b7ac0442 | 148 | Spi.ADC2_Accum += LPC_SSP0->DR; |
Kovalev_D | 198:fb22ba6aad54 | 149 | /*Spi.ADC1_Accum +*/Gyro.test = LPC_SSP0->DR; |
Kovalev_D | 198:fb22ba6aad54 | 150 | |
Kovalev_D | 198:fb22ba6aad54 | 151 | /*sprintf((Time),"%d \r\n", Gyro.test);//выдаем в терминал для постройки граффика регулировки периметра. |
Kovalev_D | 198:fb22ba6aad54 | 152 | WriteCon(Time);*/ |
Kovalev_D | 197:7a05523bf588 | 153 | |
Kovalev_D | 157:1069c80f4944 | 154 | while (LPC_SSP0->SR & RX_SSP_notEMPT) { |
Kovalev_D | 170:d099c3025f87 | 155 | DummySPI = LPC_SSP0->DR; //если буфер SPI не пуст.//очистить буфер. |
Kovalev_D | 157:1069c80f4944 | 156 | } |
Kovalev_D | 112:4a96133a1311 | 157 | DAC_OutPut(); |
Kovalev_D | 198:fb22ba6aad54 | 158 | /* if (CountV31 == 0) { // просто фильтруем по 32 точкам. |
Kovalev_D | 197:7a05523bf588 | 159 | // выставояем бит, что есть новы данные |
Kovalev_D | 157:1069c80f4944 | 160 | Spi.ADC1 = Spi.ADC1_Accum >> 5; // подгоотавливаем данные (в той эе сетке) те ADC1 0..65535 |
Kovalev_D | 157:1069c80f4944 | 161 | Spi.ADC2 = Spi.ADC2_Accum >> 5; |
Kovalev_D | 157:1069c80f4944 | 162 | Spi.ADC3 = Spi.ADC3_Accum >> 5; |
Kovalev_D | 157:1069c80f4944 | 163 | Spi.ADC4 = Spi.ADC4_Accum >> 5; |
Kovalev_D | 157:1069c80f4944 | 164 | Spi.ADC5 = Spi.ADC5_Accum >> 5; |
Kovalev_D | 157:1069c80f4944 | 165 | Spi.ADC1_Accum = 0; // сбрасывкем аккамулятор |
Kovalev_D | 157:1069c80f4944 | 166 | Spi.ADC2_Accum = 0; |
Kovalev_D | 157:1069c80f4944 | 167 | Spi.ADC3_Accum = 0; |
Kovalev_D | 157:1069c80f4944 | 168 | Spi.ADC4_Accum = 0; |
Kovalev_D | 157:1069c80f4944 | 169 | Spi.ADC5_Accum = 0; |
Kovalev_D | 157:1069c80f4944 | 170 | Spi.ADC_NewData = 1; |
Kovalev_D | 197:7a05523bf588 | 171 | |
Kovalev_D | 198:fb22ba6aad54 | 172 | }*/ |
Kovalev_D | 197:7a05523bf588 | 173 | |
Kovalev_D | 197:7a05523bf588 | 174 | |
Kovalev_D | 197:7a05523bf588 | 175 | |
Kovalev_D | 197:7a05523bf588 | 176 | |
Kovalev_D | 197:7a05523bf588 | 177 | BuffADC_64Point[CountV64]=ADC5New; |
Kovalev_D | 197:7a05523bf588 | 178 | Buff_ADC_5[CountV255] = (0x7fff-ADC5New)<<2; |
Kovalev_D | 198:fb22ba6aad54 | 179 | |
Kovalev_D | 197:7a05523bf588 | 180 | PLCRegul(); |
Kovalev_D | 112:4a96133a1311 | 181 | } |
Kovalev_D | 113:8be429494918 | 182 | |
Kovalev_D | 190:289514f730ee | 183 | void ShowMod(void)//технологическая функция для просмотра в ориджине мод на всем диапазпне цап |
Kovalev_D | 158:0c8342e1837a | 184 | { |
Kovalev_D | 158:0c8342e1837a | 185 | |
Kovalev_D | 158:0c8342e1837a | 186 | ////////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 158:0c8342e1837a | 187 | //////////////////////////////////смотрим все моды///////////////////////////////////////////////// |
Kovalev_D | 158:0c8342e1837a | 188 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 197:7a05523bf588 | 189 | if(dispersion>5) |
Kovalev_D | 197:7a05523bf588 | 190 | { |
Kovalev_D | 197:7a05523bf588 | 191 | if( (Gyro.PLC_Lern<60000)&&(Gyro.PLC_Error2Mode >1))//пробигаем по нескольким значениям цап(60*0х3с=0хВВ8) для определения максимальной амплитуды. |
Kovalev_D | 158:0c8342e1837a | 192 | { |
Kovalev_D | 158:0c8342e1837a | 193 | Gyro.PLC_Error2Mode--; |
Kovalev_D | 158:0c8342e1837a | 194 | Gyro.PLC_Lern++; |
Kovalev_D | 197:7a05523bf588 | 195 | Spi.DAC_B += tempstrafe*side; |
Kovalev_D | 197:7a05523bf588 | 196 | if(side>0)side=(-1); |
Kovalev_D | 197:7a05523bf588 | 197 | else side = 1; |
Kovalev_D | 197:7a05523bf588 | 198 | tempstrafe-=40; |
Kovalev_D | 197:7a05523bf588 | 199 | dispersion=0; |
Kovalev_D | 168:f4a6abb18358 | 200 | } |
Kovalev_D | 197:7a05523bf588 | 201 | else {Gyro.LogPLC=0;} |
Kovalev_D | 197:7a05523bf588 | 202 | } |
Kovalev_D | 197:7a05523bf588 | 203 | else dispersion++; |
Kovalev_D | 197:7a05523bf588 | 204 | sprintf((Time),"%d %d %d %d \r\n", Gyro.CuruAngle, Spi.DAC_B, Gyro.AD_Slow, Gyro.Termo); |
Kovalev_D | 197:7a05523bf588 | 205 | Gyro.CuruAngle=0; |
Kovalev_D | 197:7a05523bf588 | 206 | WriteCon(Time); |
Kovalev_D | 158:0c8342e1837a | 207 | } |
Kovalev_D | 144:083c667ba848 | 208 | |
Kovalev_D | 144:083c667ba848 | 209 | |
Kovalev_D | 144:083c667ba848 | 210 | |
Kovalev_D | 144:083c667ba848 | 211 | |
Kovalev_D | 144:083c667ba848 | 212 | |
Kovalev_D | 195:bcc769f5292b | 213 | void PlcRegul(void) |
Kovalev_D | 195:bcc769f5292b | 214 | //Программа расчет напряжения для модулятора(//выполняется 1.25 микросек.) |
Kovalev_D | 195:bcc769f5292b | 215 | { |
Kovalev_D | 195:bcc769f5292b | 216 | |
Kovalev_D | 195:bcc769f5292b | 217 | int templm=0; |
Kovalev_D | 157:1069c80f4944 | 218 | int PLC_In; |
Kovalev_D | 157:1069c80f4944 | 219 | int tempDac; |
Kovalev_D | 197:7a05523bf588 | 220 | if(start<=5) |
Kovalev_D | 195:bcc769f5292b | 221 | { |
Kovalev_D | 196:f76dbc081e63 | 222 | if(ttt) |
Kovalev_D | 196:f76dbc081e63 | 223 | {// +25 С° |
Kovalev_D | 196:f76dbc081e63 | 224 | templm = (Gyro.TermoNKU-Gyro.Termo); //дельта |
Kovalev_D | 195:bcc769f5292b | 225 | if(templm>0) Gyro.Ktermo=1; |
Kovalev_D | 195:bcc769f5292b | 226 | else Gyro.Ktermo=0; |
Kovalev_D | 195:bcc769f5292b | 227 | Spi.DAC_B+=templm; |
Kovalev_D | 196:f76dbc081e63 | 228 | ttt=0; |
Kovalev_D | 195:bcc769f5292b | 229 | } |
Kovalev_D | 195:bcc769f5292b | 230 | } |
Kovalev_D | 196:f76dbc081e63 | 231 | |
Kovalev_D | 196:f76dbc081e63 | 232 | if(!(Gyro.PinReg & PinRegBitL) && (start>0)) start--; |
Kovalev_D | 196:f76dbc081e63 | 233 | |
Kovalev_D | 196:f76dbc081e63 | 234 | else if((start==0)) |
Kovalev_D | 193:a0fe8bfc97e4 | 235 | { |
Kovalev_D | 197:7a05523bf588 | 236 | |
Kovalev_D | 193:a0fe8bfc97e4 | 237 | PLC_In = Gyro.AD_Slow; //выбираем даные для фильтрации |
Kovalev_D | 191:40028201ddad | 238 | Gyro.PLC_Delta = PLC_In - Gyro.PLC_Old; //узнаем приращение |
Kovalev_D | 191:40028201ddad | 239 | Gyro.PLC_DeltaADD = Gyro.PLC_Delta * Gyro.PLC_ADC_DOld; //приращение с учетом знака (и количества) прошлого приращения |
Kovalev_D | 191:40028201ddad | 240 | Gyro.PLC_Old = PLC_In; //запоминание значения |
Kovalev_D | 193:a0fe8bfc97e4 | 241 | if(Gyro.flagGph_W) |
Kovalev_D | 193:a0fe8bfc97e4 | 242 | { |
Kovalev_D | 193:a0fe8bfc97e4 | 243 | AD_MAX=0; |
Kovalev_D | 193:a0fe8bfc97e4 | 244 | Gyro.flagGph_W--; |
Kovalev_D | 193:a0fe8bfc97e4 | 245 | Gyro.PLC_Error2Mode=3; |
Kovalev_D | 191:40028201ddad | 246 | } //если изменился коэфициент усиления ФД //3600 (размер моды порядка 3000) |
Kovalev_D | 193:a0fe8bfc97e4 | 247 | if((Gyro.PLC_Lern < 150) && (Gyro.PLC_Error2Mode != 0)) |
Kovalev_D | 193:a0fe8bfc97e4 | 248 | { //пробигаем по нескольким значениям цап(60*0х3с=0хВВ8) для определения максимальной амплитуды. |
Kovalev_D | 195:bcc769f5292b | 249 | |
Kovalev_D | 195:bcc769f5292b | 250 | if(Gyro.Ktermo)Spi.DAC_B += 0x3c; //добовляем в значение цапа 60 |
Kovalev_D | 195:bcc769f5292b | 251 | else Spi.DAC_B -= 0x3c; |
Kovalev_D | 193:a0fe8bfc97e4 | 252 | if(AD_MAX < PLC_In){AD_MAX = PLC_In;} //если максимальная амплитуда меньше текущей записываем новую максимальную амплитуду. |
Kovalev_D | 197:7a05523bf588 | 253 | else if ((AD_MAX>PLC_In)&&(AD_MAX>1550800000)) r++; //если текущая амплитуда меньше максимально найденной то инкрементируем счетчик. |
Kovalev_D | 193:a0fe8bfc97e4 | 254 | if (r>10) |
Kovalev_D | 193:a0fe8bfc97e4 | 255 | { |
Kovalev_D | 197:7a05523bf588 | 256 | Gyro.PLC_Lern=151; |
Kovalev_D | 193:a0fe8bfc97e4 | 257 | Gyro.PLC_Error2Mode=3; |
Kovalev_D | 191:40028201ddad | 258 | } //если текущая амплитуда меньше максимально найденной в течении 5 тактов то выходим из поиска |
Kovalev_D | 197:7a05523bf588 | 259 | Gyro.CuruAngle = 0; //не считаем угол пока ищем максивальную амплитуду. |
Kovalev_D | 197:7a05523bf588 | 260 | } //работает только первые ~30-40 секунд (37 сек). |
Kovalev_D | 193:a0fe8bfc97e4 | 261 | if (Gyro.PLC_Lern<160) Gyro.PLC_Lern++; |
Kovalev_D | 193:a0fe8bfc97e4 | 262 | |
Kovalev_D | 191:40028201ddad | 263 | if(AD_MAX < PLC_In) {AD_MAX = PLC_In; l=0;} //обновление максимального значения амплитуды обнуление счетчика малого понижения амплитуды. |
Kovalev_D | 191:40028201ddad | 264 | else l++; //инкрементируем счетчик малого понижения желаемой амплитуды (максимальной замеченной) |
Kovalev_D | 197:7a05523bf588 | 265 | if((l > 300)&&(Gyro.PLC_Error2Mode == 0)) {AD_MAX -= 2107200;k=15;l=0;} //если счетчик малого понижения амплитуды больше 100(аммплитуда не обновлялась 100 раз). m |
Kovalev_D | 197:7a05523bf588 | 266 | if ((k == 15)&&(Gyro.PLC_Lern > 150)) Spi.DAC_B += 75; //после уменьшения максимальной амплитуды двигаем шевелем цап |
Kovalev_D | 197:7a05523bf588 | 267 | else if((k == 1)&&(Gyro.PLC_Lern > 150)) {Spi.DAC_B -= 75; k=0;l=0;} //для быстрог поиска новог максимума. |
Kovalev_D | 195:bcc769f5292b | 268 | if(k>0)k--; |
Kovalev_D | 160:6170df6f5a5c | 269 | |
Kovalev_D | 191:40028201ddad | 270 | Gyro.PlC_MaxD=(unsigned int)(AD_MAX-PLC_In); //ищем разницу между желаемой и действительной амплитудами. |
Kovalev_D | 160:6170df6f5a5c | 271 | |
Kovalev_D | 197:7a05523bf588 | 272 | if(Gyro.ModJump==1) { ///прыжок с моды на моду. (-->) |
Kovalev_D | 197:7a05523bf588 | 273 | Gyro.OldCuruAngle = Gyro.CuruAngle; |
Kovalev_D | 197:7a05523bf588 | 274 | Gyro.ModJump=0; |
Kovalev_D | 197:7a05523bf588 | 275 | Spi.DAC_B += 4300; |
Kovalev_D | 197:7a05523bf588 | 276 | Gyro.PLC_Error2Mode=1; |
Kovalev_D | 197:7a05523bf588 | 277 | Gyro.StopCuruAngle=2; |
Kovalev_D | 197:7a05523bf588 | 278 | } |
Kovalev_D | 197:7a05523bf588 | 279 | |
Kovalev_D | 197:7a05523bf588 | 280 | if(Gyro.ModJump==2) { ///прыжок с моды на моду. (<--) |
Kovalev_D | 197:7a05523bf588 | 281 | Gyro.OldCuruAngle = Gyro.CuruAngle; |
Kovalev_D | 197:7a05523bf588 | 282 | Gyro.ModJump=0; |
Kovalev_D | 197:7a05523bf588 | 283 | Spi.DAC_B -= 5250; |
Kovalev_D | 197:7a05523bf588 | 284 | Gyro.PLC_Error2Mode=1; |
Kovalev_D | 197:7a05523bf588 | 285 | Gyro.StopCuruAngle=2; |
Kovalev_D | 197:7a05523bf588 | 286 | } |
Kovalev_D | 197:7a05523bf588 | 287 | |
Kovalev_D | 191:40028201ddad | 288 | if(Gyro.RgConA&0x8) { // если контур регулирования замкнут |
Kovalev_D | 191:40028201ddad | 289 | if ( Gyro.PLC_Error2Mode > 0) { Gyro.PLC_Error2Mode --; Gyro.PLC_ADC_DOld = 0;} // если ошибка(нахожление в двух модовом) |
Kovalev_D | 191:40028201ddad | 290 | else if ( Gyro.PLC_DeltaADD > 0) { Gyro.PLC_ADC_DOld = 1;} |
Kovalev_D | 191:40028201ddad | 291 | else if ( Gyro.PLC_DeltaADD < 0) { Gyro.PLC_ADC_DOld = -1;} |
Kovalev_D | 191:40028201ddad | 292 | else { Gyro.PLC_ADC_DOld = 1;} |
Kovalev_D | 157:1069c80f4944 | 293 | } |
Kovalev_D | 191:40028201ddad | 294 | else {Gyro.PLC_Error2Mode = 1; Gyro.PLC_DeltaADD = 0;} |
Kovalev_D | 191:40028201ddad | 295 | |
Kovalev_D | 191:40028201ddad | 296 | ///прыжок с моды на моду. |
Kovalev_D | 171:d227a6045305 | 297 | |
Kovalev_D | 197:7a05523bf588 | 298 | |
Kovalev_D | 197:7a05523bf588 | 299 | |
Kovalev_D | 197:7a05523bf588 | 300 | |
Kovalev_D | 190:289514f730ee | 301 | |
Kovalev_D | 191:40028201ddad | 302 | tempADC5=0x7fff-Spi.ADC5; |
Kovalev_D | 191:40028201ddad | 303 | // контур замкнут включен лазер |
Kovalev_D | 193:a0fe8bfc97e4 | 304 | if((Gyro.RgConA&0x8) && (tempADC5>1000)) |
Kovalev_D | 197:7a05523bf588 | 305 | { |
Kovalev_D | 197:7a05523bf588 | 306 | if(Gyro.PlC_MaxD>(50<<17)) { // 3 режим регулирования |
Kovalev_D | 172:ef7bf1663645 | 307 | tempDac=(unsigned int)(Gyro.PlC_MaxD>>19); |
Kovalev_D | 197:7a05523bf588 | 308 | if(tempDac>600) tempDac=600; //ограничение на регулирование если очень большая разница амплитуд |
Kovalev_D | 197:7a05523bf588 | 309 | Spi.DAC_B += Gyro.PLC_ADC_DOld * tempDac; //новое значение в цап (±1 * значение регулировки) |
Kovalev_D | 197:7a05523bf588 | 310 | tempDac = Gyro.PLC_ADC_DOld * tempDac; //используется только для выдачи |
Kovalev_D | 171:d227a6045305 | 311 | flagmod=3; |
Kovalev_D | 171:d227a6045305 | 312 | } |
Kovalev_D | 197:7a05523bf588 | 313 | else if(Gyro.PlC_MaxD>(12<<17)) { // 2 режим регулирования |
Kovalev_D | 172:ef7bf1663645 | 314 | tempDac=(unsigned int)(Gyro.PlC_MaxD>>19); |
Kovalev_D | 171:d227a6045305 | 315 | Spi.DAC_B += Gyro.PLC_ADC_DOld * (tempDac); |
Kovalev_D | 197:7a05523bf588 | 316 | tempDac = Gyro.PLC_ADC_DOld * (tempDac); //используется только для выдачи |
Kovalev_D | 171:d227a6045305 | 317 | flagmod=2; |
Kovalev_D | 171:d227a6045305 | 318 | } |
Kovalev_D | 197:7a05523bf588 | 319 | /* else if(Gyro.PlC_MaxD<(2<<17)) { //режим если дельта равна 0;Gyro.ModJump |
Kovalev_D | 197:7a05523bf588 | 320 | tempDac=2; |
Kovalev_D | 171:d227a6045305 | 321 | Spi.DAC_B += Gyro.PLC_ADC_DOld * tempDac; |
Kovalev_D | 171:d227a6045305 | 322 | flagmod=0; |
Kovalev_D | 197:7a05523bf588 | 323 | } */ |
Kovalev_D | 171:d227a6045305 | 324 | else { |
Kovalev_D | 197:7a05523bf588 | 325 | tempDac=2; // 1 режим регулирования |
Kovalev_D | 171:d227a6045305 | 326 | Spi.DAC_B += Gyro.PLC_ADC_DOld *tempDac; |
Kovalev_D | 171:d227a6045305 | 327 | tempDac = Gyro.PLC_ADC_DOld * tempDac; |
Kovalev_D | 171:d227a6045305 | 328 | flagmod=1; |
Kovalev_D | 191:40028201ddad | 329 | } |
Kovalev_D | 197:7a05523bf588 | 330 | } |
Kovalev_D | 196:f76dbc081e63 | 331 | |
Kovalev_D | 195:bcc769f5292b | 332 | |
Kovalev_D | 197:7a05523bf588 | 333 | if ( Spi.DAC_B < 15300 ) {Spi.DAC_B = 32000; Gyro.PLC_Error2Mode = 5; Gyro.PLC_DeltaADD = 0;} //проверка на переваливание за границу. |
Kovalev_D | 195:bcc769f5292b | 334 | else if ( Spi.DAC_B > 53000) {Spi.DAC_B = 32000; Gyro.PLC_Error2Mode = 5; Gyro.PLC_DeltaADD = 0;} |
Kovalev_D | 195:bcc769f5292b | 335 | |
Kovalev_D | 191:40028201ddad | 336 | } |
Kovalev_D | 197:7a05523bf588 | 337 | if(Gyro.StopCuruAngle) {Gyro.CuruAngle = Gyro.OldCuruAngle; Gyro.StopCuruAngle--;} |
Kovalev_D | 157:1069c80f4944 | 338 | /////////////////////// |
Kovalev_D | 157:1069c80f4944 | 339 | //////////лог////////// |
Kovalev_D | 157:1069c80f4944 | 340 | /////////////////////// |
Kovalev_D | 157:1069c80f4944 | 341 | if(Gyro.LogPLC==1) { |
Kovalev_D | 196:f76dbc081e63 | 342 | // LoopOn |
Kovalev_D | 197:7a05523bf588 | 343 | sprintf((Time),"%d %d %d %d %d %d %d %d %d \r\n",Gyro.CuruAngle, Gyro.Frq, Gyro.MaxAmp, Spi.DAC_B, tempDac, flagmod, AD_MAX, PLC_In, Gyro.Termo);//выдаем в терминал для постройки граффика регулировки периметра. |
Kovalev_D | 196:f76dbc081e63 | 344 | Gyro.CuruAngle=0; |
Kovalev_D | 196:f76dbc081e63 | 345 | Gyro.tempdelta=0; |
Kovalev_D | 196:f76dbc081e63 | 346 | Gyro.tempdelta2=0; |
Kovalev_D | 141:c6de20b9b483 | 347 | WriteCon(Time); |
Kovalev_D | 197:7a05523bf588 | 348 | // LoopOff |
Kovalev_D | 157:1069c80f4944 | 349 | } |
Kovalev_D | 157:1069c80f4944 | 350 | } |
Kovalev_D | 141:c6de20b9b483 | 351 | |
Kovalev_D | 141:c6de20b9b483 | 352 | |
Kovalev_D | 141:c6de20b9b483 | 353 | |
Kovalev_D | 141:c6de20b9b483 | 354 | |
Kovalev_D | 141:c6de20b9b483 | 355 | /* |
Kovalev_D | 157:1069c80f4944 | 356 | |
Kovalev_D | 116:66f1f0ff2dab | 357 | void PlcRegul(void) //Программа расчет напряжения для модулятора |
Kovalev_D | 116:66f1f0ff2dab | 358 | { |
Kovalev_D | 116:66f1f0ff2dab | 359 | int PLC_In; |
Kovalev_D | 116:66f1f0ff2dab | 360 | |
igor_v | 127:6a7472d67804 | 361 | |
igor_v | 127:6a7472d67804 | 362 | PLC_In = Gyro.AD_Slow; //выбираем даные для фильтрации |
Kovalev_D | 116:66f1f0ff2dab | 363 | // PLC_In = Gyro.AD_Fast; |
Kovalev_D | 128:1e4675a36c93 | 364 | //или+,или-(знак) |
Kovalev_D | 128:1e4675a36c93 | 365 | Gyro.PLC_Delta = PLC_In - Gyro.PLC_Old; // узнаем приращение |
Kovalev_D | 128:1e4675a36c93 | 366 | // (знак) * (то на что инкрементировали цап) |
Kovalev_D | 128:1e4675a36c93 | 367 | Gyro.PLC_DeltaADD = Gyro.PLC_Delta * Gyro.PLC_ADC_DOld; //приращение с учетом знака (и количества) прошлого приращения |
Kovalev_D | 128:1e4675a36c93 | 368 | Gyro.PLC_Old = PLC_In; // запоминание значения |
igor_v | 127:6a7472d67804 | 369 | |
Kovalev_D | 128:1e4675a36c93 | 370 | if(Gyro.RgConA&0x2) // если включон контур регулирования |
Kovalev_D | 157:1069c80f4944 | 371 | { |
Kovalev_D | 140:1fbf117fc120 | 372 | if (Gyro.PLC_Error2Mode > 0) {Gyro.PLC_Error2Mode --; Gyro.PLC_ADC_DOld = 0; } // если ошибка(нахожление в двух модовом) |
Kovalev_D | 128:1e4675a36c93 | 373 | else if ( Gyro.PLC_Delta > (3000 * 65536)) {Spi.DAC_B += 2500; Gyro.PLC_Error2Mode = 5; Gyro.PLC_ADC_DOld = 0;} // проверка на двух модовость |
Kovalev_D | 128:1e4675a36c93 | 374 | else if ( Gyro.PLC_Delta < (-3000 * 65536)) {Spi.DAC_B += 2500; Gyro.PLC_Error2Mode = 5; Gyro.PLC_ADC_DOld = 0;} |
Kovalev_D | 157:1069c80f4944 | 375 | |
Kovalev_D | 157:1069c80f4944 | 376 | else if (Gyro.PLC_DeltaADD > 0) |
igor_v | 127:6a7472d67804 | 377 | { |
Kovalev_D | 157:1069c80f4944 | 378 | |
Kovalev_D | 159:38f39c0c143f | 379 | // Gyro.PLC_ADC_DOld = (Gyro.PLC_DeltaADD /6553600 )+1; |
Kovalev_D | 128:1e4675a36c93 | 380 | Gyro.PLC_ADC_DOld = 1; |
igor_v | 127:6a7472d67804 | 381 | } |
Kovalev_D | 157:1069c80f4944 | 382 | else if (Gyro.PLC_DeltaADD < 0) |
igor_v | 127:6a7472d67804 | 383 | { |
igor_v | 127:6a7472d67804 | 384 | |
Kovalev_D | 128:1e4675a36c93 | 385 | // Gyro.PLC_ADC_DOld = (Gyro.PLC_DeltaADD /6553600 )-1; |
Kovalev_D | 128:1e4675a36c93 | 386 | Gyro.PLC_ADC_DOld = -1; |
igor_v | 127:6a7472d67804 | 387 | } |
igor_v | 127:6a7472d67804 | 388 | else |
igor_v | 127:6a7472d67804 | 389 | { |
Kovalev_D | 128:1e4675a36c93 | 390 | Gyro.PLC_ADC_DOld = 1; |
igor_v | 127:6a7472d67804 | 391 | } |
igor_v | 127:6a7472d67804 | 392 | } |
Kovalev_D | 157:1069c80f4944 | 393 | else |
igor_v | 127:6a7472d67804 | 394 | { |
Kovalev_D | 128:1e4675a36c93 | 395 | Gyro.PLC_Error2Mode = 1; Gyro.PLC_DeltaADD = 0; |
igor_v | 127:6a7472d67804 | 396 | } |
Kovalev_D | 157:1069c80f4944 | 397 | |
Kovalev_D | 157:1069c80f4944 | 398 | |
Kovalev_D | 141:c6de20b9b483 | 399 | Spi.DAC_B += Gyro.PLC_ADC_DOld * 16; |
Kovalev_D | 157:1069c80f4944 | 400 | |
Kovalev_D | 157:1069c80f4944 | 401 | |
Kovalev_D | 128:1e4675a36c93 | 402 | if ( Spi.DAC_B < 1000 ) {Spi.DAC_B = 32000; Gyro.PLC_Error2Mode = 5; Gyro.PLC_DeltaADD = 0;} |
Kovalev_D | 128:1e4675a36c93 | 403 | if ( Spi.DAC_B > 63000 ) {Spi.DAC_B = 32000; Gyro.PLC_Error2Mode = 5; Gyro.PLC_DeltaADD = 0;} |
Kovalev_D | 157:1069c80f4944 | 404 | |
Kovalev_D | 141:c6de20b9b483 | 405 | if(Gyro.LogPLC==1) |
Kovalev_D | 141:c6de20b9b483 | 406 | { |
Kovalev_D | 157:1069c80f4944 | 407 | sprintf((Time),"%d %d %d %d %d %d\r\n", Spi.DAC_B, temp9,flagmod, AD_MAX, Gyro.AD_Slow, k);//выдаем в терминал для постройки граффика регулировки периметра. |
Kovalev_D | 157:1069c80f4944 | 408 | WriteCon(Time); |
Kovalev_D | 141:c6de20b9b483 | 409 | } |
Kovalev_D | 157:1069c80f4944 | 410 | |
Kovalev_D | 128:1e4675a36c93 | 411 | } |
Kovalev_D | 116:66f1f0ff2dab | 412 | |
Kovalev_D | 116:66f1f0ff2dab | 413 | |
Kovalev_D | 191:40028201ddad | 414 | *//* |
Kovalev_D | 157:1069c80f4944 | 415 | void PlcRegul_old(void) // на всякий случай |
Kovalev_D | 112:4a96133a1311 | 416 | { |
Kovalev_D | 157:1069c80f4944 | 417 | int Delta; |
Kovalev_D | 157:1069c80f4944 | 418 | |
Kovalev_D | 157:1069c80f4944 | 419 | ADD_AMP+=Spi.ADC5; |
Kovalev_D | 157:1069c80f4944 | 420 | Count_AMP++; |
Kovalev_D | 157:1069c80f4944 | 421 | if(Count_AMP>=(32*32+8)) { |
Kovalev_D | 157:1069c80f4944 | 422 | Delta = ADD_AMP - Cur_Amp; |
Kovalev_D | 157:1069c80f4944 | 423 | |
Kovalev_D | 157:1069c80f4944 | 424 | if(Gyro.RgConA&0x2) { |
Kovalev_D | 157:1069c80f4944 | 425 | if (Znak_Amp > 1) { |
Kovalev_D | 157:1069c80f4944 | 426 | Znak_Amp --; |
Kovalev_D | 157:1069c80f4944 | 427 | } else if ( Delta > 30000000 ) { |
Kovalev_D | 157:1069c80f4944 | 428 | AD_Regul += 5000000; |
Kovalev_D | 157:1069c80f4944 | 429 | Znak_Amp = 5; |
Kovalev_D | 157:1069c80f4944 | 430 | } else if ( Delta < (-3000000)) { |
Kovalev_D | 157:1069c80f4944 | 431 | AD_Regul += 5000000; |
Kovalev_D | 157:1069c80f4944 | 432 | Znak_Amp = 5; |
Kovalev_D | 157:1069c80f4944 | 433 | } else if ((Delta * Znak_Amp) > 0) { |
Kovalev_D | 157:1069c80f4944 | 434 | Znak_Amp = 1; |
Kovalev_D | 157:1069c80f4944 | 435 | AD_Regul -= (Delta * Znak_Amp * 10); |
Kovalev_D | 157:1069c80f4944 | 436 | } else { |
Kovalev_D | 157:1069c80f4944 | 437 | Znak_Amp = -1; |
Kovalev_D | 157:1069c80f4944 | 438 | AD_Regul -= (Delta * Znak_Amp * 10); |
Kovalev_D | 157:1069c80f4944 | 439 | } |
Kovalev_D | 157:1069c80f4944 | 440 | |
Kovalev_D | 157:1069c80f4944 | 441 | Spi.DAC_B = (AD_Regul + 0x1fffffff)/65536; |
Kovalev_D | 157:1069c80f4944 | 442 | } |
Kovalev_D | 157:1069c80f4944 | 443 | Cur_Amp=ADD_AMP; |
Kovalev_D | 157:1069c80f4944 | 444 | Count_AMP=0; |
Kovalev_D | 157:1069c80f4944 | 445 | ADD_AMP=0; |
Kovalev_D | 157:1069c80f4944 | 446 | } |
Kovalev_D | 157:1069c80f4944 | 447 | |
igor_v | 110:6406b7ac0442 | 448 | } |
igor_v | 110:6406b7ac0442 | 449 | |
igor_v | 110:6406b7ac0442 | 450 | |
Kovalev_D | 191:40028201ddad | 451 | */ |
Kovalev_D | 116:66f1f0ff2dab | 452 | |
Kovalev_D | 112:4a96133a1311 | 453 | void DAC_OutPut(void)//выдача в цапы |
igor_v | 0:8ad47e2b6f00 | 454 | { |
Kovalev_D | 197:7a05523bf588 | 455 | Modulator(); |
Kovalev_D | 157:1069c80f4944 | 456 | LPC_SSP0->DR=0x5555; |
igor_v | 31:c783288001b5 | 457 | LPC_SSP0->DR=0x5555; |
igor_v | 31:c783288001b5 | 458 | LPC_SSP0->DR=0x5555; |
igor_v | 0:8ad47e2b6f00 | 459 | |
igor_v | 110:6406b7ac0442 | 460 | if (CountV31 & 1) { //если нечетный такт то |
Kovalev_D | 197:7a05523bf588 | 461 | LPC_SSP0->DR = WRITE_DAC0; //e.команда для ЦАП_0 передавать. |
igor_v | 31:c783288001b5 | 462 | LPC_SSP0->DR = (Spi.DAC_A); //e. передача 12 бит |
Kovalev_D | 157:1069c80f4944 | 463 | } else { //если такт четный. |
Kovalev_D | 157:1069c80f4944 | 464 | LPC_SSP0->DR = WRITE_DAC1 ; //e.команда для ЦАП_1 передавать. |
Kovalev_D | 157:1069c80f4944 | 465 | |
Kovalev_D | 157:1069c80f4944 | 466 | switch( Gyro.StrayPLC_flag) { |
Kovalev_D | 157:1069c80f4944 | 467 | |
Kovalev_D | 157:1069c80f4944 | 468 | case 0://режим без воздействия |
Kovalev_D | 157:1069c80f4944 | 469 | LPC_SSP0->DR = (Spi.DAC_B); |
Kovalev_D | 157:1069c80f4944 | 470 | temp9=Spi.DAC_B; |
Kovalev_D | 157:1069c80f4944 | 471 | break; |
Kovalev_D | 195:bcc769f5292b | 472 | /* |
Kovalev_D | 157:1069c80f4944 | 473 | case 1://малое воздействие + |
Kovalev_D | 157:1069c80f4944 | 474 | temp9=Spi.DAC_B + Gyro.StrayPLC_Pls; |
Kovalev_D | 157:1069c80f4944 | 475 | LPC_SSP0->DR = temp9; |
Kovalev_D | 157:1069c80f4944 | 476 | break; |
Kovalev_D | 157:1069c80f4944 | 477 | |
Kovalev_D | 157:1069c80f4944 | 478 | case 3://малое воздействие - |
Kovalev_D | 157:1069c80f4944 | 479 | temp9=Spi.DAC_B + Gyro.StrayPLC_Mns; |
Kovalev_D | 157:1069c80f4944 | 480 | LPC_SSP0->DR = temp9; |
Kovalev_D | 157:1069c80f4944 | 481 | break; |
Kovalev_D | 157:1069c80f4944 | 482 | |
Kovalev_D | 157:1069c80f4944 | 483 | case 2://большое воздействие + |
Kovalev_D | 157:1069c80f4944 | 484 | temp9=Spi.DAC_B + Gyro.StrayPLC_2Mode; |
Kovalev_D | 157:1069c80f4944 | 485 | LPC_SSP0->DR = temp9;//вгоняем в многомодовый режим |
Kovalev_D | 157:1069c80f4944 | 486 | break; |
Kovalev_D | 195:bcc769f5292b | 487 | */ |
Kovalev_D | 157:1069c80f4944 | 488 | } |
Kovalev_D | 157:1069c80f4944 | 489 | // LPC_SSP0->DR = Spi.DAC_B; //e. передача 12 бит |
Kovalev_D | 157:1069c80f4944 | 490 | |
igor_v | 31:c783288001b5 | 491 | } |
Kovalev_D | 112:4a96133a1311 | 492 | } |
Kovalev_D | 112:4a96133a1311 | 493 | |
Kovalev_D | 112:4a96133a1311 | 494 | |
Kovalev_D | 113:8be429494918 | 495 | |
Kovalev_D | 113:8be429494918 | 496 | |
Kovalev_D | 113:8be429494918 | 497 | |
Kovalev_D | 113:8be429494918 | 498 | |
Kovalev_D | 113:8be429494918 | 499 | |
Kovalev_D | 113:8be429494918 | 500 | |
Kovalev_D | 113:8be429494918 | 501 | |
Kovalev_D | 113:8be429494918 | 502 | |
Kovalev_D | 113:8be429494918 | 503 | |
Kovalev_D | 113:8be429494918 | 504 | |
Kovalev_D | 113:8be429494918 | 505 | |
Kovalev_D | 113:8be429494918 | 506 | |
Kovalev_D | 113:8be429494918 | 507 | |
Kovalev_D | 113:8be429494918 | 508 | |
Kovalev_D | 113:8be429494918 | 509 | |
Kovalev_D | 113:8be429494918 | 510 | |
Kovalev_D | 113:8be429494918 | 511 | |
Kovalev_D | 113:8be429494918 | 512 | |
Kovalev_D | 113:8be429494918 | 513 | |
Kovalev_D | 113:8be429494918 | 514 | |
Kovalev_D | 113:8be429494918 | 515 | |
Kovalev_D | 113:8be429494918 | 516 | |
Kovalev_D | 113:8be429494918 | 517 | |
Kovalev_D | 113:8be429494918 | 518 | |
Kovalev_D | 113:8be429494918 | 519 | |
Kovalev_D | 113:8be429494918 | 520 | |
Kovalev_D | 113:8be429494918 | 521 | |
Kovalev_D | 113:8be429494918 | 522 | |
Kovalev_D | 113:8be429494918 | 523 | /* |
Kovalev_D | 112:4a96133a1311 | 524 | void SPI_Exchange(void) |
Kovalev_D | 112:4a96133a1311 | 525 | { |
Kovalev_D | 112:4a96133a1311 | 526 | unsigned int DummySPI; |
Kovalev_D | 157:1069c80f4944 | 527 | |
Kovalev_D | 112:4a96133a1311 | 528 | |
Kovalev_D | 112:4a96133a1311 | 529 | Spi.ADC5 = LPC_SSP0->DR; |
Kovalev_D | 112:4a96133a1311 | 530 | Spi.ADC4 = LPC_SSP0->DR; |
Kovalev_D | 112:4a96133a1311 | 531 | Spi.ADC3 = LPC_SSP0->DR; |
Kovalev_D | 112:4a96133a1311 | 532 | Spi.ADC2 = LPC_SSP0->DR; |
Kovalev_D | 112:4a96133a1311 | 533 | Spi.ADC1 = LPC_SSP0->DR; |
Kovalev_D | 112:4a96133a1311 | 534 | |
Kovalev_D | 112:4a96133a1311 | 535 | Input.ArrayIn[2]= Spi.ADC5; |
Kovalev_D | 157:1069c80f4944 | 536 | |
Kovalev_D | 112:4a96133a1311 | 537 | DAC_OutPut(); |
igor_v | 0:8ad47e2b6f00 | 538 | |
Kovalev_D | 99:3d8f206ceac2 | 539 | // LPC_DAC->CR = (((SinPLC[CountV64]*35/5)+24300));// модулятор |
Kovalev_D | 112:4a96133a1311 | 540 | |
Kovalev_D | 89:a0d344db227e | 541 | while (LPC_SSP0->SR & RX_SSP_notEMPT) //если буфер SPI не пуст. |
Kovalev_D | 89:a0d344db227e | 542 | DummySPI = LPC_SSP0->DR; //очистить буфер. |
igor_v | 31:c783288001b5 | 543 | |
Kovalev_D | 112:4a96133a1311 | 544 | //заполнение буферов еденичных значений АЦП. |
Kovalev_D | 157:1069c80f4944 | 545 | Buff_ADC_1 [CountV31] = Spi.ADC1; |
Kovalev_D | 112:4a96133a1311 | 546 | Buff_ADC_2 [CountV31] = Spi.ADC2; |
Kovalev_D | 112:4a96133a1311 | 547 | Buff_ADC_3 [CountV31] = Spi.ADC3; |
Kovalev_D | 112:4a96133a1311 | 548 | Buff_ADC_4 [CountV31] = Spi.ADC4; |
Kovalev_D | 95:dd51e577e114 | 549 | Buff_ADC_5 [CountV255] = Spi.ADC5; // ампл ацп. |
igor_v | 110:6406b7ac0442 | 550 | |
Kovalev_D | 157:1069c80f4944 | 551 | |
igor_v | 110:6406b7ac0442 | 552 | Temp_AMP64P += Buff_ADC_5[CountV255]; |
Kovalev_D | 96:1c8536458119 | 553 | Temp_AMP64P -= Buff_ADC_5[(CountV255-64) & 0xff]; // заполнение буфера накопленых приращений за 8 тактов |
Kovalev_D | 96:1c8536458119 | 554 | Buff_AMP64P[CountV255] = (unsigned int) (Temp_AMP64P); |
Kovalev_D | 96:1c8536458119 | 555 | |
igor_v | 31:c783288001b5 | 556 | |
Kovalev_D | 47:d902ef6f7564 | 557 | Temp_ADC_2 += Buff_ADC_2[CountV31]; |
Kovalev_D | 47:d902ef6f7564 | 558 | Temp_ADC_2 -= Buff_ADC_2[(CountV31-32) & 0xff]; |
igor_v | 31:c783288001b5 | 559 | |
Kovalev_D | 47:d902ef6f7564 | 560 | Temp_ADC_3 += Buff_ADC_3[CountV31]; |
Kovalev_D | 95:dd51e577e114 | 561 | Temp_ADC_3 -= Buff_ADC_3[(CountV31-32) & 0xff]; |
igor_v | 31:c783288001b5 | 562 | |
Kovalev_D | 47:d902ef6f7564 | 563 | Temp_ADC_4 += Buff_ADC_4[CountV31]; |
Kovalev_D | 47:d902ef6f7564 | 564 | Temp_ADC_4 -= Buff_ADC_4[(CountV31-32) & 0xff]; |
igor_v | 31:c783288001b5 | 565 | |
igor_v | 31:c783288001b5 | 566 | Temp_ADC_5 += Buff_ADC_1[CountV255]; |
igor_v | 31:c783288001b5 | 567 | Temp_ADC_5 -= Buff_ADC_1[(CountV255-32) & 0xff]; |
Kovalev_D | 112:4a96133a1311 | 568 | Spi.PLC_NewData=1; |
Kovalev_D | 113:8be429494918 | 569 | }*/ |