Pages: 1 [2]   Go Down
Author Topic: MPU6050 + arduino nano + raw data over serial  (Read 7571 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

yes yes, I see that even the range can be changed, the accelerometer can messure 2g (default) 4 8 and +-16g, for me I think 4 g would be great.

I think I need to give a better look at the datasheet and library and see the functions and call wire.write(FUNTION) in the correct way to make changes to the configuration. Am I right?

It's my firs time with an I2C board, but I'm starting to like it as a protocol.
Logged

Offline Offline
Edison Member
*
Karma: 9
Posts: 1015
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The Wire.write() is a function, which is used during the I2C-communication: http://arduino.cc/en/Reference/WireWrite

In my sketch ( http://arduino.cc/playground/Main/MPU-6050 ) I have already made a function which you can use to write to a register of the MPU-6050, called "MPU6050_write()".
You could try to write a few registers. If you understand how to use it, you might try the library by Jeff Rowberg http://www.i2cdevlib.com/devices/mpu6050#source
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, let's see.
As an example, I want to modify the REg 0x1B (27 DEC)
the registry consist of:
b7   b6   b5   b4   b3   b2   b1   b0
ST   ST   ST   FS_SEL    RESERVED

So, to modify the range I need to put on the bites 3 and 4 the value DEC1 - meaning a BYN 01 - = 00001000

If I understand your function to write I think I should put
void setup ();

MPU6050_write(27, 8, smiley-cool

or something like that?????
I don't get the function of the last number in your function and how should I work with reserved registry bits.
Logged

Offline Offline
Edison Member
*
Karma: 9
Posts: 1015
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I used a function to write multiple bytes, and used that to write a single byte.
For someone used to handle data and pointers is looks standard, but it looks weird the first time.

This is how it was:
Code:
uint8_t c;           // an unsigned character of 8 bits

c = 0x08;           // the value to write to the register

// Use address of 'c', by using '&c'.
// Third parameter if '1', that is the number of bytes to write.
MPU6050_write (MPU6050_GYRO_CONFIG, &c, 1);


But now I have added a function to write a single byte. Get the new code : http://arduino.cc/playground/Main/MPU-6050
It is now like this:
Code:
MPU6050_write_reg (MPU6050_GYRO_CONFIG, 0x08);
That's a lot easier.
« Last Edit: June 28, 2012, 03:32:45 am by Krodal » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry but I still don't get it.
you have the function, the pointing reg to write, and the last value, I don't get how I'm supposed to determine the number I need.

I have to modify the 1B and the 1C, MPU6050_GYRO_CONFIG and MPU6050_ACCEL_CONFIG.

on gyroconfig I need to write 00001000 ; but bits 2, 1 and 0 are reserved.

on accelconfig I need to write 00001000 ; but here non of the bites are reserved.

I just have to use
Code:
MPU6050_write_reg (MPU6050_GYRO_CONFIG, 0x08);
MPU6050_write_reg (MPU6050_ACCEL_CONFIG, 0x08);
and that's all?????
just that?
AWSOME!
Logged

Offline Offline
Edison Member
*
Karma: 9
Posts: 1015
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That's it.
The reserved bits can (must?) be written with zeros.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Krodal, You rock!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 46
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

pardon the intrusion ...

the code uses is shown in http://arduino.cc/playground/Main/MPU-6050??
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

can we use this as kalmen filter
Logged

Pages: 1 [2]   Go Up
Jump to: