STM Imu acquisition setup using ethernet
Dependencies: F7_Ethernet mbed HTS221 LPS22HB LSM303AGR LSM6DSL
Fork of Nucleo_F746ZG_Ethernet by
Revision 8:ee9a824852bf, committed 2018-01-31
- Comitter:
- nirnakern
- Date:
- Wed Jan 31 13:27:53 2018 +0000
- Parent:
- 7:6b56beca495e
- Child:
- 9:45a96c88754d
- Commit message:
- added RAW data option
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Jan 31 11:39:32 2018 +0000 +++ b/main.cpp Wed Jan 31 13:27:53 2018 +0000 @@ -8,6 +8,7 @@ #define ECHO_SERVER_PORT 7 #define DEBUG 0 +#define RAW 0 static XNucleoIKS01A2 *mems_expansion_board = XNucleoIKS01A2::instance(D14, D15, D4, D5); Timer t; @@ -17,8 +18,14 @@ int main() { //cose per accelerometro + + #if !RAW int32_t axes[3]; int32_t axes2[3]; + #else + int16_t axes[3]; + int16_t axes2[3]; + #endif uint8_t id; static LSM6DSLSensor *acc_gyro = mems_expansion_board->acc_gyro; @@ -109,9 +116,14 @@ long counter=0; for (int i=0;i<4500;i++){ + #if !RAW acc_gyro->get_x_axes(axes); acc_gyro->get_g_axes(axes2); + #else + acc_gyro->get_x_axes_raw(axes); + acc_gyro->get_g_axes_raw(axes2); + #endif //offsetGX=offsetGX+ axes[0]; //offsetGY=offsetGY+ axes[1]; //offsetGZ=offsetGZ+ axes[2]; @@ -152,12 +164,21 @@ #endif //send imu memset (&buffer[0], '\0', sizeof(buffer)); + #if !RAW acc_gyro->get_x_axes(axes); acc_gyro->get_g_axes(axes2); + #else + acc_gyro->get_x_axes_raw(axes); + acc_gyro->get_g_axes_raw(axes2); + #endif double accConversion = 0.009806; double gyrConversion = 0.0174533/1000; + #if !RAW sprintf(buffer, "%02.6f,%02.6f,%02.6f,%03.6f,%03.6f,%03.6f\n\r", (axes[0]*accConversion), (axes[1]*accConversion), (axes[2]*accConversion), (axes2[0]*gyrConversion), (axes2[1]*gyrConversion), (axes2[2]*gyrConversion)); + #else + sprintf(buffer, "%d,%d,%d,%d,%d,%d\n\r", axes[0], axes[1], axes[2], axes2[0], axes2[1], axes2[2]); + #endif #if DEBUG