Softpy
Posts: 25
Joined: Wed Sep 11, 2013 2:45 pm
Location: Chișinău, Republic of Moldova
Contact: Website

Multiple MPU-6050 sensors

Sat Sep 14, 2013 12:40 pm

Please help me to connect more MPU-6050 (I2C) to my raspberry pi.

Screenshots:
http://s14.directupload.net/images/130914/l32wb8aj.jpg
http://s7.directupload.net/images/130914/p5que2m4.jpg

My results (work with MPU-6050):
http://qper.net/?q=lay9K (excel file)

VCC -> 3.3V
GND -> GND
SCL -> SCL
SDA -> SDA
XDA -> -?-
XCL -> -?-
ADO -> -?-
INT -> -?-

danjperron
Posts: 2855
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Multiple MPU-6050 sensors

Sun Sep 15, 2013 2:29 am

Hi Softpi,

AD0 will select 0x68 or 0x69 for the i2c address.

If you only need 2 devices just put AD0 to ground on one device and to vcc on the other.

SDA , SCL , ground and VCC will be use on both/all devices. You don't need AUX_SCL, AUX_SDA and INT

if you need more use one 74hc138 . Select up to 8 devices.
You will need 3 gpios ( 2 power 3 = 8) connect to a1,a2 and a3 input. Put all AD0 devices to a Y0 to Y7 output. E1 and E2 to ground. E3 to vcc.
This method only allow one device to be selected by the GPIOs (using the 74hc138 decoder) to work at 0x68. All the others units are at the address 0x69 and should not be access (conflict).

P.S. Most mpu-6050 board have pull-up resistors. You should remove them since the Rpi already have some and to many pull-up load will cause the system to fail.

Daniel

Softpy
Posts: 25
Joined: Wed Sep 11, 2013 2:45 pm
Location: Chișinău, Republic of Moldova
Contact: Website

Re: Multiple MPU-6050 sensors

Sun Sep 15, 2013 11:24 am

I am sorry but i do not understood.
I need to connect ~100 or ~50 MPU-6050 sensors to one raspberry pi.
How can i connect all sensors?... :roll:

danjperron
Posts: 2855
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Multiple MPU-6050 sensors

Sun Sep 15, 2013 12:09 pm

Hi Softpy,

you should tell more about your project since it is quite space out.

What is the maximum length between each accelerometer?
What is you aquisition speed?
Does it need to be real time or it could support lag delay ?
What kind of physical layout are you thinking?

Depending of the speed you need, I see 2 methods.

Method 1,

Use multiple Rpi in cluster , network connected. Each ones will have "n" accelerometers using the 74hc138 method.


Method 2,

Use a small cpu on each accelerometer and hook it up using a more robust serial bus than I2C like rs-485 or CANBUS.


I did a small interface with bluetooth and a accelerometer on this post
http://www.raspberrypi.org/phpBB3/viewt ... 22#p390222

And I just replied to a post for distribute I/O

http://www.raspberrypi.org/phpBB3/viewt ... 52#p421752

Daniel

Softpy
Posts: 25
Joined: Wed Sep 11, 2013 2:45 pm
Location: Chișinău, Republic of Moldova
Contact: Website

Re: Multiple MPU-6050 sensors

Mon Sep 16, 2013 6:32 am

Hi Daniel,

I need to connect up to 100 sensors to detect vibrations on many machines.
I did many test with one MPU-6050 and i got good information on delay 0.01 sec.

I need to connect all sensors to my raspberry pi, But i do not know how can i do that, what i need to buy.

P.S. Sorry for my bad english.

danjperron
Posts: 2855
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Multiple MPU-6050 sensors

Mon Sep 16, 2013 11:07 am

Hi Softpy,

You forgot to tell me the most important.

Are far away are each machine. is 1, 3,10 meter or more. This is what will induce the most on your design.
Obviously you can't use digital chip select or i2c if you are over 3 meter or more. And USB has a maximum of 3 meters without active repeaters.

Long distance will need a kind of bus which can handle noise immunity , wire capacitance, etc.. RS-485, modbus, canbus, ethernet, ...

Are those machines create a lot of magnetic around them (Powerfull electric motor, 5HP and more)? Ground loop problem in the environment ( not a metal foundry I hope).

What is you minimum acquisition rate for each and all of them together?

Daniel

Softpy
Posts: 25
Joined: Wed Sep 11, 2013 2:45 pm
Location: Chișinău, Republic of Moldova
Contact: Website

Re: Multiple MPU-6050 sensors

Mon Sep 16, 2013 2:09 pm

Daniel,

Please look at this image:
http://s7.directupload.net/images/130916/cgflj2w7.png

What i need to buy to connect all sensors to Raspberry PI?

danjperron
Posts: 2855
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Multiple MPU-6050 sensors

Mon Sep 16, 2013 3:36 pm

The layout explain everything.

This is a modbus or canbus layout.

Use the Rpi and create cpu modules which connect each individual accelerometer and transfer the data to the rpi.

1mbs CANBUS will be ideal. Easy to do but a big learning curve. This is the more robust approach.

Method 1 the best one .
Use this little board from modtronix SBC28PC-IR4 Rs-485 or SBC28PC-IR2 Rs232 and use a pic18f2580 or similar. Software is not so hard since it will be the same for all of them except the node id. Each accelerometer data will be send to the bus realtime. Not exactly realtime but close.

Method 2.

Use individual arduino board and create a modbus or master/slave rs-485 system. Later you could just buy the cpu ad make your little board.

Method 3. Use one rpi for each accelerometer. In theory you should be able to connect 4 accelerometer on each rpi. there is two I2C bus and using AD0 , you will have two accelerometer, one on 0x68 and the other on 0x69.
Use the ethernet to connect all your RPi .

Method 4. Use my egg dropping project and create a cluster of bluetooth device all connected to the rpi. I never test more than one bluetooth connection but this is the cheapest approach. Maybe you could get away with 5 Rpi because bluetooth distance is not so good.

P.S. you could easily change the bluetooth to an rs-485 protocol.

In my own opinion , I will use CANBUS. This is very robust . Once you know how to use CANBUS it is the simplest to code. But like I said , it is a big learning curve.

Daniel
Last edited by danjperron on Mon Sep 16, 2013 5:01 pm, edited 1 time in total.

danjperron
Posts: 2855
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Multiple MPU-6050 sensors

Mon Sep 16, 2013 4:52 pm

B.T.W.

I'm planning to update the Raspberry Pi small cpu programmer to include the pic18F family.
This way you could program this little cpu using the RPi.

I do have some pic18f2580 on hand to update my programmer.

I will investigate it. I already post my intention from this post

http://www.raspberrypi.org/phpBB3/viewt ... 70#p422270

And I still have the original code used by Stefen Siegel work (Circuit Cellar). If you go to that road you should get those two artcicles. ( ar least the june 2010 part 2).

Daniel

danjperron
Posts: 2855
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Multiple MPU-6050 sensors

Mon Sep 16, 2013 5:18 pm

An other very cheap method will be to implements I2C with a star mode using four PCF8575C I/O node.

Each node will deliver the I2C data and a individual I/O pin which it is connected at the AD0 pin.
Only the one with the I/O pin low should talk. It means all the other I/O pins will be at High .

I don't recommend it but it should work.

Daniel

slava
Posts: 2
Joined: Sun Sep 22, 2013 2:06 pm
Location: Chisinau, Moldova

Re: Multiple MPU-6050 sensors

Sun Sep 22, 2013 2:27 pm

Hello Softpi,
I will be offtopic, but I couldn't find any other way to contact you. How did you get your PI unit to Moldova?
Any help will be much appreciated. Thanks ;)

Softpy
Posts: 25
Joined: Wed Sep 11, 2013 2:45 pm
Location: Chișinău, Republic of Moldova
Contact: Website

Re: Multiple MPU-6050 sensors

Mon Sep 23, 2013 8:56 am

Thanks to all.

Now i try to modify I2C addresses of my MPU-6050 sensors.
Please help me :(
Any snippets code?

P.S. Slava you have PM.

danjperron
Posts: 2855
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Multiple MPU-6050 sensors

Sun Oct 20, 2013 11:26 pm

Hi Softpy,

I had fun trying to use a canbus system with two MPU6050.
I used a PIC18F26K80 with the source forge code from http://sourceforge.net/projects/canopen ... Node-1.10/

I did have to modify it for compatibilities with the new cpu and I add DIP switches for NodeId. This way I could use up to 64 modules without changing the code.

The canbus speed is set to 1MBS.

Each module is capable to run 2 MPU6050 at 500 samples/sec. With that sample rate, one canbus network will be able to handle 7 modules. If you reduce the sample rate to 100, you will be able to have 35 modules which will be 70 accelerometers.

this is the github of the code with all modifications done.
https://github.com/danjperron/CANOpenGrav1

You could just use the Grav1.hex file to program the CPU using the burn program I made https://github.com/danjperron/burnLVP. which is on that post http://www.raspberrypi.org/phpBB3/viewt ... 43#p430643

This is a picture of my prototype board with two MPU6050s in operation https://dl.dropboxusercontent.com/s/mpw ... 160931.jpg

This is the can bus analyzer result output
Image

This show you one module output result with accelerometer information with a sample rate of 500/sec.
This module is Node 1, address 181 is accelerometer 1 output, 182 is accelerometer device 2 output.
The can bus address 201 was received from the module to set the sample rate,(This is done manually by me).

And this is the schematic of the board
https://dl.dropboxusercontent.com/s/gc9 ... MODULE.png



This post will give you information on how to connect the can bus to the Raspberry Pi.

http://www.raspberrypi.org/phpBB3/viewt ... lit=canbus


Daniel
Last edited by danjperron on Sat Mar 31, 2018 4:14 pm, edited 2 times in total.

RSC
Posts: 1
Joined: Mon Sep 14, 2015 4:49 am

Re: Multiple MPU-6050 sensors

Tue Sep 15, 2015 1:22 am

danjperron wrote:Hi Softpy,

I had fun trying to use a canbus system with two MPU6050.
I used a PIC18F26K80 with the source forge code from http://sourceforge.net/projects/canopen ... Node-1.10/

I did have to modify it for compatibilities with the new cpu and I add DIP switches for NodeId. This way I could use up to 64 modules without changing the code.

The canbus speed is set to 1MBS.

Each module is capable to run 2 MPU6050 at 500 samples/sec. With that sample rate, one canbus network will be able to handle 7 modules. If you reduce the sample rate to 100, you will be able to have 35 modules which will be 70 accelerometers.

this is the github of the code with all modifications done.
https://github.com/danjperron/CANOpenGrav1

You could just use the Grav1.hex file to program the CPU using the burn program I made https://github.com/danjperron/burnLVP. which is on that post http://www.raspberrypi.org/phpBB3/viewt ... 43#p430643

This is a picture of my prototype board with two MPU6050s in operation https://dl.dropboxusercontent.com/u/488 ... 160931.jpg

This is the can bus analyzer result output
Image

This show you one module output result with accelerometer information with a sample rate of 500/sec.
This module is Node 1, address 181 is accelerometer 1 output, 182 is accelerometer device 2 output.
The can bus address 201 was received from the module to set the sample rate,(This is done manually by me).

And this is the schematic of the board
https://dl.dropboxusercontent.com/u/488 ... MODULE.png



This post will give you information on how to connect the can bus to the Raspberry Pi.

http://www.raspberrypi.org/phpBB3/viewt ... lit=canbus


Daniel
Hi Daniel, this code was programed in mplab v8 with c18? I cannot import this project in mplab x with c18, this project can run on pic18f4550? sounds it's very interesting
I want run 4 mpu6050 in a raspberry pi or pic
best regards

danjperron
Posts: 2855
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Multiple MPU-6050 sensors

Tue Sep 15, 2015 11:00 am

Code: Select all

this code was programed in mplab v8 with c18? I cannot import this project in mplab x with c18
You are correct but it should be not to difficult to convert it into mpab x.

There is some minor change, like the configuration bits!

http://microchip.wikidot.com/mplabx:con ... to-mplab-x

danjperron
Posts: 2855
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Multiple MPU-6050 sensors

Tue Sep 15, 2015 11:21 am

this project can run on pic18f4550?
No. You need a cpu with CAN hardware. PIC32 cpu have CAN also.

Unless you use the serial port with RS-485.

An arduino could do it!

Check that post about RFID using RS-485 on MODBUS.

viewtopic.php?p=804001#p804001

There is code to handle the MPU6050 on arduino. Just swap the RFID for the MPU6050. Still harder to do than modify the code for mplab X.

B.T.W. The avantage of the CANBUS is the self cpu scheduling and the collision handler. This is a good avantage since the data will be sent without intervention of the Pi. The RS-485 is a master slave mode.

I'm on the way to revive one of my old project. The 'Led Post'! This was using the same mplab 8 so I will see how complicated to upgrade the code for mplab X.

danjperron
Posts: 2855
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Multiple MPU-6050 sensors

Wed Sep 16, 2015 12:46 am

Well I checked my code and it will take me more than a night to convert it to X8.

But I don't need to. There is a simple method if you have a Windows computer.

The MCC18 compiler works well in mplab X IDE.

Simply download and install the MCC18 compiler.

http://ww1.microchip.com/downloads/en/D ... taller.exe

I upgrade my github for mplab X IDE.

Be sure that all your includes are located properly and the current compiler for that project is MCC18

Mathilde
Posts: 2
Joined: Mon May 21, 2018 9:48 am

Re: Multiple MPU-6050 sensors

Mon May 21, 2018 9:56 am

Hello !
I am using a MPU6050 for a school project, but it is a BJY61 Bluetooth MPU6050 Module. I would like to connect 3 sensors on my Raspberry. I have 8 pins (RX, TX, SCL, SDA, and 2 GRD, VCC). I see in this post you use AD0 pin to connect various sensor but I don't have this pin on my MPU6050. Is it possible to connect 3 sensors with i2c on my Raspberry without AD0 ?
Thanks for your answer :)

Mathilde

danjperron
Posts: 2855
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Multiple MPU-6050 sensors

Mon May 21, 2018 11:36 am

I'm a little bit confuse about that bluetooth device. Is the bluetooth read the MPU6050? If yes than you could connect multiple device using the bluetooth. There is a limit on how many bluetooth device you could connect but I thing is more than 3 anyway,

The other method is to use an analog multiplexer to select which I2C device will be connected.
https://www.maximintegrated.com/en/app- ... mvp/id/955

Another I.C. also do the trick to expand I2C but I don't remember the parts number.

Mathilde
Posts: 2
Joined: Mon May 21, 2018 9:48 am

Re: Multiple MPU-6050 sensors

Mon Jun 04, 2018 6:53 pm

Hello, I can't use bluetooth with the MPU6050. Thank you for your answer, I will try your other method :)

Return to “Automation, sensing and robotics”

Who is online

Users browsing this forum: No registered users and 10 guests