Pages: [1]   Go Down
Author Topic: Code for Tri-Axis Inertial Sensor ADIS16354 what next step?  (Read 364 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

how to read value from address 0x05 and send to PC ? i hawe arduino duemilanove

Code:
/*
Arduino Duemilanove and Tri axis senzor ADIS16354
Datasheet:
http://www.analog.com/static/imported-files/data_sheets/ADIS16354.pdf

PIN function description ADIS16354:
Pin            Mark    Type Description
------------------------------------------------
pin 3          SCLK    In   SPI Serial Clock
pin 4          DOUT    Out  SPI Data Output
pin 5          DIN     In   SPI Data Input
pin 6          CS      In   SPI Chip Select
pin 7          DIO1    I/O  Digital Input/Output
pin 8          RST     In   Reset
pin 9          DIO2    I/O  Digital Input/Output
pin 10,11,12   VCC          Power Supply 4.75 V to 5.25 V (power pin 5V)
pin 13,14,15   GND          Power Ground
pin 20         AUX_DAC  Out Auxiliary, 12-Bit, DAC Output
pin 21         AUX_ADC  In  Auxiliary, 12-Bit, ADC Input

Arduino Pin    --->  ADIS16354
pin 2                pin 7 DIO1 Digital I/O
pin 3                pin 9 DIO2 Digital I/O
pin 4                pin 4 SPI data out
pin 5                pin 5 SPI data input
pin 6                pin 6 CS SPI chip select           
pin 8                pin 8 Reset
pin 13               pin 3 SCLK - SPI serial clock

*/

#include <SPI.h>

#define DO1 2        //
#define DO2 3        //
#define SPIOUT 4     //
#define SPIIN 5      //
#define CS 6         //
#define RST 8        // Write 0x02 to Address 0x3E for factory default calibration
#define CLK 13       //
#define XGYRO_O 0x05       // X, Y, Z gyroscope output data address
#define YGYRO_O 0x07       
#define ZGYRO_O 0x09       
#define XACCL_O 0x0B       // X, Y, Z accelerometer data output address
#define YACCL_O 0x0D       
#define ZACCL_O 0x05F       

void setup()
{
  Serial.begin (112500);
  pinMode(CS, INPUT);
  pinMode(DO1, OUTPUT);
  pinMode(DO2, OUTPUT);
  pinMode(SPIIN, INPUT);
  pinMode(SPIOUT, OUTPUT);
  pinMode(RST, INPUT);
  pinMode(CLK, INPUT);
  pinMode(XGYRO_O, OUTPUT};
  pinMode(YGYRO_O, OUTPUT};
  pinMode(ZGYRO_O, OUTPUT};
  pinMode(XACCLO_O, OUTPUT};
  pinMode(YACCL_O, OUTPUT};
  pinMode(ZACCL_O, OUTPUT};
 
  digitalWrite(CS, HIGH); //set CS to 1
 
}
« Last Edit: April 26, 2011, 02:35:10 am by mmichalll » Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 179
Posts: 8066
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you are going to use the SPI library you have to use the hardware SPI pins:  MOSI, MISO, and SCK (11, 12 and 13).  The SS pin (Slave Select) can be the hardware one (pin 10) or any other.  You have to leave the hardware SS pin (pin 10) set as an output or the SPI hardware will switch from Master to Slave.

From the built-in reference page, Help->Reference->libraries->SPI: "On the Arduino Duemilanove and other ATmega168 / 328-based boards, the SPI bus uses pins 10 (SS), 11 (MOSI), 12 (MISO), and 13 (SCK). On the Arduino Mega, this is 50 (MISO), 51 (MOSI), 52 (SCK), and 53 (SS). Note that even if you're not using the SS pin, it must remain set as an output; otherwise, the SPI interface can be put into slave mode, rendering the library inoperative."

Code:
Arduino Pin    --->  ADIS16354
pin 2                pin 8 Reset
pin 3                pin 3 SCLK (can be used arduino pin 13, is the default SPI serial clock????)
pin 4                pin 4 SPI data out
pin 5                pin 5 SPI data input
pin 6                pin 6 CS SPI chip select

void setup() {
  Serial.begin(115200); // start SPI library:
  SPI.begin();
  SPI.setClockDivider(SPI_CLOCK_DIV8);             What is this?, this 3 line???
  SPI.setBitOrder(MSBFIRST);
  SPI.setDataMode(SPI_MODE3); // set SPI mode 3
  }

Logged

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

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

i use this code, to set pin 10 like OUTPUT
Code:
const int ADIScs = 10; // pin 10 is CS (arduino duemilanove)
pinMode(ADIScs, OUTPUT);
pin 13 is SCK (arduino) and SCLK (ADIS senzor) is same

I don't understand how set addresses and bits, example:
addres 0x20 is X-accelerometer offset and i need read and save this value to log file
i dont know this program command
Thanks for help
Logged

Pages: [1]   Go Up
Jump to: