The MPU-6050 sensor module contains an accelerometer and a gyro in a single chip. It is very accurate, as it contains 16-bits analog to digital conversion hardware for each channel. Therefore it captures the x, y, and z channel at the same time. The sensor uses the I2C-bus to interface with the Arduino
In rundown, this application note is about how to have the Arduino correspond with IMUs., how to compose the code which will advise Arduino to peruse the information from the sensors, the best approach to have the product presentation caught information in the serial screen in an instinctive structure, and the technique for time stamping the information.
Adding Arduino Libraries
Once the product set up is done, client can continue to next step – including libraries. Libraries are a gathering of code that makes it simple for clients to utilize the elements of an Arduino.
Arduino programming accompanies some form in libraries like SPI, WiFi and SD. Including extra libraries can expand the capacity of Arduino. It is likewise required if client need to associate extra parts like sensor, showcase and modules to Arduino. In the group’s configuration venture, two vital libraries included are “MPU6050” and “I2Cdev”.
MPU6050 library is utilized for MPU6050 sensor, which is a prior variant of MPU9150. The distinction between them is MPU6050 is a 6-pivot movement catch sensor made out of a 3-hub accelerometer and a 3-hub spinner. MPU9150 is a more up to date variant which is equipped for doing 9-pivot estimation with an extra magnetometer. In light of the closeness shared by the two sensors, a MPU6050 library is effectively altered to be perfect with MPU9150.
So as to include the vital library, firstly, download the MPU6050 libraries from official website, the libraries disseminated are ZIP records. Uncompress the ZIP file, and duplicate the craved libraries envelope into the product’s libraries’ organize
const int MPU=0x68; // I2C address of the MPU-6050
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0); // set to zero (wakes up the MPU-6050)
Wire.write(0x3B); // starting with register 0x3B (ACCEL_XOUT_H)
Wire.requestFrom(MPU,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(" | 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);
The three primary libraries are one form in library named “Wire.h” and two extra libraries included by group named “I2Cdev.h” and “MPU6050.h”.
Since the correspondence picked in the configuration task is I2C, relating libraries should be included development to dynamic the correspondence. Between the two libraries identified with I2C correspondence, “Wire.h” is utilized to bolster the working of “I2Cdev.h”.
With respect to the “MPU6050.h”, it is code library particularly utilized for IMUs. Manufacture in elements of this library permits the client to get information of 9-hub estimation with one single summon, which makes the programming much simpler.
Serial.begin (baudrate) – the speed of transferring data, replace “baudrate” with number of desired speed.
Wire.begin() – active the I2C bus.
Both of the two codes are utilized for setup reason. The I2C correspondence does not consequently dynamic, along these lines utilize this fabricate in code from library trigger on the information move of I2C transport.
The Arduino support a few baud rates, i.e. 9600, 38400 etc. Higher baud rate permits more information to be transmitted in a unit time. For exactness reason, a high baud rate is picked in the outline to guarantee that a lot of information is gathered.
You can buy all project modules from our Robomart Store find the following link to buy the module.
In the next tutorial we’re going to make Computer controlled Robot with Windows VB.net application. Stay updated..