![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
forkd
Fork of LGstaandart by
Diff: SPI.c
- Revision:
- 225:f8fee6c586cc
- Parent:
- 224:598aec95415f
- Child:
- 226:4a4d5bd5fcd7
--- a/SPI.c Tue Nov 21 07:31:05 2017 +0000 +++ b/SPI.c Tue Dec 12 05:53:39 2017 +0000 @@ -32,7 +32,7 @@ int Buff_OUT1 [64]; int Buff_OUT [64]; int RegulADC,DeltaRegul,tempDeltaRegul; -int count10v=0,AMPSUM,AMPSUMP,AMPSUMM,AMPSUM_DESP,AMPSUMPout,AMPSUMMout,AMPSUMout,SumDelta,PLC_EROR,PLC_Flag,HFO_Flag,HFOdelta,HFOregul,HFOSumDelta; +int count10v=0,AmpWorms,MinWorms,MaxWorms,AMPSUM,AMPSUMP,AMPSUMM,AMPSUM_DESP,AMPSUMPout,AMPSUMMout,AMPSUMout,SumDelta,PLC_EROR,PLC_Flag,HFO_Flag,HFOdelta,HFOregul,HFOSumDelta; //int BuffADC_32Point [64]; @@ -208,8 +208,9 @@ - if (count10v>=64*8) + if (count10v>=64*32) { + LoopOn count10v=0; for(int q=0; q<32; q++) @@ -218,6 +219,7 @@ SumBuff -= BuffADC_10v_OLD[q+32]; BuffADC_10v_F [q] = SumBuff; } + for(int q=32; q<64; q++) { SumBuff += BuffADC_10v[q]; @@ -225,27 +227,17 @@ BuffADC_10v_F [q] = SumBuff; } - for(int q=0; q<32; q++) - { - AMPSUMP +=BuffADC_10v_F [q]; - - } - for(int q=32; q<64; q++) - { - AMPSUMM += BuffADC_10v_F [q]; - } - - - - - for(int q=0; q<64; q++) + for(int q=0; q<32; q++) {AMPSUMP += BuffADC_10v_F [q];} + for(int q=32; q<64; q++) {AMPSUMM += BuffADC_10v_F [q];} + + for(int q=0; q<64; q++) { AMPSUM+=BuffADC_10v[q]; AMPSUMout+=BuffADC_10v_F[q]; BuffADC_10v_OLD[q]= BuffADC_10v[q]; - BuffADC_10v[q] =0; + BuffADC_10v[q] =0; } - for(int q=0; q<64; q++) + for(int q=0; q<64; q++) { Buff_OUT[q]=(BuffADC_10v_F[q]-(AMPSUM>>1))>>3; } @@ -253,32 +245,45 @@ /*sprintf((Time),"%d \r\n", Spi.DAC_A); WriteCon(Time);*/ - AMPSUMPout=AMPSUMP; - AMPSUMMout=AMPSUMM; + AMPSUMPout=AMPSUMP>>1; + AMPSUMMout=AMPSUMM>>1; AMPSUMout=AMPSUM; + Delta= (AMPSUMPout - AMPSUMMout); + + // if((Delta<(-5000000))||(Delta>5000000))Delta=0; + SumDelta+=Delta; + Gyro.PLC_Eror_count=SumDelta/Gyro.PLC_Gain; SumDelta-=Gyro.PLC_Gain*Gyro.PLC_Eror_count; + + PLC_EROR+=Gyro.PLC_Eror_count; + + AMPSUM=AMPSUM>>6; AMPSUM=AMPSUM>>3; + AMPSUM=AMPSUM>>2; AMPSUM_DESP=AMPSUM; HFOdelta=(int)((Gyro.HFO_ref)-AMPSUM); - PLC_EROR=Gyro.PLC_Eror_count; + HFOSumDelta+=HFOdelta; HFOregul=HFOSumDelta/(int)(Gyro.HFO_Gain); HFOSumDelta-=Gyro.HFO_Gain*HFOregul; + tempDeltaRegul=HFOregul; + tempDeltaRegul+=HFOdelta; HFO_Flag=1; PLC_Flag=1; AMPSUMM=0; AMPSUMP=0; AMPSUM=0; + LoopOff } } @@ -349,15 +354,16 @@ { if(HFO_Flag) { - switch(HFOregul){ + /* switch(HFOregul){ - // case 1: HFOregul=0; break; - // case -1: HFOregul=0; break; -// case 2: HFOregul=1; break; -// case -2: HFOregul=1; break; + case 1: HFOregul=0; break; + case -1: HFOregul=0; break; + case 2: HFOregul=1; break; + case -2: HFOregul=1; break; - } + }*/ + Spi.DAC_A -= HFOregul; HFO_Flag=0; DeltaRegul=0; @@ -384,25 +390,27 @@ if(PLC_Flag) { PLC_Flag=0; - if (Gyro.PLCDelay){} + if (Gyro.PLCDelay) + { + + } else Spi.DAC_B+=(Gyro.PLC_Eror_count); - sprintf((Time),"%d %d %d\r\n", Gyro.PLC_Eror_count, Gyro.PLCDelay, Spi.DAC_B); - WriteCon(Time); + } } Gyro.PLC_Eror_count=0; if(Gyro.LG_Type==1) { - if(Spi.DAC_B < Gyro.HighTreshold ) + if(Spi.DAC_B > Gyro.HighTreshold ) { Spi.DAC_B = (Gyro.ResetLevelCool); - Gyro.PLCDelay = GyroP.Str.PLCDelay/10; + Gyro.PLCDelay = GyroP.Str.PLCDelay; } - else if(Spi.DAC_B > Gyro.DownTreshold ) + else if(Spi.DAC_B < Gyro.DownTreshold ) { Spi.DAC_B = (Gyro.ResetLevelHeat); - Gyro.PLCDelay = GyroP.Str.PLCDelay/10; + Gyro.PLCDelay = GyroP.Str.PLCDelay; } } else