Hi there,
I've been playing around with the ADIS16210-CMLZ IMU and it was working quite well. However it has suddenly stopped showing any values that make sense. I used some old code that I knew worked and so I believe the issue lies with the IMU. I'm using an Arduino MEGA 2560 for the connection. Here's the code:
#include <SPI.h>
#define SS 53
int16_t x16,y16,z16;
float xOut = 1,yOut = 1,zOut = 1;
int16_t ax16,ay16,az16;
float axOut = 1,ayOut = 1,azOut = 1;
int16_t test = 0;
void setup() {
Serial.begin(57600);
SPI.begin();
SPI.beginTransaction(SPISettings(830000,MSBFIRST,SPI_MODE3));
pinMode(SS, OUTPUT); //added on suggestion
Serial.println();
digitalWrite(SS,LOW);
SPI.transfer(0xB8);
SPI.transfer(0x00);//Change this variable for Sample Rate (Table 23) //Changed to 0x00
delay(1);
SPI.transfer(0xBE);
SPI.transfer(0x01);
delay(1000);
//Edit 1
SPI.transfer(0x3E);
SPI.transfer(0x10); //Clear DIAG_STAT register
delay(300);
SPI.transfer(0x3E);
SPI.transfer(0x04);// Self Test
delay(300);
SPI.transfer16(0x3C20); // DIAG_STAT[5]
delay(1);
int16_t selfcheck = SPI.transfer16(0);
delay(1);
Serial.print(" "); Serial.print("Self Check: "); Serial.print(selfcheck,HEX);
SPI.transfer16(0x5600);// Prod ID
delay(1);
int16_t prodID = SPI.transfer16(0);
delay(1);
Serial.print(" "); Serial.print("Prod ID: "); Serial.print(prodID,HEX);
Serial.println();
int16_t temp = 0;
int16_t reg = 0;
for(int i = 0; i < 12; i++){
reg = 0x3C00 + (0x01 << i);
SPI.transfer16(reg);
delay(1);
temp = SPI.transfer16(0);
delay(1);
Serial.print(" "); Serial.print("DIAG_STAT["); Serial.print(i);Serial.print("] ");
Serial.print((reg),HEX); Serial.print(" "); Serial.print(temp,BIN);
Serial.println();
}
Serial.println();
//End of Edit 1
digitalWrite(SS,HIGH);
}
void loop() {
digitalWrite(SS,LOW);
delay(2);
//--------------Accelerometer-----------------//
SPI.transfer16(0x0400);
delay(1);
ax16 = SPI.transfer16(0);
axOut = ((float)ax16)/16384;
delay(1);
Serial.print(" "); Serial.print("ax: "); Serial.print(ax16); Serial.print(" "); Serial.print(axOut); Serial.print(" ");
SPI.transfer16(0x0600);
delay(1);
ay16 = SPI.transfer16(0);
ayOut = ((float)ay16)/16384;
delay(10);
Serial.print(" "); Serial.print("ay: "); Serial.print(ay16); Serial.print(" "); Serial.print(ayOut); Serial.print(" ");
SPI.transfer16(0x0800);
delay(1);
az16 = SPI.transfer16(0x0000);
azOut = ((float)az16)/16384;
delay(1);
Serial.print(" "); Serial.print("az: "); Serial.print(az16); Serial.print(" "); Serial.print(azOut); Serial.print(" ");
//--------------Incline-----------------//
SPI.transfer16(0x0C00);
delay(1);
x16 = SPI.transfer16(0x0000);
xOut = ((float)x16)*180/32768;
delay(1);
Serial.print(" "); Serial.print("x: "); Serial.print(x16); Serial.print(" "); Serial.print(xOut); Serial.print(" ");
SPI.transfer16(0x0E00);
delay(1);
y16 = SPI.transfer16(0x0000);
yOut = ((float)y16)*180/32768;
delay(1);
Serial.print(" "); Serial.print("y: "); Serial.print(y16); Serial.print(" "); Serial.print(yOut); Serial.print(" ");
SPI.transfer16(0x1000);
delay(1);
z16 = SPI.transfer16(0x0000);
zOut = ((float)z16)*180/32768;
delay(1);
Serial.print(" "); Serial.print("z: "); Serial.print(z16); Serial.print(" "); Serial.print(zOut); Serial.print(" ");
Serial.println();
digitalWrite(SS,HIGH);
delay(10);
}
Some of the more consistent or interesting trends:
x acc will sharply drop from 0.56 to -1.14. x inc will go from 24 to -124 degrees. All of this happens at about a 60 degree incline
Doing a full rotation y acc will climb to 0.64, then go back down to -0.64
Doing a full rotation z acc will go from -1 to 0 to 0.06 then back to 0 then down to -0.75 then sharply jump to 1.22 then back to 0.76 then sharply jump to -1.24 then climb back to -1 at its original position
I'm at my wits end. Is the IMU simply broken?
Edit Notes
Changed sample rate, set SS to OUTPUT[edited by: lotm at 1:44 AM (GMT -4) on 27 Jul 2021]



