Gyro Camera For Motorcycle Using Arduino

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

Gyro Camera for Motorcycle using Arduino

As seen in MotoGP Race, the rider is seen riding through corners while laying aside his bike to the left and
right. But there is an interesting moment when the motor looks to collapse sideward, the front views remain
horizontally. How could that be?
Such onboard camera applies GYRO system, where the camera will be fixed perpendicular to the gravity of the
earth.

Step 1: BUILD YOUR OWN GYRO CAMERA


We could build our own Gyro Camera by using GYRO and ACCELEROMETER modules.
They are two separate modules, hence we have to use two modules simultaneously. Then we make Gyro Chip
and Accelerometer Chip in one module (there are two chips in one module). In latest version they are made in
one chip only, thus minimizing the distortion of movement calculation

In this article, the module is Triple Axis Accelerometer & Gyro Breakout MPU-6050, which has 3-axis
gyroscope and 3-axis accelerometer in one chip, supplied by power of 3.3volt.

In addition to module MPU6050, the following similar modules could also be applied:
IMU Fusion Board ADXL345 & IMU3000
IMU Digital Combo Board 6 Degrees of Freedom ITG3200/ADXL345

Module MPU6050 with its tiny size of 20mm x 15mm and height of 1.6mm.

If you using different board than Arduino Uno R3, SCL and SDA pins of MPU are also different:
VDD : +3.3V
VIO : +3.3V
GND : GND
SDA : Pin A4 (Arduino Uno, Ethernet) / Pin 20 (Mega2560, Due) / Pin 2 (Leonardo)
SCL : Pin A5 (Arduino Uno, Ethernet) / Pin 21 (Mega2560, Due) / Pin 3 (Leonardo)

Step 2: PROGRAMMING
After having completely assembled, it is time now to upload the program to Arduino.

This circuit is only to drive servo in axis-X only. However, data from Axis Y and Z are still required for the
respective Gyroscope and Accelerometer. I tried to combine them by applying Kalman Filter calculation so as to
reduce noise output from Gyroscope + Accelerometer so that servo movement is smooth and no unwanted
movement.

CODE:

/*

GYRO CAMERA - saft7.com

Demonstrates auto-leveling Camera Video by using Gyro & Accelerometer with Arduino
The circuit:

Servo controlled by Arduino, using Gyro and Accelerometer as reference of movement.

Created March 12, 2013

by Firmansyah Saftari

www.saft7.com

This code and complete article can be found at:

http://www.saft7.com/

Programming Language: C++

*/

#include <Servo.h>

Servo xservo;

#include <Wire.h>

#include "Kalman.h"

Kalman kalmanX;

Kalman kalmanY;

uint8_t IMUAddress = 0x68; // MPU6050 Address


Knob

Control the position of a RC (hobby) servo motor with your Arduino and a
potentiometer.

This example makes use of the Arduino servo library.

Hardware Required

Arduino Board
(1) Servo Motor
(1) Potentiometer
hook-up wire

Circuit

Servo motors have three wires: power, ground, and signal. The power wire is
typically red, and should be connected to the 5V pin on the Arduino board. The
ground wire is typically black or brown and should be connected to a ground
pin on the Arduino board. The signal pin is typically yellow or orange and
should be connected to pin 9 on the Arduino board.

The potentiometer should be wired so that its two outer pins are connected to
power (+5V) and ground, and its middle pin is connected to analog input 0 on
the Arduino.

click the images to enlarge


images developed using Fritzing. For more circuit examples, see the Fritzing project page

Schematic
Code
// Controlling a servo position using a potentiometer (variable resistor)
// by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>

#include <Servo.h>

Servo myservo; // create servo object to control a servo

int potpin = 0; // analog pin used to connect the potentiometer


int val; // variable to read the value from the analog pin

void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}

void loop()
{
val = analogRead(potpin); // reads the value of the
potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo
(value between 0 and 180)
myservo.write(val); // sets the servo position according
to the scaled value
delay(15); // waits for the servo to get there
}

[Get Code]

See also

attach()
write()
map()
analogRead()
Servo library reference
Sweep - sweep the shaft of a servo motor back and forth.

Barrido con un Servo y Arduino


Publicado el 7 de mayo de 2012de nosoybob
ste ejemplo es muy simple, y no hacen falta muchas partes mas que un Servo y una Arduino.

Para esto solo har falta un Servo y cables

El esquema para hacer todo an ms fcil :D


Y por ltimo el cdigo:

// Sweep
// by BARRAGAN <http://barraganstudio.com&gt;
// This example code is in the public domain.
#include <Servo.h>

Servo myservo; // create servo object to control a servo


// a maximum of eight servo objects can be created

int pos = 0; // variable to store the servo position

void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}

void loop()
{
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable pos
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable pos
delay(15); // waits 15ms for the servo to reach the position
}
}

You might also like