A project similar to http://mbed.org/users/lhiggs/code/UM6_IMU_AHRS_2012/, where I'm trying to log data from a UM6 (CH Robotics orientation sensor) and a GPS transceiver to an sd card. I've adapted LHiggs code to include ModGPS. For sum reason a soon as I pick up a gps signal the UM6 data freezes i.e. the time and gps signals continue to print out but the UM6 signals fixes on a single value.
Dependencies: MODGPS MODSERIAL SDFileSystem mbed
main.cpp
- Committer:
- njewin
- Date:
- 2013-05-23
- Revision:
- 2:4a6e89c2d82a
- Parent:
- 1:9fe40d9ac0f5
- Child:
- 3:b3358ec2f57c
File content as of revision 2:4a6e89c2d82a:
#include "mbed.h" //------------ system and interface setup ----------------------------// LocalFileSystem local("local"); // sets up local file on mbed Serial pc(USBTX, USBRX); // sets up serial connection to pc terminal //------------ Hardware setup ----------------------------------------// DigitalOut myled(LED1); // debug LED DigitalIn enable(p10); // enable signal for logging data to file //------------ interrupt and variable setup --------------------------// Ticker tick; int counter=0; int flag=0; //------------ LogData interrupt function ----------------------------// void LogData() { counter++; flag=1; } //============= Main Program =========================================// int main() { pc.baud(115200); // baud rate to pc interface FILE *fp = fopen("/local/ticker4.txt", "w"); tick.attach(&LogData, 0.01); // attaches LogData function to 'tick' ticker interrupt every 0.5s while(1) { while(enable) { if(flag==1) { // prints counter value every interrupt raises flag myled=1; fprintf(fp,"%d \n",counter); pc.printf("%d \n",counter); flag=0; } // end if(flag=1) loop } // end while(enable) loop fclose(fp); myled=0; // turns off LED when enable switch off counter=0; // resets counter } // end while(1) loop } // end main() loop