![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
forkd
Fork of LGstaandart by
QEI.c@197:7a05523bf588, 2016-10-19 (annotated)
- Committer:
- Kovalev_D
- Date:
- Wed Oct 19 10:55:05 2016 +0000
- Revision:
- 197:7a05523bf588
- Parent:
- 196:f76dbc081e63
- Child:
- 202:c03b7b128e11
- Child:
- 205:775d54fdf646
modul
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 | 108:030cdde08314 | 18 | |
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 | 197:7a05523bf588 | 31 | //LPC_QEI->CON = 0xF; |
igor_v | 21:bc8c1cec3da6 | 32 | Dif_QEI = (Cur_QEI - Last_QEI); // получение приращения.() |
Kovalev_D | 193:a0fe8bfc97e4 | 33 | |
igor_v | 21:bc8c1cec3da6 | 34 | Last_QEI = Cur_QEI; // запись текущего значения энкодера в регистр предыдущего значения. |
Kovalev_D | 112:4a96133a1311 | 35 | |
igor_v | 21:bc8c1cec3da6 | 36 | if (Dif_QEI < -0xfff) Dif_QEI += 0x10000; // обработка прохода значения через ноль |
igor_v | 21:bc8c1cec3da6 | 37 | if (Dif_QEI > 0xfff) Dif_QEI -= 0x10000; // обработка прохода значения через ноль |
Kovalev_D | 108:030cdde08314 | 38 | Buff_1Point[CountV255] = Dif_QEI ; // накопление в буфер еденичных значений приращения по каждому такту. |
Kovalev_D | 193:a0fe8bfc97e4 | 39 | |
Kovalev_D | 197:7a05523bf588 | 40 | |
Kovalev_D | 197:7a05523bf588 | 41 | |
Kovalev_D | 197:7a05523bf588 | 42 | //LoopOn |
igor_v | 21:bc8c1cec3da6 | 43 | ////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 108:030cdde08314 | 44 | Pulse_8Point += Buff_1Point[CountV255]; |
igor_v | 21:bc8c1cec3da6 | 45 | Pulse_8Point -= Buff_1Point[(CountV255-8) & 0xff]; // заполнение буфера накопленых приращений за 8 тактов |
Kovalev_D | 112:4a96133a1311 | 46 | Buff_8Point[CountV31] = (Pulse_8Point); |
igor_v | 0:8ad47e2b6f00 | 47 | |
igor_v | 21:bc8c1cec3da6 | 48 | Pulse_16Point += Buff_1Point[CountV255]; |
igor_v | 21:bc8c1cec3da6 | 49 | Pulse_16Point -= Buff_1Point[(CountV255-16) & 0xff]; // заполнение буфера накопленых приращений за 16 тактов |
Kovalev_D | 112:4a96133a1311 | 50 | Buff_16Point[CountV31] = (Pulse_16Point ); |
igor_v | 21:bc8c1cec3da6 | 51 | |
igor_v | 21:bc8c1cec3da6 | 52 | Pulse_32Point += Buff_1Point[CountV255]; |
igor_v | 21:bc8c1cec3da6 | 53 | Pulse_32Point -= Buff_1Point[(CountV255-32) & 0xff]; // заполнение буфера накопленых приращений за 32 тактов |
Kovalev_D | 112:4a96133a1311 | 54 | Gyro.Cnt_Dif = (Pulse_32Point); |
Kovalev_D | 112:4a96133a1311 | 55 | Buff_32Point[CountV31] = (Pulse_32Point ); |
Kovalev_D | 183:7e200f4d9b16 | 56 | |
Kovalev_D | 193:a0fe8bfc97e4 | 57 | Pulse_64Point += Buff_1Point[CountV255]; |
Kovalev_D | 193:a0fe8bfc97e4 | 58 | Pulse_64Point -= Buff_1Point[(CountV255-32) & 0xff]; // заполнение буфера накопленых приращений за два 32 тактов |
Kovalev_D | 183:7e200f4d9b16 | 59 | Gyro.Cnt_Dif = (Pulse_64Point); |
Kovalev_D | 183:7e200f4d9b16 | 60 | Buff_64Point[CountV31] = (Pulse_64Point ); |
Kovalev_D | 193:a0fe8bfc97e4 | 61 | |
igor_v | 0:8ad47e2b6f00 | 62 | |
igor_v | 21:bc8c1cec3da6 | 63 | Pulse_16PointD += Buff_1Point[CountV255]; |
igor_v | 21:bc8c1cec3da6 | 64 | Pulse_16PointD -= Buff_1Point[(CountV255-16) & 0xff]; // заполнение буфера накопленых приращений за 16 тактов Двойныз |
igor_v | 21:bc8c1cec3da6 | 65 | Pulse_16PointD += Buff_1Point[(CountV255-32) & 0xff]; // |
Kovalev_D | 169:140743e3bb96 | 66 | Pulse_16PointD -= Buff_1Point[(CountV255-48) & 0xff]; // |
Kovalev_D | 108:030cdde08314 | 67 | Buff_16PointD[CountV31] = Pulse_16PointD ; |
Kovalev_D | 183:7e200f4d9b16 | 68 | |
Kovalev_D | 197:7a05523bf588 | 69 | |
Kovalev_D | 197:7a05523bf588 | 70 | //LoopOff |
Kovalev_D | 196:f76dbc081e63 | 71 | Buff_Restored_sin [CountV31] = (Buff_16PointD[CountV31]) - Buff_32Point[CountV31]; |
Kovalev_D | 196:f76dbc081e63 | 72 | Buff_Restored_sin2 [CountV31] = (Buff_16Point[CountV31]) - Buff_32Point[CountV31]; |
Kovalev_D | 193:a0fe8bfc97e4 | 73 | if((Buff_Restored_sin [CountV31]) > 0) |
Kovalev_D | 193:a0fe8bfc97e4 | 74 | { |
Kovalev_D | 193:a0fe8bfc97e4 | 75 | CaunAddPlus += Buff_Restored_sin [CountV31]; |
Kovalev_D | 193:a0fe8bfc97e4 | 76 | if(Gyro.QEIznak2) |
Kovalev_D | 193:a0fe8bfc97e4 | 77 | { |
Kovalev_D | 197:7a05523bf588 | 78 | //Gyro.Reper_Event=1; |
Kovalev_D | 193:a0fe8bfc97e4 | 79 | Gyro.QEIznak2=0; |
Kovalev_D | 193:a0fe8bfc97e4 | 80 | } |
Kovalev_D | 193:a0fe8bfc97e4 | 81 | |
Kovalev_D | 193:a0fe8bfc97e4 | 82 | } // счетчик положительных импульсов |
Kovalev_D | 196:f76dbc081e63 | 83 | else {CaunAddMin -= Buff_Restored_sin [CountV31]; Gyro.QEIznak2=1;} //счетчик отрицательных импульсов // расчет амплитуды |
Kovalev_D | 196:f76dbc081e63 | 84 | |
Kovalev_D | 197:7a05523bf588 | 85 | |
Kovalev_D | 197:7a05523bf588 | 86 | Gyro.CuruAngle += Buff_32Point [CountV31]; |
Kovalev_D | 197:7a05523bf588 | 87 | |
igor_v | 21:bc8c1cec3da6 | 88 | } |
Kovalev_D | 196:f76dbc081e63 | 89 | /* |
Kovalev_D | 193:a0fe8bfc97e4 | 90 | void CurAngle(void) |
Kovalev_D | 193:a0fe8bfc97e4 | 91 | { |
Kovalev_D | 193:a0fe8bfc97e4 | 92 | for (int i = 0; i < 32; i++ ) |
Kovalev_D | 193:a0fe8bfc97e4 | 93 | { |
Kovalev_D | 197:7a05523bf588 | 94 | Gyro.CuruAngle += Buff_32Point[i]; |
Kovalev_D | 193:a0fe8bfc97e4 | 95 | } |
Kovalev_D | 193:a0fe8bfc97e4 | 96 | } |
Kovalev_D | 193:a0fe8bfc97e4 | 97 | void CurAngleLOG(void) |
Kovalev_D | 193:a0fe8bfc97e4 | 98 | { |
Kovalev_D | 193:a0fe8bfc97e4 | 99 | sprintf((Time)," %d %d \r\n", Gyro.tempdelta,Gyro.CuruAngle); |
Kovalev_D | 193:a0fe8bfc97e4 | 100 | WriteCon(Time); |
Kovalev_D | 193:a0fe8bfc97e4 | 101 | Gyro.CuruAngle=0; |
Kovalev_D | 193:a0fe8bfc97e4 | 102 | Gyro.tempdelta=0; |
Kovalev_D | 196:f76dbc081e63 | 103 | }*/ |
Kovalev_D | 193:a0fe8bfc97e4 | 104 |