CMPS10 heading changes when tilted

Including Thermal, Compass etc.

Moderator: chris

CMPS10 heading changes when tilted

Postby eclipsh » Wed Dec 21, 2011 10:56 pm

My CMPS10 was working fine for a while. When I was rewiring my system I accidentally wired the I2C pins to mode and factory use instead of the communication pins. Now the heading changes dramatically when the compass is tilted. The pitch and yaw functions still read out fine. Is the magnetometer damaged or did some software get scrambled? I tried resetting to factory specs but may have done it wrong. Here is the code I used:

void reset(){
Wire.beginTransmission(deviceId);
Wire.write(22);
delay(10);
Wire.write(0x20);
delay(100);
Wire.write(0x2A);
delay(100);
Wire.write(0x60);
Wire.endTransmission();
delay(100);

Serial.println("done");

}


This is running on an Arduino Mega with 5v power going to the compass. I've also got pull up resistors wired in to the I2C lines at the compass.

Thanks for any help you can provide.
eclipsh
 
Posts: 4
Joined: Wed Dec 21, 2011 10:50 pm

Re: CMPS10 heading changes when tilted

Postby Gerry » Thu Dec 22, 2011 12:17 pm

Your code to restore factory calibration is not correct. You MUST send the 3 bytes in 3 separate transaction, not all in the same tranaction as you are doing.

Try somethin like this:
Wire.beginTransmission(deviceId);
Wire.write(22);
Wire.write(0x20);
Wire.endTransmission();
delay(100);
Wire.beginTransmission(deviceId);
Wire.write(22);
Wire.write(0x2A);
Wire.endTransmission();
delay(100);
Wire.beginTransmission(deviceId);
Wire.write(22);
Wire.write(0x60);
Wire.endTransmission();
User avatar
Gerry
Site Admin
 
Posts: 245
Joined: Wed Nov 08, 2006 12:28 pm

Re: CMPS10 heading changes when tilted

Postby eclipsh » Thu Dec 22, 2011 5:20 pm

Thanks, I tried that code and I'm still getting major heading changes when the compass is tilted. The serial print below is heading, pitch then roll.

Data received, value is: 656, 255, 1
Data received, value is: 656, 255, 1
Data received, value is: 650, 254, 1
Data received, value is: 588, 253, 1
Data received, value is: 630, 254, 1
Data received, value is: 485, 249, 0
Data received, value is: 434, 246, 0
Data received, value is: 380, 242, 0
Data received, value is: 371, 241, 255
Data received, value is: 379, 242, 0
Data received, value is: 385, 242, 0
Data received, value is: 383, 242, 0
Data received, value is: 388, 242, 0
Data received, value is: 388, 243, 0
Data received, value is: 390, 243, 06
Data received, value is: 390, 243, 0

As you can see, a 12 degree tilt results in a 26 degree heading change. Any thoughts on how to fix this?
eclipsh
 
Posts: 4
Joined: Wed Dec 21, 2011 10:50 pm

Re: CMPS10 heading changes when tilted

Postby Gerry » Tue Jan 03, 2012 11:55 am

What Firmware version do you have?
(read from register 0).
User avatar
Gerry
Site Admin
 
Posts: 245
Joined: Wed Nov 08, 2006 12:28 pm

Re: CMPS10 heading changes when tilted

Postby eclipsh » Tue Jan 03, 2012 7:57 pm

Thanks for the response. I'm very new to coding for communications so I may have done this wrong.

I put in this code:

void loop(){
Wire.beginTransmission(deviceId);
Wire.requestFrom(deviceId, 0);
delay(10);
int avail = Wire.available();
unsigned int value = ((unsigned int)Wire.read()) << 8;
value = value + ((unsigned int)Wire.read());

Serial.print("Data received, value is: ");
Serial.println(value);

delay(1000);
}


and get a response of 65279

Is that correct?
eclipsh
 
Posts: 4
Joined: Wed Dec 21, 2011 10:50 pm

Re: CMPS10 heading changes when tilted

Postby Gerry » Wed Jan 04, 2012 2:21 pm

Your code is not correct.

From our Arduino example, try something like:

int soft_ver()
{
int data; // Software version of CMPS10 is read into data and then returned

Wire.beginTransmission(ADDRESS);
Wire.send(0); // Sends the register we wish to start reading from
Wire.endTransmission();

Wire.requestFrom(ADDRESS, 1); // Request byte from CMPS10
while(Wire.available() < 1);
data = Wire.receive();

return(data);
}
User avatar
Gerry
Site Admin
 
Posts: 245
Joined: Wed Nov 08, 2006 12:28 pm

Re: CMPS10 heading changes when tilted

Postby eclipsh » Wed Jan 04, 2012 6:47 pm

Thanks again for the help. It looks like I'm running version 4. I had to change the return command to a Serial.println to get a print out. Hopefully that didn't screw anything up.

For what it is worth, writing to 0 doesn't work in Arduino 1.0 software. I had to go back to 0022 to check this. Hopefully they'll fix that but someone else might have the same problem before then.
eclipsh
 
Posts: 4
Joined: Wed Dec 21, 2011 10:50 pm

Re: CMPS10 heading changes when tilted

Postby Gerry » Thu Jan 05, 2012 2:06 pm

eclipsh wrote:I'm running version 4.

Thanks, there was a calibration issue with V4 that may explain your results.
Please contact support11@robot-electronics.co.uk
User avatar
Gerry
Site Admin
 
Posts: 245
Joined: Wed Nov 08, 2006 12:28 pm

Re: CMPS10 heading changes when tilted

Postby c1p81 » Fri Jun 01, 2012 12:54 pm

i have the exact same problem with version 7
in flat position the bearing is quite ok (difference < 5° from a magnetic geological compass)
but tilting the pcb the data changes as i modify the roll and the pitch of PCB
c1p81
 
Posts: 3
Joined: Fri Jun 01, 2012 12:51 pm

Re: CMPS10 heading changes when tilted

Postby c1p81 » Fri Jun 01, 2012 1:08 pm

i have the same problem with version 7

L
c1p81
 
Posts: 3
Joined: Fri Jun 01, 2012 12:51 pm

Re: CMPS10 heading changes when tilted

Postby c1p81 » Fri Jun 01, 2012 1:25 pm

i think i have found the solution for my problem
the pcb is mounted up-side down on my breadboard
the right way is put the pin on the top

Luca
c1p81
 
Posts: 3
Joined: Fri Jun 01, 2012 12:51 pm


Return to Other Sensors

Who is online

Users browsing this forum: No registered users and 1 guest

cron