Pages: [1]   Go Down
Author Topic: spi, registers, and values  (Read 632 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 49
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello all, I have a ADIS16210. I am able to read from it all right, but my question comes about how do I write to the registers? I have a specific address, and a specific value, but how do I program the Arduino to do that?
Is is just 2 consecutive spi.transfers?
Here is the datasheet http://www.analog.com/static/imported-files/data_sheets/ADIS16210.pdf
look at table 23

Thanks,
Mike
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 518
Posts: 26338
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Pretty much - that's how you shift 16 bits out.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

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

Here is the code that I have. I can read from the sensor fine, but it's still the default 1 sample per second. I would like to get 128 samples per second. Thanks!

Code:
#include <SPI.h>

int ss=10;
int ax, ax_l, ay, az;
int datax, datay, dataz;

void setup()
{
  Serial.begin (9600);
  pinMode(ss, LOW); //
  SPI.begin(); //
  SPI.setDataMode(SPI_MODE3);
  SPI.setBitOrder(MSBFIRST);  
  SPI.setClockDivider(SPI_CLOCK_DIV16);
  
  digitalWrite(ss, LOW);
  SPI.transfer(0x38);
  SPI.transfer(0x0002);
  digitalWrite(ss, HIGH);
  delay(5);
}

void loop()
{
 digitalWrite(ss,LOW);
 ax=SPI.transfer(0x0C);
 ax_l = SPI.transfer(0);
 digitalWrite(ss,HIGH);

 datax=(ax<<8) | ax_l;
 Serial.print("X Accel: ");
 Serial.println(datax, DEC);
 delay(25);
}
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 518
Posts: 26338
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Increase with serial port speed
decrease the SPI clock divider
reduce/delete the delays
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 518
Posts: 26338
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

dhenry, your totally useless answer has been deleted.
Moderator
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Pages: [1]   Go Up
Jump to: