![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
forkd
Fork of LGstaandart by
Diff: MTimer.c
- Revision:
- 231:079835d508ef
- Parent:
- 228:a8195e1b1123
- Child:
- 232:130a2b5003e6
--- a/MTimer.c Tue Jan 09 13:25:45 2018 +0000 +++ b/MTimer.c Thu Jan 25 13:59:43 2018 +0000 @@ -8,7 +8,7 @@ #include "SPI.h" #include "InputOutput.h" #include "time.h" - +//#define HALFINT 16384 unsigned int CountV64=0; unsigned int CountV31=0; unsigned int CountV255=0; @@ -16,6 +16,8 @@ unsigned int f,MODCount=0; int loop=0; int t; +float aPLC[5]; +float bPLC[5]; ///////////////////////////////////////////////////// /////////////////////EVENT/////////////////////////// ///////////////////////////////////////////////////// @@ -26,8 +28,11 @@ { if(Event1250Hz) { + Gyro.EvenRate7=1; - + +/* sprintf((Time),"%d %d\r\n", Spi.DAC_B, PlcWormDeltaout); + WriteCon(Time);*/ Event1250Hz--; } @@ -56,28 +61,72 @@ ///////////////////////////////////////////////////// ///////////////////// 1Hz /////////////////////////// ///////////////////////////////////////////////////// +/*int InitPlcFilt ( void ) +{ + + int CenterFreq = 12800; + int BandWidth = 50; + float K, R, Cos_x_2, R_x_R; + float pi = 3.1415; + + R = 1.0 - 3.0 * BandWidth; + R_x_R = R * R; + Cos_x_2 = cos(2.0 * pi * CenterFreq) * 2.0; + K = (1.0 - R * Cos_x_2 + R_x_R)/(2.0 - Cos_x_2); + + aPLC[0] = ((1.0 - K)); + aPLC[1] = (((K - R) * Cos_x_2)); + aPLC[2] = ((R_x_R - K)); + + bPLC[0] = 0; + bPLC[1] = ((R * Cos_x_2)); + bPLC[2] = ((- R_x_R)); + + for(int q=0; q<3; q++) + { + sprintf((Time),"%f %f\r\n", aPLC[q],bPLC[q]); + WriteCon(Time); + } + return 0; + +}*/ + + void Event_1Hz(void)// событие раз в 1 Гц { - - //string ster = 255; + static int OldTermoMod; static int tempdac=0,tempdac1,JumpTimer=0; - - - // unsigned int timer; - if (Event1Hz) { - /* timer = time(NULL); */ + + + + if(Gyro.ParamFlag) {/*Switch(Gyro.NP)*/}; + + + + + + + if(Gyro.TemperNewData) + { + Gyro.TemperNewData = 0; + + if(Gyro.TermoMod>0)Gyro.TermoMod = 1; + else if(Gyro.TermoMod==0)Gyro.TermoMod = OldTermoMod; + else Gyro.TermoMod =(-1); + OldTermoMod = Gyro.TermoMod; + } + + PlcWormDeltaout=0; - - if(Gyro.RgConA&0x4) JumpTimer=0; + if(Gyro.RgConA&0x4) JumpTimer=0; else { - /*sprintf((Time),"%d %d\r\n",Gyro.RgConA,JumpTimer); - WriteCon(Time);*/ + JumpTimer++; if(JumpTimer>(Gyro.TimeToJump-1)) { @@ -101,6 +150,7 @@ WriteCon(Time);*/ /*sprintf(Time,"%s %s.",__DATE__, __TIME__ ); //Подготовка даты и времени компиляции WriteCon(Time);*/ + } } @@ -114,34 +164,29 @@ Event1K --; Time1K++;//первый ++ работает каждые 125 (event100kHz)второй был в 100 кГц - if (Time1K > 1000) + if (Time1K > 1007) { - Time1K -=1000; + Time1K =0; Event1Hz ++; } - + } } -void Event_5KHz(void)// событие раз в 5 кГц +void Event_10KHz(void)// событие раз в 5 кГц { int temp=0; - if (Event5K) + if (Event10K) { - Gyro.EvenRate5K++; - Event5K --; + // Gyro.EvenRate10K++; + Event10K --; } } void Event_500Hz(void)// событие раз в 500 Гц { if(Event500Hz) { - if(Gyro.Debag2) - { - sprintf((Time),"%d %d %d\r\n", (0xffff-Spi.DAC_A), ((Spi.DAC_B-0x7fff)&0xffff), BuffADC_128Point[CountV64]); - WriteCon(Time); - - } + Event500Hz--; Gyro.Event_500Hz=1;// Event 500Гц выдачи данных для постройки графика управления вибро } @@ -263,15 +308,15 @@ SPI_Exchange(); //Чтение ADC_SPI LPC_TIM1->IR = 1; - + } /////////////////////////////////////////////////////////////////////// /////////////////////////прерывание таймера 2////////////////////////// /////////////////////////////////////////////////////////////////////// __irq void TIMER2_IRQHandler (void) -{ - /// LoopOn +{ + LPC_TIM2->IR = 1; if (Gyro.UARTFlag) { @@ -287,46 +332,39 @@ Time500Hz++; Time250Hz++; Time100K++; - Time5K++; + Time10K++; //Time2K++; // Time250Hz++; - if (Time1250Hz > 79) + if (Time1250Hz > 1000) { - Time1250Hz -= 80; + Time1250Hz -= 1000; Event1250Hz ++; } - if (Time100K == 100) - { // LoopOn - Time100K = 0; + if (Time100K == 89) + { + + Time100K -= 89; Event1K ++; - // LoopOn + } - if (Time5K > 200000) - { Time5K = 0; - if(Gyro.Debag) - { - for(int q=0; q<64; q++) - { - sprintf((Time),"%i \r\n", ModArraySin [q]); - WriteCon(Time); - } - } - Event5K ++; + if (Time10K > 8) + { + + + Time10K = 0; + + + Event10K ++; + } - if (Time500Hz > 200) + if (Time500Hz > 180) { // LoopOn - Time500Hz -= 200; - Event500Hz ++; + + Time500Hz -= 180; + Event500Hz ++; + } - - if (Time250Hz > 6) - { // LoopOn - Time250Hz -= 6; - Event250Hz ++; - } - - //LoopOff } \ No newline at end of file