filewriting program for second mbed

Dependencies:   QEI mbed

Committer:
lukeplummer
Date:
Sun Dec 01 22:57:09 2013 +0000
Revision:
1:fcfef1d9aa3d
Parent:
0:62a5c4d985cc
Child:
2:4355e6305710
fixed

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lukeplummer 0:62a5c4d985cc 1 #include "mbed.h"
lukeplummer 0:62a5c4d985cc 2 #include "QEI.h"
lukeplummer 0:62a5c4d985cc 3
lukeplummer 0:62a5c4d985cc 4 QEI encoder1(p25, p26, NC, 1200, QEI::X4_ENCODING);
lukeplummer 0:62a5c4d985cc 5 QEI encoder2(p23, p24, NC, 1200, QEI::X4_ENCODING);
lukeplummer 0:62a5c4d985cc 6 DigitalIn trigger(p21);
lukeplummer 0:62a5c4d985cc 7 AnalogIn force1(p20);
lukeplummer 0:62a5c4d985cc 8 AnalogIn force2(p19);
lukeplummer 0:62a5c4d985cc 9 AnalogIn current1(p18);
lukeplummer 0:62a5c4d985cc 10 AnalogIn current2(p17);
lukeplummer 0:62a5c4d985cc 11
lukeplummer 0:62a5c4d985cc 12 LocalFileSystem local("local");
lukeplummer 0:62a5c4d985cc 13 FILE *fp = fopen("/local/OUT.csv", "w");
lukeplummer 0:62a5c4d985cc 14
lukeplummer 0:62a5c4d985cc 15 int main() {
lukeplummer 0:62a5c4d985cc 16 while (trigger.read() == 0) {
lukeplummer 0:62a5c4d985cc 17 //do nothing
lukeplummer 0:62a5c4d985cc 18 }
lukeplummer 0:62a5c4d985cc 19 while (trigger.read() == 1) {
lukeplummer 0:62a5c4d985cc 20 float c1 = current1.read();
lukeplummer 0:62a5c4d985cc 21 float c2 = current2.read();
lukeplummer 0:62a5c4d985cc 22 float f1 = force1.read();
lukeplummer 0:62a5c4d985cc 23 float f2 = force2.read();
lukeplummer 0:62a5c4d985cc 24 float e1 = encoder1.getPulses()*2*3.14/1200.0;
lukeplummer 0:62a5c4d985cc 25 float e2 = encoder2.getPulses()*2*3.14/1200.0;
lukeplummer 0:62a5c4d985cc 26
lukeplummer 1:fcfef1d9aa3d 27 fprintf(fp, "enc pos: %f, %f F: %f, %f Favg: %f CS: %f, %f", e1, e2, f1, f2, (f1+f2)/2.0, c1, c2);
lukeplummer 0:62a5c4d985cc 28 }
lukeplummer 0:62a5c4d985cc 29 fclose(fp);
lukeplummer 0:62a5c4d985cc 30 }