Temperature Data Logger or Display. Program uses the EA LPCXpresso Board's on-board temp sensor and SD card to constantly monitor the temperature. Optionally, the temp can be displayed on the EA OLED display.
Dependencies: mbed SDFileSystem
Revision 1:37f2341e763b, committed 2010-06-16
- Comitter:
- tyger23
- Date:
- Wed Jun 16 16:08:29 2010 +0000
- Parent:
- 0:e05fd3c9c4b3
- Commit message:
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r e05fd3c9c4b3 -r 37f2341e763b main.cpp --- a/main.cpp Tue Jun 15 20:21:07 2010 +0000 +++ b/main.cpp Wed Jun 16 16:08:29 2010 +0000 @@ -8,16 +8,15 @@ #include "EAOLED.h" #include "SDFileSystem.h" -SDFileSystem sd(p5, p6, p7, p24, "sd"); //Used for file system writes to the EA SD card. Comment this out if displaying on OLED. +SDFileSystem sd(p5, p6, p7, p24, "sd"); //Used for file system writes to the EA SD card. Comment this out if displaying on OLED. Make sure J55 pins 1&2 (A) are disconnected! DigitalOut myled1(LED1); DigitalOut myled2(LED2); DigitalOut myled3(LED3); //EAOLED oled(p5, p6, p7, p8, p25); // mosi, dnc, sclk, cs, power ***this is only used if displaying temp on OLED instead of file writing*** InterruptIn sense(p8); //make sure EA board J25 is set to PIO0_2 ***if using the OLED, must change this to pin 10 and connect wire from J25 center pin to pin10 on mBed, make sure J25 does not have a jumper populated*** -Timer timer; //timer used for keeping track of elapesd time Timeout timeout; //timeout used for calculation of frequency -int edgecount, on, seconds; +int edgecount, on, et; float temp, freq, tempf; void edge(){ @@ -35,18 +34,22 @@ // oled.locate(0,2); //*** make sure this is not commented out if using the OLED // oled.printf("Temperature:"); //*** make sure this is not commented out if using the OLED myled1 = 1; //indicates the program is running - timer.start(); //starts the tracking timer. Can comment this out if using the OLED. FILE *fp = fopen("/sd/temperat.csv", "w"); //formats the file header. Comment this out if using the OLED. fprintf(fp,"Time, Freq, TempC, TempF\n"); //Comment this out if using the OLED fclose(fp); //Comment this out if using the OLED + et = 0; //Sets elapsed time to 0. Can comment this out if using OLED. while(1){ + myled2 = 0; //indicates temperature is not being monitored. Can be commented out if using OLED. + myled3 = 1; //indicates safe to remove power or SD card. Can be commented out if using OLED. + wait(1); //wait time to allow for safe card removal or powerdown. Can be commented out if using OLED. + myled2 = 1; //indicates the temperature is being monitored. Can be commented out if using OLED. + myled3 = 0; //indicates not safe to remove SD card or power. Can be commented out if using OLED. + + FILE *fp = fopen("/sd/temperat.csv", "a"); //comment this out if using the OLED + on=1; edgecount = 0; - myled2 = 1; //indicates the temperature is being monitored - myled3 = 0; - FILE *fp = fopen("/sd/temperat.csv", "a"); //comment this out if using the OLED - timeout.attach(&attimeout, 5); //sets the amount of time used to calcuate the frequency of the temp sensor while(on){ sense.rise(&edge); //tracks the rising edge of the temp sensor @@ -66,12 +69,8 @@ tempf = tempf + 32; //calcualtes the temperature in degrees F // oled.locate(0,4); //*** make sure this is not commented out if using the OLED // oled.printf("%2.3f", tempf); //*** make sure this is not commented out if using the OLED - seconds = timer.read(); //Reads the elaped time - fprintf(fp, "%d, ", seconds); //Comment this out if using the OLED - fprintf(fp,"%4.3f, %2.3f, %2.3f\n", freq, temp, tempf); //Comment this out if using the OLED + et = et+6; //Calculates the elaped time in seconds. If changing the timeout or the wait time for SD safe removal, you must change this accordingly. Comment this out if using the OLED + fprintf(fp,"%d, %4.3f, %2.3f, %2.3f\n", et, freq, temp, tempf); //Comment this out if using the OLED fclose(fp); //Comment this out if using the OLED - myled2 = 0; //indicates temperature monitoring is over - myled3 = 1; //indicates safe to remove power or SD card - wait(1); //wait time to allow for safe card removal or powerdown. Can be commented out if using OLED. } }