ES305H Lanier Turchan
/
Turret_Angle
Measure encoder angle
Diff: Turret_Angle_encoder.cpp
- Revision:
- 3:caefffcb7141
- Parent:
- 1:ec3cdf28c947
--- a/Turret_Angle_encoder.cpp Thu Mar 12 12:47:39 2015 +0000 +++ b/Turret_Angle_encoder.cpp Tue Mar 24 12:15:50 2015 +0000 @@ -3,33 +3,34 @@ QEI myEncoder (p16,p15, NC, 1600); Timer t; - +LocalFileSystem local("local"); +Serial pc(USBTX, USBRX); + int main () { + printf("Running"); int counter = 0; - float time[500] ; - float theta[500] ; + float time[500]={0} ; + float theta[500]={0} ; int pulses = 0; int k = 0; + + wait (1); t.start(); - - wait (1); - while (time[counter]<5.05) { wait(0.01); pulses = myEncoder.getPulses(); theta[counter] = ((float)pulses/ (1600.0*2.0))*2.0*3.14; time[counter] = t.read(); - printf("Time(%d)= %f Angle(%d) = %f \n", counter+1,time[counter],counter+1, theta[counter]); + //printf("Time(%d)= %f Angle(%d) = %f \n", counter+1,time[counter],counter+1, theta[counter]); counter= counter + 1; } t.stop(); printf("Printing log variables to file on mBed ... "); - LocalFileSystem local("local"); - FILE *fp = fopen("/local/turret_angle.M", "w"); + FILE *fp = fopen("/local/TURRET.M", "w"); if(1) {