I need your help ( gyroscope and stepper motor)

hey guys i am preparing my graduation project and i want your help .the project idea is connect stepper motors with gyroscope l3g4200d .
i saw a video in youtube conect gyro with stepper motor i wil appreciate it if any one send programing of this project

i wil appreciate it if any one send programing of this project

Maybe school has changed since I went, but I always got the impression that the professors wanted me to do the work for my own project rather than asking people to do it for me.

i think the word appreciate isn't that annoying one , also being formal or polite in asking ppl isn't that offending .
i also appreciate ur comment :stuck_out_tongue:
thanks for helping me that much.

MASTERZMIND:
i think the word appreciate isn't that annoying one , also being formal or polite in asking ppl isn't that offending .
i also appreciate ur comment :stuck_out_tongue:
thanks for helping me that much.

It has nothing to do with being annoyed or impolite. Most people managed to finish school without having to ask other people to do projects for them. There is a huge difference between these types of posts:

Hey, I have a project to do X and Y, how do I do it. <--- Your post

Hey, I have a project to do X and Y, this is what I've done so far, this is the problem I have and my question is... <-- Correct way

my project is divided into parts gyroscope ( x and y axis) & stepper motor . i've tested gyroscope on x & y axis & it worked, my problem is how to combine gyroscope with stepper motor .

MASTERZMIND:
my project is divided into parts gyroscope ( x and y axis) & stepper motor . i've tested gyroscope on x & y axis & it worked, my problem is how to combine gyroscope with stepper motor .

Did you get the stepper motor working? What have you tried so far? Code?

stepper motor using arduino :

#include <Stepper.h>

const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
                                     // for your motor

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8,9,10,11);            

int stepCount = 0;         // number of steps the motor has taken

void setup() {
  // initialize the serial port:
  Serial.begin(9600);
}

void loop() {
  // step one step:
  myStepper.step(1);
  Serial.print("steps:" );
  Serial.println(stepCount);
  stepCount++;
  delay(500);
}

gyroscope:

#include <Wire.h>

#define CTRL_REG1 0x20
#define CTRL_REG2 0x21
#define CTRL_REG3 0x22
#define CTRL_REG4 0x23

int Addr = 105;                 // I2C address of gyro
int x, y;

void setup(){
  Wire.begin();
  Serial.begin(9600);
  writeI2C(CTRL_REG1, 0x1B);    // Turn on all axes, disable power down
  writeI2C(CTRL_REG3, 0x08);    // Enable control ready signal
  writeI2C(CTRL_REG4, 0x80);    // Set scale (500 deg/sec)
  getGyroValues();              // Get new values
  
  delay(100);                   // Wait to synchronize 
}

void loop(){
  getGyroValues();              // Get new values
  // In following Dividing by 114 reduces noise
  Serial.print("X:");  Serial.print(x / 114);  
  Serial.println("Y:"); Serial.print(y / 114);
 
  delay(500);                   // Short delay between reads
}

void getGyroValues () {
  byte MSB, LSB;

  MSB = readI2C(0x29);
  LSB = readI2C(0x28);
  x = ((MSB << 8) | LSB);

  MSB = readI2C(0x2B);
  LSB = readI2C(0x2A);
  y = ((MSB << 8) | LSB);

  MSB = readI2C(0x2D);
  LSB = readI2C(0x2C);
  z = ((MSB << 8) | LSB);
}

int readI2C (byte regAddr) {
    Wire.beginTransmission(Addr);
    Wire.write(regAddr);                // Register address to read
    Wire.endTransmission();             // Terminate request
    Wire.requestFrom(Addr, 1);          // Read a byte
    while(!Wire.available()) { };       // Wait for receipt
    return(Wire.read());                // Get result
}

void writeI2C (byte regAddr, byte val) {
    Wire.beginTransmission(Addr);
    Wire.write(regAddr);
    Wire.write(val);
    Wire.endTransmission();
}

Moderator edit: please use CODE TAGS when posting code, not quotes

Those look like example sketches, so I'm guessing you haven't actually done anything with the code, just tested the hardware with the example code? Have you tried anything at all? Do you understand what that code is doing, what the x and y values mean?

look my problem is that i can't understand the output of the gyro, the datasheet says that the data is stored in the output register as 2's complement by don't know how to use it http://img818.imageshack.us/img818/4008/jklln.jpg

this is avery good project but Unfortunately ihave no info about gyro but i can help you in stepper

MASTERZMIND:
look my problem is that i can't understand the output of the gyro

look you never said you didn't understand what the outputs were.

The gyro stores the angular velocity it's registers in what appears to be degrees per second, although a single image from the datasheet isn't as useful as the entire datasheet. Assuming you are trying to replicate the project in the video you posted earlier, you need to use those values to to determine the heading. Simple integral calculus should yield that.

i understand well that gyro gives me the angular rate and even i don't need the angle so i don't need to do equation to get it i just want to know how to read the value stored in the output register to use it and to write it in the threshold int register

http://www.google.com.eg/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=0CFEQFjAB&url=http%3A%2F%2Fwww.stm32circle.com%2Fresources%2FDatasheets%2FL3G4200D.pdf&ei=hJLHT_zCHsqOswbB-djjDg&usg=AFQjCNFhuAe8b6WZkbqJ9DmGK5RnOehwYQ&sig2=4EhorBN0ni2pKhXYIZqTTQ

mr. Arrch if you have info about this problem tell him but if you dont know don't do that u understand infront of him

The table in the JPEG in reply #8 doesn't appear in the .pdf in reply #12.

Maybe that's where some of the confusion is coming from.

MASTERZMIND:
i understand well that gyro gives me the angular rate and even i don't need the angle so i don't need to do equation to get it i just want to know how to read the value stored in the output register to use it and to write it in the threshold int register

The example code you provided (which I gather works) implemented two function that should aid you with that: writeI2C and readI2C. To read the values in the register, simply call the readI2C function, passing which register you want to read from. The return value will be the value in the register. The writeI2C function accepts the register to write to and the value as it's arguments. Sections 7.10, 7.11, and 7.12 in the datasheet should tell you which registers the data is stored in.

abdelrahman:
mr. Arrch if you have info about this problem tell him

The issue is what his problem actually is. First, it was I have a project can someone send me code. It then proceeded to I don't understand the output of the gyro. Now it's I don't know how to get info from the gyro. I can't tell him "info about this problem" without knowing what the problem actually is.

but if you dont know don't do that u understand infront of him

I have no idea what this means.

but in sections 7.10 7.11 7.11 in datasheet tells that the data is expressed as two's complement and in the reply #7 it is not from the datasheet it is from the application note

Jasmine, maybe you and the OP can get together - you both seem to be working on similar problems, and in the same part of the world.

jasmine_hossam:
but in sections 7.10 7.11 7.11 in datasheet tells that the data is expressed as two's complement and in the reply #7 it is not from the datasheet it is from the application note

I'm not sure the issue here. The image posted is just an example of what data you get when you pull the X data out of the 0x28 and 0x29 registers.

yes it is an example but do u understand how it converted the dps to this hexa 2 bytes