6448浏览
查看: 6448|回复: 2

[已解决] 6DOF shield ITG3205+ADXL345和Arduino Yun

[复制链接]
把6DOF直接插在Yun上,然后用例子代码:

////////////////////////////////////////////////////////////
// Arduino firmware for use with FreeSixCube processing example
////////////////////////////////////////////////////////////

#include <FreeSixIMU.h>
#include <FIMU_ADXL345.h>
#include <FIMU_ITG3200.h>

#define DEBUG
#ifdef DEBUG
#include "DebugUtils.h"
#endif

#include "CommunicationUtils.h"
#include "FreeSixIMU.h"
#include <Wire.h>


float q[4]; //hold q values

// Set the FreeIMU object
FreeSixIMU my3IMU = FreeSixIMU();

void setup() {
  Serial.begin(115200);
  Wire.begin();

  delay(5);
  my3IMU.init();
  delay(5);
}


void loop() {
  my3IMU.getQ(q);
  serialPrintFloatArr(q, 4);
  Serial.println(""); //line break

  delay(60);
}



上传时报错如下:

Sketch uses 15,284 bytes (53%) of program storage space. Maximum is 28,672 bytes.
Global variables use 522 bytes (20%) of dynamic memory, leaving 2,038 bytes for local variables. Maximum is 2,560 bytes.
Found programmer: Id = "S"; type = p
    Software Version = V. ; Hardware Version = v.

avrdude: error: buffered memory access not supported. Maybe it isn't
a butterfly/AVR109 but a AVR910 device?
processing.app.debug.RunnerException
        at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:129)
        at processing.app.Sketch.upload(Sketch.java:1672)
        at processing.app.Sketch.exportApplet(Sketch.java:1578)
        at processing.app.Sketch.exportApplet(Sketch.java:1550)
        at processing.app.Editor$DefaultExportHandler.run(Editor.java:2399)
        at java.lang.Thread.run(Unknown Source)
Caused by: processing.app.debug.RunnerException: Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
        at cc.arduino.packages.Uploader.executeUploadCommand(Uploader.java:113)
        at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:127)
        ... 5 more


请问这是什么情况?该如何解决?

futuremeng  见习技师
 楼主|

发表于 2014-2-22 00:04:39

// # Editor     : Roy from DFRobot
// # Date       : 10.12.2013
// # E-Mail : roy.yu@dfrobot.com

// # Product name: 6 Dof shield for Arduino
// # Product SKU : DFR0209
// # Version     : 0.1

// # Description:
// # The sketch for driving the 6 Dof shield for Arduino via I2C interface

#include <FreeSixIMU.h>
#include <FIMU_ADXL345.h>
#include <FIMU_ITG3200.h>

#include <Wire.h>

int16_t angle[2]; // pitch & roll

// Set the FreeSixIMU object
FreeSixIMU sixDOF = FreeSixIMU();
int rawSixDof[6];
void setup()
{
  Serial.begin(9600);
  Wire.begin();
   
  delay(5);
  sixDOF.init();                        //begin the IMU
  delay(5);
}

void loop() {
     
  sixDOF.getRawValues(rawSixDof);
  for (int i=0; i<6; i++)              //output the raw data
  {
    switch (i)
    {
        case 0:
      Serial.print("Acc.x :");
      break;
      case 1:
        Serial.print("Acc.y :");
        break;
      case 2:
        Serial.print("Acc.z :");
        break;
      case 3:
        Serial.print("gyro.x :");
        break;
      case 4:
        Serial.print("gyro.y :");
        break;
      case 5:
        Serial.print("gyro.z :");
      break;
        default:
            Serial.print("Err");
    }
    Serial.println(rawSixDof);
  }
  Serial.println("");
  angle[0] = _atan2(rawSixDof[0],rawSixDof[2]);
  angle[1] = _atan2(rawSixDof[1],rawSixDof[2]);
   
  Serial.print("X:");              //pitch & roll
  Serial.println(angle[0]/10.0);
  Serial.print("Y:");
  Serial.println(angle[1]/10.0);
  Serial.println("");
  delay(1000);
}

int16_t _atan2(int32_t y, int32_t x)   //get the _atan2
{
  float z = (float)y / x;
  int16_t a;
  if ( abs(y) < abs(x) )
  {
    a = 573 * z / (1.0f + 0.28f * z * z);
    if (x<0)
    {
    if (y<0) a -= 1800;
    else a += 1800;
    }
  }
  else
  {
    a = 900 - 573 * z / (z * z + 0.28f);
    if (y<0) a -= 1800;
  }
  return a;
}

这个可以,来自http://www.dfrobot.com/wiki/index.php/6_Dof_Shield_(DFR0209) 还没明白什么意思,先能跑了再说,呵呵。

下面这个也可以,来自6 Dof shield library\FreeSixIMU\examples\sixDOF_Example

#include <FreeSixIMU.h>
#include <FIMU_ADXL345.h>
#include <FIMU_ITG3200.h>

#include <Wire.h>

float angles[3]; // yaw pitch roll

// Set the FreeSixIMU object
FreeSixIMU sixDOF = FreeSixIMU();

void setup() {
  Serial.begin(9600);
  Wire.begin();
  
  delay(5);
  sixDOF.init(); //begin the IMU
  delay(5);
}

void loop() {
  
  sixDOF.getEuler(angles);
  
  Serial.print(angles[0]);
  Serial.print(" | ");  
  Serial.print(angles[1]);
  Serial.print(" | ");
  Serial.println(angles[2]);
  
  delay(100);
}
回复

使用道具 举报

Grey  中级技匠

发表于 2014-4-14 14:52:24

avrdude: error: buffered memory access not supported. Maybe it isn't
a butterfly/AVR109 but a AVR910 device?
好像可以通过更改串口,或者避免使用USB3.0 来解决这个问题
回复

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies |上传

本版积分规则

为本项目制作心愿单
购买心愿单
心愿单 编辑
[[wsData.name]]

硬件清单

  • [[d.name]]
btnicon
我也要做!
点击进入购买页面
关于楼主
上海智位机器人股份有限公司 沪ICP备09038501号-4

© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed

mail