Thursday, 12 March 2015

Motor Drivers


Work has commenced on interfacing the hardware with the motor driver and the arduino. This is less simple as the arduino uses 3.3v logic, where as the motor drivers run at 5v logic. Therefore a step up / step down circuit is being used between all of the connections. A simple clamped diode set up has also been used to protect the motor drivers from back emf spikes from the motors.

Thursday, 5 March 2015

Output of serial data

Today after managing to write some simple code to be able to get the arduino to output the raw values for the acceleration and rotation in all 3 axis over the serial port I decided to try and do something with this data. As it currently stands it is very difficult to visualise the data from a stream of numbers.

The plan is to use Octave to read the serial data, and then plot simple graphs of the value for each Degree of Freedom against time, so that the data can be visualised and tested.

It will also be desirable to look more closely at how the MPU is processing the data, setting the clock to make it as accurate as possible and various other optimization tasks. These are all possible relatively simply by changing the values for the various different registries as denoted in the registry map. The basic syntax for this is to write 2 bytes across the I2C bus, the first being the address of the registry (normally in hex) and the second being the value to be written (often in binary for ease).

The code currently stands like so :


#include <Wire.h> //include the Wire library for comunication with the MPU 6050 over the I2C bus.
//The adress of the MPU6050 is 0x68 with the ADO pin not connected or put to grund. //For connection to the DUE make sure it goes into pins 20 and 21 for the SDA and SCL as they have
 internal pull up resistors. If using the TWI2 pins, it will not work with out pull up resistors.     int AcX; //declare variables     int AcY;     int AcZ;     int Tmp;     int GyX;     int GyY;     int GyZ;          byte address; void setup() // run once, when the sketch starts {   Serial.begin(9600); // set up Serial library at 9600 bps   Wire.begin();      Wire.beginTransmission(0x68);//reset mpu   Wire.write(0x6B);   Wire.write(0x40);   Wire.endTransmission(true);      Wire.beginTransmission(0x68);//wake device (clear sleep bit)   Wire.write(0x6B);   Wire.write(0x00);   Wire.endTransmission(true);      Wire.beginTransmission(0x68); //who am i   Wire.write(0x75);   Wire.endTransmission(true);   Wire.requestFrom(0x68,1);       address=Wire.read();   Serial.print("MPU6050: ");     Serial.print("MPU I2C Adress: 0x");     Serial.println(address,HEX);      Serial.println("Start");    //  Wire.beginTransmission(0x68);  //  Wire.write(0x35);             //FIFO Enable //  Wire.write(B11111000); //  Wire.endTransmission(true); //   } void loop() // run over and over again {           Wire.beginTransmission(0x68);   Wire.write(0x3B); // starting with register 0x3B (ACCEL_XOUT_H)   Wire.endTransmission(false);   Wire.requestFrom(0x68,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("AcX = "); Serial.print(AcX);   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);        Serial.print("Temp1: ");   Serial.println(analogRead(0));   Serial.print("Tempt2: ");   Serial.println(analogRead(1));      Serial.println();              delay(1000);                                      }

Wednesday, 4 March 2015

Comunication with mpu6050

This morning was somewhat of a break through with getting the comunication working with the mpu6050. It turns out that the twi2 pins on the due dont have the required pull up resistors to work with the I2c bus installed, and so the channel was constantly low. I then connected the sensor to the TWI1 SDA and SCL ports, which do have internal pull up resistors built in, and ran the I2C scanner code, and it found the device on 0x68. I then tried to run the example code that I got from the arduino play ground, and this worked, outputting values for 6DOF movement.

Tuesday, 3 March 2015

mpu6050

I ran the code with out the sensor attached. It seemed to produce the same output, so I can assume this is a signal generated by the code and that it was receiving no signal from the sensor, as I have checked all physical wiring it is assumed that this sensor is not working.

MPU 6050 interface


The Majority of the work over the last few days has been with trying to interface the MPU6050 with the arduino DUE.

This has been done by using the arduino Wire library. Other help was found from this article, and the data sheets for the MPU.

Difficulties are still being had with the interface, with the simple example code onoly returning 0's over the serial out put, suggesting the mpu is still in sleep mode. When attempting to run a version of the more complex example code, the MPU was outputting an oscilitary reponse as shown below.

It currently seems unsure of how to progress with this, as all the physical connections are in order and have been checked with a DMM. The next step might be to try and test it with a 'Scope.
Progress has also been slowed due to a delivery from 'protopic' has been delayed by over a week, which contains the motor drivers and various other essential components for a full electronic assembly.