Go Down

Topic: Code for Tri-Axis Inertial Sensor ADIS16354 what next step? (Read 908 times) previous topic - next topic


Apr 21, 2011, 01:23 pm Last Edit: Apr 26, 2011, 09:35 am by mmichalll Reason: 1
how to read value from address 0x05 and send to PC ? i hawe arduino duemilanove

Code: [Select]
Arduino Duemilanove and Tri axis senzor ADIS16354

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


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: [Select]

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.setClockDivider(SPI_CLOCK_DIV8);             What is this?, this 3 line???
  SPI.setDataMode(SPI_MODE3); // set SPI mode 3

Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp


i use this code, to set pin 10 like OUTPUT
Code: [Select]

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

Go Up