[Solved] Getting Different Value When Using CT-ARM
Posted: Mon Mar 12, 2018 10:55 am
Hi, I am using the coding below to get data from magnetometer (HMC5883L) from GY-80 module.
When I am using Arduino Mega, these are the datas I get:
But when I am using CT-ARM, with the same coding, I am getting this:
These are the data for one turn - 360 degree. Why am I not getting negative value when using CT-ARM? I have tried change <<8 to <<32 because CT-ARM is 32-bit? Anyway it does not work. Need help and need some explanation. Thanks in advanced.
I am sorry for the long post.
- CODE: SELECT_ALL_CODE
#include <Wire.h> //I2C Arduino Library
#define Magnetometer_mX0 0x03
#define Magnetometer_mX1 0x04
#define Magnetometer_mZ0 0x05
#define Magnetometer_mZ1 0x06
#define Magnetometer_mY0 0x07
#define Magnetometer_mY1 0x08
int mX0, mX1, mX_out;
int mY0, mY1, mY_out;
int mZ0, mZ1, mZ_out;
float Xm,Ym,Zm;
#define Magnetometer 0x1E //I2C 7bit address of HMC5883
void setup(){
//Initialize Serial and I2C communications
Serial.begin(9600);
Wire.begin();
delay(100);
Wire.beginTransmission(Magnetometer);
Wire.write(0x02); // Select mode register
Wire.write(0x00); // Continuous measurement mode
Wire.endTransmission();
}
void loop(){
//---- X-Axis
Wire.beginTransmission(Magnetometer); // transmit to device
Wire.write(Magnetometer_mX1);
Wire.endTransmission();
Wire.requestFrom(Magnetometer,1);
if(Wire.available()<=1)
{
mX0 = Wire.read();
}
Wire.beginTransmission(Magnetometer); // transmit to device
Wire.write(Magnetometer_mX0);
Wire.endTransmission();
Wire.requestFrom(Magnetometer,1);
if(Wire.available()<=1)
{
mX1 = Wire.read();
}
//---- Y-Axis
Wire.beginTransmission(Magnetometer); // transmit to device
Wire.write(Magnetometer_mY1);
Wire.endTransmission();
Wire.requestFrom(Magnetometer,1);
if(Wire.available()<=1)
{
mY0 = Wire.read();
}
Wire.beginTransmission(Magnetometer); // transmit to device
Wire.write(Magnetometer_mY0);
Wire.endTransmission();
Wire.requestFrom(Magnetometer,1);
if(Wire.available()<=1)
{
mY1 = Wire.read();
}
//---- Z-Axis
Wire.beginTransmission(Magnetometer); // transmit to device
Wire.write(Magnetometer_mZ1);
Wire.endTransmission();
Wire.requestFrom(Magnetometer,1);
if(Wire.available()<=1)
{
mZ0 = Wire.read();
}
Wire.beginTransmission(Magnetometer); // transmit to device
Wire.write(Magnetometer_mZ0);
Wire.endTransmission();
Wire.requestFrom(Magnetometer,1);
if(Wire.available()<=1)
{
mZ1 = Wire.read();
}
//---- X-Axis
mX1=mX1<<8;
mX_out =mX0+mX1; // Raw data
// From the datasheet: 0.92 mG/digit
Xm = mX_out*0.00092; // Gauss unit
//* Earth magnetic field ranges from 0.25 to 0.65 Gauss, so these are the values that we need to get approximately.
//---- Y-Axis
mY1=mY1<<8;
mY_out =mY0+mY1;
Ym = mY_out*0.00092;
//---- Z-Axis
mZ1=mZ1<<8;
mZ_out =mZ0+mZ1;
Zm = mZ_out*0.00092;
//Print out values of each axis
//Serial.print("x: ");
Serial.print(Xm);
Serial.print(",");
Serial.print(Ym);
Serial.print(",");
Serial.println(Zm);
delay(50);
}
When I am using Arduino Mega, these are the datas I get:
- CODE: SELECT_ALL_CODE
0.03 -0.34 0.16
0.36 -0.18 0.1
0.37 -0.18 0.09
0.37 -0.18 0.09
0.37 -0.18 0.1
0.36 -0.18 0.09
0.36 -0.18 0.09
0.37 -0.18 0.1
0.37 -0.18 0.1
0.37 -0.18 0.1
0.37 -0.18 0.09
0.37 -0.18 0.09
0.37 -0.18 0.09
0.36 -0.18 0.1
0.37 -0.18 0.1
0.37 -0.18 0.1
0.36 -0.18 0.09
0.36 -0.18 0.09
0.36 -0.18 0.1
0.36 -0.18 0.1
0.36 -0.18 0.09
0.36 -0.18 0.1
0.36 -0.18 0.1
0.36 -0.18 0.1
0.36 -0.18 0.1
0.36 -0.18 0.1
0.36 -0.18 0.1
0.37 -0.18 0.1
0.37 -0.18 0.1
0.37 -0.18 0.09
0.37 -0.17 0.1
0.37 -0.18 0.09
0.37 -0.18 0.09
0.37 -0.18 0.09
0.36 -0.18 0.09
0.37 -0.18 0.09
0.37 -0.18 0.09
0.37 -0.18 0.09
0.37 -0.18 0.09
0.37 -0.18 0.09
0.38 -0.16 0.1
0.39 -0.15 0.1
0.4 -0.14 0.11
0.4 -0.13 0.11
0.4 -0.13 0.11
0.41 -0.13 0.11
0.41 -0.12 0.11
0.41 -0.11 0.11
0.42 -0.11 0.11
0.42 -0.11 0.11
0.42 -0.11 0.11
0.43 -0.09 0.12
0.43 -0.08 0.12
0.43 -0.07 0.12
0.44 -0.06 0.12
0.44 -0.06 0.12
0.44 -0.05 0.13
0.44 -0.04 0.12
0.44 -0.02 0.13
0.44 -0.01 0.13
0.44 -0.01 0.13
0.44 -0.01 0.13
0.45 0.03 0.13
0.44 0.06 0.13
0.43 0.09 0.13
0.41 0.13 0.12
0.41 0.13 0.12
0.39 0.16 0.12
0.37 0.18 0.11
0.33 0.22 0.11
0.3 0.24 0.1
0.3 0.24 0.1
0.3 0.24 0.1
0.24 0.26 0.09
0.21 0.27 0.08
0.18 0.27 0.08
0.16 0.27 0.08
0.16 0.27 0.08
0.13 0.27 0.07
0.11 0.27 0.07
0.09 0.26 0.07
0.08 0.26 0.06
0.08 0.26 0.06
0.07 0.26 0.06
0.07 0.26 0.07
0.08 0.26 0.07
0.09 0.26 0.07
0.09 0.26 0.07
0.09 0.26 0.07
0.06 0.25 0.06
0.04 0.24 0.05
0.03 0.24 0.05
0.02 0.23 0.05
0.02 0.23 0.05
0.02 0.23 0.05
0.01 0.22 0.05
0 0.22 0.05
0 0.21 0.04
0 0.21 0.04
0 0.21 0.04
0 0.21 0.05
-0.01 0.21 0.05
0 0.21 0.05
0 0.21 0.05
0 0.21 0.05
0 0.21 0.05
-0.01 0.21 0.05
-0.01 0.21 0.05
-0.02 0.19 0.04
-0.02 0.19 0.04
-0.02 0.19 0.04
-0.06 0.15 0.03
-0.07 0.12 0.03
-0.08 0.11 0.02
-0.08 0.09 0.02
-0.08 0.09 0.02
-0.08 0.08 0.02
-0.08 0.07 0.02
-0.08 0.07 0.02
-0.08 0.07 0.02
-0.08 0.07 0.02
-0.08 0.07 0.02
-0.08 0.06 0.02
-0.08 0.05 0.02
-0.09 0.04 0.02
-0.08 0.02 0.02
-0.08 0.02 0.02
-0.08 0 0.01
-0.07 -0.03 0.01
-0.07 -0.05 0.01
-0.06 -0.06 0.01
-0.06 -0.06 0.01
-0.06 -0.07 0.02
-0.05 -0.08 0.01
-0.04 -0.09 0.01
-0.03 -0.1 0.01
-0.03 -0.1 0.01
-0.03 -0.1 0.01
-0.01 -0.13 0.01
0 -0.14 0.01
0.01 -0.15 0.01
0.03 -0.17 0.01
0.03 -0.17 0.01
0.04 -0.18 0.01
0.05 -0.19 0.01
0.06 -0.2 0.01
0.08 -0.21 0.01
0.08 -0.21 0.01
0.08 -0.21 0.01
0.1 -0.23 0.02
0.11 -0.23 0.02
0.12 -0.24 0.03
0.14 -0.25 0.03
0.14 -0.25 0.03
0.16 -0.25 0.04
0.17 -0.26 0.04
0.19 -0.25 0.05
0.22 -0.26 0.05
0.22 -0.26 0.05
0.22 -0.26 0.05
0.26 -0.25 0.06
0.28 -0.25 0.07
0.28 -0.24 0.07
0.3 -0.23 0.07
0.3 -0.23 0.07
0.32 -0.22 0.07
0.34 -0.21 0.07
0.34 -0.21 0.07
0.35 -0.2 0.08
0.35 -0.2 0.08
0.35 -0.2 0.08
0.36 -0.19 0.08
0.37 -0.18 0.08
0.37 -0.17 0.08
0.38 -0.16 0.08
0.38 -0.16 0.08
0.39 -0.15 0.09
0.39 -0.14 0.09
0.4 -0.13 0.09
0.4 -0.13 0.09
0.4 -0.13 0.09
0.39 -0.13 0.09
0.4 -0.13 0.09
0.4 -0.13 0.09
0.39 -0.13 0.09
0.39 -0.13 0.09
0.4 -0.13 0.09
0.4 -0.12 0.1
0.4 -0.12 0.1
0.4 -0.12 0.1
0.4 -0.12 0.1
0.4 -0.12 0.1
0.4 -0.12 0.09
0.4 -0.12 0.1
0.4 -0.12 0.1
0.4 -0.12 0.1
0.4 -0.12 0.1
0.4 -0.12 0.1
0.4 -0.12 0.1
0.4 -0.12 0.1
0.4 -0.12 0.1
But when I am using CT-ARM, with the same coding, I am getting this:
- CODE: SELECT_ALL_CODE
56.52 60.2 56.52
56.52 60.2 56.52
56.52 60.2 56.52
56.52 60.19 56.52
56.52 60.2 56.52
56.52 60.2 56.52
56.52 60.2 56.52
56.52 60.2 56.52
56.52 60.2 56.52
56.52 60.2 56.52
56.52 60.2 56.52
56.52 60.19 56.52
56.52 60.19 56.52
56.52 60.2 56.52
56.52 60.19 56.52
56.52 60.2 56.52
56.52 60.19 56.52
56.52 60.19 56.52
56.52 60.19 56.52
56.52 60.19 56.52
56.52 60.2 56.52
56.52 60.2 56.52
56.52 60.19 56.52
56.52 60.19 56.52
56.52 60.19 56.52
56.52 60.2 56.52
56.52 60.2 56.52
56.52 60.2 56.52
56.52 60.2 56.52
56.52 60.2 56.52
56.52 60.21 56.52
56.52 60.21 56.52
56.52 60.22 56.52
56.52 60.23 56.52
56.52 60.23 56.52
56.52 60.23 56.52
56.52 60.24 56.52
56.52 60.25 56.52
56.52 60.26 56.52
56.52 60.26 56.52
56.52 60.26 56.52
56.52 60.27 56.52
56.52 60.27 56.52
56.52 60.27 56.52
56.52 60.27 56.52
56.52 60.27 56.52
56.52 60.28 56.52
56.52 60.28 56.52
56.52 0 56.52
56.52 0.01 56.52
56.52 0.01 56.52
56.52 0.01 56.52
56.52 0.03 56.52
56.52 0.04 56.52
56.52 0.04 56.52
56.52 0.05 56.52
56.52 0.05 56.52
56.52 0.06 56.52
56.52 0.07 56.52
56.52 0.08 56.52
56.52 0.09 56.52
56.52 0.09 56.52
56.52 0.1 56.52
56.52 0.11 56.52
56.52 0.12 56.52
56.52 0.13 56.52
56.52 0.13 56.52
56.52 0.14 56.52
56.52 0.14 56.52
56.52 0.15 56.52
56.52 0.16 56.52
56.52 0.16 56.52
56.52 0.17 56.52
56.52 0.18 56.52
56.52 0.19 56.52
56.52 0.2 56.52
56.52 0.2 56.52
56.52 0.2 56.52
56.52 0.2 56.52
56.52 0.21 56.52
56.52 0.21 56.52
56.52 0.21 56.52
56.52 0.21 56.52
56.52 0.22 56.52
56.52 0.23 56.52
56.52 0.23 56.52
56.52 0.23 56.52
56.52 0.23 56.52
56.52 0.24 56.52
56.52 0.24 56.52
56.52 0.25 56.52
56.52 0.25 56.52
56.52 0.25 56.52
56.52 0.25 56.52
56.52 0.26 56.52
56.52 0.26 56.52
56.52 0.27 56.52
56.52 0.27 56.52
56.52 0.28 56.52
56.52 0.29 56.52
56.52 0.3 56.52
56.52 0.3 56.52
56.52 0.3 56.52
56.52 0.32 56.52
56.52 0.33 56.52
56.52 0.34 56.52
56.52 0.34 56.52
56.52 0.34 56.52
56.52 0.34 56.52
56.52 0.35 56.52
56.52 0.35 56.52
56.52 0.36 56.52
56.52 0.36 56.52
56.52 0.36 56.52
56.52 0.37 56.52
56.52 0.37 56.52
56.52 0.38 56.52
56.52 0.38 56.52
56.52 0.38 56.52
56.52 0.39 56.52
56.52 0.39 56.52
56.52 0.4 56.52
56.52 0.4 56.52
56.52 0.41 56.52
56.52 0.41 56.52
56.52 0.41 56.52
56.52 0.42 56.52
56.52 0.42 56.52
56.52 0.42 56.52
56.52 0.43 56.52
56.52 0.43 56.52
56.52 0.43 56.52
56.52 0.44 56.52
56.52 0.44 56.52
56.52 0.44 56.52
56.52 0.44 56.52
56.52 0.45 56.52
56.52 0.44 56.52
56.52 0.44 56.52
56.52 0.45 56.52
56.52 0.45 56.52
1.86 0.44 56.52
1.85 0.44 56.52
1.85 0.44 56.52
1.84 0.44 56.52
1.84 0.44 56.52
1.82 0.45 56.52
1.82 0.44 56.52
1.82 0.44 56.52
1.81 0.45 56.52
1.79 0.44 56.52
1.79 0.44 56.52
1.79 0.44 56.52
1.79 0.44 56.52
1.76 0.44 56.52
1.74 0.44 56.52
1.74 0.44 56.52
1.74 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.72 0.45 56.52
1.72 0.45 56.52
1.72 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.72 0.44 56.52
1.72 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.73 0.44 56.52
1.71 0.43 56.52
1.7 0.43 56.52
1.68 0.42 56.52
1.68 0.42 56.52
1.67 0.42 56.52
1.67 0.41 56.52
1.66 0.41 56.52
1.64 0.41 56.52
1.64 0.41 56.52
1.63 0.4 56.52
1.63 0.39 56.52
1.61 0.39 56.52
1.6 0.37 56.52
1.6 0.37 56.52
1.58 0.37 56.52
1.57 0.35 56.52
1.56 0.34 56.52
1.56 0.34 56.52
1.56 0.34 56.52
1.54 0.32 56.52
1.53 0.31 56.52
1.52 0.3 56.52
1.52 0.3 56.52
1.52 0.3 56.52
1.52 0.29 56.52
1.51 0.28 56.52
1.51 0.27 56.52
1.51 0.27 56.52
1.5 0.26 56.52
1.5 0.25 56.52
1.49 0.24 56.52
1.49 0.23 56.52
1.49 0.23 56.52
1.48 0.22 56.52
1.48 0.21 56.52
1.48 0.2 56.52
1.48 0.2 56.52
1.48 0.2 56.52
1.47 0.18 56.52
1.47 0.18 56.52
1.47 0.17 56.52
1.47 0.17 56.52
1.47 0.17 56.52
1.46 0.15 56.52
1.46 0.14 56.52
1.46 0.14 56.52
1.46 0.14 56.52
1.46 0.12 56.52
1.46 0.11 56.52
1.46 0.1 56.52
1.46 0.1 56.52
1.46 0.1 56.52
1.46 0.08 56.52
1.45 0.07 56.52
1.46 0.06 56.52
1.46 0.06 56.52
1.46 0.06 56.52
1.45 0.04 56.52
1.45 0.03 56.52
1.46 0.03 56.52
1.46 0.03 56.52
1.46 0.03 56.52
1.46 0.01 56.52
1.46 0.01 56.52
1.46 60.29 56.52
1.46 60.29 56.52
1.46 60.28 56.52
1.46 60.27 56.52
1.46 60.26 56.52
1.47 60.25 56.52
1.47 60.25 56.52
1.47 60.25 56.52
1.48 60.23 56.52
1.48 60.23 56.52
1.48 60.21 56.52
1.48 60.21 56.52
1.48 60.21 56.52
1.49 60.19 56.52
1.5 60.18 56.52
1.51 60.17 56.52
1.51 60.15 56.52
1.52 60.15 56.52
1.53 60.14 56.52
1.54 60.13 56.52
1.54 60.11 56.52
1.55 60.11 56.52
1.55 60.11 56.52
1.57 60.09 56.52
1.58 60.08 56.52
1.59 60.07 56.52
1.6 60.06 56.52
1.6 60.06 56.52
1.61 60.05 56.52
1.62 60.05 56.52
1.64 60.04 56.52
1.65 60.03 56.52
1.65 60.03 56.52
1.67 60.02 56.52
1.68 60.01 56.52
1.7 60.01 56.52
1.72 60 56.52
1.72 60 56.52
1.73 59.99 56.52
1.75 59.99 56.52
1.77 59.98 56.52
1.78 59.98 56.52
1.78 59.98 56.52
1.78 59.98 56.52
1.8 59.97 56.52
1.81 59.97 56.52
1.82 59.97 56.52
1.82 59.97 56.52
1.82 59.97 56.52
1.84 59.96 56.52
1.86 59.97 56.52
56.52 59.97 56.52
56.52 59.97 56.52
56.52 59.97 56.52
56.52 59.97 56.52
56.52 59.97 56.52
56.52 59.97 56.52
56.52 59.98 56.52
56.52 59.98 56.52
56.52 59.98 56.52
56.52 59.98 56.52
56.52 59.98 56.52
56.52 59.99 56.52
56.52 59.99 56.52
56.52 59.99 56.52
56.52 59.99 56.52
56.52 59.99 56.52
56.52 60 56.52
56.52 60 56.52
56.52 60 56.52
56.52 60 56.52
56.52 60.01 56.52
56.52 60.01 56.52
56.52 60.02 56.52
56.52 60.03 56.52
56.52 60.03 56.52
56.52 60.03 56.52
56.52 60.04 56.52
56.52 60.05 56.52
56.52 60.05 56.52
56.52 60.05 56.52
56.52 60.05 56.52
56.52 60.06 56.52
56.52 60.07 56.52
56.52 60.07 56.52
56.52 60.08 56.52
56.52 60.08 56.52
56.52 60.08 56.52
56.52 60.09 56.52
56.52 60.09 56.52
56.52 60.1 56.52
56.52 60.1 56.52
56.52 60.1 56.52
56.52 60.11 56.52
56.52 60.11 56.52
56.52 60.11 56.52
56.52 60.12 56.52
56.52 60.12 56.52
56.52 60.12 56.52
56.52 60.13 56.52
56.52 60.13 56.52
56.52 60.14 56.52
56.52 60.15 56.52
56.52 60.15 56.52
56.52 60.15 56.52
56.52 60.16 56.52
56.52 60.16 56.52
56.52 60.17 56.52
56.52 60.17 56.52
56.52 60.17 56.52
56.52 60.18 56.52
56.52 60.18 56.52
56.52 60.18 56.52
56.52 60.18 56.52
56.52 60.18 56.52
56.52 60.18 56.52
56.52 60.18 56.52
56.52 60.18 56.52
56.52 60.18 56.52
56.52 60.18 56.52
56.52 60.18 56.52
56.52 60.18 56.52
56.52 60.18 56.52
56.52 60.18 56.52
56.52 60.18 56.52
56.52 60.18 56.52
56.52 60.18 56.52
56.52 60.18 56.52
56.52 60.18 56.52
56.52 60.18 56.52
56.52 60.18 56.52
56.52 60.18 56.52
56.52 60.2 56.52
56.52 60.2 56.52
56.52 60.21 56.52
56.52 60.22 56.52
56.52 60.22 56.52
56.52 60.23 56.52
56.52 60.24 56.52
56.52 60.25 56.52
56.52 60.25 56.52
56.52 60.26 56.52
56.52 60.26 56.52
56.52 60.26 56.52
56.52 60.26 56.52
56.52 60.27 56.52
56.52 60.28 56.52
56.52 60.28 56.52
56.52 60.28 56.52
56.52 0 56.52
56.52 0.01 56.52
56.52 0.02 56.52
56.52 0.02 56.52
56.52 0.02 56.52
56.52 0.03 56.52
56.52 0.03 56.52
56.52 0.03 56.52
56.52 0.03 56.52
56.52 0.03 56.52
These are the data for one turn - 360 degree. Why am I not getting negative value when using CT-ARM? I have tried change <<8 to <<32 because CT-ARM is 32-bit? Anyway it does not work. Need help and need some explanation. Thanks in advanced.
I am sorry for the long post.