Go Down

Topic: MPU6050 + arduino nano + raw data over serial (Read 10037 times) previous topic - next topic

augustinoy

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.

Krodal

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

augustinoy

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, 8)

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.

Krodal

#18
Jun 28, 2012, 10:16 am Last Edit: Jun 28, 2012, 10:32 am by Krodal Reason: 1
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: [Select]

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: [Select]

MPU6050_write_reg (MPU6050_GYRO_CONFIG, 0x08);

That's a lot easier.

augustinoy

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: [Select]

MPU6050_write_reg (MPU6050_GYRO_CONFIG, 0x08);
MPU6050_write_reg (MPU6050_ACCEL_CONFIG, 0x08);

and that's all?????
just that?
AWSOME!

Krodal

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

augustinoy


julio79

pardon the intrusion ...

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

dheerajp


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy