![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
fork
Fork of LG by
Diff: SPI.c
- Revision:
- 148:7ce8c1fd00f7
- Parent:
- 147:1aed74f19a8f
- Child:
- 150:29c9f7671bac
--- a/SPI.c Fri Apr 29 07:27:50 2016 +0000 +++ b/SPI.c Fri Apr 29 13:53:50 2016 +0000 @@ -7,7 +7,7 @@ int Znak_Amp; int AD_Regul = 0; int temp9; - +int AD_MAX=0; unsigned int Temp_ADC_2; unsigned int Temp_ADC_3; @@ -135,20 +135,21 @@ int tempDelta; int tempDac; int flagmod; - int AD_MAX; + PLC_In = Gyro.AD_Slow; //выбираем даные для фильтрации // PLC_In = Gyro.AD_Fast; //или+,или-(знак) Gyro.PLC_Delta = PLC_In - Gyro.PLC_Old; // узнаем приращение Gyro.PLC_DeltaADD = Gyro.PLC_Delta * Gyro.PLC_ADC_DOld; //приращение с учетом знака (и количества) прошлого приращения Gyro.PLC_Old = PLC_In; // запоминание значения - AD_MAX=1941520832; + //AD_MAX=1943420832; //15728640 + //AD_MAX=1943400; + if(AD_MAX<Gyro.AD_Slow) + {AD_MAX=Gyro.AD_Slow/*+2621440*10;*/;} tempDelta=AD_MAX-Gyro.AD_Slow; if(Gyro.RgConA&0x2) // если включон контур регулирования { - - if ( Gyro.PLC_Error2Mode > 0) {Gyro.PLC_Error2Mode --; Gyro.PLC_ADC_DOld = 0;} // если ошибка(нахожление в двух модовом) else if ( Gyro.PLC_Delta > (3500 * 65536)) {Spi.DAC_B += 2500; Gyro.PLC_Error2Mode = 5; Gyro.PLC_ADC_DOld = 0;} // проверка на двух модовость else if ( Gyro.PLC_Delta < (-3500 * 65536)) {Spi.DAC_B += 2500; Gyro.PLC_Error2Mode = 5; Gyro.PLC_ADC_DOld = 0;} @@ -156,7 +157,6 @@ else if ( Gyro.PLC_DeltaADD < 0) {Gyro.PLC_ADC_DOld = -1;} else { - //Gyro.PLC_Delta=1114111;//если делта 0 то Spi.DAC_B += 4; Gyro.PLC_ADC_DOld = 1; } } @@ -164,28 +164,24 @@ { Gyro.PLC_Error2Mode = 1; Gyro.PLC_DeltaADD = 0; } - - - if(((tempDelta>>18)>50)||((tempDelta>>18)<(-50))) + if(((tempDelta>>18)>30)||((tempDelta>>18)<(-30))) { tempDac=(unsigned int)(tempDelta>>18); - if(tempDac>450) - {tempDac=400; - } - Spi.DAC_B += Gyro.PLC_ADC_DOld * tempDac /*Gyro.PLC_Delta>>18*/; + if(tempDac>450) {tempDac=400;} + Spi.DAC_B += Gyro.PLC_ADC_DOld * tempDac/*Gyro.PLC_Delta>>18*/; tempDac = Gyro.PLC_ADC_DOld * tempDac; flagmod=3; } - else if(((tempDelta>>18)>30)||((tempDelta>>18)<(-30))) + else if(((tempDelta>>18)>10)||((tempDelta>>18)<(-10))) { - tempDac=(unsigned int)(tempDelta>>19); - Spi.DAC_B += Gyro.PLC_ADC_DOld * (tempDac+5); - tempDac = Gyro.PLC_ADC_DOld * (tempDac+5); + tempDac=(unsigned int)(tempDelta>>18); + Spi.DAC_B += Gyro.PLC_ADC_DOld * (tempDac); + tempDac = Gyro.PLC_ADC_DOld * (tempDac); flagmod=2; } else { - tempDac=(unsigned int)(tempDelta>>20); + tempDac=(unsigned int)(tempDelta>>19); Spi.DAC_B += Gyro.PLC_ADC_DOld *tempDac; tempDac = Gyro.PLC_ADC_DOld * tempDac; flagmod=1;