Pages: [1]   Go Down
Author Topic: Defining address for 2 component compass  (Read 667 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 154
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all

I have followed a tutorial to create a tilt compensated compass using the HMC5883L compass and the ADXL345 accelerometer.
Both are stored as variables.

Is it possible to define them as a complete unit?
ie if I was using the following in my code

Code:
#define compassAddress 0x32 >> 1

How do i go about assigning both components a single address to reference from that address.

Excuse the terminology, it may be incorrect. I did a lot of googling trying to find an answer but realised I dont even know how to ask the question smiley
Hopefully it will make sense to someone

Thanks
Steve
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27434
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

You would need an intermediate device with 1 address that would then pass the message to one device or the other.
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
Full Member
***
Karma: 0
Posts: 154
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Bummer.
I never considered that.

Could I not just se it up so when I address the compass it runs a separate loop that encompasses both devices and returns the appropriate data?

Like nesting perhaps.

If not what sort of device might we be referring to?
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27434
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

Could be an AVR with I2C interface.  Maybe one of the ATTiny devices.

Post links for 2 the devices you want to use.
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
Full Member
***
Karma: 0
Posts: 154
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is the link to the HMC5883L
http://www.google.co.nz/url?sa=t&rct=j&q=hmc5883l&source=web&cd=1&cad=rja&ved=0CDcQFjAA&url=http%3A%2F%2Fwww51.honeywell.com%2Faero%2Fcommon%2Fdocuments%2Fmyaerospacecatalog-documents%2FDefense_Brochures-documents%2FHMC5883L_3-Axis_Digital_Compass_IC.pdf&ei=bfU7Ub2sBIOikQXu44GICw&usg=AFQjCNERVlsMXwth4SXIth4jIgNI8Y3gJg&sig2=d6hdUhYFIJLDARfhL76dig&bvm=bv.43287494,d.dGI
And the ADXL345
http://www.google.co.nz/url?sa=t&rct=j&q=adxl345&source=web&cd=2&cad=rja&sqi=2&ved=0CDYQFjAB&url=http%3A%2F%2Fwww.analog.com%2Fstatic%2Fimported-files%2Fdata_sheets%2FADXL345.pdf&ei=7PU7UZanAYfykAXg4IG4Aw&usg=AFQjCNFy6muK3LQUSYM8psaVQwl5M1hmvg&sig2=18jUFUDZF19X6cnBpthhLg&bvm=bv.43287494,d.dGI
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27434
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

I2C Address
8-bit read address 0x3D
8-bit write address 0x3C

With the ALT ADDRESS pin high, the 7-bit I2C address for the device is 0x1D, followed by the R/W bit.
This translates to 0x3A for a write and 0x3B for a read.
An alternate I2C address of 0x53 (followed by the R/W bit) can be chosen by grounding the ALT ADDRESS pin (Pin 12).
This translates to 0xA6 for a write and 0xA7 for a read.

So you've two different addresses, with wholly different data coming from each part.
3A/3B you get one's part info, 3C/3D you get the other.
Talk to both using normal library kind of calls.
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.

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have followed a tutorial to create a tilt compensated compass using the HMC5883L compass and the ADXL345 accelerometer.
Both are stored as variables.

Is it possible to define them as a complete unit?

How do i go about assigning both components a single address to reference from that address.

I'm trying to guess why you're trying to do this, and I couldn't think of a reason. If you want to represent both devices as a single conceptual thing in your code, you could define a class to encapsulate them both. Or if classes aren't your thing you could just define a struct to contain the two addresses, and another struct to contain both sets of results, and a function to read the results from the devices.

Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Full Member
***
Karma: 0
Posts: 154
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Peter

At the end of the day all it does is the HMC outputs a bearing and then the ADXL corrects it for tilt and outputs a tilt compensated bearing.
All I require is to get the tilt compensated bearing with one call basicaly.
Suspected it would be hard to see wy I needed this, especially if you are experiences with code as I am not.

Regards
Steve
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27434
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

Have you seen this chip?
https://www.sparkfun.com/products/10888?

"LSM303DLMTR Breakout Board - Tilt Compensated Compass"

Sounds kinda like what you're after: "a tilt compensated compass using the HMC5883L compass and the ADXL345 accelerometer"
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
Full Member
***
Karma: 0
Posts: 154
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes I did but but only after I have made one now out of seperate components so I will battle on.
Thanks for the replies guys.
Logged

Pages: [1]   Go Up
Jump to: