Teensy 3.2 + Adafruit NXP Precision 9DoF Breakout + Teensy Fusion Library?

Status
Not open for further replies.

solardude

Well-known member
I'm trying to get a Teensy 3.2 to work with the Adafruit 9 DOF board that uses the same accel and gyro sensors as the Teensy Prop shield.

https://www.adafruit.com/product/3463

I try to follow the directions to calibrate the Accel but when I load the recommended calibration sketch Motion Cal receives no data when I open the port the Teensy 3.2 is connected to. The serial output is "config error FXOS8700" so basically it fails as soon as this function is called in the Calibraion code needed to run the Motion Cal software.

I'm using this recommended library: https://github.com/PaulStoffregen/NXPMotionSense

Code:
bool NXPMotionSense::begin()
{
	unsigned char buf[NXP_MOTION_CAL_SIZE];
	uint8_t i;
	uint16_t crc;

	Wire.begin();
	Wire.setClock(400000);

	memset(accel_mag_raw, 0, sizeof(accel_mag_raw));
	memset(gyro_raw, 0, sizeof(gyro_raw));

	//Serial.println("init hardware");
	while (!FXOS8700_begin()) {
		Serial.println("config error FXOS8700");
		delay(1000);
	}
	while (!FXAS21002_begin()) {
		Serial.println("config error FXAS21002");
		delay(1000);
	}
	while (!MPL3115_begin()) {
		Serial.println("config error MPL3115");
		delay(1000);
	}
	//Serial.println("init done");

	for (i=0; i < NXP_MOTION_CAL_SIZE; i++) {
		buf[i] = EEPROM.read(NXP_MOTION_CAL_EEADDR + i);
	}
	crc = 0xFFFF;
	for (i=0; i < NXP_MOTION_CAL_SIZE; i++) {
		crc = _crc16_update(crc, buf[i]);
	}
	if (crc == 0 && buf[0] == 117 && buf[1] == 84) {
		memcpy(cal, buf+2, sizeof(cal));
	} else {
		memset(cal, 0, sizeof(cal));
		cal[9] = 50.0f;
	}
	return true;

}

I'm using this recommended library: https://github.com/PaulStoffregen/NXPMotionSense

I'm trying to run the latest Madgwick Sensor Fusion code in the NXPMotionSense Library to get the most accurate compass readings possible with tilt calibration.

Should this code work with the Teensy 3.2 and Adafruit breakout with the same two gyro and compass sensors?

I was able to calibrate the compass using Adafruits instructions to load ther ARHS Calibrate USB code along with Pauls Motion Cal software and then add the offsets to their Madgwick code manually. It works but the compass readings are wrong, it shows like 3 0-360 degree revolutions for every 1 full 360 degree turn. I think their Madgwick code is not correct and that's why I'm perferring to use Teensy's Madgwick code instead.





Any help is apperciated!
 
Last edited:
The FXOS8700 accel has two inputs for I2C address selection. Prop shield sets them to GND and the Adafruit board to Vcc. So, on the Prop shield the I2C address is 0x1E and on the Adafruit it is 0x1F. You need to change the I2C address in the NXPMotionSense library. Same for the gyro.
 
The FXOS8700 accel has two inputs for I2C address selection. Prop shield sets them to GND and the Adafruit board to Vcc. So, on the Prop shield the I2C address is 0x1E and on the Adafruit it is 0x1F. You need to change the I2C address in the NXPMotionSense library. Same for the gyro.

Sweet! Thanks for the info!

I'll confirm this solves the problem shortly :)
 
I got it working!

I was able to calibrate the sensor and save the cal data to Teensy 3's EEPROM.

I ran the Madgwick program but the heading readigns are not right? It constantly slowly scrolls in one heading direction for some reason. I thought it was just the Madgwick algo running but I left it for hours while I slept and it never settled out.

Also my heading readigns seem to be 180 degrees out of phase for some reason?

Is the heading relative to it's position when the code starts running?

I'm just trying to get accurate compass readings.

The calibration was 1% on Gap's and accuracy and the tilt compensation works good.

Had anybody go this working as a reliable compass?
 
I have the breakout NXP has(this board: https://www.digikey.com.au/product-detail/en/nxp-usa-inc/BRKT-STBC-AGM01/BRKT-STBC-AGM01-ND/5214621), any idea how to disable MPL3115, as it is not needed?

I mofied to the code to remove the MPL3115 and it's working with the Teensy 3.2.

You will still need to load the Madgwick or Mahoney .h file library if you want to run those sketches.

Let me know if the compass works for you.

View attachment NXPMotionSense-master_Modfied.zip
 
Hi, l also wish to use the adafruit nxp pecision board with the NXP motion sensor code for orientation so l can try heading with kalman filter versus adafruit madg/mah. I have tried altering NXP sensor redg.h without luck, could someone explain what/what else l need to do.

//#define FXOS8700_I2C_ADDR0 0x1E // SA1 = Gnd, SA0 = Gnd---default
#define FXOS8700_I2C_ADDR0 0x1F // SA1 = Gnd, SA0 = Gnd


//#define FXOS8700_I2C_ADDR1 0x1D // SA1 = Gnd, SA0 = Vcc--default
#define FXOS8700_I2C_ADDR1 0x1F // SA1 = Gnd, SA0 = Vcc


//#define FXOS8700_I2C_ADDR2 0x1C // SA1 = Vcc, SA0 = Gnd--default
#define FXOS8700_I2C_ADDR2 0x1F // SA1 = Vcc, SA0 = Gnd



//#define FXAS21002_I2C_ADDR0 0x20 // SA0 = Gnd---default
#define FXAS21002_I2C_ADDR0 0x1F // SA0 = Gnd




#define FXAS21002_I2C_ADDR1 0x21 // SA0 = Vcc

l current get config error FXOS8700

Thanks Kevin
 
l think l was supposed to change last bit, so have altered to this without and luck

//#define FXOS8700_I2C_ADDR0 0x1E // SA1 = Gnd, SA0 = Gnd
#define FXOS8700_I2C_ADDR0 0x1F // SA1 = Gnd, SA0 = Gnd


//#define FXOS8700_I2C_ADDR1 0x1D // SA1 = Gnd, SA0 = Vcc
#define FXOS8700_I2C_ADDR1 0x1C // SA1 = Gnd, SA0 = Vcc

#define FXOS8700_I2C_ADDR2 0x1C // SA1 = Vcc, SA0 = Gnd

//#define FXAS21002_I2C_ADDR1 0x21 // SA0 = Vcc
#define FXAS21002_I2C_ADDR1 0x20 // SA0 = Vcc

Still config error
Regards
 
also changed below in sense.h
if (!read_regs(i2c_addr, FXOS8700_WHO_AM_I, &b, 0)) return false;


//if (!read_regs(i2c_addr, FXOS8700_WHO_AM_I, &b, 1)) return //false;


//if (!read_regs(i2c_addr, FXAS21002_WHO_AM_I, &b, 1)) //return false;

if (!read_regs(i2c_addr, FXAS21002_WHO_AM_I, &b, 0)) return false;

Regards kevin
 
Status
Not open for further replies.
Back
Top