Need to have Arduino Uno talk with Analog ADXRS453 digital gyro

Im very new at i2c & SPI bus. Does anyone have a sketch or more information for me to get the data from this IC only so I can read it in the serial monitor. This will get me started. Ultimately, I just need a H/W - S/W product I can Pan/Tilt small servo PT unit. I also plan to use a serial data 270x zoom camera module via wixel, that's another day.. Any help appreciated.

See figure 26 or 27 of the datasheet for the external components you should connect and where. Then hook up MOSI, MISO, SCK, and SS/CS to the corresponding pins on the Arduino (See: Help->Reference->Library Reference->SPI)

Tables 9 and 10 show the 4-byte commands and 4-byte responses. As you send a 4-byte command, using the SPI.transaction() function four times, the result of the PREVIOUS command will come in as the results of those four calls to SPI.transaction().

Registers 0 and 1 each contain 8 bits of data. Together they provide the current rate of rotation in (degrees per second * 80). Divide the value by 80 to get Degrees per Second. Integrate over time to get Degrees.

Hi johnwasser!

Im currently working on the same Gyroscope, but I have run into some problems during the init of the sensor.
Have you got it working or just have been reading the datasheet?

Regards Niklas C.

NiklasC:
Im currently working on the same Gyroscope, but I have run into some problems during the init of the sensor.
Have you got it working or just have been reading the datasheet?

Just reading the datasheet.

johnwasser:
Just reading the datasheet.

Dear Johnwasser, I am so stressful. Because I could not find any sample code for ADXRS453 for arduino. Could you write only few raws for this device? I feel bad really.

#include <SPI.h>
const int CSpin = 40;
void setup()
{
  Serial.begin(9600);
  pinMode(CSpin, OUTPUT);  // set CS pin as OUTPUT
  digitalWrite(CSpin, HIGH);  // sets cs to high
  SPI.setClockDivider(SPI_CLOCK_DIV16);  // sets SPI clock to 5MHz
  SPI.begin();  // start SPI
  GyroSetup();
}

void loop(){
  delay(100);
  // Gyro();
}

void GyroSetup(){
  delay(200);
  digitalWrite(CSpin, LOW);  // sets chip select to transfer data
  delay(100);
  long result = SPI.transfer(0x20);  // sends a byte of data
  Serial.println(result, BIN);
  result = result << 8;
  result += SPI.transfer(0x00);
  Serial.println(result, BIN);
  result = result << 8;
  result += SPI.transfer(0x00);
  Serial.println(result, BIN);
  result = result << 8;
  result += SPI.transfer(0x03);
  Serial.println(result, BIN);
  digitalWrite(CSpin, HIGH);  // de-selects chip select
  Serial.println(result, BIN);  // output value
}

This is my code. But does not work. Please...

What does the command 20 00 00 03 do?

You are sending one command and, at the same time, receiving the results from the previous command. What do you expect to receive. What do you receive?

It appears that function will only be called once.

Don't you want to access the gyro reading often ?

If you look at page 20 of the datasheet, they seem to expect sending 4 byte messages to the device and getting 4 byte messages back ( 32 cycles of the spi clock ).

It is probably a bad idea to screw arround sending serial port messages while this SPI transaction is going on. that takes a long time.

Dear helpful friends,

I reconfigured my code as you briliant me

#include <SPI.h>
const int CSpin = 40;
void setup()
{
  Serial.begin(9600);
  pinMode(CSpin, OUTPUT);  // set CS pin as OUTPUT
  digitalWrite(CSpin, HIGH);  // sets cs to high
  SPI.setClockDivider(SPI_CLOCK_DIV16);  // sets SPI clock to 5MHz
  SPI.begin();  // start SPI
  GyroSetup();
}

void loop(){
  delay(200);
  Gyro_regular();
}

void GyroSetup(){
  delay(200);
  digitalWrite(CSpin, LOW);  // sets chip select to transfer data
  delay(100);
  long result = SPI.transfer(0x20);  // sends a byte of data
  result = result << 8;
  result += SPI.transfer(0x00);
  result = result << 8;
  result += SPI.transfer(0x00);
  result = result << 8;
  result += SPI.transfer(0x03);
  Serial.println(result, BIN);  // output value
  digitalWrite(CSpin, HIGH);  // de-selects chip select
}

void Gyro_regular(){
  digitalWrite(CSpin, LOW);
  long result = SPI.transfer(0x20);  //sends a byte of data
  result = result << 8;
  result += SPI.transfer(0x00);
  result = result << 8;
  result += SPI.transfer(0x00);
  result = result << 8;
  result += SPI.transfer(0x00);
  Serial.println(result, BIN);  //output value
  digitalWrite(CSpin, HIGH);  //de-selects chip select
}

And the results are:

100000000000000000000000000
10100000000101101000000000001
10111111011111011010000000000
111111111000101010000000001
10111111110000000110000000000
111111011011100000000000000
111111101100010000000000001
10111111111011000000000000001
100000001101001010000000001
10100000111000000100000000001
10100000010111110110000000001
10100000000100000100000000001
100000000000100000000000001
100000000000011110000000000
10100000000100011010000000001
10100000000011001100000000001
10111101101100010110000000001
111111001001011110000000001
111111000101011110000000001
10111111101110010110000000001
111111100000011110000000000
111111011011111110000000000
100000001010000010000000001
10100000011101010010000000001
10100010111011101100000000000
100011001010010000000000001
10100001111010110010000000001
10100000110010000100000000001
10100000110100010000000000001
100000101000001100000000000
100000011111011100000000000
10100000001001011110000000001
111111111111101100000000000
10111111011000100100000000000
111110101000110110000000000
111110101001000000000000001
10111011110010101010000000001
10111101100000001000000000001
111110011001011100000000000
10111110111110010000000000001
10111111110001001010000000001
10100000000101001000000000000
10100010001010101000000000000
100001101011010100000000001
111111111111001000000000000
10111111111101000110000000001
10111111111100110110000000000
100000000001001010000000001

Did I successed? or failed?

http://www.analog.com/static/imported-files/data_sheets/ADXRS453.pdf

The GyroSetup() message seems to be setting the CHK bit which forces a fault and an error report. Probably not what you want.

The message in Gyro_regular() seems to be another Sensor Data message. At least that one doesn't have the CHK bit set.

It looks like the recommend initialization is a GyroSetup() followed by three Gyro_regular() at 200 mS intervals.

At some point you will probably want to add a read of Register 0 which contains the gyro rate information.

Is there anybody who has any idea about using of ADXRS453 with Arduino?
I purchased it 4 months ago but still waiting. Could you help?

Did you manage to get this working? Very beginner at all this and it would be amazing if you could share all the code you have (even if it doesnt work 100%)

This is an expensive device, so remington would be your man . I am not familiar with it.

The datasheet seems fairly clear. It seems to be a conventional SPI device. You send it a command, and it sends you an answer. The command syntax seems gratuitously complicated, but the explanation is clear enough. Make sure you pay attention to any obligatory mode settings. Some devices will just start outputing data as soon as you power them up, other devices require you to actually send them some information to get them started.

This is an old topic but I wanted to share my working code anyway.. It took me quite a while to get this going and I hope you will find it useful.

ADXRS453.ino (13.9 KB)

ADXRS453.h (2.51 KB)