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