Difference between revisions of "S16: Camera Gimbal"

From Embedded Systems Learning Academy
Jump to: navigation, search
(Hardware Interface)
(Implementation)
Line 236: Line 236:
  
 
=== Implementation ===
 
=== Implementation ===
This section includes implementation, but again, not the details, just the high level. For example, you can list the steps it takes to communicate over a sensor, or the steps needed to write a page of memory onto SPI Flash. You can include sub-sections for each of your component implementation.
+
The euler angles passed from the MPU-9250 to the SJ One board are mapped to PWM values. For servo control methods and for putting the MPU's feedback on the handle and not introducing it on the gimbaled section, a simple and direct method of positioning the servos in relation to the MPU feedback is used. Every time the servo control method is called, center positioning is saved and where the MPU is in in terms of how far from the center is saved. The result then tells the servo to move to this position that is the center summed with the offset. This first method works but introduces oscillation around the target position. To remove this oscillation, instead of commanding the servo to go to the offset, small increments are taken toward the target position. Using this method with different levels of incrementation according to how far the offset is and using a low pass filter on all feedback axis will remove the oscillation while also providing quick response. A closed-loop system like this is used on all three rotational axes.
  
 
== Testing & Technical Challenges ==
 
== Testing & Technical Challenges ==

Revision as of 06:35, 24 May 2016

Grading Criteria

  • How well is Software & Hardware Design described?
  • How well can this report be used to reproduce this project?
  • Code Quality
  • Overall Report Quality:
    • Software Block Diagrams
    • Hardware Block Diagrams
      Schematic Quality
    • Quality of technical challenges and solutions adopted.

Abstract

Finished Gimbal Prototype

The ‘Camera Gimbal’ is an active stabilization system for camera phones. Smartphones and handheld devices encounter issues when slight movements are encountered when a user attempts to take an image or record a video. Such issues include blurring of images and/or video. This gadget will be able to stabilize a phone by using three low RPM brushless motors that are actively controlled using PID with an accelerometer and magnetometer as feedback to the system. Using this gadget, users will achieve crisp clean photos/videos without any additional hassle.

Objectives & Introduction

The objective of this project was to create a 3-axis self-stabilizing phone holder, or gimbal. Entirely 3D printed, the system can stabilize any standard sized smartphone that is mounted using several neodymium magnets. The system utilizes 3 DC servo motors, one per each XYZ-axis of rotation to account for all degrees of motion; each motor is controlled through PWM from the SJ One Board running FreeRTOS. Using the MPU-9250 IMU, sensor data is used to compute gimbal orientation, which is mapped to PWM values as shown below. By applying filter algorithms to account for drift and/or noise, near accurate stabilization was made possible. Reproduction involves the following steps.

1. Find high precision digital servos and make sure they have the proper degrees of freedom needed.

2. Write or fine-tune software that will precisely control the servo’s movement to the nearest micro-second.

3. Interface with an accelerometer and magnetometer to get the feedback needed to create a closed loop-control system.

4. Creating a structure in Solid-works that holds all the individual parts together and 3D print the design.

5. Create a basic control system that controls Pitch and Roll to keep the phone in a single orientation.

6. Fine-tune that control system, implementing filters and methods of dampening to quickly go to a position while not overshooting and causing oscillation.

7. Implement Yaw control using the magnetometer’s feedback.

8. Fine tune the Yaw control system using filters and dampeners.

9. Integrate all degrees of freedom together and make proper changes to the control systems if any are needed.

Team Members & Responsibilities

  • Matthew Boyd
    • Solidworks & controls systems
  • Ronald Cheng
    • 9DoF solution

Schedule

Week # Start Date End Date Task Status Notes
1 3/28 4/03 Project Proposal and outline Completed - Parts ordered 3/25
2 4/04 4/10 Component testing/setup and PCB design Completed - Servomotors chosen over brushless motors due to ease of control circuitry
3 4/11 4/17 1. Start of SolidWorks design
2. Being motor control driver development
3. PCB final review & order
Completed - Frame 3D printed and commercial phone holder used

- Initial prototype done on Arduino Mega

4 4/18 4/24 1. Create PID system
2. Verify PCB
3. Review CAD design & start print
Completed - Wiring housed in a 3D printed encasing

- 3D printing started at SJSU SCE

5 4/25 5/01 Product integration & testing Completed - 3rd axis of integration often most complex

- Complimentary/Kalman filters recommended to overcome error as result of drift and noise

- Final z-axis rotation was delayed to 5/02 as result of noise in yaw

6 5/02 5/08 1. Design improvements
2. Update Wiki guidelines & create demo video
Completed - Wire housing was enlarged to account for voltage regulators

- Yaw was computed using gyroscope and Riemann summation (relative to power-on position)

7 5/09 5/15 Final product testing Completed - Due to damage, one of the servos needed to be swapped

Parts List & Cost

Part Cost($/per) Retailer Details
SJ One Board 80 Preet
MPU-9250 9DoF IMU 12.50 Amazon - Includes AK8963 3-Axis magnetometer
HS-5065MG Servo Motors 35 Amazon (Serocity)
5V Voltage Regulator 15 Pololu - SJ One Board 5V power
6V Voltage Regulator 15 Pololu - Servo motor power
Kit of M2 Screws 10 Amazon - Used to mount servo motors
3D printing Free - Included in SJSU SCE membership fee
WizGear Phone Mount 6.50 Amazon - Neodymium magnets
Jumper Wires 7.29 Amazon

Design & Implementation

Figure 1. Gimbal system overview

Hardware Design

This section includes the detailed hardware schematics and interface. The parts required for this system are listed above. It includes 3 servo motors control by the SJ One board, a MPU-9250 9DoF sensor to measure system orientation, and two voltage regulars to both power the SJ One board and servo motors.

Gimbal Frame

Power Regulators

Servo Motors

9DoF IMU

Figure 2. MPU-9250 9DoF IMU

The MPU-9250 is a 9DoF (degrees of freedom) IMU housing two dies integrated into a single QFN package. One die houses the 3-axis gyroscope and 3-axis accelerometer (Figure 2). The other die houses the AK8963 3-axis magnetometer.


Because the SJ One board only includes a 6DoF, this sensor provides an accurate solution of measuring yaw in respect to magnetic north. However, magnetometers often include error as a result of noise; this is solved by applying filtering algorithms (complimentary or kalman filter).Though measuring yaw is possible with only a gyroscope by applying a Riemann summation, this measurement is in reference to when sensor is powered on.







Hardware Interface

Figure 4. Servo freedom range and time association

This section describes how the different hardware components communicate.

Communication among the different parts are through I2C and PWM for servo control. The servos use a special form of PWM that does not rely on how much of a duty cycle is high but rather for how long of a duration the pulse in the duty cycle remains high. For most applications, this time amount is measured in micro-seconds. The specific time intervals that are required for the servos used can be seen on the right (Figure 4).

While tuning the GPIO driver created by Preetpal Kang supplied in the libraries included, it was found that setting a based frequency of 21Hz generated an output of 250Hz. From there, it was deduced that 0.025% gave an output of 1us when setting PWM duty cycle to control servo motors (Figure 5). Proportionally we could multiply that percentage by how many microseconds were needed to precisely control the servo position.

Table 1: Values for percent-1us pulse
Hz Cycle Time (ms) Percent for 1us
250 4000 0.025
Figure 5. GPIO with 1ms pulse at 250Hz Duty

Software Design

Show your software design. For example, if you are designing an MP3 Player, show the tasks that you are using, and what they are doing at a high level. Do not show the details of the code. For example, do not show exact code, but you may show psuedocode and fragments of code. Keep in mind that you are showing DESIGN of your software, not the inner workings of it.

Implementation

The euler angles passed from the MPU-9250 to the SJ One board are mapped to PWM values. For servo control methods and for putting the MPU's feedback on the handle and not introducing it on the gimbaled section, a simple and direct method of positioning the servos in relation to the MPU feedback is used. Every time the servo control method is called, center positioning is saved and where the MPU is in in terms of how far from the center is saved. The result then tells the servo to move to this position that is the center summed with the offset. This first method works but introduces oscillation around the target position. To remove this oscillation, instead of commanding the servo to go to the offset, small increments are taken toward the target position. Using this method with different levels of incrementation according to how far the offset is and using a low pass filter on all feedback axis will remove the oscillation while also providing quick response. A closed-loop system like this is used on all three rotational axes.

Testing & Technical Challenges

Describe the challenges of your project. What advise would you give yourself or someone else if your project can be started from scratch again? Make a smooth transition to testing section and described what it took to test your project.

Include sub-sections that list out a problem and solution, such as:

My Issue #1

Discuss the issue and resolution.

Conclusion

Conclude your project here. You can recap your testing and problems. You should address the "so what" part here to indicate what you ultimately learnt from this project. How has this project increased your knowledge?

Project Video

9DoF Gimbal

Project Source Code

References

Acknowledgement

Any acknowledgement that you may wish to provide can be included here.

References Used

List any references used in project.

Appendix

You can list the references you used.