Community
cancel
Showing results for 
Search instead for 
Did you mean: 
MWnuk
Novice
3,005 Views

accessing the magnetometer on the aero compute board

Hi,

I am attempting to set the IMU to connect to the magnetometer as per the data sheet (setting mag mode --> normal , setting mag_if[1](bit 7) --> 0) then reading from the data register, but it doesn't seem to be working.

So I attempted to just read from the device_id register via the mag_if on the imu, this also provided no joy. So then I decided to bypass the imu altogether and address the magnetometer via i2c. The device is recognized on bus 2, address 0x12 as expected. However, when attempting to read from the device registers I get nothing but 0x00 or 0xFF. I am wondering if anyone has experienced this problem before, if I am setting something up incorrectly, or if there is possibly something wrong with the process I am implementing.

Thanks

0 Kudos
10 Replies
idata
Community Manager
158 Views

Hello Matthew,

 

 

Thank you for your interest in our Intel products.

 

 

In addition to the IMU built into the flight controller (Intel Aero FC or a third party FC), the Intel Aero Compute Board includes a 6-DOF IMU: BMI 160 sensor. This sensor is connected to the Intel Atom processor via its SPI interface on bus 3 (SPI3) chip select 0 (CS0). It can be accessed via spidev as /dev/spidev3.0. The Aero Compute Board also integrates a magnetometer and a pressure sensor on its I2C.

 

 

Command to access the IMU Sensor on the Aero Compute Board

 

An example to communicate with BMI 160 is shown below:

 

root@intel-aero~# spi_xfer -b 3 -c 0 -d 0x80 -w 2

 

where,

 

 

* -b is for spi bus

 

* -c is for chip select

 

* -d is the data value

 

* -w is for number of words

 

Note: Users can also follow linux sample program showing an example on how to use spidev interface.

 

 

Command to access the Magnetometer Sensor

 

Intel Aero Compute Board includes BMM 150 sensor. This sensor is connected to Atom SoC via I2C interface on bus 2 at slave address 0x12. In order to communicate with this sensor, please use below linux i2c commands:

 

 

root@intel-aero~# i2cdetect -y -r 2

 

root@intel-aero~# i2cset -y 2 0x12 DATA-ADDRESS [VALUE] ... [MODE]

 

root@intel-aero~# i2cget -y 2 0x12 [DATA-ADDRESS [MODE]]

 

 

You can also find this information on our wiki: https://github.com/intel-aero/meta-intel-aero/wiki/94-(References)-Sensors-GPIOs-LEDs-CAN-bus

 

 

Hope this helps.

 

 

Regards,

 

Octavian
MWnuk
Novice
158 Views

Sorry I must not have explained myself well. I have full control of the IMU sensor BMI160. I am reading the gyro and accelerometer data via a python script I wrote. The BMI150 magnetometer should be able to be accessed through the BMI160 via the MAG_IF register, but it does not respond. So I attempted direct access via the I2C bus. I can ping the bus and see that the magnetometer exists on bus 2 address 0x12. However, reading from register 0x40 (Chip ID) on bus 2, address 0x12 returns 0x00. I wrote a python script to loop through all the registers on the chip and every register returns 0x00 or 0xFF

MWnuk
Novice
158 Views

Also, the pressure sensor doesn't seem to be responding at all. When I ping the bus only 0x12 address is displayed.

JDiam3
Beginner
158 Views

Hi Octavian,

I'm trying to access data from the magnetometer sensor. Can you provide more specifics of how to access actual data values. For instance, what "DATA-ADDRESS", "VALUE", and "MODE" values should I use to access the magnetometer readings, when I issue the following commands:

root@intel-aero~# i2cset -y 2 0x12 DATA-ADDRESS [VALUE] ... [MODE]

root@intel-aero~# i2cget -y 2 0x12 [DATA-ADDRESS [MODE]]

Jeff

MWnuk
Novice
158 Views

So for me it turned that the default register settings where wrong. Specifically you need to write a 1 to register 0x4B (the Power Control Bit). At which point you will have read/write access to the rest of the registers. so for example if you then send a read command:

i2cget -y 2 0x12 [0x40 [r]]

it should return the Chip ID: 0x32.... I should say that I am doing this in python, not from the command line so I cannot guarantee that the above command is the correct syntax

JDiam3
Beginner
158 Views

I tried "i2cget -y 2 0x12 [0x40 [r]]" and it returned an error. Could you show me your python code or the correct command line syntax?

MWnuk
Novice
158 Views

The sequence to read the Chip ID register is:

i2cset -y 2 0x12 0x4B 0x01 # write a 1 to the power control register enabling read/write access to all other registers

i2cget -y 2 0x12 0x40 'w' # read 1 word from register 0x40

This should return 0x32

trix
New Contributor I
158 Views

@Mwnuk may I ask what steps you took to successfully getting readings from the BMI160 chip? I am currently having trouble even opening the device. For one thing, I tried to simply do this on my python interpreter, but I got a Permission Denied error:

import spidev

spi = spidev.SpiDev()

spi.open(3, 0)

Did you have to change your compute board's configuration at all in order to enable your python script to get a reading out of the IMU?

Thanks,

Trixie

MWnuk
Novice
158 Views

using python I've had to run as root. Feel free to clone my https://github.com/wnukmat/Intel-Aero/blob/master/get_imu.py git project for the Intel-Aero (its a work in progress, I am trying to implement SLAM from scratch). The BMI-160 register map and get_IMU.py should get you started

EMill6
Beginner
158 Views

Mwnuk,

I had cloned your repo (seems to be gone now) and completed the basic drivers for the BMI160 and BMM150. I also added a ROS publisher. I published the repo https://github.com/ejmiller2/ros_aero_imu here.

Reply