imu rev1

Dependencies:   IMUfilter mbed

Fork of AIviate by UCLA IEEE

Committer:
teamgoat
Date:
Fri Nov 01 01:23:04 2013 +0000
Revision:
3:f9e18a9cd9af
Parent:
2:452dd766d212
Child:
4:44a5b1e8fd27
Gyro is working; note: need to implement zero-level canceling on gyro (zero-level is result of stress on sensor being mounted on PCB)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
teamgoat 0:0c627ff4c5ed 1 #include "steps.h"
teamgoat 0:0c627ff4c5ed 2
teamgoat 0:0c627ff4c5ed 3 Serial pc(USBTX, USBRX);
teamgoat 0:0c627ff4c5ed 4
teamgoat 0:0c627ff4c5ed 5 // in the future, change get_sensor_data to append the sensor data to a rolling list
teamgoat 0:0c627ff4c5ed 6 void get_sensor_data()
teamgoat 0:0c627ff4c5ed 7 {
teamgoat 2:452dd766d212 8 struct sensor s;
teamgoat 0:0c627ff4c5ed 9 if (read_accelerometer(&s) == 0)
teamgoat 0:0c627ff4c5ed 10 {
teamgoat 2:452dd766d212 11 pc.printf("Error in get_sensor_data while reading from accel!\r\n");
teamgoat 0:0c627ff4c5ed 12 return;
teamgoat 0:0c627ff4c5ed 13 }
teamgoat 3:f9e18a9cd9af 14 if (read_gyro(&s) == 0)
teamgoat 3:f9e18a9cd9af 15 {
teamgoat 3:f9e18a9cd9af 16 pc.printf("Error in get_sensor_data while reading from gyro!\r\n");
teamgoat 3:f9e18a9cd9af 17 return;
teamgoat 3:f9e18a9cd9af 18 }
teamgoat 3:f9e18a9cd9af 19 pc.printf("Ax: %i Ay: %i Az: %i Gx: %i Gy: %i Gz: %i\r\n", s.ax, s.ay, s.az, s.gx, s.gy, s.gz);
teamgoat 0:0c627ff4c5ed 20 return;
teamgoat 2:452dd766d212 21 }
teamgoat 2:452dd766d212 22
teamgoat 2:452dd766d212 23 void init_sensors()
teamgoat 2:452dd766d212 24 {
teamgoat 2:452dd766d212 25 // create config struct
teamgoat 2:452dd766d212 26 struct config c;
teamgoat 2:452dd766d212 27
teamgoat 2:452dd766d212 28 // set configurations
teamgoat 2:452dd766d212 29 c.frequency = 10000;
teamgoat 2:452dd766d212 30
teamgoat 2:452dd766d212 31 // pass configuration struct to configuration routine
teamgoat 2:452dd766d212 32 int ret = config_gy80(&c);
teamgoat 2:452dd766d212 33 if (ret == 0)
teamgoat 2:452dd766d212 34 {
teamgoat 2:452dd766d212 35 pc.printf("Error configuring sensors\r\n");
teamgoat 2:452dd766d212 36 }
teamgoat 0:0c627ff4c5ed 37 }