![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
fork
Fork of LG by
QEI.c@87:7e575d26d6d0, 2016-03-24 (annotated)
- Committer:
- Kovalev_D
- Date:
- Thu Mar 24 09:16:55 2016 +0000
- Revision:
- 87:7e575d26d6d0
- Parent:
- 86:398da56ef751
- Child:
- 92:c892f0311aa7
GLD_Init
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
igor_v | 1:f2adcae3d304 | 1 | #include "Global.h" |
igor_v | 0:8ad47e2b6f00 | 2 | |
igor_v | 21:bc8c1cec3da6 | 3 | |
Kovalev_D | 86:398da56ef751 | 4 | |
Kovalev_D | 86:398da56ef751 | 5 | |
Kovalev_D | 86:398da56ef751 | 6 | int CuruAngle ; |
Kovalev_D | 86:398da56ef751 | 7 | |
igor_v | 21:bc8c1cec3da6 | 8 | int Dif_QEI; |
igor_v | 42:6fc307c4963e | 9 | |
igor_v | 21:bc8c1cec3da6 | 10 | int FFF=0;//для заплатки |
igor_v | 0:8ad47e2b6f00 | 11 | |
igor_v | 42:6fc307c4963e | 12 | |
Kovalev_D | 86:398da56ef751 | 13 | int Pulse_8Point; |
Kovalev_D | 86:398da56ef751 | 14 | int Pulse_16Point; |
Kovalev_D | 86:398da56ef751 | 15 | int Pulse_32Point; |
Kovalev_D | 86:398da56ef751 | 16 | int Pulse_16PointD; |
igor_v | 21:bc8c1cec3da6 | 17 | unsigned int Iras=0,Temp_F_ras=0; |
igor_v | 21:bc8c1cec3da6 | 18 | int yy = 0; |
igor_v | 0:8ad47e2b6f00 | 19 | |
igor_v | 0:8ad47e2b6f00 | 20 | |
igor_v | 42:6fc307c4963e | 21 | |
igor_v | 42:6fc307c4963e | 22 | |
Kovalev_D | 86:398da56ef751 | 23 | int Buff_32Point [32]; |
igor_v | 43:3f7c8a0ea59c | 24 | int Buff_16Point [32]; |
igor_v | 43:3f7c8a0ea59c | 25 | int Buff_16PointD [32]; |
igor_v | 43:3f7c8a0ea59c | 26 | int Buff_8Point [32]; |
igor_v | 43:3f7c8a0ea59c | 27 | int Buff_Restored_sin [32]; |
igor_v | 43:3f7c8a0ea59c | 28 | int Buff_1Point [256]; // этот на 256 |
igor_v | 42:6fc307c4963e | 29 | |
igor_v | 42:6fc307c4963e | 30 | |
igor_v | 42:6fc307c4963e | 31 | |
Kovalev_D | 86:398da56ef751 | 32 | int unsigned Cur_QEI, Last_QEI; |
igor_v | 21:bc8c1cec3da6 | 33 | |
igor_v | 43:3f7c8a0ea59c | 34 | // ДАВАЙ попробуем сделать буфера в целых (знаковы) |
Kovalev_D | 86:398da56ef751 | 35 | |
igor_v | 21:bc8c1cec3da6 | 36 | void D_QEI(void) |
igor_v | 21:bc8c1cec3da6 | 37 | { |
igor_v | 21:bc8c1cec3da6 | 38 | Dif_QEI=0; |
igor_v | 21:bc8c1cec3da6 | 39 | Cur_QEI = LPC_QEI->POS & 0xFFFF; // считывание текущего значения энкодера. |
igor_v | 21:bc8c1cec3da6 | 40 | Dif_QEI = (Cur_QEI - Last_QEI); // получение приращения.() |
igor_v | 21:bc8c1cec3da6 | 41 | Last_QEI = Cur_QEI; // запись текущего значения энкодера в регистр предыдущего значения. |
igor_v | 21:bc8c1cec3da6 | 42 | |
igor_v | 21:bc8c1cec3da6 | 43 | if (Dif_QEI < -0xfff) Dif_QEI += 0x10000; // обработка прохода значения через ноль |
igor_v | 21:bc8c1cec3da6 | 44 | if (Dif_QEI > 0xfff) Dif_QEI -= 0x10000; // обработка прохода значения через ноль |
igor_v | 0:8ad47e2b6f00 | 45 | |
igor_v | 0:8ad47e2b6f00 | 46 | |
Kovalev_D | 45:cbc955aecebe | 47 | Buff_1Point[CountV255] = /*(unsigned int)*/ (Dif_QEI /* + 0xffff*/ );// накопление в буфер еденичных значений приращения по каждому такту. |
igor_v | 21:bc8c1cec3da6 | 48 | |
igor_v | 21:bc8c1cec3da6 | 49 | //////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 50 | /////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 51 | |
igor_v | 21:bc8c1cec3da6 | 52 | if (LPC_QEI->STAT) { //e. "+" direction //r. стали вращаться в "+" сторону |
igor_v | 30:17c84ed091b3 | 53 | Gyro.Cnt_Mns = Dif_QEI; |
igor_v | 21:bc8c1cec3da6 | 54 | } else { |
igor_v | 30:17c84ed091b3 | 55 | Gyro.Cnt_Pls = -Dif_QEI; |
igor_v | 21:bc8c1cec3da6 | 56 | } |
igor_v | 42:6fc307c4963e | 57 | |
igor_v | 21:bc8c1cec3da6 | 58 | ////////// ???? Заплатка |
igor_v | 21:bc8c1cec3da6 | 59 | ////////// ???? Проблема начального заполнения буферов |
igor_v | 21:bc8c1cec3da6 | 60 | ////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 61 | if(FFF==1) { // если прошло 32 такта вибро подвеса начать заполнять остальные буверы. |
igor_v | 21:bc8c1cec3da6 | 62 | Pulse_8Point += Buff_1Point[CountV255]; |
igor_v | 21:bc8c1cec3da6 | 63 | Pulse_8Point -= Buff_1Point[(CountV255-8) & 0xff]; // заполнение буфера накопленых приращений за 8 тактов |
Kovalev_D | 45:cbc955aecebe | 64 | Buff_8Point[CountV255] = /*(unsigned int)*/ (Pulse_8Point/* + 0xffff*/); |
igor_v | 0:8ad47e2b6f00 | 65 | |
igor_v | 21:bc8c1cec3da6 | 66 | Pulse_16Point += Buff_1Point[CountV255]; |
igor_v | 21:bc8c1cec3da6 | 67 | Pulse_16Point -= Buff_1Point[(CountV255-16) & 0xff]; // заполнение буфера накопленых приращений за 16 тактов |
Kovalev_D | 45:cbc955aecebe | 68 | Buff_16Point[CountV255] = /*(unsigned int)*/ (Pulse_16Point /*+ 0xffff*/); |
igor_v | 21:bc8c1cec3da6 | 69 | |
igor_v | 21:bc8c1cec3da6 | 70 | Pulse_32Point += Buff_1Point[CountV255]; |
igor_v | 21:bc8c1cec3da6 | 71 | Pulse_32Point -= Buff_1Point[(CountV255-32) & 0xff]; // заполнение буфера накопленых приращений за 32 тактов |
Kovalev_D | 45:cbc955aecebe | 72 | Gyro.Cnt_Dif = (Pulse_32Point/*+ 0xffff*/); |
Kovalev_D | 45:cbc955aecebe | 73 | Buff_32Point[CountV255] = /*(unsigned int)*/ (Pulse_32Point /*+ 0xffff*/); |
igor_v | 0:8ad47e2b6f00 | 74 | |
igor_v | 21:bc8c1cec3da6 | 75 | Pulse_16PointD += Buff_1Point[CountV255]; |
igor_v | 21:bc8c1cec3da6 | 76 | Pulse_16PointD -= Buff_1Point[(CountV255-16) & 0xff]; // заполнение буфера накопленых приращений за 16 тактов Двойныз |
igor_v | 21:bc8c1cec3da6 | 77 | Pulse_16PointD += Buff_1Point[(CountV255-32) & 0xff]; // |
igor_v | 21:bc8c1cec3da6 | 78 | Pulse_16PointD -= Buff_1Point[(CountV255-48) & 0xff]; // з |
igor_v | 21:bc8c1cec3da6 | 79 | |
Kovalev_D | 45:cbc955aecebe | 80 | Buff_16PointD[CountV255] = /*(unsigned int)*/ (Pulse_16PointD /*+ 0xffff*/); |
igor_v | 21:bc8c1cec3da6 | 81 | |
Kovalev_D | 45:cbc955aecebe | 82 | Buff_Restored_sin [CountV255]= /*(unsigned int)*/( Buff_16PointD [ CountV255] /*+ 65536 */ - Buff_32Point[CountV255] ); |
igor_v | 21:bc8c1cec3da6 | 83 | |
igor_v | 0:8ad47e2b6f00 | 84 | |
igor_v | 0:8ad47e2b6f00 | 85 | |
Kovalev_D | 87:7e575d26d6d0 | 86 | if(Buff_Restored_sin [CountV31] > 0) |
Kovalev_D | 87:7e575d26d6d0 | 87 | Temp_F_ras += Buff_Restored_sin [CountV31]; |
Kovalev_D | 87:7e575d26d6d0 | 88 | else Temp_F_ras -= Buff_Restored_sin [CountV31]; // расчет амплитуды |
igor_v | 21:bc8c1cec3da6 | 89 | |
Kovalev_D | 87:7e575d26d6d0 | 90 | if (CountV31 == 0) { // если определеный так, то переписываем амиплитуду |
Kovalev_D | 87:7e575d26d6d0 | 91 | Gyro.F_ras = Temp_F_ras; |
Kovalev_D | 87:7e575d26d6d0 | 92 | Temp_F_ras = 0; |
Kovalev_D | 87:7e575d26d6d0 | 93 | } |
Kovalev_D | 87:7e575d26d6d0 | 94 | |
igor_v | 0:8ad47e2b6f00 | 95 | |
igor_v | 21:bc8c1cec3da6 | 96 | } else if(CountV255 == 255) { |
igor_v | 21:bc8c1cec3da6 | 97 | FFF=1;//временная заплатка для паузы перед заполнением остальных буферов |
Kovalev_D | 45:cbc955aecebe | 98 | for (yy = 0; yy < 31; yy++ ) { |
igor_v | 21:bc8c1cec3da6 | 99 | Buff_1Point [yy] = 0xffff; |
igor_v | 21:bc8c1cec3da6 | 100 | Buff_16Point [yy] = 0xffff; |
igor_v | 21:bc8c1cec3da6 | 101 | Buff_32Point [yy] = 0xffff; |
igor_v | 21:bc8c1cec3da6 | 102 | Buff_16PointD [yy] = 0xffff; |
igor_v | 21:bc8c1cec3da6 | 103 | } |
igor_v | 0:8ad47e2b6f00 | 104 | |
igor_v | 21:bc8c1cec3da6 | 105 | } |
igor_v | 21:bc8c1cec3da6 | 106 | } |