Pages: [1]   Go Down
Author Topic: Need to have Arduino Uno talk with Analog ADXRS453 digital gyro  (Read 1555 times)
0 Members and 1 Guest are viewing this topic.
Central Florida
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 201
Posts: 8662
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 201
Posts: 8662
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Code:
#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...
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 201
Posts: 8662
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Faraday Member
**
Karma: 57
Posts: 2772
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It appears that function will only be called once.

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

Offline Offline
Faraday Member
**
Karma: 57
Posts: 2772
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Dear helpful friends,

I reconfigured my code as you briliant me

Code:
#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:
Quote
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?
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 201
Posts: 8662
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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%)
Logged

Offline Offline
Faraday Member
**
Karma: 57
Posts: 2772
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.



Logged

Pages: [1]   Go Up
Jump to: