กลับไปหน้ารวมไฟล์
3d-artificial-horizon-gyroscope-with-mpu6050-gy-521-7b8fe4-en.md

3D Artificial Horizon/ Gyroscope Using Arduino and Processing3+

Works with mouse if desired.

Also works with ADXL345 and MPU6050/GY-521 Accelerometer/Gyroscope variations.

Note: This project is not completed. Dare I ever to lose this code on my HDD.

Azimuth doesn't work, but fully serves purpose without it.

A little shaky. Altitude also doesn't work... yet

Based on Kerbal Space Program (KSP)

Face the module like this when operating.

Face the Accelerometer/Gyroscope module this way during operation.

Aerospace Navigational Geometry: 3D Artificial Horizon

When an airplane flies through the clouds, the pilot has no visual reference to the ground; if the wing dips, they might accidentally fly perfectly upside down and crash. The 3D Artificial Horizon is an incredible engineering feat that extracts pure Cartesian Acceleration and Gyroscopic vectors from a tiny silicon MPU6050 (GY-521) IMU, porting the math via serial to Processing IDE to literally draw a massive, fluidly shifting artificial 3D box on the computer screen!

The I2C MPU6050 Quaternion Output Framework

Raw accelerometer data (X=15000, Y=3000, Z=-1500) is chaotic. If the Uno shakes slightly on a desk, the numbers vibrate violently, which would make the 3D airplane on the screen visually rip itself apart!

  1. The MPU6050 contains a catastrophic feature called the DMP (Digital Motion Processor).
  2. The Arduino must aggressively utilize the massive I2Cdev.h and MPU6050_6Axis_MotionApps20.h libraries to tap into the silicon!
  3. The internal DMP chip fuses the Accelerometer gravity vectors with the Gyroscope spin momentum, mathematically calculating Quaternions and Euler Angles!
  4. It outputs an incredibly smooth decimal: Pitch: 14.5 degrees, Roll: 32.1 degrees, Yaw: 180.0 degrees.

The Serial Bridge to Processing IDE (Java Rendering)

The Uno cannot draw a stunning 3D airplane.

  • The Uno acts strictly as a data-pipe. It blasts the flawless decimal numbers out Serial.println(String(ypr[0]) + "," + String(ypr[1]) + "," + String(ypr[2])); at maximum 115200 baud!
  • The PC Java Architecture: The programmer opens a massively complex Processing IDE Java sketch.
  • Over the USB Cable, Processing intercepts the string!
// Java code applying physical rotation directly to a 3D geometry shape!
rotateZ(radians(roll));
rotateX(radians(pitch));
rotateY(radians(yaw));
box(200, 10, 200); // Draws the physical 3D wings of the plane dynamically updating 60 frames per second!

Inertial Component Matrix

  • Arduino Uno/Nano (Standard functionality).
  • MPU6050 (GY-521) 6-Axis Accelerometer/Gyroscope Module (Absolutely ensure the I2C wires SDA and SCL are connected securely. A loose wire will completely crash the DMP initialization array!).
  • Processing IDE Software (Installed on a PC/Mac to handle the heavy WebGL 3D rendering pipeline!).
  • A 12-inch massive USB cable tying the entire architecture seamlessly to the host display!

Connect the ADXL345 or MPU6050/ GY-521 into the Arduino.

We will use A4 and A5 here.

SCL - A5

SDA - A4

ข้อมูล Frontmatter ดั้งเดิม

apps:
  - "1x Processing"
  - "1x Arduino IDE"
author: "Gallax"
category: "Gadgets, Games & Toys"
components:
  - "1x 6 DOF Sensor - MPU6050"
  - "1x Jumper wires (generic)"
  - "1x Arduino UNO"
description: "Inertial navigation physics! Strip the phenomenally complex I2C acceleration data straight into a massive processing IDE geometry engine, calculating quaternions to visually render a rotating 3D airplane cockpit instrument exactly perfectly."
difficulty: "Advanced"
documentationLinks: []
downloadableFiles: []
encryptedPayload: "U2FsdGVkX196usOXd7iLGIUWM07o40p6eps7CUADPx6t1AvzMmoBw1FZNTBuqvPERMvEBEFYU6DLNfUbd5UalDwvwpMwSgus/LXZqWe8SL8cCpQi0BtQ1OWFMGyzBAg0"
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/3d-artificial-horizon-gyroscope-with-mpu6050-gy-521-7b8fe4_cover.jpg"
lang: "en"
likes: 6
passwordHash: "ec957531affa441c577a55494bdfc4dec34c0da0f56754962dba93854554582c"
price: 1120
seoDescription: "Create a 3D Artificial Horizon using Gyroscope MPU6050 GY-521. Inspired by NavBall in Kerbal Space Program. Works with ADXL345 and Mouse."
tags:
  - "gy521"
  - "gy-521"
  - "mpu6050"
  - "gyroscope"
  - "kerbal space program"
  - "arduino"
  - "accelerometer"
  - "3d"
  - "processing"
  - "navball"
  - "artificial horizon"
  - "adxl345"
title: "3D Artificial Horizon - Gyroscope with MPU6050 GY-521"
tools: []
videoLinks:
  - "https://www.youtube.com/embed/51FFv0W7VIY"
  - "https://www.youtube.com/embed/veFDSi6lUJg"
views: 17000