[SOLVED] Controlling the 9-axis motion sensor from the M4-core

Discussion in 'UDOO NEO' started by Maurice, Apr 16, 2016.

Thread Status:
Not open for further replies.
  1. Maurice

    Maurice Active Member

    Joined:
    Oct 13, 2015
    Messages:
    394
    Likes Received:
    87
    I would like to use more features of the motion sensor, and I'm trying to control the motion sensor from the M4 core. I'm following steps in "How to control the 9-axis motion sensors from the M4 Core".

    As far as I can tell I have assigned the motion sensor to the M4 in the device tree editor:
    [​IMG]

    I have downloaded the (or should I say 'a'?) FXOS8700CQ library from GitHub.

    Trying out the code that is on the page I notice that the program hangs as soon as "accMagSensor.readMagData();" gets called.

    This is the full source code of my experiment:
    Code:
    #include <Wire.h>
    
    #include <FXOS8700CQ.h>
    
    FXOS8700CQ accMagSensor = FXOS8700CQ(0x1E);
    void setup() {
      pinMode(13, OUTPUT);
      Serial.begin(115200);
    
      Wire1.begin();
      accMagSensor.init();
    
    }
    
    void loop() {
      Serial.println("Flash5");
      digitalWrite(13, HIGH);
      accMagSensor.readMagData();
    Serial.print("Accel ");
    Serial.print("  ");
    Serial.print((int)accMagSensor.accelData.x);
    Serial.print("  ");
    Serial.print((int)accMagSensor.accelData.y);
    Serial.print("  ");
    Serial.println((int)accMagSensor.accelData.z);
    
      delay(25);
      digitalWrite(13, LOW);
      delay(3000 -25);
    }
    
    (btw the motion sensor still show up on the Neo's webpage, I would expect them not to after the device tree has been edited).

    -- update -- apperently they weren't assigned to M4, but after correcting that it still seems to hang at the call ---
     
    Last edited: Apr 16, 2016
  2. Maurice

    Maurice Active Member

    Joined:
    Oct 13, 2015
    Messages:
    394
    Likes Received:
    87
    --- update 2: to make sure it isn't a wrong library I retried it from the internal Arduino IDE - same result --
     
  3. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    You have to use accMagSensor.readAccelData(); accMagSensor.readMagData();
     
  4. Maurice

    Maurice Active Member

    Joined:
    Oct 13, 2015
    Messages:
    394
    Likes Received:
    87
    Same result - hangs when reading sensor.
    Doesn't matter whether I do
    Code:
    accMagSensor.readAccelData();
    accMagSensor.readMagData();
    
    or
    Code:
    accMagSensor.readAccelData();
    
    #sadpanda
     
  5. Maurice

    Maurice Active Member

    Joined:
    Oct 13, 2015
    Messages:
    394
    Likes Received:
    87
    Anybody else willing to try? I now read the values in Linux, but I think it is more efficient in Arduino, and I'd like to use the interrupt capabilities of the sensor.
     
  6. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    Sorry, I don't have a Neo full.
     
  7. klakier2121

    klakier2121 Member

    Joined:
    Dec 5, 2015
    Messages:
    48
    Likes Received:
    15
    It doesn't work for me too. UDOO FULL
     
  8. Maurice

    Maurice Active Member

    Joined:
    Oct 13, 2015
    Messages:
    394
    Likes Received:
    87
    Thanks for trying. I'll reach out to UDOO Support.
     
  9. ektor5

    ektor5 Administrator Staff Member

    Joined:
    Jul 1, 2013
    Messages:
    97
    Likes Received:
    48
    Hi there,
    I saw that the documentation about it is broken, and it'll be updated soon.

    You don't have to use the standard version of the Library, but ours. On this repo you can find a compilation of libraries ported to UDOO Neo.
    Just click on "Download ZIP", and import to your Arduino IDE Library Manager with:

    Sketch -> Include Library -> Import Zip Library...

    You'll find all libraries under "UDOO Neo Library Pack". Don't forget to add #include <Wire.h> before including any library.
    Also, those libraries are already available in the latest UDOObuntu release (2rc2).


    Let me know,
    Ek5
     
  10. Maurice

    Maurice Active Member

    Joined:
    Oct 13, 2015
    Messages:
    394
    Likes Received:
    87
    I've installed the libraries from the aforementioned git repo, and the result is the same, that is: 'hangs'. Given that they should be the same as the ones on rc2 this comes as no surprise, I already tried those directly available on the board.
     
  11. ektor5

    ektor5 Administrator Staff Member

    Joined:
    Jul 1, 2013
    Messages:
    97
    Likes Received:
    48
    The right libraries ported to UDOO Neo are called:
    Code:
    #include <FXOS8700CQ_neo.h>
    Are you using the this one?

    Second, I read from your code that you call
    Code:
    accMagSensor.readMagData();  // magnetometer call
    But then you want to access the acceleration values.

    Please create a gist or update the sketch you are using if you modify it.
    Thanks

    edit: I'm using the "Serial" example, and it works.
    It is located under Examples -> UDOO Neo Library Pack, try it out.
     
    Last edited: Apr 18, 2016
  12. Maurice

    Maurice Active Member

    Joined:
    Oct 13, 2015
    Messages:
    394
    Likes Received:
    87
    Last edited: Apr 19, 2016
  13. ektor5

    ektor5 Administrator Staff Member

    Joined:
    Jul 1, 2013
    Messages:
    97
    Likes Received:
    48
    Your code is missing
    Code:
    Wire1.begin()
    in setup() function.
    Also, it's better to include Wire.h before the sensor header.
    Ek5
     
  14. ektor5

    ektor5 Administrator Staff Member

    Joined:
    Jul 1, 2013
    Messages:
    97
    Likes Received:
    48
    Ok, solved. ;)
     
Thread Status:
Not open for further replies.

Share This Page