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.
Fork of UM6_IMU_AHRS_2012 by
Revision 6:43029c69b9ac, committed 2013-05-04
- Comitter:
- njewin
- Date:
- Sat May 04 09:34:15 2013 +0000
- Parent:
- 5:b3cd0bcf2968
- Commit message:
- publish version ; bugs need correcting for:; - logging to file at 10ms rate; - reading GPS lat and long data
Changed in this revision
| UM6_config/UM6_config.h | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/UM6_config/UM6_config.h Thu May 02 11:38:25 2013 +0000
+++ b/UM6_config/UM6_config.h Sat May 04 09:34:15 2013 +0000
@@ -1,9 +1,13 @@
/* ------------------------------------------------------------------------------
File: UM6_config.h
- Author: CH Robotics
+ Author: CH Robotics, edited by Nathan Ewin
Version: 1.0
Description: Preprocessor definitions and function declarations for UM6 configuration
+
+ // added configuration for GPS signals from LS20031 sensor connected to UM6
+ // GPS ground speed and heading angle setup outputs data
+ // GPS latitude and longitude not setup correctly
------------------------------------------------------------------------------ */
#ifndef __UM6_CONFIG_H
#define __UM6_CONFIG_H
@@ -469,17 +473,17 @@
}
//-------------------------------------------------------------------
// GPS long
- // if (new_packet.address == UM6_GPS_LONGITUDE) {
+ if (new_packet.address == UM6_GPS_LONGITUDE) {
// Longitude
- // data.GPS_long = MY_DATA_GPS_LONG;
- // }
+ data.GPS_long = MY_DATA_GPS_LONG;
+ }
//------------------------------------------------------------
//-------------------------------------------------------------------
// GPS lat
- // if (new_packet.address == UM6_GPS_LATITUDE) {
+ if (new_packet.address == UM6_GPS_LATITUDE) {
// Latitude
- // data.GPS_lat = MY_DATA_GPS_LAT;
- // }
+ data.GPS_lat = MY_DATA_GPS_LAT;
+ }
//------------------------------------------------------------
} // end if(ADDRESS_TYPE_DATA)
--- a/main.cpp Thu May 02 11:38:25 2013 +0000
+++ b/main.cpp Sat May 04 09:34:15 2013 +0000
@@ -38,13 +38,14 @@
// SET SERIAL UART BAUD RATES
/////////////////////////////////////////////////////////////////////////////////////////////////////
- // set UM6 serial uart baud 9600
- um6_uart.baud(115200);
- pc.baud(115200); // pc baud for UM6 to pc interface
+ // set UM6 serial uart baud rate
+ um6_uart.baud(115200); // baud rate to um6 interface
+ pc.baud(115200); // baud rate to pc interface
// attach interupt function to uart
um6_uart.attach(&rxCallback, MODSERIAL::RxIrq);
+ // opens file for saving data to and sets up header row
FILE *fp = fopen("/local/out3.csv", "w"); // Open "out.txt" on the local file system for writing
fprintf(fp, "time (s),Yaw (deg),Roll (deg),Pitch (deg),GyroX,GyroY,GyroZ,AccelX,AccelY,AccelZ,GPScourse(x100 deg),GPSspeed(x100 m/s)\r"); // sends header to file
@@ -53,7 +54,7 @@
sync = 1;
while (enable) {
logLED = 1; // turns LED3 on when logging starts
- wait(0.05);
+ wait(0.02);
float time1=t.read();
float Yaw=data.Yaw;
float Roll=data.Roll;
@@ -64,25 +65,24 @@
float AccelX=data.Accel_Proc_X;
float AccelY=data.Accel_Proc_Y;
float AccelZ=data.Accel_Proc_Z;
- // float MagX=data.Mag_Proc_X;
- // float MagY=data.Mag_Proc_Y;
- // float MagZ=data.Mag_Proc_Z;
- // float GPSlong=data.GPS_long;
- // float GPSlat=data.GPS_lat;
+ float GPSlong=data.GPS_long; // currently I can get GPS longitude to out data
+ float GPSlat=data.GPS_lat; // currently I can get GPS latitude to out data
float GPScourse=data.GPS_course;
float GPSspeed=data.GPS_speed;
- // fprintf(fp, "%3.3f, %3.1f,%3.1f,%3.1f, %4.1f,%4.1f,%4.1f, %1.3f,%1.3f,%1.3f, %4.0f,%f\n",time1,Yaw,Roll,Pitch,GyroX,GyroY,GyroZ,AccelX,AccelY,AccelZ,MagX,MagY,MagZ,GPScourse,GPSspeed);
- // pc.printf("time %3.3f, yaw %3.1f,%3.1f,%3.1f, gyro %4.1f,%4.1f,%4.1f,accel %1.3f,%1.3f,%1.3f,speed %4.0f, course %5.0f\n",time1,Yaw,Roll,Pitch,GyroX,GyroY,GyroZ,AccelX,AccelY,AccelZ,MagX,MagY,MagZ,GPScourse,GPSspeed);
- pc.printf("time %3.3f, yaw %3.3f\n",time1,Yaw);
- fprintf(fp, "%3.3f,%3.1f,%3.1f\n",time1,Yaw,GyroX);
- pc_activity = !pc_activity; // Lights LED1 when uart RxBuff has > 40 bytes
+ // print to file every 20ms - this is what I would idealy do but it ends up freezing on a single value
+ fprintf(fp, "%3.3f, %3.1f,%3.1f,%3.1f, %4.1f,%4.1f,%4.1f, %1.3f,%1.3f,%1.3f, %4.0f,%f\n",time1,Yaw,Roll,Pitch,GyroX,GyroY,GyroZ,AccelX,AccelY,AccelZ,GPScourse,GPSspeed);
+
+ // print to screen - I use this to check that data is outputting - works fine on its own, but also freezes when above line is used
+ pc.printf("time %3.3f, yaw %3.1e,%3.1e,%3.1e, gyro %4.1e,%4.1e,%4.1e,accel %1.3e,%1.3e,%1.3e,speed %4.0e, course %5.0e\n",time1,Yaw,Roll,Pitch,GyroX,GyroY,GyroZ,AccelX,AccelY,AccelZ,GPScourse,GPSspeed);
+
+ pc_activity = !pc_activity; // Lights LED1 when uart RxBuff has > 40 bytes
} // end while(1) loop
- fprintf(fp,"%3.3f \n",t.read());
- sync = 0;
+ fprintf(fp,"%3.3f \n",t.read()); // records time at end of measurement
+ sync = 0; // zeros synchronization digital output
wait(0.6); // debug - hold LED on for 0.6s, even when while loop not true
logLED = 0; // turns LED3 off when logging ends
- fclose(fp);
+ fclose(fp); // closes log file, otherwise cannot access mbed drive
} // end main()
\ No newline at end of file
