Pages: [1]   Go Down
Author Topic: UNOs - Master-Slave and HMC6352 dig compass all three over I2C  (Read 1322 times)
0 Members and 1 Guest are viewing this topic.
Greece
Offline Offline
Jr. Member
**
Karma: 0
Posts: 75
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have two UNO boards connected with I2C and the HMC6352 digital compass which also communicates with the master board over I2C. Is this scenario possible?
All three devices are connected to SDA (A4) and SCL (A5).  While testing the HMC6352 sketch and having the two boards also connected the program stucks on Wire.endTransmission();
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 111
Posts: 5236
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Are the grounds connected? What pull-ups do you use?
Logged

Greece
Offline Offline
Jr. Member
**
Karma: 0
Posts: 75
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Doh! I had each ground separetely on the ground of the circuit I'm using. It works when I'm connecting the grounds together. Do you happen to know why this happens?
Whats the difference of having the grounds separetely from having them connected to each other?
I'm not using any pull-up resistors also. Should I ?
« Last Edit: November 19, 2012, 01:18:32 pm by blank » Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 111
Posts: 5236
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Do you happen to know why this happens?

Without the grounds connected you haven't a common reference where the potentials are measured from. The 5V the Arduino is running on is the voltage compared to ground. If you connect the ground from another device (also running on 5V) to the 5V pin of the Arduino, then you have a voltage of 10V from the Arduinos ground to the 5V of the other device (the voltages adding up).

Quote
I'm not using any pull-up resistors also. Should I ?

The Arduino has internal pull-ups for the I2C but they are weak (20k-50k), so with more than 1 device connected or with a bus length of more than 10cm you should add external pull-ups but only one pair per bus (one resistor for the SDA, the other for SCL). The value should be somewhere between 2k2 to 4k7, depending a bit on the buses total capacity and the voltage you're pulling to.
Logged

Greece
Offline Offline
Jr. Member
**
Karma: 0
Posts: 75
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for the explanation. My wirings are actually a bit longer than 10cm, I have the compass mounted at the other end of the circuit to avoid any magnetic fields.
I'm not quite sure what you mean by 2k2 and 4k7 or how can I measure the buses total capacity though. The compass works with 3.3V, thats the voltage on its SCL and SDA lines.
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 111
Posts: 5236
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

2k2 means 2.2 kOhm and 4k7 means 4.7 kOhm. The bus capacity is added up from the capacities of the connected devices plus a bit for the bus cables. If you don't have the capacity per meter cable of the wires you use, guess it from a similar cable. Usually it's a few pF per dm. If you have a scope you don't have to calculate the bus capacity, you can simply try different resistor values and have a look at the changes of the signal picture.

In your case I would try with 2k2, this probably fits your needs.
Logged

Greece
Offline Offline
Jr. Member
**
Karma: 0
Posts: 75
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

2k2 means 2.2 kOhm and 4k7 means 4.7 kOhm. The bus capacity is added up from the capacities of the connected devices plus a bit for the bus cables. If you don't have the capacity per meter cable of the wires you use, guess it from a similar cable. Usually it's a few pF per dm. If you have a scope you don't have to calculate the bus capacity, you can simply try different resistor values and have a look at the changes of the signal picture.

In your case I would try with 2k2, this probably fits your needs.

Thank you. Is this how I should connect the resistors?

« Last Edit: November 21, 2012, 03:11:07 am by blank » Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 111
Posts: 5236
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Thank you. Is this how I should connect the resistors?

No, the resistors should be pull-ups (pulling up to Vcc) and not pull-downs (pulling to ground). Because your compass module works with 3V3, you should pull the bus to that value. So put a resistor between A4 and 3V3 as well as one between A5 and 3V3.

And you probably want to connect 3V3 to Vcc on the compass module and the GND of it to Arduino's ground.
Logged

Greece
Offline Offline
Jr. Member
**
Karma: 0
Posts: 75
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Right, thats a pull-up. I had no idea.
I just didn't draw the GND and 3.3V to the compass, but I have them connected on the circuit.
Once again, thanks for all the help.

Oops.

EDIT: Should the GND of the compass be connected to Arduino's GND in order to work as a slave device, just like with the slave Arduino? Cause currently I have it on the GND of the circuit.
« Last Edit: November 21, 2012, 08:30:58 am by blank » Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 111
Posts: 5236
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Should the GND of the compass be connected to Arduino's GND in order to work as a slave device, just like with the slave Arduino? Cause currently I have it on the GND of the circuit.

Sure, the grounds of connected devices have always to be connected, otherwise they have no common reference where signal levels are related to.
Logged

Pages: [1]   Go Up
Jump to: