Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MODSERIAL SDFileSystemSeth mbed
Fork of Opstellingbachelor_opdracht by
Diff: main.cpp
- Revision:
- 4:afab0fda2cf4
- Parent:
- 3:b525b7a56553
- Child:
- 5:f92906aaf1c2
--- a/main.cpp Wed Sep 28 20:06:02 2016 +0000 +++ b/main.cpp Thu Oct 06 19:12:11 2016 +0000 @@ -41,6 +41,7 @@ volatile bool fn1_go = 0; // go-flag starts in disabled state volatile bool start = 0; +volatile bool meas = 0; float fcs_read; @@ -71,6 +72,7 @@ fn1_go = 1; // go-flag active } + void readTC() { CS_1 = 0; @@ -99,10 +101,21 @@ fprintf(fp, "%.3d\t", b[j]); } fprintf(fp, "\n\r"); - + return; } +void getsample(bool meas) +{ + if(meas){ // alleen data uitlezen en opslaan als meas = 1 + fcs_read = fcs.read(); // capture torque sensor data + fprintf(fp, "%.3f\t", fcs_read); // output data to file + readTC(); // call function to read thermocouple data + } + return; +} + + ////////////////////Main//////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// @@ -116,7 +129,7 @@ while (1) { if(fn1_go) { // statements to execute when go-flag is active fn1_go = 0; - + getsample(meas); // deze functie wordt elke ts seconde aangeroepen. afhankelijk van waarde meas (0 of 1) wordt de data opgeslagen in textfile } if(pc.readable()) { // if character available @@ -157,16 +170,12 @@ } else { pc.printf("Measurement started... \n\r"); pc.printf("Press 's' to stop measurement\n\r"); - while(1) { - fcs_read = fcs.read(); // capture torque sensor data - fprintf(fp, "%.3f\t", fcs_read); // output data to file - readTC(); // call function to read thermocouple data - } + meas = 1; // hiermee zorg je dat de functie getsample de data wegschrijft naar het .txt file } - break; } else { led_control(led_on,led_off,led_off); // RED LED when ready to stopped measuring + meas = 0; // hiermee stop je de output naar het .txt file fclose(fp); pc.printf("File saved as %s\n\r", filename_torque); // print filename to screen pc.printf("Press 'c' to perform new calibration or 't' to start new trial\n\r"); // print message to screen