![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
fork
Fork of LG by
QEI.c@207:d1ce992f5d17, 2017-01-13 (annotated)
- Committer:
- Kovalev_D
- Date:
- Fri Jan 13 08:27:28 2017 +0000
- Revision:
- 207:d1ce992f5d17
- Parent:
- 205:775d54fdf646
- Child:
- 208:19150d2b528f
4566
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 | int Dif_QEI; |
igor_v | 42:6fc307c4963e | 4 | |
igor_v | 21:bc8c1cec3da6 | 5 | int FFF=0;//для заплатки |
igor_v | 0:8ad47e2b6f00 | 6 | |
Kovalev_D | 197:7a05523bf588 | 7 | unsigned int tempmod=64,tempmod2=1; |
igor_v | 42:6fc307c4963e | 8 | |
Kovalev_D | 86:398da56ef751 | 9 | int Pulse_8Point; |
Kovalev_D | 86:398da56ef751 | 10 | int Pulse_16Point; |
Kovalev_D | 86:398da56ef751 | 11 | int Pulse_32Point; |
Kovalev_D | 183:7e200f4d9b16 | 12 | int Pulse_64Point; |
Kovalev_D | 86:398da56ef751 | 13 | int Pulse_16PointD; |
Kovalev_D | 191:40028201ddad | 14 | unsigned int CaunAddPlus =0;//счетчик ипульсов энкодера"+" за такт ВП |
Kovalev_D | 192:d32c8cf7bcd9 | 15 | unsigned int CaunAddMin =0;//счетчик ипульсов энкодера"-" за такт ВП |
Kovalev_D | 108:030cdde08314 | 16 | |
Kovalev_D | 112:4a96133a1311 | 17 | int unsigned Cur_QEI, Last_QEI; //текушее и предыдущее,(единичное) значение энкодера |
Kovalev_D | 207:d1ce992f5d17 | 18 | int temp32=0; |
Kovalev_D | 193:a0fe8bfc97e4 | 19 | int Buff_1Point [512]; |
Kovalev_D | 183:7e200f4d9b16 | 20 | int Buff_32Point [32]; |
Kovalev_D | 193:a0fe8bfc97e4 | 21 | int Buff_64Point [32]; |
igor_v | 43:3f7c8a0ea59c | 22 | int Buff_16Point [32]; |
igor_v | 43:3f7c8a0ea59c | 23 | int Buff_16PointD [32]; |
igor_v | 43:3f7c8a0ea59c | 24 | int Buff_8Point [32]; |
igor_v | 43:3f7c8a0ea59c | 25 | int Buff_Restored_sin [32]; |
Kovalev_D | 196:f76dbc081e63 | 26 | int Buff_Restored_sin2 [32]; |
igor_v | 21:bc8c1cec3da6 | 27 | void D_QEI(void) |
igor_v | 21:bc8c1cec3da6 | 28 | { |
igor_v | 21:bc8c1cec3da6 | 29 | Dif_QEI=0; |
igor_v | 21:bc8c1cec3da6 | 30 | Cur_QEI = LPC_QEI->POS & 0xFFFF; // считывание текущего значения энкодера. |
Kovalev_D | 207:d1ce992f5d17 | 31 | |
Kovalev_D | 207:d1ce992f5d17 | 32 | |
Kovalev_D | 207:d1ce992f5d17 | 33 | |
Kovalev_D | 197:7a05523bf588 | 34 | //LPC_QEI->CON = 0xF; |
igor_v | 21:bc8c1cec3da6 | 35 | Dif_QEI = (Cur_QEI - Last_QEI); // получение приращения.() |
Kovalev_D | 207:d1ce992f5d17 | 36 | temp32 = Dif_QEI; |
Kovalev_D | 207:d1ce992f5d17 | 37 | Gyro.CuruAngle32 += temp32; |
Kovalev_D | 207:d1ce992f5d17 | 38 | temp32=0; |
igor_v | 21:bc8c1cec3da6 | 39 | Last_QEI = Cur_QEI; // запись текущего значения энкодера в регистр предыдущего значения. |
Kovalev_D | 207:d1ce992f5d17 | 40 | |
igor_v | 21:bc8c1cec3da6 | 41 | if (Dif_QEI < -0xfff) Dif_QEI += 0x10000; // обработка прохода значения через ноль |
igor_v | 21:bc8c1cec3da6 | 42 | if (Dif_QEI > 0xfff) Dif_QEI -= 0x10000; // обработка прохода значения через ноль |
Kovalev_D | 108:030cdde08314 | 43 | Buff_1Point[CountV255] = Dif_QEI ; // накопление в буфер еденичных значений приращения по каждому такту. |
Kovalev_D | 193:a0fe8bfc97e4 | 44 | |
Kovalev_D | 197:7a05523bf588 | 45 | |
Kovalev_D | 197:7a05523bf588 | 46 | |
Kovalev_D | 205:775d54fdf646 | 47 | |
igor_v | 21:bc8c1cec3da6 | 48 | ////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 108:030cdde08314 | 49 | Pulse_8Point += Buff_1Point[CountV255]; |
igor_v | 21:bc8c1cec3da6 | 50 | Pulse_8Point -= Buff_1Point[(CountV255-8) & 0xff]; // заполнение буфера накопленых приращений за 8 тактов |
Kovalev_D | 112:4a96133a1311 | 51 | Buff_8Point[CountV31] = (Pulse_8Point); |
igor_v | 0:8ad47e2b6f00 | 52 | |
igor_v | 21:bc8c1cec3da6 | 53 | Pulse_16Point += Buff_1Point[CountV255]; |
igor_v | 21:bc8c1cec3da6 | 54 | Pulse_16Point -= Buff_1Point[(CountV255-16) & 0xff]; // заполнение буфера накопленых приращений за 16 тактов |
Kovalev_D | 112:4a96133a1311 | 55 | Buff_16Point[CountV31] = (Pulse_16Point ); |
igor_v | 21:bc8c1cec3da6 | 56 | |
igor_v | 21:bc8c1cec3da6 | 57 | Pulse_32Point += Buff_1Point[CountV255]; |
igor_v | 21:bc8c1cec3da6 | 58 | Pulse_32Point -= Buff_1Point[(CountV255-32) & 0xff]; // заполнение буфера накопленых приращений за 32 тактов |
Kovalev_D | 112:4a96133a1311 | 59 | Gyro.Cnt_Dif = (Pulse_32Point); |
Kovalev_D | 112:4a96133a1311 | 60 | Buff_32Point[CountV31] = (Pulse_32Point ); |
Kovalev_D | 183:7e200f4d9b16 | 61 | |
Kovalev_D | 207:d1ce992f5d17 | 62 | |
Kovalev_D | 207:d1ce992f5d17 | 63 | |
Kovalev_D | 207:d1ce992f5d17 | 64 | |
Kovalev_D | 193:a0fe8bfc97e4 | 65 | Pulse_64Point += Buff_1Point[CountV255]; |
Kovalev_D | 193:a0fe8bfc97e4 | 66 | Pulse_64Point -= Buff_1Point[(CountV255-32) & 0xff]; // заполнение буфера накопленых приращений за два 32 тактов |
Kovalev_D | 183:7e200f4d9b16 | 67 | Gyro.Cnt_Dif = (Pulse_64Point); |
Kovalev_D | 183:7e200f4d9b16 | 68 | Buff_64Point[CountV31] = (Pulse_64Point ); |
Kovalev_D | 193:a0fe8bfc97e4 | 69 | |
igor_v | 0:8ad47e2b6f00 | 70 | |
igor_v | 21:bc8c1cec3da6 | 71 | Pulse_16PointD += Buff_1Point[CountV255]; |
igor_v | 21:bc8c1cec3da6 | 72 | Pulse_16PointD -= Buff_1Point[(CountV255-16) & 0xff]; // заполнение буфера накопленых приращений за 16 тактов Двойныз |
igor_v | 21:bc8c1cec3da6 | 73 | Pulse_16PointD += Buff_1Point[(CountV255-32) & 0xff]; // |
Kovalev_D | 169:140743e3bb96 | 74 | Pulse_16PointD -= Buff_1Point[(CountV255-48) & 0xff]; // |
Kovalev_D | 108:030cdde08314 | 75 | Buff_16PointD[CountV31] = Pulse_16PointD ; |
Kovalev_D | 183:7e200f4d9b16 | 76 | |
Kovalev_D | 197:7a05523bf588 | 77 | |
Kovalev_D | 197:7a05523bf588 | 78 | //LoopOff |
Kovalev_D | 196:f76dbc081e63 | 79 | Buff_Restored_sin [CountV31] = (Buff_16PointD[CountV31]) - Buff_32Point[CountV31]; |
Kovalev_D | 196:f76dbc081e63 | 80 | Buff_Restored_sin2 [CountV31] = (Buff_16Point[CountV31]) - Buff_32Point[CountV31]; |
Kovalev_D | 193:a0fe8bfc97e4 | 81 | if((Buff_Restored_sin [CountV31]) > 0) |
Kovalev_D | 193:a0fe8bfc97e4 | 82 | { |
Kovalev_D | 193:a0fe8bfc97e4 | 83 | CaunAddPlus += Buff_Restored_sin [CountV31]; |
Kovalev_D | 193:a0fe8bfc97e4 | 84 | } // счетчик положительных импульсов |
Kovalev_D | 205:775d54fdf646 | 85 | else {CaunAddMin -= Buff_Restored_sin [CountV31];} //счетчик отрицательных импульсов // расчет амплитуды |
Kovalev_D | 205:775d54fdf646 | 86 | |
Kovalev_D | 197:7a05523bf588 | 87 | Gyro.CuruAngle += Buff_32Point [CountV31]; |
Kovalev_D | 197:7a05523bf588 | 88 | |
igor_v | 21:bc8c1cec3da6 | 89 | } |
Kovalev_D | 196:f76dbc081e63 | 90 | /* |
Kovalev_D | 193:a0fe8bfc97e4 | 91 | void CurAngle(void) |
Kovalev_D | 193:a0fe8bfc97e4 | 92 | { |
Kovalev_D | 193:a0fe8bfc97e4 | 93 | for (int i = 0; i < 32; i++ ) |
Kovalev_D | 193:a0fe8bfc97e4 | 94 | { |
Kovalev_D | 197:7a05523bf588 | 95 | Gyro.CuruAngle += Buff_32Point[i]; |
Kovalev_D | 193:a0fe8bfc97e4 | 96 | } |
Kovalev_D | 193:a0fe8bfc97e4 | 97 | } |
Kovalev_D | 193:a0fe8bfc97e4 | 98 | void CurAngleLOG(void) |
Kovalev_D | 193:a0fe8bfc97e4 | 99 | { |
Kovalev_D | 193:a0fe8bfc97e4 | 100 | sprintf((Time)," %d %d \r\n", Gyro.tempdelta,Gyro.CuruAngle); |
Kovalev_D | 193:a0fe8bfc97e4 | 101 | WriteCon(Time); |
Kovalev_D | 193:a0fe8bfc97e4 | 102 | Gyro.CuruAngle=0; |
Kovalev_D | 193:a0fe8bfc97e4 | 103 | Gyro.tempdelta=0; |
Kovalev_D | 196:f76dbc081e63 | 104 | }*/ |
Kovalev_D | 193:a0fe8bfc97e4 | 105 |