How to change dynamically selectable acceleration scale

Discussion in 'UDOO NEO' started by Matthew Dean, Jan 14, 2016.

  1. Matthew Dean

    Matthew Dean New Member

    Joined:
    Jun 9, 2015
    Messages:
    4
    Likes Received:
    2
    According to the docs, the accelerometer on the Udoo Neo has a dynamically selectable acceleration full scale ranges of ±2g / ±4g /±8g. I'd like to be able to adjust the range from ±2g to ±8g. I'm hoping that it is sort of like the "enable" file where all that is needed is to change the value in a file, but I have no idea where to look for that. Does any one have advice on how I could change the scale of the accelerometer?
     
  2. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
  3. Matthew Dean

    Matthew Dean New Member

    Joined:
    Jun 9, 2015
    Messages:
    4
    Likes Received:
    2
    The full documentation for the chip was linked in the Neo Docs. I figured that if I could understand how they got it working at all, I could modify the code for enabling the sensor or reading the data to also allow me to select the scale. Except, I don't know where to look on the Udoo Neo for that code. I feel like the answer is right under my nose, but frankly this is the first time I've spent a lot of time on ubuntu working with an integrated platform like this, so I don't even know where to look for what seems to be a working example.
    Any help pointing me in the right direction on the Udoo would be appreciated.
     
  4. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    I don't have a Neo Full but I suppose you can set it with the I2C commands in
    http://www.udoo.org/docs-neo/Hardware_&_Accessories/Motion_sensor.html
    \#!/bin/sh
    \# set to active mode
    i2cset -f -y 3 0x1e 0x2a 1
    \# enable both accelerometer and magnetometer
    i2cset -f -y 3 0x1e 0x5b 3

    In the datasheet it is written in paragraph
    10.6.1 XYZ_DATA_CFG (0x0E) register
    how to set by writing a value to register 0x0E

     
    Andrea Rovai likes this.
  5. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    Did you manage to set the scale?
     
  6. Matthew Dean

    Matthew Dean New Member

    Joined:
    Jun 9, 2015
    Messages:
    4
    Likes Received:
    2
    So, you seem to be correct. I can read the register and it is set the way I would expect it to, but for some reason the i2cset command doesn't seem to be changing the register. I wrote a script to change it and nothing happens. I tried it in command line, and still, when I read the register it is set to 0x00, when I need it to be 0x02.

    i2cget works fine, so I really don't know what I'm doing wrong. I feel like I'm missing something really obvious.

    Edit: I was missing something obvious. You can only write to registers while the chip is in standby. I had to make the initial write to put it in standby, then I could use i2cset to change it to 0x02. After that, it worked. Thanks for the help.
     
    Last edited: Jan 25, 2016
    Andrea Rovai and waltervl like this.
  7. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    Andrea Rovai likes this.

Share This Page