Subversion Repositories FlightCtrl

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1993 - 1
#include <ADXL345.h>
2
#include <HMC5843.h>
3
#include <ITG3200.h>
4
 
5
//#define DEBUG
6
#include "DebugUtils.h"
7
 
8
#include "FreeIMU.h"
9
#include <Wire.h>
10
 
11
int raw_values[9];
12
char str[512];
13
float val[9], q[4];
14
 
15
unsigned long start, stop;
16
 
17
// Set the default object
18
FreeIMU my3IMU = FreeIMU();
19
 
20
void setup() {
21
  Serial.begin(115200);
22
  Wire.begin();
23
 
24
  delay(500);
25
  my3IMU.init(true); // the parameter enable or disable fast mode
26
  delay(500);
27
}
28
 
29
void loop() {
30
  Serial.println("Testing raw reading speed (average on 1024 samples):");
31
  start = micros();
32
  for(int i=0; i<1024; i++) {
33
    my3IMU.getRawValues(raw_values);
34
  }
35
  stop = micros();
36
  Serial.print("--> result: ");
37
  Serial.print((stop - start) / 1024);
38
  Serial.print(" microseconds .... ");
39
  Serial.print(((stop - start) / 1024) / 1000);
40
  Serial.println(" milliseconds");
41
 
42
 
43
  Serial.println("Testing calibrated reading speed (average on 1024 samples):");
44
  start = micros();
45
  for(int i=0; i<1024; i++) {
46
    my3IMU.getValues(val);
47
  }
48
  stop = micros();
49
  Serial.print("--> result: ");
50
  Serial.print((stop - start) / 1024);
51
  Serial.print(" microseconds .... ");
52
  Serial.print(((stop - start) / 1024) / 1000);
53
  Serial.println(" milliseconds");
54
 
55
 
56
  Serial.println("Testing sensor fusion speed (average on 1024 samples):");
57
  start = micros();
58
  for(int i=0; i<1024; i++) {
59
    my3IMU.getQ(q);
60
  }
61
  stop = micros();
62
  Serial.print("--> result: ");
63
  Serial.print((stop - start) / 1024);
64
  Serial.print(" microseconds .... ");
65
  Serial.print(((stop - start) / 1024) / 1000);
66
  Serial.println(" milliseconds");
67
 
68
 
69
  Serial.println("Looping again..");
70
  Serial.println("----");
71
}