MPUとHMCでうごくかもver
Dependencies: ConfigFile SDFileSystem mbed
Fork of LAURUS_program by
Revision 5:182f6356bce1, committed 2015-06-11
- Comitter:
- ojan
- Date:
- Thu Jun 11 17:40:39 2015 +0000
- Parent:
- 4:45dc5590abc0
- Child:
- 6:2b68f85a984a
- Commit message:
- add Battery meter
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
myConstants.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Jun 11 15:43:07 2015 +0000 +++ b/main.cpp Thu Jun 11 17:40:39 2015 +0000 @@ -28,7 +28,11 @@ GMS6_CR6 gms(&gps, &pc); // GPS Ticker INT_timer; // 割り込みタイマー Log logger(PA_9, PA_10, PC_1, PB_5, PB_4, PB_3, PB_10); // ロガー(microSD、XBee) -DigitalIn cts(PC_1); +PwmOut servoL(PC_7), servoR(PB_6); +AnalogIn rf(PC_0); +AnalogIn servoVcc(PA_0); +AnalogIn logicVcc(PA_1); + const float dt = 0.1f; // 割り込み周期(s) @@ -103,17 +107,25 @@ INT_flag = FALSE; // 割り込みによる変数書き換えを阻止 - sprintf(data, "%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f\r\n", - acc.GetComp(1), acc.GetComp(2), acc.GetComp(3), - gyro.GetComp(1), gyro.GetComp(2), gyro.GetComp(3), + float sv = (float)servoVcc.read_u16() * ADC_LSB_TO_V * 2.0f; + float lv = (float)logicVcc.read_u16() * ADC_LSB_TO_V * 2.0f; + + sprintf(data, "%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%d\r\n", + g.GetComp(1), g.GetComp(2), g.GetComp(3), geomag.GetComp(1), geomag.GetComp(2), geomag.GetComp(3), - press, gms.longitude, gms.latitude); + press, gms.longitude, gms.latitude, + sv, lv, gms.Ns); logger.puts(data); INT_flag = TRUE; // 割り込み許可 pc.printf("time: %.3f[s]\r\n", (float)timer.read_ms()/1000.0f); + // 制御ルーチン + { + } + + // ループはきっかり1秒ごと while(timer.read_ms() < 1000); @@ -209,9 +221,6 @@ } //pc.printf("%d(us)\r\n", timer.read_us()); - //pc.printf("PC_1 = %d\r\n", (int)cts); - //pc.printf("test\r\n"); - if(INT_flag != FALSE) { g = raw_g; for(int i=0; i<3; i++) {
--- a/myConstants.h Thu Jun 11 15:43:07 2015 +0000 +++ b/myConstants.h Thu Jun 11 17:40:39 2015 +0000 @@ -1,16 +1,27 @@ #pragma once +/* Math Constants */ #define NEARLY_ZERO 0.000000001f #define ZERO_TOLERANCE 0.000001f #define RAD_TO_DEG 57.2957795f // 180 / π #define DEG_TO_RAD 0.0174532925f // π / 180 + +/* Accelerometer */ #define ACC_LSB_TO_G 0.0000610351562f // g/LSB (1/2^14 #define G_TO_MPSS 9.8f // (m/s^2)/g -//#define GYRO_LSB_TO_DEG 0.0304878048f // deg/LSB (1/32.8 -#define GYRO_LSB_TO_DEG 0.0152671755f // deg/LSB (1/65.5 + +/* Gyro Sensor */ +//#define GYRO_LSB_TO_DEG 0.0304878048f // deg/LSB (1/32.8 +#define GYRO_LSB_TO_DEG 0.0152671755f // deg/LSB (1/65.5 //#define GYRO_LSB_TO_DEG 0.00763358778f // deg/LSB (1/131 + +/* Pressure Sensor */ #define PRES_LSB_TO_HPA 0.000244140625f // hPa/LSB (1/4096 +/* Geomagnetic Sensor */ #define MAG_LSB_TO_GAUSS 0.00092f // Gauss/LSB #define MAG_MAGNITUDE 0.46f // Magnitude of GeoMagnetism (Gauss) -#define MAG_SIN -0.754709580f // Sin-Value of Inclination \ No newline at end of file +#define MAG_SIN -0.754709580f // Sin-Value of Inclination + +/* ADC */ +#define ADC_LSB_TO_V 0.000050354f // 3.3(V)/65535(LSB) \ No newline at end of file