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