Go to Post I would say that you are not an engineer until you've both obtained the aforementioned peice of paper AND done something with your tumescent engineers forebrain. - phrontist [more]
Home
Go Back   Chief Delphi > FIRST > General Forum
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 19-01-2013, 13:21
wdburk3160 wdburk3160 is offline
Registered User
AKA: William Burk
FRC #3160 (F.R.O.G.)
Team Role: Programmer
 
Join Date: Nov 2012
Rookie Year: 2011
Location: Grove, Oklahoma
Posts: 22
wdburk3160 is an unknown quantity at this point
Accelerometer Trouble

I am trying to program the ADXL345 accelerometer in labview using I2C. I open it up and it needs an address, which I believe needs to be 0x3A. I try to write that address in there and it won't let me type any letters. Any theories as to whats going wrong?
Reply With Quote
  #2   Spotlight this post!  
Unread 19-01-2013, 16:26
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,837
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Accelerometer Trouble

If you can give a snapshot of the code you are working with we might be of better assistance.

This section (ADXL345 I2C Open.vi) from the Accelerometer I2C example has the 0x3A address.
Attached Thumbnails
Click image for larger version

Name:	I2C addresses.png
Views:	29
Size:	34.2 KB
ID:	13580  
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 19-01-2013 at 16:30.
Reply With Quote
  #3   Spotlight this post!  
Unread 19-01-2013, 18:38
Sparks333's Avatar
Sparks333 Sparks333 is offline
Robotics Engineer
AKA: Dane B.
FRC #1425 (Wilsonville Robotics)
Team Role: Alumni
 
Join Date: Feb 2004
Rookie Year: 2003
Location: Wilsonville, Oregon
Posts: 184
Sparks333 is a glorious beacon of lightSparks333 is a glorious beacon of lightSparks333 is a glorious beacon of lightSparks333 is a glorious beacon of lightSparks333 is a glorious beacon of lightSparks333 is a glorious beacon of light
Send a message via AIM to Sparks333
Re: Accelerometer Trouble

I2C does an addressing scheme with the first transmitted byte consisting of 7 bits address and one bit read/write_not flag. According to the datasheet, the ADXL345 technically has an address of 0x1D (which, you may notice, is 0x3A bit-shifted to the right), and to read you transmit 0x3B and to write you transmit 0x3A. Depending on the software library/implementation used, it may or may not do this address bit shift on its own - I've seen and written it both ways. Mark McLeod is right, posting your code would be massively useful, but if you're using a library call with the address as a parameter, try the address as 0x1D.

Barring that, the ADXL345 (along with most other I2C devices) has a pin that can be grounded or dragged high to change a bit of its address, lest you want multiple identical sensors on the same I2C bus. According to the datasheet, if the ALT_ADDRESS pin is grounded, the I2C address becomes 0x53 (0xA6 with the R/W_N bit cleared, 0xA7 with the R/W_N bit set). So, check to see if that pin is grounded - if so, try the alternative address.

Also checking the datasheet - the sensor can be operated in I2C or SPI mode. Since SPI uses a chip-select scheme, it may be important that when you're using the I2C mode that the /CS pin be pulled high. This usually isn't an issue, but Figure 40 in the datasheet shows it pulled high, and usually they don't show connections unless they need to.

Lastly (electrical) - I2C is an open-drain bus. Unlike serial or pulse-width modulation, neither the sensor nor the device doing the addressing pull the line high - only low. This is massively useful when you don't want to deal with level translation, but means that you have to put a weak pull-up on both the clock and the data line. The exact value of the resistor isn't terribly important, but if it's too strong the chip or the controller won't be able to pull it down to a logic zero, and if it's too weak the voltage will not jump straight to logic high after being held low (it will gently meander, which may spill into the next bit, making for a metastable condition). The value of the resistor depends on how many devices you have on the bus, and how long of a conductor your bus uses. If you can get your hands on an o-scope, probe the bus and make sure the pulses look nice and crisp - they can have a bit of overshoot or rolloff, but if they don't reach their final (high) value within about a quarter of shortest pulse width, you need a stronger pullup.

Hope this is useful, and not going over obvious territory.

Sparks
__________________
ICs do weird things when voltage is run out of spec.

I love to take things apart. The fact that they work better when I put them back together it just a bonus.

http://www.ravenblack.net/random/surreal.html
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 11:03.

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