![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
fork
Fork of LG by
SPI.c@212:8d6784491bae, 2017-07-03 (annotated)
- Committer:
- Kovalev_D
- Date:
- Mon Jul 03 08:32:27 2017 +0000
- Revision:
- 212:8d6784491bae
- Parent:
- 211:ac8251b067d2
- Child:
- 213:9953db9543d6
prizm work
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; |
Kovalev_D | 211:ac8251b067d2 | 21 | unsigned int conuntPLS; |
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 | 211:ac8251b067d2 | 31 | int RegulADC,DeltaRegul; |
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 | 211:ac8251b067d2 | 47 | unsigned int TypeMod=2; |
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 | 209:224e7331a061 | 55 | for (int i = 0; i < 64; i++ ) |
Kovalev_D | 197:7a05523bf588 | 56 | { |
Kovalev_D | 209:224e7331a061 | 57 | if(i<32) { ModArrayTriangle[i]=Mod; Mod+=3;} |
Kovalev_D | 209:224e7331a061 | 58 | else { ModArrayTriangle[i]=Mod; Mod-=3;} |
Kovalev_D | 197:7a05523bf588 | 59 | } |
Kovalev_D | 197:7a05523bf588 | 60 | |
Kovalev_D | 207:d1ce992f5d17 | 61 | for (int i = 0; i < 16; i++ ) |
Kovalev_D | 197:7a05523bf588 | 62 | { |
Kovalev_D | 197:7a05523bf588 | 63 | ModArraySaw[i]=Mod; |
Kovalev_D | 207:d1ce992f5d17 | 64 | Mod+=1; |
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 | 209:224e7331a061 | 69 | if(!MODFlag) |
Kovalev_D | 209:224e7331a061 | 70 | { |
Kovalev_D | 197:7a05523bf588 | 71 | switch(TypeMod) |
Kovalev_D | 197:7a05523bf588 | 72 | { |
Kovalev_D | 211:ac8251b067d2 | 73 | case 0: LPC_DAC->DACR = (ModArraySin [(CountV64-2)&0x3f]*Gyro.ModAmp); break; |
Kovalev_D | 197:7a05523bf588 | 74 | case 1: LPC_DAC->DACR = (ModArraySaw [CountV64]*Gyro.ModAmp); break; |
Kovalev_D | 211:ac8251b067d2 | 75 | case 2: LPC_DAC->DACR = (ModArrayTriangle [(CountV64-2)&0x3f]*Gyro.ModAmp); break; |
Kovalev_D | 197:7a05523bf588 | 76 | } |
Kovalev_D | 209:224e7331a061 | 77 | } |
Kovalev_D | 197:7a05523bf588 | 78 | } |
Kovalev_D | 197:7a05523bf588 | 79 | void PLCRegul(void) |
Kovalev_D | 208:19150d2b528f | 80 | { |
Kovalev_D | 211:ac8251b067d2 | 81 | unsigned int temp, Temp_Dac_B=0,Side=0; |
Kovalev_D | 208:19150d2b528f | 82 | static int CountFaza; |
Kovalev_D | 211:ac8251b067d2 | 83 | |
Kovalev_D | 211:ac8251b067d2 | 84 | |
Kovalev_D | 211:ac8251b067d2 | 85 | // Temp_Dac_B=(0xffff-Spi.DAC_B); |
Kovalev_D | 211:ac8251b067d2 | 86 | if(conuntPLS<10) |
Kovalev_D | 211:ac8251b067d2 | 87 | { |
Kovalev_D | 209:224e7331a061 | 88 | for (CountFaza = 0; CountFaza <32; CountFaza++ ) SinPls+= BuffADC_64Point[ (CountFaza + Gyro.PLC_Phase) & 0x3f]; |
Kovalev_D | 209:224e7331a061 | 89 | for (CountFaza = 32; CountFaza <64; CountFaza++) SinMns+= BuffADC_64Point[ (CountFaza + Gyro.PLC_Phase) & 0x3f]; |
Kovalev_D | 211:ac8251b067d2 | 90 | conuntPLS++; |
Kovalev_D | 211:ac8251b067d2 | 91 | } |
Kovalev_D | 211:ac8251b067d2 | 92 | else |
Kovalev_D | 211:ac8251b067d2 | 93 | { |
Kovalev_D | 211:ac8251b067d2 | 94 | conuntPLS=0; |
Kovalev_D | 211:ac8251b067d2 | 95 | Gyro.PLC_Eror = SinMns-SinPls; |
Kovalev_D | 211:ac8251b067d2 | 96 | if(Gyro.RgConA&0x8) |
Kovalev_D | 211:ac8251b067d2 | 97 | { |
Kovalev_D | 211:ac8251b067d2 | 98 | if(Gyro.PLC_Eror>0) {Spi.DAC_B+=Gyro.PLC_Gain;} |
Kovalev_D | 211:ac8251b067d2 | 99 | else {Spi.DAC_B-=Gyro.PLC_Gain;} |
Kovalev_D | 211:ac8251b067d2 | 100 | } |
Kovalev_D | 211:ac8251b067d2 | 101 | if(Gyro.PLC_Eror>0) {Gyro.PLC_Eror_count++;} |
Kovalev_D | 211:ac8251b067d2 | 102 | else {Gyro.PLC_Eror_count--;} |
Kovalev_D | 211:ac8251b067d2 | 103 | |
Kovalev_D | 211:ac8251b067d2 | 104 | if(Gyro.LG_Type==1) |
Kovalev_D | 211:ac8251b067d2 | 105 | { |
Kovalev_D | 211:ac8251b067d2 | 106 | if ( Spi.DAC_B < Gyro.HighTreshold ) Spi.DAC_B = (Gyro.ResetLevelHeat); |
Kovalev_D | 211:ac8251b067d2 | 107 | else if ( Spi.DAC_B > Gyro.DownTreshold ) Spi.DAC_B = (Gyro.ResetLevelCool); |
Kovalev_D | 211:ac8251b067d2 | 108 | |
Kovalev_D | 211:ac8251b067d2 | 109 | } |
Kovalev_D | 211:ac8251b067d2 | 110 | else |
Kovalev_D | 211:ac8251b067d2 | 111 | { |
Kovalev_D | 211:ac8251b067d2 | 112 | if ( Spi.DAC_B < 10300 ) Spi.DAC_B = 32000; //проверка на переваливание за границу. |
Kovalev_D | 211:ac8251b067d2 | 113 | else if ( Spi.DAC_B > 57000 ) Spi.DAC_B = 32000; |
Kovalev_D | 211:ac8251b067d2 | 114 | } |
Kovalev_D | 211:ac8251b067d2 | 115 | |
Kovalev_D | 211:ac8251b067d2 | 116 | SinPls=0; |
Kovalev_D | 197:7a05523bf588 | 117 | SinMns=0; |
Kovalev_D | 211:ac8251b067d2 | 118 | } |
Kovalev_D | 197:7a05523bf588 | 119 | } |
Kovalev_D | 197:7a05523bf588 | 120 | |
Kovalev_D | 208:19150d2b528f | 121 | |
Kovalev_D | 209:224e7331a061 | 122 | void PLCRegul250(void) |
Kovalev_D | 209:224e7331a061 | 123 | { |
Kovalev_D | 209:224e7331a061 | 124 | unsigned int temp; |
Kovalev_D | 209:224e7331a061 | 125 | static int CountFaza; |
Kovalev_D | 209:224e7331a061 | 126 | temp = MODCount; |
Kovalev_D | 209:224e7331a061 | 127 | for (CountFaza = 0; CountFaza <32; CountFaza++ ) SinPls+= BuffADC_64Point[ (CountFaza + Gyro.PLC_Phase) & 0x3f]; |
Kovalev_D | 209:224e7331a061 | 128 | for (CountFaza = 32; CountFaza <64; CountFaza++) SinMns+= BuffADC_64Point[ (CountFaza + Gyro.PLC_Phase) & 0x3f]; |
Kovalev_D | 209:224e7331a061 | 129 | Gyro.PLC_Eror = SinMns-SinPls; |
Kovalev_D | 211:ac8251b067d2 | 130 | /* sprintf((Time)," %d %d %d %d %d\r\n",Spi.ADC5, Spi.DAC_B, SinPls, SinMns, Gyro.PLC_Eror); |
Kovalev_D | 209:224e7331a061 | 131 | WriteCon(Time);*/ |
Kovalev_D | 209:224e7331a061 | 132 | if(Gyro.RgConA&0x8) |
Kovalev_D | 209:224e7331a061 | 133 | { |
Kovalev_D | 209:224e7331a061 | 134 | if(Gyro.PLC_Eror>0) {Spi.DAC_B+=1 * Gyro.PLC_Gain;} |
Kovalev_D | 209:224e7331a061 | 135 | else {Spi.DAC_B-=1 * Gyro.PLC_Gain;} |
Kovalev_D | 209:224e7331a061 | 136 | } |
Kovalev_D | 209:224e7331a061 | 137 | if(Gyro.PLC_Eror>0) {Gyro.PLC_Eror_count++;} |
Kovalev_D | 209:224e7331a061 | 138 | else {Gyro.PLC_Eror_count--;} |
Kovalev_D | 209:224e7331a061 | 139 | |
Kovalev_D | 209:224e7331a061 | 140 | if ( Spi.DAC_B < 10300 ) Spi.DAC_B = 32000; //проверка на переваливание за границу. |
Kovalev_D | 209:224e7331a061 | 141 | else if ( Spi.DAC_B > 57000 ) Spi.DAC_B = 32000; |
igor_v | 110:6406b7ac0442 | 142 | |
Kovalev_D | 209:224e7331a061 | 143 | SinPls=0; |
Kovalev_D | 209:224e7331a061 | 144 | SinMns=0; |
Kovalev_D | 209:224e7331a061 | 145 | } |
Kovalev_D | 211:ac8251b067d2 | 146 | void HFORegul(void) |
Kovalev_D | 211:ac8251b067d2 | 147 | { |
Kovalev_D | 211:ac8251b067d2 | 148 | RegulADC=32767-Spi.ADC5; |
Kovalev_D | 211:ac8251b067d2 | 149 | DeltaRegul=((Gyro.HFO_ref-RegulADC)>>11); |
Kovalev_D | 211:ac8251b067d2 | 150 | if(Gyro.RgConA&0x2) |
Kovalev_D | 211:ac8251b067d2 | 151 | { |
Kovalev_D | 211:ac8251b067d2 | 152 | Spi.DAC_A-=DeltaRegul*Gyro.HFO_Gain; |
Kovalev_D | 212:8d6784491bae | 153 | |
Kovalev_D | 212:8d6784491bae | 154 | if(Spi.DAC_A>Gyro.HFO_Min) Spi.DAC_A-=0x7ff; |
Kovalev_D | 212:8d6784491bae | 155 | else if(Spi.DAC_A<Gyro.HFO_Max) Spi.DAC_A+=0x7ff; |
Kovalev_D | 211:ac8251b067d2 | 156 | } |
Kovalev_D | 211:ac8251b067d2 | 157 | |
Kovalev_D | 211:ac8251b067d2 | 158 | } |
Kovalev_D | 208:19150d2b528f | 159 | |
Kovalev_D | 208:19150d2b528f | 160 | |
Kovalev_D | 208:19150d2b528f | 161 | |
Kovalev_D | 208:19150d2b528f | 162 | // Spi.DAC_B-=ADCDIF>>6; |
Kovalev_D | 208:19150d2b528f | 163 | |
Kovalev_D | 147:1aed74f19a8f | 164 | void ADS_Acum(void) |
Kovalev_D | 147:1aed74f19a8f | 165 | { |
Kovalev_D | 157:1069c80f4944 | 166 | Spi.ADC_NewData = 0; |
Kovalev_D | 209:224e7331a061 | 167 | // Gyro.Termo = (unsigned int)(((Spi.ADC1>>1) + Gyro.Tmp_OffsetT4) * Gyro.Tmp_scaleT4); |
Kovalev_D | 209:224e7331a061 | 168 | Gyro.Termo = (unsigned int)(Spi.ADC1>>1); |
Kovalev_D | 209:224e7331a061 | 169 | Gyro.IN1_Accum += Spi.ADC2; |
Kovalev_D | 209:224e7331a061 | 170 | Gyro.IN2_Accum += Spi.ADC3; |
Kovalev_D | 209:224e7331a061 | 171 | // Gyro.DeltaT = (unsigned int)(((Spi.ADC4>>1) + Gyro.Tmp_OffsetT5) * Gyro.Tmp_scaleT5); |
Kovalev_D | 209:224e7331a061 | 172 | Gyro.DeltaT = (unsigned int)(Spi.ADC4>>1); |
Kovalev_D | 208:19150d2b528f | 173 | |
Kovalev_D | 172:ef7bf1663645 | 174 | TempA = (0xffff - Spi.ADC5); // перевернем знак и умножим на два (было 32000...0 стало 0 ...32000 /*сдвиг(<<1) стало 0 ...64000*/) |
Kovalev_D | 211:ac8251b067d2 | 175 | Gyro.TermLM = Spi.ADC1; |
Kovalev_D | 157:1069c80f4944 | 176 | Gyro.ADF_Accum += TempA; |
Kovalev_D | 157:1069c80f4944 | 177 | Gyro.ADS_Accum += TempA; |
Kovalev_D | 208:19150d2b528f | 178 | /// Gyro.ADS_AccumTermLM+=TempTermLM; |
Kovalev_D | 157:1069c80f4944 | 179 | Gyro.ADF_Count ++; |
Kovalev_D | 157:1069c80f4944 | 180 | Gyro.ADS_Count ++; |
Kovalev_D | 209:224e7331a061 | 181 | Gyro.ADM_Count ++; |
Kovalev_D | 209:224e7331a061 | 182 | /* sprintf((Time),"%d %d\r\n",((Gyro.In1>>1) - 0x4fff),(Spi.DAC_B-0x4fff)); |
Kovalev_D | 209:224e7331a061 | 183 | WriteCon(Time);*/ |
Kovalev_D | 209:224e7331a061 | 184 | if (Gyro.ADM_Count > 255) { |
Kovalev_D | 209:224e7331a061 | 185 | Gyro.In1 = Gyro.IN1_Accum>>8; |
Kovalev_D | 209:224e7331a061 | 186 | Gyro.In2 = Gyro.IN2_Accum>>8; |
Kovalev_D | 209:224e7331a061 | 187 | Gyro.IN1_Accum=0; |
Kovalev_D | 209:224e7331a061 | 188 | Gyro.IN2_Accum=0; |
Kovalev_D | 209:224e7331a061 | 189 | Gyro.ADM_Count=0; |
Kovalev_D | 147:1aed74f19a8f | 190 | |
Kovalev_D | 209:224e7331a061 | 191 | } |
Kovalev_D | 207:d1ce992f5d17 | 192 | if (Gyro.ADF_Count > 15) { // если прошло 16 тактов виброподвеса |
Kovalev_D | 172:ef7bf1663645 | 193 | Gyro.AD_Fast = Gyro.ADF_Accum << 11; //обновляем данные и приводим в один масштаб |
Kovalev_D | 157:1069c80f4944 | 194 | Gyro.ADF_Count = 0;// |
Kovalev_D | 157:1069c80f4944 | 195 | Gyro.ADF_Accum = 0; |
Kovalev_D | 157:1069c80f4944 | 196 | Gyro.ADF_NewData = 1; |
Kovalev_D | 157:1069c80f4944 | 197 | } |
Kovalev_D | 207:d1ce992f5d17 | 198 | if (Gyro.ADS_Count > 255) { // если прошло 256 тактов виброподвеса |
Kovalev_D | 172:ef7bf1663645 | 199 | Gyro.AD_Slow = Gyro.ADS_Accum << 7; //обновляем данные и приводим в один масштаб |
Kovalev_D | 211:ac8251b067d2 | 200 | // Gyro.TermLM = Gyro.ADS_AccumTermLM << 3; |
Kovalev_D | 157:1069c80f4944 | 201 | Gyro.ADS_Count = 0; |
Kovalev_D | 157:1069c80f4944 | 202 | Gyro.ADS_Accum = 0; |
Kovalev_D | 158:0c8342e1837a | 203 | Gyro.ADS_AccumTermLM=0; |
Kovalev_D | 207:d1ce992f5d17 | 204 | Gyro.ADS_NewData = 1; |
Kovalev_D | 209:224e7331a061 | 205 | } |
Kovalev_D | 147:1aed74f19a8f | 206 | } |
igor_v | 114:5cc38a53d8a7 | 207 | void SPI_Exchange(void) // новая функция чтения, в нецй не должно быть ничего лишнего |
Kovalev_D | 157:1069c80f4944 | 208 | { |
Kovalev_D | 157:1069c80f4944 | 209 | unsigned int DummySPI; |
Kovalev_D | 197:7a05523bf588 | 210 | //unsigned int ADC5Dif; |
Kovalev_D | 197:7a05523bf588 | 211 | ADC5New = LPC_SSP0->DR;// Чтение АЦП |
Kovalev_D | 207:d1ce992f5d17 | 212 | //Spi.ADC5_Accum += LPC_SSP0->DR; |
igor_v | 110:6406b7ac0442 | 213 | Spi.ADC4_Accum += LPC_SSP0->DR; |
igor_v | 110:6406b7ac0442 | 214 | Spi.ADC3_Accum += LPC_SSP0->DR; |
igor_v | 110:6406b7ac0442 | 215 | Spi.ADC2_Accum += LPC_SSP0->DR; |
igor_v | 110:6406b7ac0442 | 216 | Spi.ADC1_Accum += LPC_SSP0->DR; |
Kovalev_D | 207:d1ce992f5d17 | 217 | Spi.ADC5_Accum += ADC5New; |
Kovalev_D | 209:224e7331a061 | 218 | |
Kovalev_D | 207:d1ce992f5d17 | 219 | while (LPC_SSP0->SR & RX_SSP_notEMPT) |
Kovalev_D | 207:d1ce992f5d17 | 220 | { |
Kovalev_D | 170:d099c3025f87 | 221 | DummySPI = LPC_SSP0->DR; //если буфер SPI не пуст.//очистить буфер. |
Kovalev_D | 157:1069c80f4944 | 222 | } |
Kovalev_D | 112:4a96133a1311 | 223 | DAC_OutPut(); |
Kovalev_D | 157:1069c80f4944 | 224 | if (CountV31 == 0) { // просто фильтруем по 32 точкам. |
Kovalev_D | 197:7a05523bf588 | 225 | // выставояем бит, что есть новы данные |
Kovalev_D | 157:1069c80f4944 | 226 | Spi.ADC1 = Spi.ADC1_Accum >> 5; // подгоотавливаем данные (в той эе сетке) те ADC1 0..65535 |
Kovalev_D | 157:1069c80f4944 | 227 | Spi.ADC2 = Spi.ADC2_Accum >> 5; |
Kovalev_D | 157:1069c80f4944 | 228 | Spi.ADC3 = Spi.ADC3_Accum >> 5; |
Kovalev_D | 157:1069c80f4944 | 229 | Spi.ADC4 = Spi.ADC4_Accum >> 5; |
Kovalev_D | 157:1069c80f4944 | 230 | Spi.ADC5 = Spi.ADC5_Accum >> 5; |
Kovalev_D | 157:1069c80f4944 | 231 | Spi.ADC1_Accum = 0; // сбрасывкем аккамулятор |
Kovalev_D | 157:1069c80f4944 | 232 | Spi.ADC2_Accum = 0; |
Kovalev_D | 157:1069c80f4944 | 233 | Spi.ADC3_Accum = 0; |
Kovalev_D | 157:1069c80f4944 | 234 | Spi.ADC4_Accum = 0; |
Kovalev_D | 157:1069c80f4944 | 235 | Spi.ADC5_Accum = 0; |
Kovalev_D | 157:1069c80f4944 | 236 | Spi.ADC_NewData = 1; |
Kovalev_D | 209:224e7331a061 | 237 | |
Kovalev_D | 207:d1ce992f5d17 | 238 | } |
Kovalev_D | 197:7a05523bf588 | 239 | |
Kovalev_D | 209:224e7331a061 | 240 | if(!MODFlag) BuffADC_64Point[CountV64]=ADC5New; |
Kovalev_D | 197:7a05523bf588 | 241 | Buff_ADC_5[CountV255] = (0x7fff-ADC5New)<<2; |
Kovalev_D | 113:8be429494918 | 242 | |
Kovalev_D | 112:4a96133a1311 | 243 | } |
Kovalev_D | 113:8be429494918 | 244 | |
Kovalev_D | 190:289514f730ee | 245 | void ShowMod(void)//технологическая функция для просмотра в ориджине мод на всем диапазпне цап |
Kovalev_D | 158:0c8342e1837a | 246 | { |
Kovalev_D | 158:0c8342e1837a | 247 | |
Kovalev_D | 158:0c8342e1837a | 248 | ////////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 158:0c8342e1837a | 249 | //////////////////////////////////смотрим все моды///////////////////////////////////////////////// |
Kovalev_D | 158:0c8342e1837a | 250 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 197:7a05523bf588 | 251 | if(dispersion>5) |
Kovalev_D | 197:7a05523bf588 | 252 | { |
Kovalev_D | 197:7a05523bf588 | 253 | if( (Gyro.PLC_Lern<60000)&&(Gyro.PLC_Error2Mode >1))//пробигаем по нескольким значениям цап(60*0х3с=0хВВ8) для определения максимальной амплитуды. |
Kovalev_D | 158:0c8342e1837a | 254 | { |
Kovalev_D | 158:0c8342e1837a | 255 | Gyro.PLC_Error2Mode--; |
Kovalev_D | 158:0c8342e1837a | 256 | Gyro.PLC_Lern++; |
Kovalev_D | 197:7a05523bf588 | 257 | Spi.DAC_B += tempstrafe*side; |
Kovalev_D | 197:7a05523bf588 | 258 | if(side>0)side=(-1); |
Kovalev_D | 197:7a05523bf588 | 259 | else side = 1; |
Kovalev_D | 197:7a05523bf588 | 260 | tempstrafe-=40; |
Kovalev_D | 197:7a05523bf588 | 261 | dispersion=0; |
Kovalev_D | 168:f4a6abb18358 | 262 | } |
Kovalev_D | 197:7a05523bf588 | 263 | else {Gyro.LogPLC=0;} |
Kovalev_D | 197:7a05523bf588 | 264 | } |
Kovalev_D | 197:7a05523bf588 | 265 | else dispersion++; |
Kovalev_D | 197:7a05523bf588 | 266 | sprintf((Time),"%d %d %d %d \r\n", Gyro.CuruAngle, Spi.DAC_B, Gyro.AD_Slow, Gyro.Termo); |
Kovalev_D | 197:7a05523bf588 | 267 | Gyro.CuruAngle=0; |
Kovalev_D | 197:7a05523bf588 | 268 | WriteCon(Time); |
Kovalev_D | 158:0c8342e1837a | 269 | } |
Kovalev_D | 209:224e7331a061 | 270 | void ShowMod2(void)//технологическая функция для просмотра в ориджине мод на всем диапазпне цап |
Kovalev_D | 209:224e7331a061 | 271 | { |
Kovalev_D | 211:ac8251b067d2 | 272 | if(dispersion>3) |
Kovalev_D | 211:ac8251b067d2 | 273 | { |
Kovalev_D | 211:ac8251b067d2 | 274 | unsigned int step = 50, ENDMOD=32767; |
Kovalev_D | 209:224e7331a061 | 275 | sprintf((Time),"%d %d %d %d %d %d %d\r\n", Gyro.CuruAngle, Spi.DAC_B, Gyro.AD_Slow, Spi.ADC5, 0xfFFf-Spi.ADC1, Spi.ADC1, Gyro.Termo); |
Kovalev_D | 209:224e7331a061 | 276 | Gyro.CuruAngle=0; |
Kovalev_D | 209:224e7331a061 | 277 | WriteCon(Time); |
Kovalev_D | 211:ac8251b067d2 | 278 | Spi.DAC_B-=step; |
Kovalev_D | 211:ac8251b067d2 | 279 | if(Spi.DAC_B<ENDMOD) |
Kovalev_D | 211:ac8251b067d2 | 280 | { |
Kovalev_D | 211:ac8251b067d2 | 281 | Gyro.LogMod=0; |
Kovalev_D | 211:ac8251b067d2 | 282 | PlcON |
Kovalev_D | 211:ac8251b067d2 | 283 | Spi.DAC_B = 32000; |
Kovalev_D | 211:ac8251b067d2 | 284 | } |
Kovalev_D | 211:ac8251b067d2 | 285 | dispersion=0; |
Kovalev_D | 209:224e7331a061 | 286 | } |
Kovalev_D | 211:ac8251b067d2 | 287 | else dispersion++; |
Kovalev_D | 191:40028201ddad | 288 | } |
Kovalev_D | 112:4a96133a1311 | 289 | void DAC_OutPut(void)//выдача в цапы |
igor_v | 0:8ad47e2b6f00 | 290 | { |
Kovalev_D | 208:19150d2b528f | 291 | if(Gyro.RgConA&0x10) Modulator(); |
Kovalev_D | 157:1069c80f4944 | 292 | LPC_SSP0->DR=0x5555; |
igor_v | 31:c783288001b5 | 293 | LPC_SSP0->DR=0x5555; |
igor_v | 31:c783288001b5 | 294 | LPC_SSP0->DR=0x5555; |
igor_v | 0:8ad47e2b6f00 | 295 | |
Kovalev_D | 209:224e7331a061 | 296 | if (CountV31 & 1) |
Kovalev_D | 209:224e7331a061 | 297 | { //если нечетный такт то |
Kovalev_D | 197:7a05523bf588 | 298 | LPC_SSP0->DR = WRITE_DAC0; //e.команда для ЦАП_0 передавать. |
igor_v | 31:c783288001b5 | 299 | LPC_SSP0->DR = (Spi.DAC_A); //e. передача 12 бит |
Kovalev_D | 209:224e7331a061 | 300 | } |
Kovalev_D | 209:224e7331a061 | 301 | else |
Kovalev_D | 209:224e7331a061 | 302 | { //если такт четный. |
Kovalev_D | 157:1069c80f4944 | 303 | LPC_SSP0->DR = WRITE_DAC1 ; //e.команда для ЦАП_1 передавать. |
Kovalev_D | 205:775d54fdf646 | 304 | LPC_SSP0->DR = (Spi.DAC_B); |
igor_v | 31:c783288001b5 | 305 | } |
Kovalev_D | 112:4a96133a1311 | 306 | } |
Kovalev_D | 112:4a96133a1311 | 307 | |
Kovalev_D | 112:4a96133a1311 | 308 | |
Kovalev_D | 113:8be429494918 | 309 | |
Kovalev_D | 113:8be429494918 | 310 | |
Kovalev_D | 113:8be429494918 | 311 | |
Kovalev_D | 113:8be429494918 | 312 |