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

Thread: SPI communication with IMU ADIS16480

Hybrid View

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Posts
    3

    SPI communication with IMU ADIS16480

    Great job with the Teensy 3.0.

    I'm trying now to integrate an ADIS16480 from Analog Devices with the Teensy 3.0 but no matter what I do, the IMU doesnt answer. I know it works because I can test it in another device and it works perfectly.

    I have used some libraries (SDFAT and cmason), mix everything, etc. but still does not work.

    Enclosed the teensySPI.c and .h. And my main():
    int main(void) {

    short count = 0;
    char msg[64];
    uint8_t buffOut[8];
    uint8_t buffIn[8];
    int value;
    short i;

    // Serial Init
    serial_begin(9600);
    serial_print("Hello World\n");

    // SPI Init
    pinMode (chipSelect, OUTPUT);
    digitalWriteFast(chipSelect, HIGH);

    SPIbegin();
    SPIinit(SPI_CLOCK_DIV16);
    SPIsetDataMode(SPI_MODE3);


    // SPI comm
    buffOut[0] = 0x80; buffOut[1] = 0x00;
    buffOut[2] = 0x00; buffOut[3] = 0x00;

    digitalWrite(chipSelect, LOW);
    SPIsendMultiple(buffOut, 4);
    digitalWrite(chipSelect, HIGH);

    while (1) {

    // SPI comm
    digitalWrite(chipSelect, LOW);
    delayMicroseconds(4);
    buffOut[0] = 0x80; buffOut[1] = 0x00;
    buffOut[2] = 0x00; buffOut[3] = 0x00;
    SPIsendMultiple(buffOut, 4);
    delayMicroseconds(4);
    digitalWrite(chipSelect, HIGH);

    delayMicroseconds(25);

    digitalWrite(chipSelect, LOW);
    delayMicroseconds(4);
    buffOut[0] = 0x7E; buffOut[1] = 0x00;
    buffOut[2] = 0x00; buffOut[3] = 0x00;
    SPIsendMultiple(buffOut, 4);
    delayMicroseconds(4);
    digitalWrite(chipSelect, HIGH);

    delayMicroseconds(25);

    digitalWrite(chipSelect, LOW);
    delayMicroseconds(4);
    buffOut[0] = 0x22; buffOut[1] = 0x00;
    buffOut[2] = 0x00; buffOut[3] = 0x00;
    SPIsendMultiple(buffOut, 4);
    delayMicroseconds(4);
    digitalWrite(chipSelect, HIGH);

    delayMicroseconds(25);

    }

    return 0;

    }

    The specs of the IMU is in this link (http://www.analog.com/static/importe.../ADIS16480.pdf). The characteristics
    - SPI Mode 3
    - MSB-First Mode
    - 16-bit mode

    I have tried to change the configurations of the registers SPI0_MCR and SPI0_CTAR0/1. Without any success.

    Has anyone already got an ADIS IMU working with a Teensy 3.0? Could anyone help?

    Thanks in advance.
    Attached Files Attached Files

  2. #2
    Senior Member Constantin's Avatar
    Join Date
    Nov 2012
    Location
    In the yard with a 17' Dia. Ferris Wheel
    Posts
    1,408
    Hi,

    Some questions - does the Teensy produce the right signals on the way to the IMU? In other words, have you verified with a logic analyzer that these non-standard commands work?

    The reason I say this is while using the SDfat library may add some nifty features, you may be better off using traditional SPI commands instead. Also, if those delays are based on an arduino AVR code expectation, then you may have to fiddle with the length a bit to see when you get the right one... IIRC, the Teensy 3 has a much more accurate clock than the Arduino in terms of scheduling, so a 4ms delay on the Arduino might be called with a delay (1) command, while on the Teensy 3 it has to be delay(4).

    While re-writing the code to not use the SDFat library may be a bit of an inconvenience, it may very well help you trouble-shoot the problem.

  3. #3
    Junior Member
    Join Date
    Nov 2013
    Posts
    3
    Thanks Constantin,

    enclosed you can find a screen capture of a logic analyzer. To me, they seem like perfect signal conditions for SPI mode 3.
    Click image for larger version. 

Name:	Capture2.jpg 
Views:	378 
Size:	60.5 KB 
ID:	1097

    I did not use standard SPI library because I dont know how to transfer 16 bits at once and receive also 16 bits per transfer() call.

  4. #4
    Junior Member
    Join Date
    Nov 2013
    Posts
    3
    teensy3.zipWell,

    I got it finally working. The screen capture was ok. There were some other problems with connectors and also the stubbornness of this IMU for communicating in not perfect conditions.

    However, because it took me so much time to have it working, and there is not much support on the web for SPI communication with 16bits and this IMU, I include enclosed to this post the code working producing the timing diagram of my previous post.

    Best regards.

  5. #5
    gilbertnax
    Guest
    I did not use standard SPI library..I have tried to change the configurations thats why

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
  •