Pages: [1]   Go Down
Author Topic: gyro LPR530al  (Read 1015 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi i'am trying connect this gyro with arduino and not mutch luck  smiley-cry
Pls has anybody sample code how to get data from gyro?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26338
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What have you got, and what doesn't it do that you want it to?
(or, what does it do that you don't want it to?)

What experience have you got with gyros?

Code:
int x = analogRead (X_AXIS) - x_null;
Where "x_null" is the average stationary reading.
If you leave it at zero, it'll just return the raw value from the device.
« Last Edit: June 14, 2012, 08:52:21 am by AWOL » Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

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

Hi i've got zero experience with gyro ;-) but i can undestand teory of mems gyroskopes;-)
this is my arduino code:

int x,y;
float cas, hodnota_x, hodnota_y;
void setup(){
  Serial.begin(9600);
  }
void loop(){
  x = analogRead(2);
  y = analogRead(3);
  cas = millis();
  //hodnota_x =  (x/1.0323)*cas/1000;
  //hodnota_y =  (y/1.0323)*cas/1000;
  Serial.print("osa x = ");
  Serial.print(x);
  Serial.print("  ");
  Serial.print("osa y = ");
  Serial.println(y);
  delay(500);
}
 


--------
i think i connected the gyro with arduino corectly.
i get data from sezor but i need convert it to degrees per seconds °/s smiley can you know how i make it???
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26338
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The data sheet will specify the sensitivity of the device in millivolts per degree (or radians) per second.
You know what voltage you're reading, so just do the arithmetic.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

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

The data sheet will specify the sensitivity of the device in millivolts per degree (or radians) per second.
You know what voltage you're reading, so just do the arithmetic.

can you write me aritmethic equation ? i don't know how  smiley-slim
Logged

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

The data sheet will specify the sensitivity of the device in millivolts per degree (or radians) per second.
You know what voltage you're reading, so just do the arithmetic.

can you write me aritmethic equation ? i don't know how  smiley-slim


here is my code:

#include <Wire.h>   //knihovna I2C
#include <math.h>   //knihovna Math

unsigned long casovac=0;
unsigned long cas=0;
//kalibrace
long resultGyroX;//x-axis
long resultGyroY;//y-axis

//
//gyros
float gyroZeroX;//x-axis
int gyroXadc;
float gyroXrate;
float gyroXangle;

float gyroZeroY;//y-axis
int gyroYadc;
float gyroYrate;
float gyroYangle;

void setup(){
  Serial.begin(9600);
  gyroZeroX = calibrateGyroX();
  gyroZeroY = calibrateGyroY();
  delay(100);
 
  }
void loop(){
  cas = millis();
  gyroXadc = analogRead(2);
  gyroYadc = analogRead(3);
  gyroXrate = (gyroXadc-gyroZeroX)/1.0323;//(gyroXadc-gryoZeroX)/Sensitivity - in quids              Sensitivity = 0.00333/3.3*1023=1.0323
  gyroXangle += gyroXrate*cas/1000;//Without any filter
  gyroYrate = (gyroYadc-gyroZeroY)/1.0323;//(gyroYadc-gryoZeroX)/Sensitivity - in quids              Sensitivity = 0.00333/3.3*1023=1.0323
  gyroYangle += gyroYrate*cas/1000;//Without any filter
  cas = millis() - casovac;
  casovac = millis();
  Serial.print("cas = ");
  Serial.print(casovac);
  Serial.print("; osa x = ");
  Serial.print(gyroXangle);
  Serial.print(" ; ");
  Serial.print("osa y = ");
  Serial.println(gyroYangle);
 
  gyroXangle = 0;
  gyroYangle = 0;
}
 
int calibrateGyroX()
{
  for(int i=0;i<100;i++)
  {
    resultGyroX += analogRead(2);
    delay(1);
  }
  resultGyroX = resultGyroX/100;
  return resultGyroX;
}

int calibrateGyroY()
{
  for(int i=0;i<100;i++)
  {
    resultGyroY += analogRead(3);
    delay(1);
  }
  resultGyroY = resultGyroY/100;
  return resultGyroY;
}
Logged

Pages: [1]   Go Up
Jump to: