So I'm building a 9DOF sensor unit to use in a performance art oriented setup with it being strapped to a performers wrist. (this is the project Takahashi's Shellfish Concern - Live @ The Noise Upstairs - YouTube)
The main board is an ArduIMU board (ArduIMU+ V2 (Flat) - DEV-09956 - SparkFun Electronics) which has onboard 3axis accel(ADXL335) and 3axis gyro (LY530/LPR530) and I've also added a 3axis magnetometer(HMC5883L) which is being read through the I2C bus.
The approach I'm taking, since I'm going to be using Max/MSP to handle all the actual data mapping and everything, is to have the ArduIMU just spit out raw sensor values over serial (XBee send/receive pair using a call/response type setup) and all the numbers will be calibrated/filtered/etc.. in Max/MSP.
The main problem I'm having is that the raw sensor values seem to be incredibly noisy. You can see this short little video here:
http://rodrigoconstanzo.com/sensors/sensors.MOV
My Accel X and Magnetometer axis' seem to just jump from 0 to 250 or so, and just go back and forth. That doesn't seem quite right. It should also be noted that I get radically different numbers sometimes when turning the sensor unit on (sometimes its other axis' that do that "jump from zero" stuff).
Now as far as treating the numbers I'm using this wonderful guide here (http://arduino.cc/forum/index.php/topic,58048.0.html), and then just applying the same ideas but to Max/MSP. (ie for my calibration code I'm taking the mean of the idle value, then subtracting the sensor value from that, and dividing by 102.3 (basically this accVal = (accAdc-accZero)/102.3 ).
I eventually want to do something like this MARG filtering (An efficient orientation filter for MARG sensor arrays (real-time demonstration) - YouTube) but with the raw values being what they are, it's mucking up all the number crunching down the line.
Here is the Arduino code
#include <Wire.h> //I2C Arduino Library
#define address 0x1E //0011110b, I2C 7bit address of HMC5883
#define aX A0
#define aY A1
#define aZ A2
#define gX A6
#define gY A7
#define gZ A3
// define sensor variables
int AccX;
int AccY;
int AccZ;
int GyroX;
int GyroY;
int GyroZ;
int inByte = 0; // incoming serial byte
void setup()
{
// start serial port at 9600 bps:
Serial.begin(57600);
Wire.begin();
//Put the HMC5883 IC into the correct operating mode
Wire.beginTransmission(address); //open communication with HMC5883
Wire.write(0x02); //select mode register
Wire.write(0x00); //continuous measurement mode
Wire.endTransmission();
establishContact(); // send a byte to establish contact until receiver responds
}
void loop()
{
int x,y,z; //triple axis data for magnetometer
//Tell the HMC5883 where to begin reading data
Wire.beginTransmission(address);
Wire.write(0x03); //select register 3, X MSB register
Wire.endTransmission();
//Read data from each axis of magnetometer, 2 registers per axis
Wire.requestFrom(address, 6);
if(6<=Wire.available()){
x = Wire.read()<<8; //X msb
x |= Wire.read(); //X lsb
z = Wire.read()<<8; //Z msb
z |= Wire.read(); //Z lsb
y = Wire.read()<<8; //Y msb
y |= Wire.read(); //Y lsb
}
// if we get a valid byte, read analog ins:
if (Serial.available() > 0) {
inByte = Serial.read();
AccX = analogRead(aX);
AccY = analogRead(aY);
AccZ = analogRead(aZ);
GyroX = analogRead(gX);
GyroY = analogRead(gY);
GyroZ = analogRead(gZ);
Serial.write(AccX);
Serial.write(AccY);
Serial.write(AccZ);
Serial.write(GyroX);
Serial.write(GyroY);
Serial.write(GyroZ);
Serial.write(x);
Serial.write(y);
Serial.write(z);
}
}
void establishContact() {
while (Serial.available() <= 0) {
Serial.write('A'); // send a capital A
delay(300);
}
}
So is there any reason why I should be getting this kind of sensor behavior? And more importantly, what can I do about it?