Hi there,
I am trying to accomplish high speed communication between an arduino Diecimila and an IMU ( ADIS 16375). I am using an optoisolator in between because I want to replace the arduino with a gumstix in the future. The optoisolator is ADUM 3150. The datasheets can be found here.
ADIS 16375 Check Page 26 as this is the board I am using with the IMU
For some reason, I can communicate just fine with speeds 1/32 and below (0.5 MHz and slower) but as soon as I try to go faster(1/16), it stops working correctly. This happens only when I am asking for more than 1 data output and it works fine if I only ask for one item (eg just x data, not x and Y data). This makes me think that there is some problem with my code.
In the sample code attached here, I am asking for the Product ID , which is a constant value (check page 10 of IMU datasheet) and the temperature in celsius.
#include <SPI.h>
const int dataReadyPin = 6;
const int chipSelectPin = 7;
const int Dout = 0x00;
const int TEMP_OUT = 0x0E;
const int PROD_ID = 0x7E;
void setup() {
Serial.begin(9600);
// SPI stuff
SPI.begin();
SPI.setClockDivider(SPI_CLOCK_DIV16);
pinMode(dataReadyPin, INPUT);
pinMode(chipSelectPin, OUTPUT);
delay(100);
}
void loop() {
digitalWrite(chipSelectPin, LOW);
request_data(PROD_ID);
String ID= String(request_data(PROD_ID),HEX);
delay(1);
request_data(TEMP_OUT);
float TEMP =25+.00565* request_data(TEMP_OUT);
delay(1);
digitalWrite(chipSelectPin,HIGH);
Serial.println("PROD ID");
Serial.println(ID);
delay(1);
Serial.println("TEMP");
Serial.println(TEMP);
}
int request_data(byte address){
// function which requests
//SPI.transfer(0x7E);
byte output_part1 = SPI.transfer((byte)address);
byte output_part2 = SPI.transfer((byte)0x00);
int output = (((int)output_part1)<<8) | ((int)output_part2);
return (output);
}
Could someone please tell me where I am going wrong?