10 Replies Latest reply on Apr 11, 2018 4:56 PM by bluevalhalla

    accessing the magnetometer on the aero compute board

    Mwnuk

      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

        • 1. Re: accessing the magnetometer on the aero compute board
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          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

          • 2. Re: accessing the magnetometer on the aero compute board
            Mwnuk

            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

            • 3. Re: accessing the magnetometer on the aero compute board
              Mwnuk

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

              • 4. Re: accessing the magnetometer on the aero compute board
                Jeffrey95

                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

                • 5. Re: accessing the magnetometer on the aero compute board
                  Mwnuk

                  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

                  • 6. Re: accessing the magnetometer on the aero compute board
                    Jeffrey95

                    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?

                     

                    • 7. Re: accessing the magnetometer on the aero compute board
                      Mwnuk

                      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

                      • 8. Re: accessing the magnetometer on the aero compute board
                        Trixie

                        @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

                        • 9. Re: accessing the magnetometer on the aero compute board
                          Mwnuk

                          using python I've had to run as root. Feel free to clone my 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

                          • 10. Re: accessing the magnetometer on the aero compute board
                            bluevalhalla

                            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 here.