How to connect and test FreeIMU v0.4 with Arduino and the FreeIMU library

Submitted by fabio on Tue, 2012-04-17 10:31.

One of the FreeIMU users, who bought one of our production run FreeIMU boards, shipped me his board as a faulty one. We promptly shipped him a replacement board but when I tested his board I found out that it was working perfectly.

This motivated me enough to record this video (actually using exactly his board) showing you how to correctly connect a FreeIMU board and testing it with the FreeIMU library.

A librarz used by this sketch is not installed properly

Submitted by Sidi (not verified) on Wed, 2014-02-26 22:27.

I have a error by the run sketch:

Catched URISyntaxException: Illegal character in fragment at index 19: file:/D:/#%20AVR%20#/#ARDUINO%20-%20PROJEKTY#/MPU-6050/processing-2.1.1/core/library/gluegen-rt.jar, while addNativeJarLibsImpl(classFromJavaJar class com.jogamp.common.os.Platform, classJarURI jar:file:/D:/%23%20AVR%20%23/%23ARDUINO%20-%20PROJEKTY%23/MPU-6050/processing-2.1.1/core/library/gluegen-rt.jar!/com/jogamp/common/os/Platform.class, nativeJarBaseName gluegen-rt-natives-windows-amd64.jar):
java.lang.NullPointerException
at processing.mode.java.runner.Runner.findException(Runner.java:926)
at processing.mode.java.runner.Runner.reportException(Runner.java:871)
at processing.mode.java.runner.Runner.exceptionEvent(Runner.java:797)
at processing.mode.java.runner.Runner$2.run(Runner.java:686)
A library relies on native code that's not available.
Or only works properly when the sketch is run as a 32-bit application.

Multiple GY-521 sensors on Arduino

Submitted by Robert (not verified) on Sun, 2013-06-16 14:25.

I have tried the GY-521 (with MPU-6050 chip) sensor on Arduino by using the guide from (http://playground.arduino.cc/Main/MPU-6050). It worked well. Can anyone guide me on how can I add another GY-512 module please? I am planning to use a total of four of them connected to my Arduino Uno.

I have learned for the comments above that I need to configure four I2C addresses as I am planning to use four of the modules. How do I do that? Please help.

I've made it.

Submitted by Robert (not verified) on Wed, 2013-06-19 09:18.

Dear all,

Millions of thanks to

Ms Debra, http://www.geekmomprojects.com
Dr Anindo Ghosh, http://electronics.stackexchange.com
Mr Muddy, http://forum.arduino.cc

I have managed to make the 2 sensor modules work.

freeIMU i2c not with ardiuno IDE

Submitted by pbr (not verified) on Sat, 2013-01-05 16:15.

Hi,

I'm trying to learn som MCU programming, with the goal of using a RTOS (FreeRTOS by Atmel). My MCU is an Arduino Due and as mentioned, I'm not running the standard Arduino IDE.

I have problems communicationg with the freeIMU 0.4.3 over i2c, probably related to address-settings in my code.

My code looks something like this:

void twi_init(void)
{
twi_master_options_t opt = {
.speed = 400000,
.chip = 0x??
};
twi_master_setup(TWI0, &opt);
}

In main() (after inits etc):

const uint8_t test_pattern[] = {0x55,0xA5,0x5A,0x77,0x99};
twi_package_t packet_write = {
.addr = 0x??, // TWI slave memory address data
.addr_length = sizeof (uint16_t), // TWI slave memory address data size
.chip = 0x??, // TWI slave bus address
.buffer = (void *)test_pattern, // transfer data source buffer
.length = sizeof(test_pattern) // transfer data size (bytes)
};
while (twi_master_write(TWI0, &packet_write) != TWI_SUCCESS );
.....
.....

This code is from example code from the Atmel Studio 6 IDE.

What should the addresses be? I've tried with 0x77/68 and 0x0A (some base adds found in freeIMU.h. The code ends up in a loop not receiving TX.
Chip-addr = ?
TWI slave memory address data = ?
TWI slave bus address = ?

What should the message(test_pattern) I send be?

Glad for any input I can get!

Dear Fabio, I've designed a

Submitted by Masoud (not verified) on Sat, 2012-10-20 18:51.

Dear Fabio,
I've designed a board with an MPU6050,HMC5883 and an Atmega32 which grabs data from this sensors.It's really like your FreeIMU board.
now I'm trying to run it, but I think I'm having an unknown problem.
The data I'm reading from the low bytes of gyro and accel sensor are really noisy, and the noise is somehow periodic :p.
It has a nonsense output like 255,1,133,53,223....
My friend says this is because MPU6050 is not a good one!! Is it?
how much noise do you have on your gyro and accel output?

The MPU6050 is a pretty good

Submitted by fabio on Sat, 2012-10-20 20:39.

The MPU6050 is a pretty good sensor. Everyone using it. You will only have problems if you screwed up the power design of your board.

If you are using the gyro at full sensitivity, like in the FreeIMU library, readings of that kind are pretty ok.

Have you tried running some visual testing such as the Processing sketches in the FreeIMU library?

Dear fabio,Well these are

Submitted by Anonymous (not verified) on Sun, 2012-10-21 09:42.

Dear fabio,
Well these are the figures.
500_sample_1
500_sample_2
100_sample_1

I've set the clock source on internal oscillator, but even when I set the clock source on gyro axes with PLL I don't get a better result.
and this is the configuration segment of my code.

 
int MPU_config()
{   int result = TRUE;
    //define these 2 variables
    //and call the fi2c_write(MPU_address,reg_address,data); 
    fi2c_write(MPU_ADDRESS,MPU6050_RA_SMPLRT_DIV,0x07);
    fi2c_write(MPU_ADDRESS ,MPU6050_RA_CONFIG, 0x00);
    fi2c_write(MPU_ADDRESS,MPU6050_RA_GYRO_CONFIG,0x08);
    fi2c_write(MPU_ADDRESS,MPU6050_RA_PWR_MGMT_1,0x00);    //Clock select and sleep off   Clock is set to internal oscillator
    
   



return result ; //just for test
}

Are the graphs for the gyro

Submitted by fabio on Sun, 2012-10-21 10:09.

Are the graphs for the gyro or the acc readings?

Well It's the gyro output,

Submitted by Masoud (not verified) on Sun, 2012-10-21 16:07.

Well It's the gyro output, the blue plot is x axe, The green one is the y axe and the red one is the z axe.This data is grabbed when the board was stable on a desk.
Today I enabled the Low-pass-filter(DPLF) on it's max amount(5 Hz).
well the output is much better, but It has some noise, and the delay is increased to 19.0 msec on each sampling.
Do you have any suggestion for me? Fabio how much noise do you see on your FreeIMU board?
Oh did you take look at the PCB? Is there any problem with it?

http://sprunge.us/XDQS that

Submitted by fabio on Sun, 2012-10-21 17:26.

http://sprunge.us/XDQS that is a sample taken from the FreeIMU_raw program running using the default settings in the FreeIMU library.

Each line is are acc_x, acc_y, acc_z, gyro_x, gyro_y, gyro_z, magn_x, magn_y, magn_z, baro_temp, baro_press.

So, basically I'm getting about 3 or 4 units of noise on the gyro.

I don't see any huge mistake in that board design.. The only problem I see is that you used a 10uF capacitor as output from the voltage regulator. Instead the datasheet of the regulator suggest a much bigger value like 22uF, also use tantalum not ceramic capacitor for that.

You can test if this is the problem by placing a big trough hole electrolytic capacitor in parallel to the power rail of the gyroscope. Put it as close as you can place it to the gyro. Use 50uF or more.

Well I put a 100uF capacitor

Submitted by Masoud (not verified) on Mon, 2012-10-22 19:03.

Well I put a 100uF capacitor in parallel to the C4. The DLPF is on 5 Hz. now the gyro output has a peak to peak change of 20 units. Well much better!!! thanks. thanks. thanks.
But It's is far from 4-5 units that you reached. I appreciate any suggestion from you and your readers.

I guess that your problem is

Submitted by fabio on Tue, 2012-10-23 10:02.

I guess that your problem is the voltage regulator you used then... too noisy for this application. I would suggest you giving a look at the specs of the MIC5203 used on the FreeIMU compared to the one you are using and see if the noise figures are inline with the effect you are experiencing. If it is so, you'll have to change voltage regulator.

Today I made a visual test

Submitted by Masoud (not verified) on Wed, 2012-10-24 17:32.

Today I made a visual test with Matlab. I controlled a 3D object with only compass and accel, without any filter or calibration and even without using gyro. Well the result was amazingly great. That amount of noise didn't have a sensible effect.
Thanks for your Help,Well your FreeIMU now has a new friend; our new IUT_IMU. ;)

Thanks for fast reply

Submitted by Masoud (not verified) on Sat, 2012-10-20 21:06.

Thanks for fast reply ;)
Actually this is my first PCB design :p
I've uploaded some screenshots of my PCB to my dropbox please take a look at them.

IUT_IMU
3D_veiw_IUTIMU

These are the schematics:
Board Power schematic
MPU6050_Schematic

Well I have set the gyro full-scale on 500 deg/s.
I don't have any arduino, as I said I use an Atmega32, can I use the output of Arduino IDE to program my micro?
And about visual testing, well at this stage I use Matlab to plot the gyro data, and the figure looks noisy. right now I don't have access to board. I will upload some figures of the gyro data tomorrow.
Well thanks fabio.

New Board producing zero's

Submitted by Rick Eis (not verified) on Fri, 2012-09-14 05:20.

Hi Fab,
I just received my first new FreeIMU v0.4 from Flyduino.net
To test it I hooked it up and ran FreeIMU_raw exactly like you did in the video above.
I get all zero's in the first 9 columns the last 2 columns I get 2965(4) and 22370's
Do you have any suggestions or other tests to do?
Thanks
Rick

Have you read the install

Submitted by fabio on Fri, 2012-09-14 11:12.

Have you read the install instructions in the FreeIMU library download page? They tell you to modify the FreeIMU.h to enable the board you are using...

MPU-6050

Submitted by jk (not verified) on Thu, 2012-08-16 17:32.

Finally I've come across a fully detailed video on the IMU... :D I'm using an MPU-6050 (6 DOF) http://www.ebay.com/itm/MPU-6050-3-Axis-gyroscope-3Axis-acce-lerometer-m... , it is not really an freeimu board. Will i be able to use the same code you've shown, for it? If so, which is the part which i should uncomment in the freeimu library ?
Also, the processing IDE you showed, where did that come from?

Thank you.

Sorry, looks like I missed

Submitted by fabio on Fri, 2012-09-14 11:14.

Sorry, looks like I missed your comment. Right now we don't have any ready to use code for MPU6050 only board.. but modifying the library for this purpose should be pretty trivial if you have any programming experience.

Thanks. I designed a

Submitted by jk (not verified) on Mon, 2012-10-22 19:15.

Thanks. I designed a simulator on my own using processing for MPU-6050. Thanks anyways. :)

arduino nano-freeIMU

Submitted by Agostino (not verified) on Tue, 2012-07-17 12:45.

Hi Fabio,
I need to connect Arduino Nano to freeIMU v.0.4.3 .I would like get information about the connection between pins A4 and A5 with SDA and SCL, respectively:I must make a conversion from 5 V to 3.3 V or I can directly make the connection?
In the first case, you tell me how?
Thank you!
Agostino

The connections between the

Submitted by fabio on Tue, 2012-07-17 13:25.

The connections between the Arduino Nano and the FreeIMU v0.4.3 are exactly the same of the Arduino UNO/Duemilanove.

If you don't enable the internal pullups of the ATMEGA, you'll be perfectly fine without any logic level converter. The FreeIMU library and the MultiWii software won't enable the pullups so you'll be fine if you plan to use such softwares.

I have a problem.I measured

Submitted by Agostino (not verified) on Tue, 2012-07-17 14:53.

I have a problem.I measured the logic levels on the breadbord and they are ok.I have uploaded freeimu_raw sketch on the arduino software. The loading had no errors but nothing appears on the serial monitor.Can you give me some explanation about it?

Have you set the speed of

Submitted by fabio on Tue, 2012-07-17 14:55.

Have you set the speed of your serial monitor to 115200 bauds?

yes....what is the problem?

Submitted by Agostino (not verified) on Tue, 2012-07-17 14:58.

yes....what is the problem?

have you modified the file

Submitted by fabio on Tue, 2012-07-17 15:05.

have you modified the file FreeIMU.h as explained in the FreeIMU library download section? (uncommenting the correct board)

no no...

Submitted by Agostino (not verified) on Tue, 2012-07-17 15:09.

no no...

You have to. By default the

Submitted by fabio on Tue, 2012-07-17 15:51.

You have to. By default the FreeIMU library it's configured to be used on v0.3.5_MS. In order to use on a different board, open the file FreeIMU.h and uncomment the correct version of your board.

I have setted the speed of

Submitted by Agostino (not verified) on Tue, 2012-07-17 15:50.

I have setted the speed of your serial monitor to 9600 bauds: now the values ​​are printed on the monitor but they are fixed to zero, that are not updated by moving the freeimu.

Dear Fabio, I am currently

Submitted by Yap (not verified) on Fri, 2012-07-13 05:36.

Dear Fabio,

I am currently working on a project. I need to use two sensor to sense the angle between two segment of our body. For example, the knee joint angle.

May i know how can i start with? I have managed to built one sensor and use the free imu library.

Should i use two arduino board? how about the programming part?

If you used the MPU6050 for

Submitted by fabio on Fri, 2012-07-13 08:10.

If you used the MPU6050 for your sensor, you can build exactly another one and connect the two sensors to the same Arduino I2C bus. The MPU6050 can be configured to have two I2C addresses.. you will use one address on one sensor and the other address on the other sensor. This way you'll have access to both sensors froom the same microcontroller.

can i know how can i modify

Submitted by Yap (not verified) on Fri, 2012-07-13 10:08.

can i know how can i modify the i2c address?
I have an exact configuration as the video u showed above.

is it changing the code of adxl345.h?

Sorry i am a newbie to programming and electronic.

Read the ADXL345 detasheet...

Submitted by fabio on Fri, 2012-07-13 10:59.

Read the ADXL345 detasheet... everything is explained there.

Thank you=) What if i am

Submitted by Yap (not verified) on Fri, 2012-07-13 08:52.

Thank you=)

What if i am using the adxl345,itg3200 and hmc 5883?

Than you'll have to use some

Submitted by fabio on Fri, 2012-07-13 09:46.

Than you'll have to use some kind of I2C multiplexer: both the ADXL345 and ITG3200 have I2C addresses configurable, allowing you to have 2 of each of them on a single bus but the HMC5883L doesn't allow any I2C configuration so only one address available. This means that you can use only one HMC5883L per I2C, so you'll need some I2C multiplexer.

Dear Fabio I managed to get a

Submitted by HK (not verified) on Thu, 2012-07-12 10:29.

Dear Fabio

I managed to get a FreeIMU sensor.

I managed to upload the code successfully using arduino UNO.

However, I wonder why there are no readings in serial monitor?

Is it because of the sensor problem or my connection is loose?

SpeedTest

Submitted by Anonymous (not verified) on Thu, 2012-05-31 11:16.

Hi Fabio,

I've just one question, I see you have a FreeIMU_speedtest sample, could you tell us, whats are the results running this program.

Thanks
Regards.

That example code should

Submitted by fabio on Thu, 2012-05-31 12:05.

That example code should allow you to test the speed of the readings. With a FreeIMU v0.4.3, this is what I get:

Testing raw reading speed (average on 1024 samples):
--> result: 1349 microseconds .... 1 milliseconds
Testing calibrated reading speed (average on 1024 samples):
--> result: 1276 microseconds .... 1 milliseconds
Testing sensor fusion speed (average on 1024 samples):
--> result: 3037 microseconds .... 3 milliseconds

Hi Fabio! What is the

Submitted by zhivko (not verified) on Wed, 2012-05-16 09:44.

Hi Fabio!

What is the precission of this IMU device? Can it be ported to Arm MBED environment? Do you know for some such efforts already?

Thanks

The precision highly depends

Submitted by fabio on Sat, 2012-05-19 20:09.

The precision highly depends on the kind of application you plan to use your imu on and on the precision of the calibration of your sensors. Personally, while I don't have exact numbers, I'm using boards capable of reaching something around 1 degree of accuracy.

You can use FreeIMU with any microcontroller capable of I2C communication. Then also on the MBED. Unfortunately, I'm not aware of any of such effort so far.

You may wanna have a look at http://mbed.org/cookbook/IMU .. the sensors are those used in older versions of FreeIMU than the current 0.4.3 but it should still be a good source of inspiration.

Hi Fabio, I am a bit confused

Submitted by Federico Galli (not verified) on Fri, 2012-05-11 13:32.

Hi Fabio,
I am a bit confused about the pullup resistors. They were necessary till some time ago and now they are necessary just on the mega board? Are the diecimila and 2009 ok? Why?
Can you explain it more precisely?
Thanks,
Federico

FreeIMU v0.4r3 has integrated

Submitted by fabio on Fri, 2012-05-11 14:23.

FreeIMU v0.4r3 has integrated pullup resistors. You don't have to add external ones. You can simply connect it to the 2009/UNO but keep the ATMEGA internal pullups disabled (the FreeIMU library or MultiWii will do this for you)

The Original Arduino Mega has 5V pullups which need to be desoldered in order to use it with the FreeIMU or a logic level converter needs to be added.

Let me know if you have further questions.

Interal pull-up and Wire.begin()

Submitted by Julian (not verified) on Wed, 2012-08-29 10:13.

Hello Fabio,
You say your library would not activate the internal pull up resistors.
But you're using but the Wire library, I read that this enabled the interen resistors.

source:
http://arduino.cc/playground/Main/I2CBi-directionalLevelShifter

"The Wire library of Arduino 1.0. (In 2012) Enables those internal pull-up resistors with the Wire.begin function (). Those internal pull-up resistors are connected to +5 V Which could violate the specifications of the I2C component"

supplement: Wire.begin() => twi_int()

Submitted by Julian (not verified) on Wed, 2012-08-29 12:30.

supplement:

void TwoWire::begin(void)
{
 ...
  twi_init();
}

void twi_init(void)
{
..
  // activate internal pullups for twi.
  digitalWrite(SDA, 1);
  digitalWrite(SCL, 1);
 ...
}

They are disabled in

Submitted by fabio on Thu, 2012-08-30 10:00.

They are disabled in FreeIMU::init in FreeIMU.cpp .. so as soon as Wire enables then, my library disables them.

Just one more question. If I

Submitted by Federico Galli (not verified) on Fri, 2012-05-11 18:21.

Just one more question. If I have others i2c components on my bus, should I add pullups or change the ones on the freeImu?
Thanks Fabio :-)

If they all are 3.3V logic

Submitted by fabio on Thu, 2012-08-30 10:02.

If they all are 3.3V logic level capable devices then just use the pullups on the FreeIMU. If you have mixed logic levels then you'll need to setup some logic level conversions.

FreeIMU FreeSixCube and Xbee

Submitted by ykchan (not verified) on Sun, 2012-04-29 07:09.

Hello Fabio,

Nice work and presentation with your open projects and IMU. I love them all, particularly the visualization program FreeSixCube.pde is excellent. I have fun with SixCube with a 6DOF most of the time sitting down. I plan to try something new, use the SixCube to monitor 9DOF IMU mounted on a bicycle moving in circular path and figure-of-eight path. This calls for a pair of Xbee to replace the original USB cable for wireless link. During preparation, I ran into problem with the SixCube and the Processing-tool. I am new to this field and hope to receive some advice here.
Thank you,
YK Chan

This is the symptom I gathered.
I saw excellent operation between Arduino-UNO and the SixCube via USB link, COM7 in this case. I also saw normal operation between Arduino-UNO and Arduino-serial-monitor via Xbee link at COM6, then I launch the SixCube aimed at COM6 into the Processing tool. But SixCube has problem responding to information. I saw the Cube frozen when the Processing-window is displayed. The numericals on top-left Processing-window are frozen. There was a warning message:
RXTX Version mismatch
Jar version = RXTX-2.2pre1
native lib Version = RXTX-2.2pre2

Post new comment

The content of this field is kept private and will not be shown publicly.
If you have a personal or company website insert its address in the form http://www.example.com/ .
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre> <small> <del> <img> <h2> <h3> <h4> <b> <video> <sub> <sup>
  • Lines and paragraphs break automatically.
  • Images can be added to this post.
  • You may use [inline:xx] tags to display uploaded files or images inline.
  • You may insert videos with [video:URL]
  • Each email address will be obfuscated in a human readable fashion or (if JavaScript is enabled) replaced with a spamproof clickable link.

More information about formatting options