Go to Post The on-going debate on this thread is just because we care. - Steve Wherry [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 02-10-2014, 22:22
wre136's Avatar
wre136 wre136 is offline
Registered User
AKA: Will Edds
FRC #2461 (The METAL-SKINS)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2002
Location: Oklahoma City
Posts: 30
wre136 is an unknown quantity at this point
Question ADXL345 Accelerometer and Arduino

I am finally getting around to playing with the ADXL345 Accelerometer that is included with the FRC Kit of parts. Right now I am trying to make the Accelerometer work with an Arduino Uno. However, after several attempts, I am not getting anywhere. I am reading nothing but -1 values and can cannot verify if it is wiring, commands or codes.

I would like to ask if anyone has done work on the ADXL345 Accelerometer and Arduino using the SPI or I2C bus. Looking for wiring diagrams and perhaps example code. Please note, I have looked at spec sheets on the ADXL345 but it doesn't quite match up to the one we get in the kit of parts. No arduino examples I found have worked. Anything to help.

Will
  #2   Spotlight this post!  
Unread 02-10-2014, 23:09
Ben Wolsieffer Ben Wolsieffer is offline
Dartmouth 2020
AKA: lopsided98
FRC #2084 (Robots by the C)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Manchester, MA (Hanover, NH)
Posts: 520
Ben Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud of
Re: ADXL345 Accelerometer and Arduino

You might want to take a look at this: https://github.com/adafruit/Adafruit_ADXL345

We used this library to test our accelerometers with an Arduino and it worked perfectly.
__________________



2016 North Shore District - Semifinalists and Excellence in Engineering Award
2015 Northeastern University District - Semifinalists and Creativity Award
2014 Granite State District - Semifinalists and Innovation in Control Award
2012 Boston Regional - Finalists
  #3   Spotlight this post!  
Unread 02-10-2014, 23:22
Ben Wolsieffer Ben Wolsieffer is offline
Dartmouth 2020
AKA: lopsided98
FRC #2084 (Robots by the C)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Manchester, MA (Hanover, NH)
Posts: 520
Ben Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud of
Re: ADXL345 Accelerometer and Arduino

Here is the code we used to test our ADXL345 (and our analog gyro), if you want an example. This requires the Adafruit libraries (Adafruit_Sensor and Adafruit_ADXL345).
Attached Files
File Type: zip GyroAccelTest.ino.zip (1.1 KB, 202 views)
__________________



2016 North Shore District - Semifinalists and Excellence in Engineering Award
2015 Northeastern University District - Semifinalists and Creativity Award
2014 Granite State District - Semifinalists and Innovation in Control Award
2012 Boston Regional - Finalists
  #4   Spotlight this post!  
Unread 03-10-2014, 08:17
protoserge's Avatar
protoserge protoserge is offline
CAD, machining, circuits, fun!
AKA: Some call me... Tim?
FRC #0365 (MOE) & former 836 Mentor)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2002
Location: Wilmington, DE
Posts: 750
protoserge has a reputation beyond reputeprotoserge has a reputation beyond reputeprotoserge has a reputation beyond reputeprotoserge has a reputation beyond reputeprotoserge has a reputation beyond reputeprotoserge has a reputation beyond reputeprotoserge has a reputation beyond reputeprotoserge has a reputation beyond reputeprotoserge has a reputation beyond reputeprotoserge has a reputation beyond reputeprotoserge has a reputation beyond repute
Re: ADXL345 Accelerometer and Arduino

Posting your code might help as well. It might be something very simple.

And a picture of your wiring.

Is this the KoP board you are referencing?

Last edited by protoserge : 03-10-2014 at 09:20.
  #5   Spotlight this post!  
Unread 03-10-2014, 09:21
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: ADXL345 Accelerometer and Arduino

If you are using SPI, the kit board inverts the chip select line of the adxl345 so you would need to make it active high on the arduino to make it work. I2C should just work.
  #6   Spotlight this post!  
Unread 03-10-2014, 10:43
wre136's Avatar
wre136 wre136 is offline
Registered User
AKA: Will Edds
FRC #2461 (The METAL-SKINS)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2002
Location: Oklahoma City
Posts: 30
wre136 is an unknown quantity at this point
Re: ADXL345 Accelerometer and Arduino

Attached is the code I found that should work but doesn't. Yes, we are using the Andy Mark am-2067 sensor module. Thank you for verifying.

In the example, it holds the Chip Select (CS) pin high and holds it low when actually transferring data (Both directions). When I read files, all I get when converted to an int is -1, -1, -1 for all 3 variables. So I am wondering if perhaps I have it cabled incorrectly, if I'm not actually sending the correct hex codes (or the code isn't being converted correctly), it I'm not sending MSB First or what. Just finding this difficult that I cannot get it to respond to anything I send.

Will
Attached Files
File Type: zip ADXL345_Basic.zip (1.6 KB, 163 views)
  #7   Spotlight this post!  
Unread 03-10-2014, 11:08
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: ADXL345 Accelerometer and Arduino

The chip select needs to be high during the transfer. That's what active means.
  #8   Spotlight this post!  
Unread 03-10-2014, 11:13
wre136's Avatar
wre136 wre136 is offline
Registered User
AKA: Will Edds
FRC #2461 (The METAL-SKINS)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2002
Location: Oklahoma City
Posts: 30
wre136 is an unknown quantity at this point
Re: ADXL345 Accelerometer and Arduino

Awesome! I'll invert my Chip Select Pin next try I get which will be this evening.

Will
  #9   Spotlight this post!  
Unread 23-10-2014, 08:21
wre136's Avatar
wre136 wre136 is offline
Registered User
AKA: Will Edds
FRC #2461 (The METAL-SKINS)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2002
Location: Oklahoma City
Posts: 30
wre136 is an unknown quantity at this point
Talking Re: ADXL345 Accelerometer and Arduino

I inverted my chip select so that it as pulled high only during transmission (which is opposite to what stated in the manual for this accelerometer) and now I am able to read data using the SPI bus. Thank you so much for the suggestion!

Will Edds
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 02:45.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi