Go Down

Topic: read vector NAV IMU using SPI (Read 974 times) previous topic - next topic

surajcs

Hi,

I have a vectornav IMU VN100 which i am using to read sensor data through serial port which is working fine.

when i read the same from SPI i am not getting any output. I am using Arduino DUE

below is my code

#include <SPI.h>
/*
code to read vectornav data via an arduino DUE SPI pins
*/
int attitude[16]; // yaw, pitch, & roll
const int slaveSelectPin = 10; //52 or 4 or 10
void setup()
{
  Serial.begin(38400);
  SPI.begin(slaveSelectPin);

}

void loop()
{
      attitude[0] = SPI.transfer(slaveSelectPin, 0x01, SPI_CONTINUE);
     
      attitude[1] = SPI.transfer(slaveSelectPin, 0x08, SPI_CONTINUE);
     
      attitude[2] = SPI.transfer(slaveSelectPin, 0x00, SPI_CONTINUE);
     
      attitude[3] = SPI.transfer(slaveSelectPin, 0x00, SPI_CONTINUE);
     
      attitude[4] = SPI.transfer(slaveSelectPin, 0x00, SPI_CONTINUE);
     
      attitude[5] = SPI.transfer(slaveSelectPin, 0x00, SPI_CONTINUE);
     
      attitude[6] = SPI.transfer(slaveSelectPin, 0x00, SPI_CONTINUE);
     
      attitude[7] = SPI.transfer(slaveSelectPin, 0x00, SPI_CONTINUE);
     
      attitude[8] = SPI.transfer(slaveSelectPin, 0x00, SPI_CONTINUE);

      attitude[9] = SPI.transfer(slaveSelectPin, 0x00, SPI_CONTINUE);

      attitude[10] = SPI.transfer(slaveSelectPin, 0x00, SPI_CONTINUE);

      attitude[11] = SPI.transfer(slaveSelectPin, 0x00, SPI_CONTINUE);

      attitude[12] = SPI.transfer(slaveSelectPin, 0x00, SPI_CONTINUE);

      attitude[13] = SPI.transfer(slaveSelectPin, 0x00, SPI_CONTINUE);

      attitude[14] = SPI.transfer(slaveSelectPin, 0x00, SPI_CONTINUE);

      attitude[15] = SPI.transfer(slaveSelectPin, 0x00);


       for (int i = 0; i < 16; i++)
      {
        Serial.write(attitude);
      }
}

So with the above code I'm just trying to get attitude vales (heading, pitch, roll). The message I'm sending is:

01 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00

but the answer is also the same

Any advice?

http://www.vectornav.com


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy