fork

Dependencies:   mbed

Fork of LG by igor Apu

Committer:
igor_v
Date:
Sat Jan 30 13:53:19 2016 +0000
Revision:
1:f2adcae3d304
Parent:
0:8ad47e2b6f00
Child:
21:bc8c1cec3da6
123

Who changed what in which revision?

UserRevisionLine numberNew contents of line
igor_v 1:f2adcae3d304 1 #include "Global.h"
igor_v 0:8ad47e2b6f00 2
igor_v 0:8ad47e2b6f00 3 int Pulse_midl = 0;
igor_v 0:8ad47e2b6f00 4 int PulseHalf = 0;
igor_v 0:8ad47e2b6f00 5 int CuruAngle = 0;
igor_v 0:8ad47e2b6f00 6 int Dif_QEI;
igor_v 1:f2adcae3d304 7 int FFF=0;//��� ��������
igor_v 0:8ad47e2b6f00 8
igor_v 0:8ad47e2b6f00 9 int Pulse_8Point = 0;
igor_v 0:8ad47e2b6f00 10 int Pulse_16Point = 0;
igor_v 0:8ad47e2b6f00 11 int Pulse_32Point = 0;
igor_v 0:8ad47e2b6f00 12 int Pulse_16PointD = 0;
igor_v 0:8ad47e2b6f00 13 unsigned int Iras=0,Temp_F_ras=0;
igor_v 0:8ad47e2b6f00 14 int yy = 0;
igor_v 0:8ad47e2b6f00 15
igor_v 0:8ad47e2b6f00 16
igor_v 0:8ad47e2b6f00 17 unsigned int Buff_32Point [256];
igor_v 0:8ad47e2b6f00 18 unsigned int Buff_16Point [256];
igor_v 0:8ad47e2b6f00 19 unsigned int Buff_16PointD [256];
igor_v 0:8ad47e2b6f00 20 unsigned int Buff_8Point [256];
igor_v 0:8ad47e2b6f00 21 unsigned int Buff_1Point [256];
igor_v 0:8ad47e2b6f00 22 unsigned int Buff_Restored_sin [256];
igor_v 0:8ad47e2b6f00 23 int unsigned Cur_QEI = 0, Last_QEI=0;
igor_v 0:8ad47e2b6f00 24
igor_v 0:8ad47e2b6f00 25
igor_v 0:8ad47e2b6f00 26 void D_QEI(void)
igor_v 0:8ad47e2b6f00 27 {
igor_v 0:8ad47e2b6f00 28 Dif_QEI=0;
igor_v 0:8ad47e2b6f00 29
igor_v 0:8ad47e2b6f00 30
igor_v 1:f2adcae3d304 31 Cur_QEI = LPC_QEI->POS & 0xFFFF; // ���������� �������� �������� ��������.
igor_v 1:f2adcae3d304 32 Dif_QEI = (Cur_QEI - Last_QEI); // ��������� ����������.()
igor_v 1:f2adcae3d304 33 Last_QEI = Cur_QEI; // ������ �������� �������� �������� � ������� ����������� ��������.
igor_v 0:8ad47e2b6f00 34
igor_v 0:8ad47e2b6f00 35
igor_v 1:f2adcae3d304 36 if (Dif_QEI < -0xfff) Dif_QEI += 0x10000; // ��������� ������� �������� ����� ����
igor_v 1:f2adcae3d304 37 if (Dif_QEI > 0xfff) Dif_QEI -= 0x10000; // ��������� ������� �������� ����� ����
igor_v 0:8ad47e2b6f00 38
igor_v 0:8ad47e2b6f00 39
igor_v 1:f2adcae3d304 40 Buff_1Point[CountV255] = (unsigned int) (Dif_QEI + 0xffff);// ���������� � ����� ��������� �������� ���������� �� ������� �����.
igor_v 0:8ad47e2b6f00 41
igor_v 0:8ad47e2b6f00 42 ////////////////////////////////////////////////////////////////////////////////////////////
igor_v 0:8ad47e2b6f00 43 ///////////////////////////////////////////////////////////////////////////////////////////
igor_v 0:8ad47e2b6f00 44
igor_v 1:f2adcae3d304 45 if (LPC_QEI->STAT) //e. "+" direction //r. ����� ��������� � "+" �������
igor_v 0:8ad47e2b6f00 46 {
igor_v 0:8ad47e2b6f00 47 Main.Cnt_Mns = Dif_QEI;
igor_v 0:8ad47e2b6f00 48 }
igor_v 0:8ad47e2b6f00 49 else
igor_v 0:8ad47e2b6f00 50 {
igor_v 0:8ad47e2b6f00 51 Main.Cnt_Pls = -Dif_QEI;
igor_v 0:8ad47e2b6f00 52 }
igor_v 1:f2adcae3d304 53 ////////// ???? ��������
igor_v 1:f2adcae3d304 54 ////////// ???? �������� ���������� ���������� �������
igor_v 0:8ad47e2b6f00 55 //////////////////////////////////////////////////////////////////////////////////////////////
igor_v 1:f2adcae3d304 56 if(FFF==1) // ���� ������ 32 ����� ����� ������� ������ ��������� ��������� ������.
igor_v 0:8ad47e2b6f00 57 {
igor_v 0:8ad47e2b6f00 58 Pulse_8Point += Buff_1Point[CountV255];
igor_v 1:f2adcae3d304 59 Pulse_8Point -= Buff_1Point[(CountV255-8) & 0xff]; // ���������� ������ ���������� ���������� �� 8 ������
igor_v 0:8ad47e2b6f00 60 Buff_8Point[CountV255] = (unsigned int) (Pulse_8Point + 0xffff);
igor_v 0:8ad47e2b6f00 61
igor_v 0:8ad47e2b6f00 62 Pulse_16Point += Buff_1Point[CountV255];
igor_v 1:f2adcae3d304 63 Pulse_16Point -= Buff_1Point[(CountV255-16) & 0xff]; // ���������� ������ ���������� ���������� �� 16 ������
igor_v 0:8ad47e2b6f00 64 Buff_16Point[CountV255] = (unsigned int) (Pulse_16Point + 0xffff);
igor_v 0:8ad47e2b6f00 65
igor_v 0:8ad47e2b6f00 66 Pulse_32Point += Buff_1Point[CountV255];
igor_v 1:f2adcae3d304 67 Pulse_32Point -= Buff_1Point[(CountV255-32) & 0xff]; // ���������� ������ ���������� ���������� �� 32 ������
igor_v 0:8ad47e2b6f00 68 Main.Cnt_Dif = (Pulse_32Point+ 0xffff);
igor_v 0:8ad47e2b6f00 69 Buff_32Point[CountV255] = (unsigned int) (Pulse_32Point + 0xffff);
igor_v 0:8ad47e2b6f00 70
igor_v 0:8ad47e2b6f00 71 Pulse_16PointD += Buff_1Point[CountV255];
igor_v 1:f2adcae3d304 72 Pulse_16PointD -= Buff_1Point[(CountV255-16) & 0xff]; // ���������� ������ ���������� ���������� �� 16 ������ �������
igor_v 0:8ad47e2b6f00 73 Pulse_16PointD += Buff_1Point[(CountV255-32) & 0xff]; //
igor_v 1:f2adcae3d304 74 Pulse_16PointD -= Buff_1Point[(CountV255-48) & 0xff]; // �
igor_v 0:8ad47e2b6f00 75
igor_v 0:8ad47e2b6f00 76 Buff_16PointD[CountV255] = (unsigned int) (Pulse_16PointD + 0xffff);
igor_v 0:8ad47e2b6f00 77
igor_v 0:8ad47e2b6f00 78
igor_v 0:8ad47e2b6f00 79 // Buff_Restored_sin [CountVf]= (unsigned int)( ((Buff_16Point[CountVf]*2)) - Buff_32Point[CountVf] );
igor_v 0:8ad47e2b6f00 80
igor_v 0:8ad47e2b6f00 81 Buff_Restored_sin [CountV255]= (unsigned int)( Buff_16PointD [ CountV255] + 65536 - Buff_32Point[CountV255] );
igor_v 0:8ad47e2b6f00 82
igor_v 0:8ad47e2b6f00 83
igor_v 0:8ad47e2b6f00 84
igor_v 0:8ad47e2b6f00 85 if(Buff_32Point[CountV255]>0)
igor_v 0:8ad47e2b6f00 86 {
igor_v 0:8ad47e2b6f00 87 Temp_F_ras += Buff_32Point[CountV255];
igor_v 0:8ad47e2b6f00 88 }
igor_v 0:8ad47e2b6f00 89 else if ((CountV255 & 0x1f)==0)
igor_v 0:8ad47e2b6f00 90 {
igor_v 0:8ad47e2b6f00 91 Main.F_ras=Temp_F_ras;
igor_v 0:8ad47e2b6f00 92 Temp_F_ras=0;
igor_v 0:8ad47e2b6f00 93 }
igor_v 0:8ad47e2b6f00 94 else
igor_v 0:8ad47e2b6f00 95 {
igor_v 0:8ad47e2b6f00 96 Temp_F_ras -= Buff_32Point[CountV255];
igor_v 0:8ad47e2b6f00 97 }
igor_v 0:8ad47e2b6f00 98
igor_v 0:8ad47e2b6f00 99 //unsigned int T_Vib;
igor_v 0:8ad47e2b6f00 100
igor_v 0:8ad47e2b6f00 101 }
igor_v 0:8ad47e2b6f00 102 else if(CountV255 == 255)
igor_v 0:8ad47e2b6f00 103 {
igor_v 1:f2adcae3d304 104 FFF=1;//��������� �������� ��� ����� ����� ����������� ��������� �������
igor_v 0:8ad47e2b6f00 105 for (yy = 0; yy < 256; yy++ )
igor_v 0:8ad47e2b6f00 106 {
igor_v 0:8ad47e2b6f00 107 Buff_1Point [yy] = 0xffff;
igor_v 0:8ad47e2b6f00 108 Buff_16Point [yy] = 0xffff;
igor_v 0:8ad47e2b6f00 109 Buff_32Point [yy] = 0xffff;
igor_v 0:8ad47e2b6f00 110 Buff_16PointD [yy] = 0xffff;
igor_v 0:8ad47e2b6f00 111 }
igor_v 0:8ad47e2b6f00 112
igor_v 0:8ad47e2b6f00 113 }
igor_v 0:8ad47e2b6f00 114 }
igor_v 0:8ad47e2b6f00 115