Have a problem with reading Gyroscope value from GY-801

Go To Last Post
24 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

I have a problem with connecting with reading data of Gyroscope as the data is constant as shown below in image:

Note :I am interfacing with Atmega32 :

#define I2C_Clock 2

#define BaudRate 51

//--- Accelerometer Register Addresses
#define Power_Register 0x2D
//--- GYROSCOPE Register Addresses
#define CTRL_REG1      0X20
#define CTRL_REG4      0X23
#define Link       5
#define AUTO_SLEEP 4
#define Measure    3
#define Sleep      2
#define Wakeup_1   1
#define Wakeup_0   0
#define GY_801_GYRO_I2CAddress       0x69//Device address in which is also included the 8th bit for selecting the mode, read in this case.
#define GYRO_X                                   0x28
#define GYRO_X_OUT_L                       0x28
#define GYRO_X_OUT_H                       0x29
#define GYRO_Y                                   0x2A
#define GYRO_Y_OUT_L                        0x2A
#define GYRO_Y_OUT_H                       0x2B
#define GYRO_Z                                  0X2C
#define GYRO_Z_OUT_L                       0X2C
#define GYRO_Z_OUT_H                      0X2D
#define GY_801_Acc_I2CAddress          0x53//Device address in which is also included the 8th bit for selecting the mode, read in this case.
#define ACC_X                                     0x32
#define ACCEL_X_OUT_L                      0x32
#define ACCEL_X_OUT_H                     0x33
#define ACC_Y                                    0x34
#define ACCEL_Y_OUT_L                     0x34
#define ACCEL_Y_OUT_H                    0x35
#define ACC_Z                                   0X36
#define ACCEL_Z_OUT_L                     0X36
#define ACCEL_Z_OUT_H                    0X37
#define I2C_Interrupt_flag               (TWCR>>7)
#define I2C_Status_bits                     TWSR
#define I2C_Wait_Status_bits()      while(!(TWCR&(1<<TWINT)));

 

//typedef

typedef enum {X,Y,Z}Directions;

typedef enum {MASTER, SLAVE} I2C_MODES;
typedef enum {Write , Read } Aims;

u8 arr[50];

 

void UART_initiate(u16 Baudrate){
/* Set baud rate */
UBRR1H = (u8)(Baudrate>>8);
UBRR1L = (u8) Baudrate;
/* Enable receiver and transmitter */
UCSR1B = (1<<RXEN1)|(1<<TXEN1);
/* Set frame format: 8data, 2stop bit */
UCSR1C = (1<<USBS1)|(1<<UCSZ10)|(1<<UCSZ11);
}

void UART_Sendchar(u8 Character)
{
    while ( !( UCSR1A & (1<<UDRE1)) );
    UDR1=Character;
    
}

  void UART_SendString(u8*index)
  {
      
      while(*(index))
      {
          UART_Sendchar(*index++);
      }
  }

  void UART_PRINT_FLOAT_VALUE(float FLOAT_VALUE)
  {
      u8 str[50];
      u8 *tmpSign = (FLOAT_VALUE < 0) ? "-" : "";
      float tmpVal = (FLOAT_VALUE < 0) ? -FLOAT_VALUE:FLOAT_VALUE;

      int tmpInt1 = tmpVal;                  // Get the integer (678).
      float tmpFrac = tmpVal - tmpInt1;      // Get fraction (0.0123).
      int tmpInt2 = trunc(tmpFrac * 10000);  // Turn into integer (123).
      
      // Print as parts, note that you need 0-padding for fractional bit.

      sprintf (str, "%s%d.%04d", tmpSign, tmpInt1, tmpInt2);
      UART_SendString(str);
  }

 

void I2C_initiate(u8 I2c_clock , I2C_MODES I2C_MODE )
    if(I2C_MODE==MASTER)
{
    //_delay_ms(150);//FOR POWER UP TIME
    {
        //initialize clock by TWBR and PRESCALER BIT=0 in TWSR
        TWBR=I2c_clock;
        
        
    }
    else
    {
        //Set the slave address
        TWAR=(Slave_Address<<1);
        //enable acknowledgment
        TWCR=(1<<TWEA);
        
    }
    

}

 
void I2C_Master_send_Start()
{
    TWCR=(1<<TWSTA)|(1<<TWEN);
    I2C_Wait_Status_bits();
 

    
}
void I2C_Master_send_Repeated_Start()
{
    TWCR=(1<<TWSTA)|(1<<TWEN)|(1<<TWINT);
    I2C_Wait_Status_bits();
    
}
void I2C_Master_Send_BYTE(u8 Byte)
{
    TWDR=Byte;
    TWCR=(1<<TWINT)|(1<<TWEN);  //Continue the rest of process
    I2C_Wait_Status_bits();

}
void I2C_Master_Send_Address(u8 seven_bits_address,Aims Aim)
{
    I2C_Master_Send_BYTE((seven_bits_address<<1)|Aim);

    
}
void I2C_Master_Choose_Register(u8 Register,u8* Name_of_register)
    {
    I2C_Master_Send_BYTE(Register);
  
    
}
void I2C_Master_Write_DATA_in_Register(u8 Register,u8* Name_of_register,u8 DATA)
{
    I2C_Master_Choose_Register(Register,Name_of_register);
    I2C_Master_Send_BYTE(DATA);
    
 
}

u8 I2C_Master_Read_DATA_from_Register_WITH_ACK_SINGLE(u8* Name_of_register)
{
    TWCR=(1<<TWINT)|(1<<TWEN)|(1<<TWEA);
    I2C_Wait_Status_bits();

      

    return TWDR;
    
}

u8 I2C_Master_Read_DATA_from_Register_WITHOUT_ACK_SINGLE(u8* Name_of_register)
{
    TWCR=(1<<TWINT)|(1<<TWEN)|(0<<TWEA);
    I2C_Wait_Status_bits();
 
    return TWDR;
}
//Editable
s16 I2C_Master_Read_DATA_from_Register_BURST(u8* Name_of_register)
{
    s16 DATA=0,HIGHEST_DATA=0,LOWEST_DATA=0;
    HIGHEST_DATA=I2C_Master_Read_DATA_from_Register_WITH_ACK_SINGLE( Name_of_register)<<8;
    LOWEST_DATA=I2C_Master_Read_DATA_from_Register_WITHOUT_ACK_SINGLE( Name_of_register);
    DATA=HIGHEST_DATA|LOWEST_DATA;
    
    return DATA;
}

void I2C_Master_send_Stop()
{
    TWCR=(1<<TWSTO)|(1<<TWEN)|(1<<TWINT);
      

}

 

 

int main()

{

s16 GYRO_Data_X=0xFFFF;

u8 str[50];

I2C_initiate(I2C_clock , MASTER );

 

 

  UART_initiate(BaudRate);

   I2C_initiate(I2C_clock , MASTER );

//Master says: pay attention please slaves i will call one to communicate with him
    I2C_Master_send_Start();
    //Master communicate with slave and send to him address and order to write(Master says: GY_80x's ACCELEROMETER i will communicate with you focus with me )
    I2C_Master_Send_Address(GY_801_GYRO_I2CAddress,Write);
    //Master chooses register CTRL_REG1 from slave registers to write data in
    I2C_Master_Write_DATA_in_Register(CTRL_REG1,"CTRL_REG1",15);
    //Master releases the slave
    I2C_Master_send_Stop();

    //Master says: pay attention please slaves i will call one to communicate with him
    I2C_Master_send_Start();
    //Master communicate with slave and send to him address and order to write(Master says: GY_80x's gyroscope i will communicate with you focus with me )
    I2C_Master_Send_Address(GY_801_GYRO_I2CAddress,Write);
    //Master chooses register CTRL_REG4 from slave registers to write data in
    I2C_Master_Write_DATA_in_Register(CTRL_REG4,"CTRL_REG4",48);
    //Master releases the slave
    I2C_Master_send_Stop();

 

 

    while(1)

{
    I2C_Master_send_Start();
    //Master says attention please slaves
    //Master communicate with slave and send to him address and order to write U8
    I2C_Master_Send_Address(GY_801_GYRO_I2CAddress,Write);
    //Master chooses register x or y or z Axis from slave registers to read data from
    I2C_Master_Choose_Register(GYRO_X,"GYRO_X");
    //Repeated start bit for reading data form the register we have chosen
    I2C_Master_send_Repeated_Start();
    //Master communicate with slave and send to him address and order to write
    I2C_Master_Send_Address(GY_801_GYRO_I2CAddress,Read);
    //Master reads the data byte of x or y or z Axis from slave registers
    GYRO_Data_X=I2C_Master_Read_DATA_from_Register_WITH_ACK_SINGLE( "GYRO_X")|I2C_Master_Read_DATA_from_Register_WITHOUT_ACK_SINGLE( "GYRO_X")<<8;
    //Master releases the slave
    I2C_Master_send_Stop();
    sprintf(str,"%d",GYRO_Data_X);
    UART_SendString("GYRO_Data_X");
    UART_SendString(" = ");
    UART_SendString(str);
    UART_SendString("\n");

 

 

}

 

}

 

I am living to bring up new earth ,and not to eat and destroy earth.

Last Edited: Sat. Sep 28, 2019 - 04:23 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

So it can be easier to read!

 

#define I2C_Clock 2

#define BaudRate 51

//--- Accelerometer Register Addresses
#define Power_Register 0x2D
//--- GYROSCOPE Register Addresses
#define CTRL_REG1      0X20
#define CTRL_REG4      0X23
#define Link       5
#define AUTO_SLEEP 4
#define Measure    3
#define Sleep      2
#define Wakeup_1   1
#define Wakeup_0   0
#define GY_801_GYRO_I2CAddress       0x69//Device address in which is also included the 8th bit for selecting the mode, read in this case.
#define GYRO_X                                   0x28
#define GYRO_X_OUT_L                       0x28
#define GYRO_X_OUT_H                       0x29
#define GYRO_Y                                   0x2A
#define GYRO_Y_OUT_L                        0x2A
#define GYRO_Y_OUT_H                       0x2B
#define GYRO_Z                                  0X2C
#define GYRO_Z_OUT_L                       0X2C
#define GYRO_Z_OUT_H                      0X2D
#define GY_801_Acc_I2CAddress          0x53//Device address in which is also included the 8th bit for selecting the mode, read in this case.
#define ACC_X                                     0x32
#define ACCEL_X_OUT_L                      0x32
#define ACCEL_X_OUT_H                     0x33
#define ACC_Y                                    0x34
#define ACCEL_Y_OUT_L                     0x34
#define ACCEL_Y_OUT_H                    0x35
#define ACC_Z                                   0X36
#define ACCEL_Z_OUT_L                     0X36
#define ACCEL_Z_OUT_H                    0X37
#define I2C_Interrupt_flag               (TWCR>>7)
#define I2C_Status_bits                     TWSR
#define I2C_Wait_Status_bits()      while(!(TWCR&(1<<TWINT)));

 

//typedef

typedef enum {X,Y,Z}Directions;

typedef enum {MASTER, SLAVE} I2C_MODES;
typedef enum {Write , Read } Aims;

u8 arr[50];

 

void UART_initiate(u16 Baudrate){
/* Set baud rate */
UBRR1H = (u8)(Baudrate>>8);
UBRR1L = (u8) Baudrate;
/* Enable receiver and transmitter */
UCSR1B = (1<<RXEN1)|(1<<TXEN1);
/* Set frame format: 8data, 2stop bit */
UCSR1C = (1<<USBS1)|(1<<UCSZ10)|(1<<UCSZ11);
}

void UART_Sendchar(u8 Character)
{
    while ( !( UCSR1A & (1<<UDRE1)) );
    UDR1=Character;
    
}

  void UART_SendString(u8*index)
  {
      
      while(*(index))
      {
          UART_Sendchar(*index++);
      }
  }
  /*
void UART_SendArray(u8*,u8 size_of_array)
{
    
    
}*/
  void UART_PRINT_FLOAT_VALUE(float FLOAT_VALUE)
  {
      u8 str[50];
      u8 *tmpSign = (FLOAT_VALUE < 0) ? "-" : "";
      float tmpVal = (FLOAT_VALUE < 0) ? -FLOAT_VALUE:FLOAT_VALUE;

      int tmpInt1 = tmpVal;                  // Get the integer (678).
      float tmpFrac = tmpVal - tmpInt1;      // Get fraction (0.0123).
      int tmpInt2 = trunc(tmpFrac * 10000);  // Turn into integer (123).
      
      // Print as parts, note that you need 0-padding for fractional bit.

      sprintf (str, "%s%d.%04d", tmpSign, tmpInt1, tmpInt2);
      UART_SendString(str);
  }

 

void I2C_initiate(u8 I2c_clock , I2C_MODES I2C_MODE )
    if(I2C_MODE==MASTER)
{
    //_delay_ms(150);//FOR POWER UP TIME
    {
        //initialize clock by TWBR and PRESCALER BIT=0 in TWSR
        TWBR=I2c_clock;
        
        
    }
    else
    {
        //Set the slave address
        TWAR=(Slave_Address<<1);
        //enable acknowledgment
        TWCR=(1<<TWEA);
        
    }
    

}

 
void I2C_Master_send_Start()
{
    TWCR=(1<<TWSTA)|(1<<TWEN);
    I2C_Wait_Status_bits();
 

    
}
void I2C_Master_send_Repeated_Start()
{
    TWCR=(1<<TWSTA)|(1<<TWEN)|(1<<TWINT);
    I2C_Wait_Status_bits();
    
}
void I2C_Master_Send_BYTE(u8 Byte)
{
    TWDR=Byte;
    TWCR=(1<<TWINT)|(1<<TWEN);  //Continue the rest of process
    I2C_Wait_Status_bits();

}
void I2C_Master_Send_Address(u8 seven_bits_address,Aims Aim)
{
    I2C_Master_Send_BYTE((seven_bits_address<<1)|Aim);

    
}
void I2C_Master_Choose_Register(u8 Register,u8* Name_of_register)
    {
    I2C_Master_Send_BYTE(Register);
  
    
}
void I2C_Master_Write_DATA_in_Register(u8 Register,u8* Name_of_register,u8 DATA)
{
    I2C_Master_Choose_Register(Register,Name_of_register);
    I2C_Master_Send_BYTE(DATA);
    
 
}

u8 I2C_Master_Read_DATA_from_Register_WITH_ACK_SINGLE(u8* Name_of_register)
{
    TWCR=(1<<TWINT)|(1<<TWEN)|(1<<TWEA);
    I2C_Wait_Status_bits();

      

    return TWDR;
    
}

u8 I2C_Master_Read_DATA_from_Register_WITHOUT_ACK_SINGLE(u8* Name_of_register)
{
    TWCR=(1<<TWINT)|(1<<TWEN)|(0<<TWEA);
    I2C_Wait_Status_bits();
 
    return TWDR;
}
//Editable
s16 I2C_Master_Read_DATA_from_Register_BURST(u8* Name_of_register)
{
    s16 DATA=0,HIGHEST_DATA=0,LOWEST_DATA=0;
    HIGHEST_DATA=I2C_Master_Read_DATA_from_Register_WITH_ACK_SINGLE( Name_of_register)<<8;
    LOWEST_DATA=I2C_Master_Read_DATA_from_Register_WITHOUT_ACK_SINGLE( Name_of_register);
    DATA=HIGHEST_DATA|LOWEST_DATA;
    
    return DATA;
}

void I2C_Master_send_Stop()
{
    TWCR=(1<<TWSTO)|(1<<TWEN)|(1<<TWINT);
      

}

 

 

int main()

{

s16 GYRO_Data_X=0xFFFF;

u8 str[50];

I2C_initiate(I2C_clock , MASTER );

 

 

  UART_initiate(BaudRate);

   I2C_initiate(I2C_clock , MASTER );

//Master says: pay attention please slaves i will call one to communicate with him
    I2C_Master_send_Start();
    //Master communicate with slave and send to him address and order to write(Master says: GY_80x's ACCELEROMETER i will communicate with you focus with me )
    I2C_Master_Send_Address(GY_801_GYRO_I2CAddress,Write);
    //Master chooses register CTRL_REG1 from slave registers to write data in
    I2C_Master_Write_DATA_in_Register(CTRL_REG1,"CTRL_REG1",15);
    //Master releases the slave
    I2C_Master_send_Stop();

    //Master says: pay attention please slaves i will call one to communicate with him
    I2C_Master_send_Start();
    //Master communicate with slave and send to him address and order to write(Master says: GY_80x's gyroscope i will communicate with you focus with me )
    I2C_Master_Send_Address(GY_801_GYRO_I2CAddress,Write);
    //Master chooses register CTRL_REG4 from slave registers to write data in
    I2C_Master_Write_DATA_in_Register(CTRL_REG4,"CTRL_REG4",48);
    //Master releases the slave
    I2C_Master_send_Stop();

 

 

    while(1)

{
    I2C_Master_send_Start();
    //Master says attention please slaves
    //Master communicate with slave and send to him address and order to write U8
    I2C_Master_Send_Address(GY_801_GYRO_I2CAddress,Write);
    //Master chooses register x or y or z Axis from slave registers to read data from
    I2C_Master_Choose_Register(GYRO_X,"GYRO_X");
    //Repeated start bit for reading data form the register we have chosen
    I2C_Master_send_Repeated_Start();
    //Master communicate with slave and send to him address and order to write
    I2C_Master_Send_Address(GY_801_GYRO_I2CAddress,Read);
    //Master reads the data byte of x or y or z Axis from slave registers
    GYRO_Data_X=I2C_Master_Read_DATA_from_Register_WITH_ACK_SINGLE( "GYRO_X")|I2C_Master_Read_DATA_from_Register_WITHOUT_ACK_SINGLE( "GYRO_X")<<8;
    //Master releases the slave
    I2C_Master_send_Stop();
    sprintf(str,"%d",GYRO_Data_X);
    UART_SendString("GYRO_Data_X");
    UART_SendString(" = ");
    UART_SendString(str);
    UART_SendString("\n");

 

 

}

 

}

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Question: is this your code or you copied this code from somewhere else ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mine of course why you are asking ???

 

I am living to bring up new earth ,and not to eat and destroy earth.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The problem when i read from my GY-801 the value is constant could you help 

I am living to bring up new earth ,and not to eat and destroy earth.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

How have you tested you TWI functions? Do you know if they work? Can you read the whoami register from the gyro?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


211 which equivalent to default value of GYRO Who AM I register i think the problem in updating the registers does'nt update their values or could the problem on my code

I am living to bring up new earth ,and not to eat and destroy earth.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Thanks for modification

I am living to bring up new earth ,and not to eat and destroy earth.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For how to do it yourself, see Tip #1

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

 

void I2C_Master_send_Start()
{
    TWCR=(1<<TWSTA)|(1<<TWEN);
    I2C_Wait_Status_bits();
}

You would normally set TWINT as well. Might make a difference.

If you're writing your own i2c functions, it doesn't hurt to take a look at some proven i2c code, see what other people have done.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

MrKendo wrote:
take a look at some proven i2c code, 

+1

 

The most commonly recommended one here being:  http://homepage.hispeed.ch/peterfleury/avr-software.html

 

Atmel Microchip also have Application Notes (with example code) explaining how to use the AVR's TWI ...

 

Also, get an oscilloscope or logic analyser on the lines to see what is actually happening

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Wed. Sep 25, 2019 - 08:51 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

What value pull up resistors do you have on your I2C bus? What speed are you running it at? And how long is the bus? Is cpu and target device on the same aPCB and using the same VCC?

Jim

 

FF = PI > S.E.T

 

Last Edited: Wed. Sep 25, 2019 - 01:29 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am running at 400 KHZ frequency ,but i am connecting with jumpers without external pull up resistor ,but you should know that i used the same things(jumpers and the same frequency) with  MPU-6050 and every things was good.

I am living to bring up new earth ,and not to eat and destroy earth.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Mohamed asaad wrote:
I am running at 400 KHZ frequency ,but i am connecting with jumpers without external pull up resistor

Just to humor me, slow speed down to 100KHz or less, and add a 4.7k pull up resistor on SDA and SCL.   You may just see it work!

 

Jim

 

 

FF = PI > S.E.T

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are there pullups on the module board?

These kind of modules often have pullups on them.

 

You might want to actually check the status register TWSR at each step after waiting for TWINT. See if each step gives the expected value (values are in the datasheet).
 

Could try writing and reading back some other registers on the device, see what that gives.

Maybe the i2c is actually working but you haven't configured enough to enable the gyro?

Too many unknowns.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

MrKendo wrote:
Too many unknowns.

So many would be revealed by the simple expedient of using an oscilloscope to look at what's actually happening on the wires!

 

Why does this always seem to be the last thing people try??

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Firstly atmega32 i2c's have pull up resistor internally ,secondly i saw after every step the status register by debugging through UART and every thing is ok

 

MrKendo wrote:

Could try writing and reading back some other registers on the device, see what that gives.

Maybe the i2c is actually working but you haven't configured enough to enable the gyro?

Too many unknowns.

 

I think that problem could be like that , But you should realize that i saw the content of registers of configuration after i had written on them and everything are OK.

I am living to bring up new earth ,and not to eat and destroy earth.

Last Edited: Wed. Sep 25, 2019 - 10:15 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I promise I will try it if GOD(Allah) ease to me to get one.

I am living to bring up new earth ,and not to eat and destroy earth.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This was my last results :

1-The magnetometer values in all direction varied correctly.

2-The accelerometer  values is is constant equal zero in all direction

3-The gyro's result varied in all direction except x.

 

 

Any suggestion about configuration or another thing.

 

 

 

I am living to bring up new earth ,and not to eat and destroy earth.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mohamed asaad wrote:
Any suggestion about configuration

That's nothing to do with the AVR, Atmel, or Microchip.

 

You need to study the device's documentation, and go to the manufacturer for help on how to properly configure & use it.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for your advice ,but i have done this and i am asking what is the problem because i can't find where is the problem after reading documentation and every thing. I guess that it could be something in configuration which i didn't take care for it or  i forgot it or another thing(could be from atmel architecture in i2c configuration also)

 

I am living to bring up new earth ,and not to eat and destroy earth.

Last Edited: Sat. Sep 28, 2019 - 01:58 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

void UART_SendArray(u8*,u8 size_of_array)
.
OK, give in, how on earth does that compile without error or at least a serious warning? The first parameter is not named??

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry ,this is unused function i already commented it , but i put it by mistake now i am going to remove it .

I am living to bring up new earth ,and not to eat and destroy earth.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

We don't even know what chip is used for the gyro, for the accelerometer etc.

A bit of searching suggests for this GY-801 module it uses ADXL345 accelerometer.

If so, in the datasheet for that accelerometer it says

"At power-up, the device is in standby mode, awaiting a command to enter measurement
mode, and all sensor functions are off. After the device is instructed to enter measurement
mode, all sensor functions are available."

Are you doing any of this setup?

 

In your code, why bother with the strings for name of register :-

 

I2C_Master_Write_DATA_in_Register(CTRL_REG1,"CTRL_REG1",15);

 

You  have a #define for the reg addr (which is good), what's the point of the name strings.

I would just get rid of them.