RoboRemo Users' Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Roboremo with MPU 6050

2 posters

Go down

Roboremo with MPU 6050 Empty Roboremo with MPU 6050

Post by Vicc Tue Jun 07, 2016 1:31 am

Hi everyone,
Is there any possibilities to get plot drawing a graph for one of six variables from MPU 6050 (Accelerometer + Gyro).

I'm getting all variables in text field in roboremo, I would like to plot a graph from them (one axis).

Arduino code suggestions?

Vicc

Posts : 7
Join date : 2016-06-07

Back to top Go down

Roboremo with MPU 6050 Empty Re: Roboremo with MPU 6050

Post by Admin Wed Jun 08, 2016 3:32 pm

Hi,
If you get them in text field, you can plot them too, just need to configure the plot. Show me a screenshot with the text field with data and the id of the text field, and I will try to help.

Admin
Admin

Posts : 150
Join date : 2016-03-08

https://roboremo.forumotion.com

Back to top Go down

Roboremo with MPU 6050 Empty Re: Roboremo with MPU 6050

Post by Vicc Wed Jun 08, 2016 4:56 pm

here's my code in arduino:



Code:
#include<Wire.h>
#define bluetooth Serial
#pragma GCC diagnostic ignored "-Wwrite-strings"
const int MPU_addr=0x68;  // I2C address of the MPU-6050
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
void setup(){
  Wire.begin();
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x6B);  // PWR_MGMT_1 register
  Wire.write(0);     // set to zero (wakes up the MPU-6050)
  Wire.endTransmission(true);
  Serial.begin(9600);
  bluetooth.begin(9600);
}
void loop(){
Wire.beginTransmission(MPU_addr);
  Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)
  Wire.endTransmission(false);
  Wire.requestFrom(MPU_addr,14,true);  // request a total of 14 registers
  AcX=Wire.read()<<8|Wire.read();  // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)    
  AcY=Wire.read()<<8|Wire.read();  // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
  AcZ=Wire.read()<<8|Wire.read();  // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
  Tmp=Wire.read()<<8|Wire.read();  // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)
  GyX=Wire.read()<<8|Wire.read();  // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
  GyY=Wire.read()<<8|Wire.read();  // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
  GyZ=Wire.read()<<8|Wire.read();  // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)
  Serial.print("AcX = "); Serial.print(AcX);
  Serial.print(" | AcY = "); Serial.print(AcY);
  Serial.print(" | AcZ = "); Serial.print(AcZ);
  Serial.print(" | Tmp = "); Serial.print(Tmp/340.00+36.53);  //equation for temperature in degrees C from datasheet
  Serial.print(" | GyX = "); Serial.print(GyX);
  Serial.print(" | GyY = "); Serial.print(GyY);
  Serial.print(" | GyZ = "); Serial.println(GyZ);
  delay(100);
}


here's what I'm getting inserting a text log in roboremo:

Roboremo with MPU 6050 Screen14

the same I get in serial on pc:

Roboremo with MPU 6050 Screen12

I'm not adding id to text log (not the text field, my mistake), just inserting it and getting this. I want to plot AcX axis for example.

Thanks!

Vicc

Posts : 7
Join date : 2016-06-07

Back to top Go down

Roboremo with MPU 6050 Empty Re: Roboremo with MPU 6050

Post by Admin Fri Jun 10, 2016 8:57 am

Hi,
replace this:
Code:

Serial.print("AcX = "); Serial.print(AcX);
  Serial.print(" | AcY = "); Serial.print(AcY);
  Serial.print(" | AcZ = "); Serial.print(AcZ);
  Serial.print(" | Tmp = "); Serial.print(Tmp/340.00+36.53);  //equation for temperature in degrees C from datasheet
  Serial.print(" | GyX = "); Serial.print(GyX);
  Serial.print(" | GyY = "); Serial.print(GyY);
  Serial.print(" | GyZ = "); Serial.println(GyZ);
with this:
Code:

Serial.print("AcX = "); Serial.println(AcX);
Serial.print("AcY = "); Serial.println(AcY);
Serial.print("AcZ = "); Serial.println(AcZ);
Serial.print("Tmp = "); Serial.println(Tmp/340.00+36.53);
Serial.print("GyX = "); Serial.println(GyX);
Serial.print("GyY = "); Serial.println(GyY);
Serial.print("GyZ = "); Serial.println(GyZ);

Then set interface cmd ending to "\n"
and plot id to  "AcX = " (without quotes)
and set plot min and max values according to your need.

Admin
Admin

Posts : 150
Join date : 2016-03-08

https://roboremo.forumotion.com

Back to top Go down

Roboremo with MPU 6050 Empty Re: Roboremo with MPU 6050

Post by Vicc Sat Jun 11, 2016 11:15 pm

thank you,

don't know how to set interface cmd to "\n" but plotting function is working great. Smile Thank you very much!!!

Vicc

Posts : 7
Join date : 2016-06-07

Back to top Go down

Roboremo with MPU 6050 Empty Re: Roboremo with MPU 6050

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum