ES305H Lanier Turchan / Mbed 2 deprecated Turret_Angle

Dependencies:   QEI mbed

Committer:
LanierUSNA16
Date:
Tue Mar 10 12:54:05 2015 +0000
Revision:
0:60646c7af7a9
Child:
1:ec3cdf28c947
To measure encoder angle;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
LanierUSNA16 0:60646c7af7a9 1 #include "mbed.h"
LanierUSNA16 0:60646c7af7a9 2 #include "QEI.h"
LanierUSNA16 0:60646c7af7a9 3
LanierUSNA16 0:60646c7af7a9 4 QEI myEncoder (p15,p16, NC, 1600);
LanierUSNA16 0:60646c7af7a9 5
LanierUSNA16 0:60646c7af7a9 6 int main ()
LanierUSNA16 0:60646c7af7a9 7 {
LanierUSNA16 0:60646c7af7a9 8 int counter = 0;
LanierUSNA16 0:60646c7af7a9 9 float time = 0.0;
LanierUSNA16 0:60646c7af7a9 10 float theta = 0.0;
LanierUSNA16 0:60646c7af7a9 11 float pulses = 0.0;
LanierUSNA16 0:60646c7af7a9 12
LanierUSNA16 0:60646c7af7a9 13 printf("The program is running\n");
LanierUSNA16 0:60646c7af7a9 14 wait (2);
LanierUSNA16 0:60646c7af7a9 15
LanierUSNA16 0:60646c7af7a9 16 while (counter<101)
LanierUSNA16 0:60646c7af7a9 17 {
LanierUSNA16 0:60646c7af7a9 18 wait(0.01);
LanierUSNA16 0:60646c7af7a9 19 pulses = myEncoder.getPulses();
LanierUSNA16 0:60646c7af7a9 20 theta = pulses/ (1600*2.0*2*3.14);
LanierUSNA16 0:60646c7af7a9 21 time = counter*0.01;
LanierUSNA16 0:60646c7af7a9 22 printf("Time(%d)= %f \n", counter,time);
LanierUSNA16 0:60646c7af7a9 23 printf("Angle(%d) = %f \n", counter, theta);
LanierUSNA16 0:60646c7af7a9 24 printf("pulses = %f \n", pulses);
LanierUSNA16 0:60646c7af7a9 25 counter= counter + 1;
LanierUSNA16 0:60646c7af7a9 26 }
LanierUSNA16 0:60646c7af7a9 27
LanierUSNA16 0:60646c7af7a9 28 }