![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
fork
Fork of LG by
QEI.c@189:8a16378724c4, 2016-08-22 (annotated)
- Committer:
- Kovalev_D
- Date:
- Mon Aug 22 10:39:08 2016 +0000
- Revision:
- 189:8a16378724c4
- Parent:
- 183:7e200f4d9b16
- Child:
- 190:289514f730ee
?????? ?? ??????????? ??????? ? ????????? ?????
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 | 183:7e200f4d9b16 | 15 | int Pulse_64Point; |
Kovalev_D | 86:398da56ef751 | 16 | int Pulse_16PointD; |
Kovalev_D | 112:4a96133a1311 | 17 | int CaunAddPlus =0;//счетчик ипульсов энкодера"+" за такт ВП |
Kovalev_D | 112:4a96133a1311 | 18 | int CaunAddMin =0;//счетчик ипульсов энкодера"-" за такт ВП |
Kovalev_D | 108:030cdde08314 | 19 | |
Kovalev_D | 112:4a96133a1311 | 20 | int unsigned Cur_QEI, Last_QEI; //текушее и предыдущее,(единичное) значение энкодера |
Kovalev_D | 108:030cdde08314 | 21 | |
Kovalev_D | 112:4a96133a1311 | 22 | int Buff_1Point [256]; // этот на 256 |
Kovalev_D | 183:7e200f4d9b16 | 23 | int Buff_32Point [32]; |
Kovalev_D | 183:7e200f4d9b16 | 24 | int Buff_64Point [32]; |
igor_v | 43:3f7c8a0ea59c | 25 | int Buff_16Point [32]; |
igor_v | 43:3f7c8a0ea59c | 26 | int Buff_16PointD [32]; |
igor_v | 43:3f7c8a0ea59c | 27 | int Buff_8Point [32]; |
igor_v | 43:3f7c8a0ea59c | 28 | int Buff_Restored_sin [32]; |
Kovalev_D | 108:030cdde08314 | 29 | |
igor_v | 21:bc8c1cec3da6 | 30 | void D_QEI(void) |
igor_v | 21:bc8c1cec3da6 | 31 | { |
igor_v | 21:bc8c1cec3da6 | 32 | Dif_QEI=0; |
igor_v | 21:bc8c1cec3da6 | 33 | Cur_QEI = LPC_QEI->POS & 0xFFFF; // считывание текущего значения энкодера. |
igor_v | 21:bc8c1cec3da6 | 34 | Dif_QEI = (Cur_QEI - Last_QEI); // получение приращения.() |
igor_v | 21:bc8c1cec3da6 | 35 | Last_QEI = Cur_QEI; // запись текущего значения энкодера в регистр предыдущего значения. |
Kovalev_D | 112:4a96133a1311 | 36 | |
igor_v | 21:bc8c1cec3da6 | 37 | if (Dif_QEI < -0xfff) Dif_QEI += 0x10000; // обработка прохода значения через ноль |
igor_v | 21:bc8c1cec3da6 | 38 | if (Dif_QEI > 0xfff) Dif_QEI -= 0x10000; // обработка прохода значения через ноль |
Kovalev_D | 108:030cdde08314 | 39 | Buff_1Point[CountV255] = Dif_QEI ; // накопление в буфер еденичных значений приращения по каждому такту. |
igor_v | 0:8ad47e2b6f00 | 40 | |
Kovalev_D | 112:4a96133a1311 | 41 | |
igor_v | 21:bc8c1cec3da6 | 42 | ////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 108:030cdde08314 | 43 | Pulse_8Point += Buff_1Point[CountV255]; |
igor_v | 21:bc8c1cec3da6 | 44 | Pulse_8Point -= Buff_1Point[(CountV255-8) & 0xff]; // заполнение буфера накопленых приращений за 8 тактов |
Kovalev_D | 112:4a96133a1311 | 45 | Buff_8Point[CountV31] = (Pulse_8Point); |
igor_v | 0:8ad47e2b6f00 | 46 | |
igor_v | 21:bc8c1cec3da6 | 47 | Pulse_16Point += Buff_1Point[CountV255]; |
igor_v | 21:bc8c1cec3da6 | 48 | Pulse_16Point -= Buff_1Point[(CountV255-16) & 0xff]; // заполнение буфера накопленых приращений за 16 тактов |
Kovalev_D | 112:4a96133a1311 | 49 | Buff_16Point[CountV31] = (Pulse_16Point ); |
igor_v | 21:bc8c1cec3da6 | 50 | |
igor_v | 21:bc8c1cec3da6 | 51 | Pulse_32Point += Buff_1Point[CountV255]; |
igor_v | 21:bc8c1cec3da6 | 52 | Pulse_32Point -= Buff_1Point[(CountV255-32) & 0xff]; // заполнение буфера накопленых приращений за 32 тактов |
Kovalev_D | 112:4a96133a1311 | 53 | Gyro.Cnt_Dif = (Pulse_32Point); |
Kovalev_D | 112:4a96133a1311 | 54 | Buff_32Point[CountV31] = (Pulse_32Point ); |
Kovalev_D | 183:7e200f4d9b16 | 55 | |
Kovalev_D | 183:7e200f4d9b16 | 56 | /* Pulse_64Point += Buff_1Point[CountV255]; |
Kovalev_D | 183:7e200f4d9b16 | 57 | Pulse_64Point -= Buff_1Point[(CountV255-64) & 0xff]; // заполнение буфера накопленых приращений за 32 тактов |
Kovalev_D | 183:7e200f4d9b16 | 58 | Gyro.Cnt_Dif = (Pulse_64Point); |
Kovalev_D | 183:7e200f4d9b16 | 59 | Buff_64Point[CountV31] = (Pulse_64Point ); |
Kovalev_D | 183:7e200f4d9b16 | 60 | */ |
igor_v | 0:8ad47e2b6f00 | 61 | |
igor_v | 21:bc8c1cec3da6 | 62 | Pulse_16PointD += Buff_1Point[CountV255]; |
igor_v | 21:bc8c1cec3da6 | 63 | Pulse_16PointD -= Buff_1Point[(CountV255-16) & 0xff]; // заполнение буфера накопленых приращений за 16 тактов Двойныз |
igor_v | 21:bc8c1cec3da6 | 64 | Pulse_16PointD += Buff_1Point[(CountV255-32) & 0xff]; // |
Kovalev_D | 169:140743e3bb96 | 65 | Pulse_16PointD -= Buff_1Point[(CountV255-48) & 0xff]; // |
Kovalev_D | 108:030cdde08314 | 66 | Buff_16PointD[CountV31] = Pulse_16PointD ; |
Kovalev_D | 183:7e200f4d9b16 | 67 | |
igor_v | 21:bc8c1cec3da6 | 68 | |
Kovalev_D | 112:4a96133a1311 | 69 | |
Kovalev_D | 183:7e200f4d9b16 | 70 | Buff_Restored_sin [CountV31]= Buff_16PointD[CountV31] - Buff_32Point[CountV31]; |
Kovalev_D | 108:030cdde08314 | 71 | if((Buff_Restored_sin [CountV31]) > 0) CaunAddPlus += Buff_Restored_sin [CountV31]; |
Kovalev_D | 108:030cdde08314 | 72 | else CaunAddMin -= (Buff_Restored_sin [CountV31]); // расчет амплитуды |
igor_v | 0:8ad47e2b6f00 | 73 | |
Kovalev_D | 112:4a96133a1311 | 74 | Gyro.CuruAngle += Buff_32Point [CountV31]; |
igor_v | 21:bc8c1cec3da6 | 75 | } |