Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: Teensy 4.0

  1. #1

    Teensy 4.0

    Hello All, I have a doubt. I am using bno055 (IMU) for my project . It takes 2ms to output a quaternion data. *(no delay given). I am using 16 BNO055 IMU sensors*with teensy 4.0 *controller and multiplexer. Now for reading * quaternion data from all 16 sensors total time taken is 32-35 ms. I need to reduce this to 10 ms to sample at 100 Hz. Any idea on how to solve this?

  2. #2
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,178
    That chip seems to support I2C fast mode - are you already using this?

  3. #3
    Yes. I am already using this

  4. #4
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    7,409
    Going over the datasheet I don't think you are going to get better than what you have. The max I2C clock is 400Khz and the max data rate when you are in fusion mode is 100hz. This is on a per sensor basis.

  5. #5
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    9,392
    Sorry I am probably not much help here.

    I am assuming that from previous answer that you are driving I2C at higher speeds, think max of 400khz for the device.

    The only things I can think of include:

    a) Would splitting up the sensors into multiple Wire busses help? Not sure. You do have have 3 of them on T4... Question would then be could you get all three of them reading at same time.
    b) Where is the time spent? If the code has to ask sensor to do measurement and then waits for that to complete, can it be reorganized to ask each of the sensors to go get their next data and then cycle back to get the data?
    c) If the above works at all would it help to have some of the sensors with the secondary I2C address?
    d) If the multiple I2C devices works, might be able to hack up some more logical I2C objects using FlexIO. I have not tried that yet, played with Serial and some SPI...

    Sorry again I know not much help, but maybe a few places to go try.

    Good luck

  6. #6
    a) Would splitting up the sensors into multiple Wire busses help? Not sure. You do have have 3 of them on T4... Question would then be could you get all three of them reading at same time. -* I DONT THINK SO. IT CANT BE READ AT THE SAME TIME*
    b) Where is the time spent? If the code has to ask sensor to do measurement and then waits for that to complete, can it be reorganized to ask each of the sensors to go get their next data and then cycle back to get the data? - * 2ms IS SPENT WHEN BNO SENDS DATA TO TEENSY*
    c) If the above works at all would it help to have some of the sensors with the secondary I2C address? * I ACTUALLY USE COMBINATION OF ADDRESSES (BNO HAS 2 ADDRESSES AND I READ THEM IN THE SAME CHANNEL )*
    d) If the multiple I2C devices works, might be able to hack up some more logical I2C objects using FlexIO. I have not tried that yet, played with Serial and some SPI... - * CAN YOU ELABORATE ON WHAT FLEX IO IS ? SOME EXAMPLES COULD HELP. (ANY LINKS) *

    Thank you in advance

  7. #7
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    9,392
    Quote Originally Posted by Sandhanakrishnan R View Post
    a) Would splitting up the sensors into multiple Wire busses help? Not sure. You do have have 3 of them on T4... Question would then be could you get all three of them reading at same time.
    -* I DONT THINK SO. IT CANT BE READ AT THE SAME TIME*
    Actually depending on coding, maybe it can... But normal code bases are not setup to do so. That is the endTransmission and requestFrom both loop waiting for the number of bytes to transfer.

    Now there are at least two ways around this.

    One could write special code that lets say duplicates the main code here but instead of just iterating over one set of IO registers for the one Wire port, it iterates over more than one... I have not done that before on this chip.. I have done it on old AVr processors for example to check two different uarts...

    Another approach is to use DMA... So you start up the transfers, and all of them run in the background transferring the bytes for each of the devices in parallel.
    On T3.x boards there is a library i2c_t3(https://github.com/nox771/i2c_t3) that has this capability. The last I checked he has not ported this library over to T4.x...
    There is another library, which I have not used before: https://github.com/Richard-Gemmell/teensy4_i2c
    Not sure if he has implemented DMA access or not. There may be others...



    Quote Originally Posted by Sandhanakrishnan R View Post
    b) Where is the time spent? If the code has to ask sensor to do measurement and then waits for that to complete, can it be reorganized to ask each of the sensors to go get their next data and then cycle back to get the data?
    - * 2ms IS SPENT WHEN BNO SENDS DATA TO TEENSY*
    Again without seeing code and the like, it may be hard to see what this means.. That is are you simply timing one call to library, like get me the XYZ data... or have you broken that code down and that is the actual time it takes on the Wire buss to transfer the N bytes to the teensy?


    Quote Originally Posted by Sandhanakrishnan R View Post
    d) If the multiple I2C devices works, might be able to hack up some more logical I2C objects using FlexIO. I have not tried that yet, played with Serial and some SPI...
    - * CAN YOU ELABORATE ON WHAT FLEX IO IS ? SOME EXAMPLES COULD HELP. (ANY LINKS) *
    For Flex IO, you can look at the latest blog that Paul posted up on the main PJRC website for the latest release of Teensyduino. And there will be a small section on FlexIO that has a link to a WIKI page on it.
    And/or you can look at Chapter 50 of the IMXRT1060RM pdf file that you can download from PJRC main website.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •