Go Down

Topic: Using multiple GY521s on I2C buss (Read 1 time) previous topic - next topic

sgarciav

Hi all,

I am currently working on a project that will use 4 GY521s to get data on four moving planes. I had some difficulty getting two of these devices to work. In fact, the documentation stated that I can toggle pin AD0 to to Vcc to get the alternate x69 address, but since my Vcc is 5v I think I fried the AD0 input on that GY521.

I tested with a second GY521, but this time connecting pin AD0 to the Arduino's 3v3 line and I was able to successfully toggle between x68 and x69. I tried the same procedure with the first GY521, but the address does not toggle at all.

I have been researching on how to handle four GY521s, but the information is skecthy. The main source of information is here on the Ardini.cc Website:

http://playground.arduino.cc/Main/MPU-6050

There it makes reference to using the AUX_DA and AUX_CL pins for the auxiliary i2c bus, but I did not find any further info to look into this further on how the hardware is hookup and software considerations. This same page makes mention of a trick where the AD0 line is controlled by the Arduino, setting all devices to x69 and then using a round robin technique to toggle the GY521's address to x68, read the data and then toggle it back to x69.

Although this is something I am willing to try, it will have to wait till more GY521s arrive, as I mentioned before, I manged to fry the AD0 pin of one of the GY521s that I have and it seems locked at address x68. In fact, this same page explicitly mentions that the AD0 line should be tied to 3v3 to select x69, not 5v. How did I miss that?

Another resource mentions using a 74HC4051 demux to toggle the address to x69 while keeping all other devices at address x68. While this looks like a good solution for many (many) GY521s, I feel that with using 4 devices I can control the AD0 line directly from the Arduino with using the demux.

https://www.youtube.com/watch?v=-1jH54xWzGM

While I feel comfortable controlling the AD0 line with the Arduino, I'll have to wait for the rest of the units to arrive, since I currently have only one device that will toggle.

I would like to look into using the auxiliary i2c buss. Where can I find more information about this? Maybe everyone just uses the trick with the AD0 line. My GY521s have 2.2K pull up resistors on the SDA and SCL lines. This works nicely with two devices, but will I have to do anything differently withthe resistance when I add two more devices to the i2c buss?

Thank you for taking the time to read this post and for any help provided. Salvador

MAS3

Did you consider using a 4052 (or similar) to do some (de)multiplexing of the I2C signals, instead of messing with the address setting ?
Have a look at "blink without delay".
Did you connect the grounds ?
Je kunt hier ook in het Nederlands terecht: http://arduino.cc/forum/index.php/board,77.0.html

Koepel

This is a I2C multiplexer : https://www.adafruit.com/product/2717

Or you could try the other two with SoftwareWire (the SoftwareWire is in the library manager).

Since that youtube movie seems to work to well, changing the address from 0x69 to 0x68 one by one seems to be the most simple solution.
If you have a module with a AD0 that doesn't work, it is probably broken.

The XDA and XCL are not very useful. They have two modes:
1 ) Connected to SDA and SCL. But then you could just as well use the normal SDA and SCL.
2 ) Internally to be used by the DMP only.

What else is on the I2C bus ? More pullups ?
I suggest to remove all the 2k2 from the modules, and have a single 4k7 for the complete I2C bus.

DuaneDegn

#3
Dec 12, 2015, 04:18 am Last Edit: Dec 12, 2015, 04:31 am by DuaneDegn
Maybe everyone just uses the trick with the AD0 line.
This sure seems like a straightforward method of reading from multiple sensors to me. As has been suggested, you want to make sure you don't have too many pull-up resistors in parallel.

How many sensors do you want to use? If it's less than 8, you could use a 3 to 8 decode chip ($1) to set one pin high (or low, I'm not sure which) at a time. Another option would be use use a '595 shift register (also $1) to set the AD0 line high or low. you could chain '595 chips to control lots of AD0 pins with three I/O pins on the Arduino.

sgarciav

This sure seems like a straightforward method of reading from multiple sensors to me. As has been suggested, you want to make sure you don't have too many pull-up resistors in parallel.

How many sensors do you want to use? If it's less than 8, you could use a 3 to 8 decode chip ($1) to set one pin high (or low) at a time. Another option would be use use a '595 shift register (also $1) to set the AD0 line high or low. you could chain '595 chips to control lots of AD0 pins with three I/O pins on the Arduino.
I will be using 4 sensors. I could also use a counter, like the 74LS393, and count modulo 4, enabling each sensor in turn. Since I am looking for simple, I can easily love with hooking up the AD0 pins to the Ardino's IO pins; however, I will need a level converter to make the 5v signal compatible with the AD0's expected 3.3v input.

My concern is the pull up resistance. The resistance goes down a bit for every GY521 that I add and I am not sure what the threshold is. The fellow in the video seems to have solved it. I can't get a good look at the circuit to see whether he added other circuitry to compensate.

Thank you for your feedback. Salvador

sgarciav

This is a I2C multiplexer : https://www.adafruit.com/product/2717

Or you could try the other two with SoftwareWire (the SoftwareWire is in the library manager).

Since that youtube movie seems to work to well, changing the address from 0x69 to 0x68 one by one seems to be the most simple solution.
If you have a module with a AD0 that doesn't work, it is probably broken.

The XDA and XCL are not very useful. They have two modes:
1 ) Connected to SDA and SCL. But then you could just as well use the normal SDA and SCL.
2 ) Internally to be used by the DMP only.

What else is on the I2C bus ? More pullups ?
I suggest to remove all the 2k2 from the modules, and have a single 4k7 for the complete I2C bus.
I like the product that you referenced in the link. I will be using 4 i2c devices. Nothing else on that buss.

Although I agree with your recommendation, desoldering smt components is easier said than done for me. I just don't have the skill or eyesight for such a surgical maneuver.

Thank you for the link and recommendations! I appreciate them much. Salvador

sgarciav

Did you consider using a 4052 (or similar) to do some (de)multiplexing of the I2C signals, instead of messing with the address setting ?

Yes. I have been looking into this possibility. I will be tending towards it if the pull up resistance begins to be a problem. Thanks for the input. Salvador

DuaneDegn

#7
Dec 12, 2015, 05:25 am Last Edit: Dec 12, 2015, 04:11 pm by DuaneDegn
Although I agree with your recommendation, desoldering smt components is easier said than done for me. I just don't have the skill or eyesight for such a surgical maneuver.
I agree removing smt components can be a pain but smt resistors aren't so bad. Just get a good sized blob of solder on the tip of your soldering iron so you can heat up the whole resistor at once. You want enough solder so both sides of the resistor are in contact with the melted solder. Once the solder holding the resistor has melted, push the resistor and solder off to one side.

(Edit: See Koepel's suggestion about holding the PCB upside down.)

I've removed many smt resistors this way and I think it's not very hard to do so.

I will need a level converter to make the 5v signal compatible with the AD0's expected 3.3v input.
An easy way around this on the AD0 lines is to pull the line high to 3.3V and use the Arduino to pull the line low. You wouldn't need to ever set the line high from the Arduino. The I/O pin would be limited to two possible states, an input pulled high to 3.3V and as an output set low to 0V.

sgarciav

I agree removing smt components can be a pain but smt resistors are so bad. Just get a good sized blob of solder on the tip of your soldering iron so you can heat up the whole resistor at once. You want enough solder so both sides of the resistor are in contact with the melted solder. Once the solder holding the resistor has melted, push the resistor and solder off to one side.

I've removed many smt resistors this way and I think it's not very hard to do so.

An easy way around this on the AD0 lines is to pull the line high to 3.3V and use the Arduino to pull the line low. You wouldn't need to ever set the line high from the Arduino. The I/O pin would be limited to two possible states, an input pulled high to 3.3V and as an output set low to 0V.
Thanks again for the helpful hints. Yes, desoldering the smt resistors is physically doable for me, but I will have to give it more thought as I need to decide whether modifying the GY521 is an option or not. I will be passing on this design to someone else and if he should want to build more of the finished item the off the shelf GY521 will not work without modification.

Regards

Koepel

#9
Dec 12, 2015, 09:16 am Last Edit: Dec 12, 2015, 09:16 am by Koepel
I can't solder smd components as well, but removing a resistor is as simple as DuaneDegn wrote. With the blob of solder over the component, it falls off very quickly. I keep it tilted/upside down and let if fall off.

Go Up