You are on page 1of 12

myRIO GoPro Gimbal

From home movies to live action cinema, a steady picture is always a sign of high quality video.
Production studios everywhere have large complex setups to keep their cameras stable while
they record masterpieces for the big screen, but that’s out of reach for the hobbyist video
maker. Depending on the location, those kinds of apparatus may not even be feasible. Wireless
drones, for instance, have become a way to capture stunning new video; but due to their small
size and weight limitations, stable video can be quite a challenge.

The camera gimbal has been a unique advancement in video recording. It is an inverse motion
device, used to keep the camera steady across as many axes as it supports. Regardless of how
the gimbal is handled, it seeks to maintain the desired camera position. Precise control
algorithms applied to motors in the gimbal’s structure account for changes in the camera’s
support and correct for them. Depending on the number of axes, these devices can become
very complex and expensive, but single and dual access gimbals can be built and designed
relatively cheaply. This project was completed to show how dual axis hardware could be
controlled using NI’s new myRIO. The goal was to produce a relatively inexpensive gimbal, thus
enabling anyone to get the professional touch they’re looking for.

the frame is very light and simple. controller. and with brushes the exchange is taken care of mechanically. Mechanically. which allows the inertia of the system to work with our controller instead of against it. and a method for positional feedback in order to apply a control algorithm to the system. For this project we chose to create a single-axis gimbal using Brushless DC (BLDC) motors.Building a Camera Gimbal There are currently many designs out there for camera gimbals. The use of BLDC motors also allows for direct drive to both rotational axes. This makes . eliminating backlash usually inherent in a geared or belt driven system. A few key advantages of the design led us to select it. The point where the current flow switches is called the commutation point. Each becomes more complex based on the number of axis it supports. Both axes of rotation pass through the center of gravity of the camera and frame. and the camera that it supports. but left us to determine all of the circuitry required to drive the motors. Because the design is so light and simple there are quite a few reasonably priced setups readily available for purchase. sensors. The set up gave us a good starting point mechanically. different drive options. To save ourselves the trouble of machining a frame and rewinding motors we decided to purchase the frame and motors of the below system made by RCTimer. BLDC Motor Control Brushed motors have a physical connection between the rotating and stationary sections of the motor in order to shift the control of the current flow through the motor based physical contacts touching at certain points.

As the point of commutation (the point where the current is reversed) is approached. The drive shaft passes through the stator and connects to a casing around the cogs. but in application the motor tends to reverse direction with only two fields. This causes both the casing and the drive shaft to spin. neither field exerts much pull on the motor allowing it to often switch directions rather than continuing on. Casing with Permanent Magnets -----. Three Phase BLDC Motor Diagram Source: http://bldc.wikidot. known as cogs.com/bldc-and-8051 . applying current in one direction or the other allows it to spin. Permanent magnetic poles in that casing are attracted or repelled by the cogs depending on the fields generated.the operation of the motor very simple. The addition of the third keeps points of commutation from lining up and forces the motor to continue spinning. attached to a stationary stator. BLDC’s are built to induce three separate fields each 120 degrees out of phase which each other. those physical connections (brushes) are removed and replaced with accurate control of current traveling into the motor.Motor Stator and Cogs Ideally these motors would only need to induce two different fields to make a full rotation. To drive the motor through those points. The direction of current applied to the motor induces magnetic fields in coils of wire. In a BLDC.

we deferred the sensorless motor control to the expertise of the engineers who designed the controller. a predetermined pattern can be applied to turn the motor until it reaches a high enough speed to produce measureable EMF. which does not occur until the motor achieves a higher number of rotations per minute (RPM). Other methods use current chopping or current measurement in order to determine the commutation point.wikidot. and can be further researched online. In the case of the GoPro gimbal. The most popular method is to sense the back EMF of the phase that is not being driven. as such only one or two fields are generated at a time. Due to the fact that position and speed are important to the correct operation of BLDC’s. our motors are never intended to complete a full rotation. A start up procedure. As we were on a limited time frame for the project. is open loop control of the motor. in its simplest form. Stepping through BLDC Commuation Source: http://bldc. The motors we used were in the latter category and require what is known as sensorless operation. a startup procedure is employed. some sort of feedback on the motor’s electrical position is required. Once the initial position of the motor is known. depending on the speed and position of the motor. the controllers are reasonably priced (~$20 each) and are pre-built to carry out the proprietary sensorless control of BLDC motors. Controllably turning the motors proved to be the most challenging aspect of the project. we have to induce the fields in the correct order at a varying rate. but some are not.com/bldc-and-8051 Sensorless operation can be based on a variety of methods and control schemes. The ESC was not a complete solution for driving our motors. which made sensorless control very difficult.Adding a third phase to drive the motor increases the complexity of driving the motor. In the end we elected to use an Electronic Speed Control (ESC) device. it still required an input from our control to determine the speed of the motor. Often found in hobbyist airplanes. As the two coincide it can be used to advance to the next step in the pattern at the correct time. The downside to this method is that enough back EMF voltage must be generated in order for it to be measured. The point at which that voltage reaches zero is also the next commutation point. as with a brushed motor. In order to reach those higher RPM’s. Some motors are made with Hall Effect sensors to provide that information. and it could only drive the motor in a single . Inducing the wrong field can oppose the desired direction and cause loss of torque and added vibration. Instead of simply applying current in one direction or the other.

For this project. and we can use these values to calculate both pitch and roll. because of 3 degrees for acceleration and 3 degrees for the gyro.direction. ESC Relay Diagram Positional Feedback Now that we were able to drive our motor successfully. so if we integrate that over time. and z axis for both acceleration and gyro data. we selected the MPU-6050 due to its small size and I2C communication abilities. The MPU 6050 is a single chip made by invensense that has both onboard accelerometers and gyros. It gives data for the x. To do so we chose to employ the use of an inertial measurement unit (IMU). As you recall from above. we were able to reverse the sequence of commutations and thus the direction that the ESC drove the motor. a BLDC motor has three inputs for each field it can generate. by swapping the 1st and 3rd wires between the BLDC and the ESC. y. Gyroscopic data is given as degree/s. we can determine position. we needed to turn that motor based on the position of our GoPro. This device is considered to have 6 degrees of freedom. In order to change directions we implemented a set of relays controlled by the myRIO FPGA to reverse the sequence of commutations the ESC was providing the motor. The problem with integrating over long periods of time is that small errors continue .

By combining these two measurements. To accommodate for this noise we will need to incorporate data from the gyro in our position calculations. and this is what is referred to as gyro drift. we can get an accurate position reading of the IMU in any state. Accelerometers are accurate when the IMU is sitting still because you can perform trigonometry functions on the acceleration vectors knowing that gravity is the only force acting on the IMU (always in the Z direction at a force of 1G). Because of this. The additional rotational forces create an output with spikes. Gyros are accurate over short periods of times when the IMU is moving. gravity is no longer the only force acting on the IMU. While accelerometer data is accurate over long periods of time when the IMU is still.com/projects/atb1/using-the-accelerometer/ When the IMU is rotating. and a low pass filter on the accelerometers to eliminate the spikes of noise when the IMU is moving. gyros are only accurate for small periods of time when the IMU is moving. position calculations solely based on acceleration data become inaccurate.to build up. which appears shown as noise in the acceleration data. This is done by utilizing a complementary filter. The trig functions to calculate position based on the acceleration data are shown below: Source: http://husstechlabs. To combine them we implemented a high pass filter on the gyroscope to only pass quick changes. Because of this. Below is a diagram of how the complimentary filter operates: .

geekmomprojects.5.5 seconds the accelerometer position is more heavily weighted. time periods less than . Because our sampling period was .5. our α=.5 worked best. we found a value of .pdf. and for time periods greater than .mit.com/gyroscopes-and-accelerometers-on-a-chip/ The time constant can be modified based on your application.edu/scolton/www/filter.001 seconds. To implement this complementary filter in code. τ = time constant greater than timescale of typical accelerometer noise Source: http://www. For this project. the following formulas were used: Filtered Angle = α × (Gyroscope Angle) + (1 − α) × (Accelerometer Angle) where α = τ/(τ + Δt) and (Gyroscope Angle) = (Last Measured Filtered Angle) + ω×Δt Δt = sampling rate.5 seconds favor the gyroscope measurement.998: This is the Block Diagram of our Code that performs the calculations on the accelerometer and gyroscope data to determine the position of the camera: . With a T Value of . and we wanted a T=. Source: http://web.

Communicating with the MPU-6050 The MPU 6050 transfers it’s data over I2C. The required connections from the myRIO to the I2C chip are shown below: . The default address of the IMU is 0x68. a two wire digital communication protocol.

com/mems/gyro/documents/RM-MPU-6000A. To initialize the the IMU at our desired settings.pdf. configuration values are written to registers in the IMU in an Initialization subVI as shown on the next page: More information about the registers. thus the clock rate for the I2C communication on the myRIO is set to 400 KHz. and how these values were chosen can be found here: http://invensense. .The maximum speed that the IMU can transfer data is 400Kbit/s.

We then parse that raw data and convert it to a meaningful position. accelerometer. we perform the I2C write read function shown below: This Writes 0x3B to address 0x68 and reads 14 bytes. PID Control Theory We are using the PID VI from the PID and Fuzzy Logic toolkit to control the Gimbal System: .The accelerometer and gryo data is stored in the registers shown below: When we want to retrieve those values. The array that is output from the above VI is all 14 bytes. which contain the raw gyro. The IMU is set up to continue sending the next register value to the master until the master stops acknowledging.. and temperature data. therefore we only need to write 0x3B and can set the master to read 14 bytes.

and the goal of the PID controller is to make the “process variable input” equal to the “setpoint” by varying the “output”. These numbers determine the behavior of the control system.The PID controller has a “setpoint” that we give as an input. The PID gains are described below from the detailed help: More information about how these gains determine the output is found from the detailed help on the PID algorithm and is shown on the next page: . which defines the minimum and maximum possible values of output. and the concept of PID gains is a thoroughly documented concept in Control Theory. We define the possible values of “output” with the “output range” control. The most important inputs to the PID VI are the PID gains.

com/products/11028 I K Ohm resistor (Qty 4) Power Supply (10V up to 1A) .mouser.085. 1e-5. We also have the PID VI in a case structure that only executes if the gimbal is between +.com/ProductDetail/Panasonic-Electric- Works/AQV252G/?qs=ZM9KzLiT/SMCdDQ80hqKow== MPU-6050 with breakout: https://www.dwt&goodsid=872 10A Brushless Motor Speed Controller: http://www.com/index.170 degrees to avoid rotating the gimbal past the length of our wires. Although our system could improve from better tuning.sparkfun.The loop of our main VI that implements PID is shown below: We are passing the position data from \the IMU through a Single Process Shared Variable with a single element RT FIFO.rctimer. Software LabVIEW myRIO Suite 2013 with FPGA module PID and Fuzzy Logic Toolkit 2013 Hardware Gimbal Frame with motors: http://www. 0. the PID values we settled on were .html Solid State Relay (Qty 4): http://www.com/product_149.rctimer.php?gOo=goods_details.