Go Down

Topic: mpu 6050 (Read 5 times) previous topic - next topic

Subsea

Grazie mille Lesto per l'esauriente risposta. In questo momento sto usando la libreria mpu6050(http://playground.arduino.cc/Main/MPU-6050#measurements) Dopo aver decommentato due voci
Code: [Select]
#include "Wire.h"

// I2Cdev and MPU6050 must be installed as libraries, or else the .cpp/.h files
// for both classes must be in the include path of your project
#include "I2Cdev.h"

#include "MPU6050_6Axis_MotionApps20.h"
//#include "MPU6050.h" // not necessary if using MotionApps include file

// class default I2C address is 0x68
// specific I2C addresses may be passed as a parameter here
// AD0 low = 0x68 (default for SparkFun breakout and InvenSense evaluation board)
// AD0 high = 0x69
MPU6050 mpu;

/* =========================================================================
  NOTE: In addition to connection 3.3v, GND, SDA, and SCL, this sketch
  depends on the MPU-6050's INT pin being connected to the Arduino's
  external interrupt #0 pin. On the Arduino Uno and Mega 2560, this is
  digital I/O pin 2.
* ========================================================================= */

/* =========================================================================
  NOTE: Arduino v1.0.1 with the Leonardo board generates a compile error
  when using Serial.write(buf, len). The Teapot output uses this method.
  The solution requires a modification to the Arduino USBAPI.h file, which
  is fortunately simple, but annoying. This will be fixed in the next IDE
  release. For more info, see these links:

  http://arduino.cc/forum/index.php/topic,109987.0.html
  http://code.google.com/p/arduino/issues/detail?id=958
* ========================================================================= */



// uncomment "OUTPUT_READABLE_QUATERNION" if you want to see the actual
// quaternion components in a [w, x, y, z] format (not best for parsing
// on a remote host such as Processing or something though)
//#define OUTPUT_READABLE_QUATERNION

// uncomment "OUTPUT_READABLE_EULER" if you want to see Euler angles
// (in degrees) calculated from the quaternions coming from the FIFO.
// Note that Euler angles suffer from gimbal lock (for more info, see
// http://en.wikipedia.org/wiki/Gimbal_lock)
//#define OUTPUT_READABLE_EULER

// uncomment "OUTPUT_READABLE_YAWPITCHROLL" if you want to see the yaw/
// pitch/roll angles (in degrees) calculated from the quaternions coming
// from the FIFO. Note this also requires gravity vector calculations.
// Also note that yaw/pitch/roll angles suffer from gimbal lock (for
// more info, see: http://en.wikipedia.org/wiki/Gimbal_lock)
#define OUTPUT_READABLE_YAWPITCHROLL

// uncomment "OUTPUT_READABLE_REALACCEL" if you want to see acceleration
// components with gravity removed. This acceleration reference frame is
// not compensated for orientation, so +X is always +X according to the
// sensor, just without the effects of gravity. If you want acceleration
// compensated for orientation, us OUTPUT_READABLE_WORLDACCEL instead.
#define OUTPUT_READABLE_REALACCEL

// uncomment "OUTPUT_READABLE_WORLDACCEL" if you want to see acceleration
// components with gravity removed and adjusted for the world frame of
// reference (yaw is relative to initial orientation, since no magnetometer
// is present in this case). Could be quite handy in some cases.
//#define OUTPUT_READABLE_WORLDACCEL

// uncomment "OUTPUT_TEAPOT" if you want output that matches the
// format used for the InvenSense teapot demo
//#define OUTPUT_TEAPOT
Secondo te mi restituisce l'angolo? Io credo di sì, perchè nel monitor seriale leggo questo:
Code: [Select]
Initializing I2C devices...
Testing device connections...
MPU6050 connection successful

Send any character to begin DMP programming and demo:
Initializing DMP...
Enabling DMP...
Enabling interrupt detection (Arduino external interrupt 0)...
DMP ready! Waiting for first interrupt...
ypr -0.16 7.15 0.27
areal 320 9 2572
ypr -0.19 7.13 0.31
areal 398 11 3163
ypr -0.21 7.11 0.36
areal 452 10 3598

lesto

bho bisognerebbe vedere il codice della libreria, ma dubito sia stato convertito
sei nuovo? non sai da dove partire? leggi qui: http://playground.arduino.cc/Italiano/Newbie

Subsea

In poche parole sono valori inutilizzbili? Ho visto che Jeff ha fatto anche uno sketch chiamato teapot in cui si fa ruotare una teiera con il giroscopio e accelerometro mpu6050. Ho caricato lo sketch ma dice che mancano questi due:
Code: [Select]
import toxi.geom.*;
import toxi.processing.*;
Sai dove posso trovarli? magari riesco a far diventare il sensore utile!!! :D

lesto

quella è roba di processing non della libreria.
Cerca sul forum di processing.
Quella libreria sembra usare una DCM, la cui unica necessità è di avere i valori del giroscopio come radianti al secondo (quindi da +PI a -PI)

Quindi probabilmente esistono delle funzioni che ti restituiscono i valori "elaborati" (cosa che comunque puoi farti da solo, sfaticato! :smiley-mr-green:) devi solo cercarle
sei nuovo? non sai da dove partire? leggi qui: http://playground.arduino.cc/Italiano/Newbie

ilmandorlone


Go Up