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