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