Recent changes
Slingshot user guide
tag Guide, user
NFCLamp user guide
tag Guide, user
Homepage
MPL115A2
Compiler Error 42
From the mbed microcontroller Cookbook.  

ITG 3200 Gyroscope

The ITG-3200 is a triple-axis, digital output gyroscope. It features three 16-bit analog-to-digital converters (ADCs) for digitizing the gyro outputs, a user-selectable internal low-pass filter bandwidth, and a Fast-Mode I2C (400kHz) interface, as well as an embedded temperature sensor and a 2% accurate internal oscillator.

http://mbed.org/media/uploads/aberk/itg3200.jpg

Hello World!

» Import this program

00001 #include "ITG3200.h"
00002 
00003 Serial pc(USBTX, USBRX);
00004 ITG3200 gyro(p9, p10);
00005 
00006 int main() {
00007 
00008     pc.printf("Now starting ITG-3200 test...\n");
00009     
00010     //Set highest bandwidth.
00011     gyro.setLpBandwidth(LPFBW_42HZ);
00012 
00013     while (1) {
00014 
00015         //Arbitrary wait for printf clarity.
00016         wait(0.1);
00017         pc.printf("%i, %i, %i\n", gyro.getGyroX(),
00018                   gyro.getGyroY(), gyro.getGyroZ());
00019 
00020     }
00021 
00022 }

Wiring

ITG-3200 Signal Namembed pin
VCCVOUT
VLOGICVOUT
GNDGND
SDAp9
SCLp10

API

» Import this library into a program

Public Member Functions

ITG3200 (PinName sda, PinName scl)
Constructor.
char getWhoAmI (void)
Get the identity of the device.
void setWhoAmI (char address)
Set the address of the device.
char getSampleRateDivider (void)
Get the sample rate divider.
void setSampleRateDivider (char divider)
Set the sample rate divider.
int getInternalSampleRate (void)
Get the internal sample rate.
void setLpBandwidth (char bandwidth)
Set the low pass filter bandwidth.
char getInterruptConfiguration (void)
Get the interrupt configuration.
void setInterruptConfiguration (char config)
Set the interrupt configuration.
bool isPllReady (void)
Check the ITG_RDY bit of the INT_STATUS register.
bool isRawDataReady (void)
Check the RAW_DATA_RDY bit of the INT_STATUS register.
float getTemperature (void)
Get the temperature of the device.
int getGyroX (void)
Get the output for the x-axis gyroscope.
int getGyroY (void)
Get the output for the y-axis gyroscope.
int getGyroZ (void)
Get the output on the z-axis gyroscope.
char getPowerManagement (void)
Get the power management configuration.
void setPowerManagement (char config)
Set power management configuration.

Library

» Import this library into a programITG3200

ITG-3200 triple axis, digital gyroscope library.

Reference




calendar Page history
Last modified 27 Nov 2010, by   user Aaron Berk   tag No tags | 24 comments  

24 comments on ITG 3200 Gyroscope:

05 Nov 2010

I recently received the ITG-3200 Gyro to use with my project and was all excited to use the gyro. I loaded you code into the controller and the gyro appears to hang on each steep. I folled all the instructions you provided. Do you have any suggestion on what I could do next.

11 Nov 2010

Two things I found you have to look out for in this lib (which is awesome btw...thanks Aaron!)

1) Depending if you are pulling up or down pin 9 on the gyro, it will change the address of the device. In my case, I had to edit ITG3200.h line 44 to reflect 0x68 instead of 0x69

Code

#define ITG3200_I2C_ADDRESS 0x68 //7-bit address.(or 0x69)

2) The library now appears to return signed integers of the rate counts instead of floats for deg/sec, so in the example hello world code seen above all the %f's in the printf() need to be changed to %i's. Also I added \r to keep all the text in a column. Don't know if that's just my terminal's issue or not.

Code

pc.printf("%i, %i, %i\n\r", gyro.getGyroX(), gyro.getGyroY(), gyro.getGyroZ());

Hope this helps.

Tim

08 Mar 2011

I bought ITG 3200 recently, and interfaced with mbed board as shown above and tried the same program, but I am getting the same data all the time which is -12852 -12852 -12852 on all axis. can you suggest me what to do...

11 Mar 2011

I have been trying to use the program provided above, but I believe something in the library is incorrect. I even tried the suggestions given above by Tim Marvin, but that did not work either. My terminal can print from other programs, but this library has an error in it that prevents any printing while running the the program on the mbed. (It compiles so its obviously not a syntactical error, but a run-time error)

11 Mar 2011

Hi all, I've tested the lib with the IMU and it seems to work sometimes and sometimes it prevents any printing to the terminal programm - like Peter described it above. Strange is, that it's working sometimes. It's really a great library and I like it. I'll try to test only the code above without IMU stuff over weekend - if I'll find some spare time. It's important to connect VLOGIC and VCC to mbed VOUT (3.3V). Did you use a bread board for wiring up the gyro, like me? If so, maybe this is a mechanical reason because of bad contacts? Let us all know if someone is investigating a solution for this, please. Regards Stanislaus

14 Mar 2011

Hi all, I am still unable to use the Gyro module (ITG-3200 Breakout board) while interfacing with mbed as shown above....

i tried it with the following changes...

1. Changing I2C address to 0x68 by changing gyro pin 9 connection.. 2. vcc and vlogic connecting to mbed vout. 3. without connecting vlogic..

in all cases i am getting some garbage value -12858,-12858,-12858.

i am still trying the same with proper wiring... can anyone suggest me better solution for this..

regards, seshu

14 Mar 2011

user seshakiran chemudipati wrote:

Hi all, I am still unable to use the Gyro module (ITG-3200 Breakout board) while interfacing with mbed as shown above....

i tried it with the following changes...

1. Changing I2C address to 0x68 by changing gyro pin 9 connection.. 2. vcc and vlogic connecting to mbed vout. 3. without connecting vlogic..

in all cases i am getting some garbage value -12858,-12858,-12858.

i am still trying the same with proper wiring... can anyone suggest me better solution for this..

regards, seshu

Make sure I2C are working well(pull ups, etc) and a device has right ID. You can use

» Import this programI2CU

to see list of devices on I2C

15 Mar 2011

user Chema Moto wrote:

user seshakiran chemudipati wrote:

Hi all, I am still unable to use the Gyro module (ITG-3200 Breakout board) while interfacing with mbed as shown above....

i tried it with the following changes...

1. Changing I2C address to 0x68 by changing gyro pin 9 connection.. 2. vcc and vlogic connecting to mbed vout. 3. without connecting vlogic..

in all cases i am getting some garbage value -12858,-12858,-12858.

i am still trying the same with proper wiring... can anyone suggest me better solution for this..

regards, seshu

Make sure I2C are working well(pull ups, etc) and a device has right ID. You can use

» Import this programI2CU

to see list of devices on I2C

Thank you very much, I tried the I2CU program to find the I2C address I am getting 0 devices found message back... so I think its because of improper wiring...

I tried in both ways.. by pulling up and pulling down pin 9 of gyroscope...

do I need to change the lpbandwidth?

Seshu.

15 Mar 2011

user seshakiran chemudipati wrote:

Thank you very much, I tried the I2CU program to find the I2C address I am getting 0 devices found message back... so I think its because of improper wiring...

I tried in both ways.. by pulling up and pulling down pin 9 of gyroscope...

do I need to change the lpbandwidth?

Seshu.

pull up SDA,SCL
vcc,vlogic to 3.3V

15 Mar 2011

user Chema Moto wrote:

user seshakiran chemudipati wrote:

Thank you very much, I tried the I2CU program to find the I2C address I am getting 0 devices found message back... so I think its because of improper wiring...

I tried in both ways.. by pulling up and pulling down pin 9 of gyroscope...

do I need to change the lpbandwidth?

Seshu.

pull up SDA,SCL
vcc,vlogic to 3.3V

Thank you very much.... I got it.

also made some difference between vcc and vlogic ( vlogic<vcc) I connected USB voltage to Gyro vcc and mbed 3.3v to vlogic.

I think its not good practice to use usb 5v I have to find other alternative.

seshu.

25 Mar 2011

Hi

I seem to have a similar problem. I just get a steady stream of -12852 output for all three gyros. My ITG3200 is part of a sens10321 stick, so has a 3 axis accelerometer and 3 axis magnetometer as well. I tried I2CU and it says 3 devices found, which is correct. Any ideas? The only outputs from the stick are Vcc,GND,Scl,Sda so no option to play with Vlogic and Vcc pins on the ITG 3200 chip

25 Mar 2011

user matthew tetlow wrote:

Hi

I seem to have a similar problem. I just get a steady stream of -12852 output for all three gyros. My ITG3200 is part of a sens10321 stick, so has a 3 axis accelerometer and 3 axis magnetometer as well. I tried I2CU and it says 3 devices found, which is correct. Any ideas? The only outputs from the stick are Vcc,GND,Scl,Sda so no option to play with Vlogic and Vcc pins on the ITG 3200 chip

ITG3200 I2C ADDRESS: 0x68 or 0x69

28 Mar 2011

user matthew tetlow wrote:

Hi

I seem to have a similar problem. I just get a steady stream of -12852 output for all three gyros. My ITG3200 is part of a sens10321 stick, so has a 3 axis accelerometer and 3 axis magnetometer as well. I tried I2CU and it says 3 devices found, which is correct. Any ideas? The only outputs from the stick are Vcc,GND,Scl,Sda so no option to play with Vlogic and Vcc pins on the ITG 3200 chip

Hi there,

you can see VIO on the gyro which is vlogic... keep vlogic always less that vcc.... may be try like this.. connect the vcc to usb voltage and then vlogic to mbed 3.3v also try connecting pull up resistors to sda and scl lines....

also check the connections..

all the best

seshu

23 Aug 2011

Hi, Has anybody managed to run this gyro? In case of choosing analog output or I2C output gyroscope which one has the major advantage? Cheers, Milan

A: I2C provide digital output so will probably has better resolution?/faster, noise redundant, less power. Right?

23 Aug 2011

Hi Milan,

The SJ1 is used for 7bit I2C address byte and define the LSB bit. Just read the datasheet everything is there! By default SJ1 is already set to high which mean 0x69 7bit address, but you can unsolder it and solder it to ground, then the 7bit address will be 0x68. The SJ2 is need to be soldered together if no external clock is used or you can leave it as it is but connect the pin5 of the JP2 to GND. So I solder this SJ2 for mine board and left to unconnected the pin5 on JP2.

Regards, Stas

23 Aug 2011

Hi, Thank you for the answer I will go back to the manual soon. As I realised that SJ1/2 are optional I deleted my question and it disappeared at the same time as you typed the answer ;) I think that your comment explains the case of 0x68 and 0x69. Have you managed to run this gyroscope? Regards, Milan

23 Aug 2011

Yes I have complete system with accel, gyro and magnetometer but I am use STM32 MCU for this 9 degree of freedom project where I have build mine library from the scratch.

30 Aug 2011

Hi Milan,

Watch this video http://youtu.be/4-LIT6xSot0

Regards, Stas

01 Sep 2011

nice nice nice, what next? have u got an application for it? I just received free samples yesterday and got footprint to Altium today so hopefully start soon. Amazing keep growng

03 Sep 2011

Thanks! :) Yes I have two.

All the best to you too!

31 Oct 2011

>> (problem: it reads continuously -12858,-12858,-12858.)

If you're using the "workshop board", pin 9 may be constantly pulled high. Change to another I2C interface, for example pins 28/27

A brief summary of what I found out.

For the coolcomponents ITG-3200 breakout board, I believe the following applies:

  • It -is- necessary to add pull-up resistors in one way or the other (there are two empty slots on the board). 1.8k was recommended somewhere.
  • Both supplies should be connected to 3.3V.
  • The datasheet clearly states Vdd max. 3.6V. Further, Vlogic may not exceed vdd. Why anybody would consider 5 V is beyond me.
  • The clock input is not required to make it work. Close the jumper on the bottom side of the board to ground it
  • My board shipped with the address line set high (jumper), as the documentation states. If so, the address is 0x69.
  • The I2CU program (see above) works as expected
  • The current version of the example code works as expected

I hope this saves someone else some time...

02 Nov 2011

I think the RAW_RDY_EN bit is not as described in the header (see register map in data sheet).

I got data interrupts working using gyro.setInterruptConfiguration(1)

22 Mar 2012

Hi all,

Does anyone has the code for this gyro sensor? http://www.active-robots.com/gyro-breakout-board-ly530al-300degrees-s.html

Regards Andrew

1 week, 6 days ago

It is working fine, have to use a >4 OHM resistor between the SCL->VIO or VDD and also SDA-> VIO or VDD to act as pull up.

Please login to post comments.