Go to Post I highly doubt the game has anything to do with water... - rotolomi [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 07-02-2011, 18:12
saquib saquib is offline
Registered User
FRC #0854
 
Join Date: Feb 2011
Location: Toronto
Posts: 2
saquib is an unknown quantity at this point
ADXL345 I2C Accelerometer NOT WORKING

ive been having some trouble coding for the accelerometer and i am very confused as to how i can use the i2c bus to actually read from the accelerometer
it would be very helpful if i could get some some sample code or a basic outline of what i need to do
Reply With Quote
  #2   Spotlight this post!  
Unread 08-02-2011, 01:45
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 I2C Accelerometer NOT WORKING

Quote:
Originally Posted by saquib View Post
ive been having some trouble coding for the accelerometer and i am very confused as to how i can use the i2c bus to actually read from the accelerometer
it would be very helpful if i could get some some sample code or a basic outline of what i need to do
There is a class for the sensor that only has a few functions and they are documented. What exactly are you having trouble with? You can look at the LabVIEW example for the ADXL345 to see a wiring diagram.

-Joe
Reply With Quote
  #3   Spotlight this post!  
Unread 09-02-2011, 15:00
brian3795 brian3795 is offline
Registered User
FRC #3795
 
Join Date: Jan 2011
Location: Garland, TX
Posts: 29
brian3795 can only hope to improve
Re: ADXL345 I2C Accelerometer NOT WORKING

Quote:
Originally Posted by jhersh View Post
There is a class for the sensor that only has a few functions and they are documented. What exactly are you having trouble with? You can look at the LabVIEW example for the ADXL345 to see a wiring diagram.

-Joe
Either we have a borked ADXL345, or the LabVIEW code isn't working. The example code just returns a "sensor not responding" error code. It's wired correctly, with the "correct" address of 0x3A.
Reply With Quote
  #4   Spotlight this post!  
Unread 09-02-2011, 15:13
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 I2C Accelerometer NOT WORKING

Quote:
Originally Posted by brian3795 View Post
Either we have a borked ADXL345, or the LabVIEW code isn't working. The example code just returns a "sensor not responding" error code. It's wired correctly, with the "correct" address of 0x3A.
Do you have any equipment (oscilloscope or logic analyzer) you can debug this with? Can you look at the I2C bus to determine if the traffic looks good or not?

-Joe
Reply With Quote
  #5   Spotlight this post!  
Unread 09-02-2011, 15:18
brian3795 brian3795 is offline
Registered User
FRC #3795
 
Join Date: Jan 2011
Location: Garland, TX
Posts: 29
brian3795 can only hope to improve
Re: ADXL345 I2C Accelerometer NOT WORKING

Quote:
Originally Posted by jhersh View Post
Do you have any equipment (oscilloscope or logic analyzer) you can debug this with? Can you look at the I2C bus to determine if the traffic looks good or not?
We have access to a scope...have any references for us as to what "good traffic" will look like?
Reply With Quote
  #6   Spotlight this post!  
Unread 09-02-2011, 15:19
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 I2C Accelerometer NOT WORKING

Quote:
Originally Posted by brian3795 View Post
We have access to a scope...have any references for us as to what "good traffic" will look like?
Just look at the data sheet for the ADXL345... it should have some waveforms in it.
Reply With Quote
  #7   Spotlight this post!  
Unread 09-02-2011, 16:42
brian3795 brian3795 is offline
Registered User
FRC #3795
 
Join Date: Jan 2011
Location: Garland, TX
Posts: 29
brian3795 can only hope to improve
Re: ADXL345 I2C Accelerometer NOT WORKING

Yep, see them...will give the scope a try and see what's up.
Reply With Quote
  #8   Spotlight this post!  
Unread 12-02-2011, 17:20
brian3795 brian3795 is offline
Registered User
FRC #3795
 
Join Date: Jan 2011
Location: Garland, TX
Posts: 29
brian3795 can only hope to improve
Re: ADXL345 I2C Accelerometer NOT WORKING

Well, we ended up getting it to work in SPI mode (we did have to shorten the loop time from 100ms to 10ms). So we'll just live with that unless we run out of DIO ports. Thanks!
Reply With Quote
  #9   Spotlight this post!  
Unread 03-03-2011, 19:13
Trevin Trevin is offline
Registered User
FRC #3191
 
Join Date: Mar 2011
Location: US
Posts: 1
Trevin is an unknown quantity at this point
Re: ADXL345 I2C Accelerometer NOT WORKING

I have been trying to hook up my accelerometer and have had similar problems. I am writing in Java and have tried using the ADXL345_I2C class to interface with the accelerometer, but to no end. Every time I try to get the acceleration all I get back is 0, no matter how much I shake it.

I have also tried using I2C directly and still got nothing.

I would like to try SPI, but I don't know how I would get the data back in the code, the DigitalInput class only returns boolean values, not doubles.

If someone could tell me how to use SPI in Java or what I'm doing wrong with the I2C I would really appreciate it!!! Thanks.
Reply With Quote
  #10   Spotlight this post!  
Unread 04-03-2011, 00:48
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
Exclamation Re: ADXL345 I2C Accelerometer NOT WORKING

Quote:
Originally Posted by Trevin View Post
I have been trying to hook up my accelerometer and have had similar problems. I am writing in Java and have tried using the ADXL345_I2C class to interface with the accelerometer, but to no end. Every time I try to get the acceleration all I get back is 0, no matter how much I shake it.

I have also tried using I2C directly and still got nothing.

I would like to try SPI, but I don't know how I would get the data back in the code, the DigitalInput class only returns boolean values, not doubles.

If someone could tell me how to use SPI in Java or what I'm doing wrong with the I2C I would really appreciate it!!! Thanks.
There is not currently an easy-to-use API in java for accessing SPI so I recommend against that (unless you are savvy C++ to Java porters and would like to contribute an implementation). I2C should work (works on the sensor I have) but check for errors on the console.

Joe
Reply With Quote
  #11   Spotlight this post!  
Unread 05-02-2012, 20:18
Bob649 Bob649 is offline
Technical Mentor
FRC #0649 (Fish)
Team Role: Mentor
 
Join Date: Feb 2012
Rookie Year: 2010
Location: Saratoga HS
Posts: 7
Bob649 is an unknown quantity at this point
Re: ADXL345 I2C Accelerometer NOT WORKING

(Bump on an old thread and hope someone sees it!)

Hello all,
I am having the same problem. We are using Java. Can someone post the wiring diagram from LabView or a screenshot of it? I can not find one though I looked. I did put a scope on the clock and data and they show traffic, but I don't have a protocol analyzer to tell if the traffic is correct.
Also can anyone who has it working confirm if we need to put out own pullup resistor on the CS pin to get into i2c mode? It doesn't look like it, but it could just be the cRIO telling the senor to wake up over and over again.
The code seems so simple I can't imagine it is the code, but if anyone knows any non-obvious points, that would also be appreciated.
Thank you in advance!

Bob
PS My first CD post!
Reply With Quote
Reply


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 09:36.

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