![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
forkd
Fork of LGstaandart by
Diff: SPI.c
- Revision:
- 214:4c70e452c491
- Parent:
- 213:9953db9543d6
- Child:
- 215:b58b887fd367
diff -r 9953db9543d6 -r 4c70e452c491 SPI.c --- a/SPI.c Wed Jul 26 13:24:39 2017 +0000 +++ b/SPI.c Wed Aug 16 09:00:25 2017 +0000 @@ -16,13 +16,16 @@ unsigned int Temp_ADC_3; unsigned int Temp_ADC_4; unsigned int Temp_ADC_5; +int ADC_5_T; unsigned int TempA; unsigned int TempTermLM; unsigned int conuntPLS; int ADC5Old,ADCDIF=0; int DACModReg; int SinPls=0,SinMns=0; +int TSinPls=0,TSinMns=0; int timer=750; + unsigned int testcount=0; unsigned int ADC5New; unsigned int Buff_ADC_1 [32]; unsigned int Buff_ADC_2 [32]; @@ -30,12 +33,20 @@ unsigned int Buff_ADC_4 [32]; int RegulADC,DeltaRegul,tempDeltaRegul; -unsigned int Buff_ADC_5 [512]; + + + int BuffADC_1Point [255]; unsigned int BuffADC_16Point [64]; -unsigned int BuffADC_32Point [64]; -unsigned int BuffADC_64Point [64]; -unsigned int BuffADC_32PointD [64]; -unsigned int Buff_Restored_Mod [64]; +int BuffADC_32Point [64]; +int BuffADC_64Point [64]; +unsigned int Buff_ADC_5 [255]; +unsigned int BuffADC_testPoint [64]; +int BuffADC_32PointD [64]; + +int Buff_Restored_Mod [64]; + int ADC_1Point; + int ADC_32PointD; + int ADC_64Point; unsigned int PulseADC_16Point; unsigned int PulseADC_32Point; @@ -45,7 +56,7 @@ unsigned int Buff_AMP [256]; unsigned int Buff_AMP64P [256]; -unsigned int TypeMod=2; +unsigned int TypeMod=0; 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}; unsigned int ModArrayTriangle [64]; unsigned int ModArraySaw [64]; @@ -71,7 +82,7 @@ { switch(TypeMod) { - case 0: LPC_DAC->DACR = (ModArraySin [(CountV64-2)&0x3f]*Gyro.ModAmp); break; + case 0: LPC_DAC->DACR = (ModArraySin [(CountV64)&0x3f]*Gyro.ModAmp); break; case 1: LPC_DAC->DACR = (ModArraySaw [CountV64]*Gyro.ModAmp); break; case 2: LPC_DAC->DACR = (ModArrayTriangle [(CountV64-2)&0x3f]*Gyro.ModAmp); break; } @@ -82,22 +93,30 @@ unsigned int temp, Temp_Dac_B=0,Side=0; static int CountFaza; - + + // Temp_Dac_B=(0xffff-Spi.DAC_B); if(conuntPLS<10) { - for (CountFaza = 0; CountFaza <32; CountFaza++ ) SinPls+= BuffADC_64Point[ (CountFaza + Gyro.PLC_Phase) & 0x3f]; - for (CountFaza = 32; CountFaza <64; CountFaza++) SinMns+= BuffADC_64Point[ (CountFaza + Gyro.PLC_Phase) & 0x3f]; - conuntPLS++; + /* for (CountFaza = 0; CountFaza <16; CountFaza++) SinPls+= BuffADC_64Point[ (CountFaza - Gyro.PLC_Phase) & 0x3f]; + for (CountFaza = 16; CountFaza <48; CountFaza++) SinMns+= BuffADC_64Point[ (CountFaza - Gyro.PLC_Phase) & 0x3f]; + for (CountFaza = 48; CountFaza <64; CountFaza++) SinPls+= BuffADC_64Point[ (CountFaza - Gyro.PLC_Phase) & 0x3f]; + conuntPLS++;*/ } else { conuntPLS=0; - Gyro.PLC_Eror = SinMns-SinPls; + Gyro.PLC_Eror = (SinMns-SinPls)>>16; + /*sprintf((Time)," %d %d %d \r\n", SinMns, SinPls,Gyro.PLC_Eror); + WriteCon(Time);*/ + TSinPls= SinPls; + TSinMns=SinMns; + SinPls=0; + SinMns=0; if(Gyro.RgConA&0x8) { - if(Gyro.PLC_Eror>0) {Spi.DAC_B+=Gyro.PLC_Gain;} - else {Spi.DAC_B-=Gyro.PLC_Gain;} + if(Gyro.PLC_Eror>0) {Spi.DAC_B-=Gyro.PLC_Eror*Gyro.PLC_Gain;} + else {Spi.DAC_B+=Gyro.PLC_Eror*Gyro.PLC_Gain;} } if(Gyro.PLC_Eror>0) {Gyro.PLC_Eror_count++;} else {Gyro.PLC_Eror_count--;} @@ -113,9 +132,7 @@ if ( Spi.DAC_B < 10300 ) Spi.DAC_B = 32000; //проверка на переваливание за границу. else if ( Spi.DAC_B > 57000 ) Spi.DAC_B = 32000; } - - SinPls=0; - SinMns=0; + } } @@ -125,10 +142,10 @@ unsigned int temp; static int CountFaza; temp = MODCount; - for (CountFaza = 0; CountFaza <32; CountFaza++ ) SinPls+= BuffADC_64Point[ (CountFaza + Gyro.PLC_Phase) & 0x3f]; - for (CountFaza = 32; CountFaza <64; CountFaza++) SinMns+= BuffADC_64Point[ (CountFaza + Gyro.PLC_Phase) & 0x3f]; + /* for (CountFaza = 0; CountFaza <32; CountFaza++ ) SinPls+= BuffADC_64Point[ (CountFaza - Gyro.PLC_Phase) & 0x3f]; + for (CountFaza = 32; CountFaza <64; CountFaza++) SinMns+= BuffADC_64Point[ (CountFaza - Gyro.PLC_Phase) & 0x3f];*/ Gyro.PLC_Eror = SinMns-SinPls; - /* sprintf((Time)," %d %d %d %d %d\r\n",Spi.ADC5, Spi.DAC_B, SinPls, SinMns, Gyro.PLC_Eror); + /* sprintf((Time)," %d %d %d %d %d\r\n",Spi.ADC5, Spi.DAC_B, SinPls, SinMns, Gyro.PLC_Eror); WriteCon(Time);*/ if(Gyro.RgConA&0x8) { @@ -253,9 +270,26 @@ } - if(!MODFlag) BuffADC_64Point[CountV64]=ADC5New; + + BuffADC_1Point[CountV255]=(0x7fff-ADC5New); + + ADC_64Point += BuffADC_1Point[CountV255 ]; + ADC_64Point -= BuffADC_1Point[(CountV255 - 64) & 0xff]; // заполнение буфера накопленых приращений за 64 тактов + BuffADC_64Point[CountV64] = ADC_64Point; + + + ADC_32PointD -= BuffADC_1Point[(CountV255 - 32) & 0xff]; // заполнение буфера накопленых приращений за 32 тактов + ADC_32PointD += BuffADC_1Point[CountV255]; + BuffADC_32PointD[CountV64] = ADC_32PointD; + + Buff_Restored_Mod[CountV64] = BuffADC_32PointD[CountV64]*2 - BuffADC_64Point[CountV64]; + + + + // BuffADC_64Point[CountV64]=ADC5New; Buff_ADC_5[CountV255] = (0x7fff-ADC5New)<<2; - + + } void ShowMod(void)//технологическая функция для просмотра в ориджине мод на всем диапазпне цап @@ -294,7 +328,7 @@ Spi.DAC_B+=step; if(Spi.DAC_B>ENDMOD) { - Gyro.LogMod=0; + // Gyro.LogMod=0; PlcON Spi.DAC_B = 48000; }