loading

This is a story of my third project with cheap gyro and Arduino.

After the earlier two projects, Easy Inverted Pendulum and 3D Calligraphy, I have thought of making Camera Gimbal with Arduino. Then I had three policies for the project.

  • Equipped with standard camera bigger than GoPro
  • Simple as possible with no special device nor kit
  • Bootstrap: Refer to fewer websites as possible and finish with no imitation

At the start of the project, I had intention of making 2-axis gimbal with Servo Motors. But it has been made clear that it is difficult to see adequate performance using Servo Motor. Consequently a 3-axis gimbal with Brushless Motors and Arduino has been made. INTRODUCTION VIDEO below shows the effectiveness of the DIY gimbal. In the video, pretty noise would be heard suddenly. It is left without any reduction to show strengths and weaknesses of the gimbal. Arbitrary film editing is avoided.

:

[INTRODUCTION VIDEO]

:
It seems that the DIY 3-axis gimbal in this video provides enough compensation for practical use. But it was not easy to make it of this level. For example, I have met with difficulties below.

  • Controlling Brushless Motor adequately with Arduino alone
  • Getting a precision frame of gimbal by using rather poor tool
  • Resolving the disturbance of SPI interface between gyros and Arduino
  • Settling frame chattering
  • Adding intended and smoothPAN or TILT to good compensation

The first problem above is a matter of programming. In contrast the second one is a pure hardware matter. And the remaining ones are found in intersection of both matters.

Also four problems except for the first one have been encountered when the second axis was added to the single axis gimbal. It means that the core of the program of multi-axis gimbal here is not different from the single axis one. But the good frame for multi-axis one requires much more efforts to be gotten than single axis one.

:

Here "How to make the DIY single axis Brushless Gimbal with Arduino" is told in detail in a later step. But it is rather a special topic to tell the whole story about the process of development a DIY camera gimbal with Arduino of level high enough for practical use. The story is as follows.

  • An important point to make a gimbal with gyro
  • DIY single axis gimbal with cheap Brush DC Motor
  • DIY single axis gimbal with Servo Motor
  • DIY single axis gimbal with Brushless DC Motor
  • Multi-axis controlled
  • Effectiveness of the DIY gimbal
  • Unresolved problems for improvement

"How to ..." is told in Step 6 to 10 mostly. And the minimum work in it might be able to be done just referring to content in Step 10 after watching DCUMENTARY (12) in Step 9. On the other hand the performance of the DIY 3-axis gimbal would be seen approximately after watching INTRODUCTION VIDEO above, DCUMENTARY (15) in Step 12 and DCUMENTARY (17) in Step 13.

:

By the way, another project entitled "Brushless Gimbal with Arduino" has been posted to Instructables in last year. It provided me the "good resource for a starting point". But its approach contrasts with mine. The difference between them would be told in Step 5.

:

I hope the attached videos and pictures would compensate for my poor English. The Japanese version of this instructable has three more steps additionally.


Step 1: An Important Matter—Which Side Is Gyro Attached To?

Motion of a rigid body in space can be described with two independent elements; rotation and parallel translation. The former can be cancelled out or compensated by an instrument called gimbal. A camera mounted on the innermost gimbal could be free from rotary motion when the support of the gimbal moved, even though it might not be free from parallel shift. Hence for the gimbal driven by motor, angle (or posture) of camera becomes the important information to keep it still.

We have several alternatives to estimate the angle of object in motion. Here cheap gyro module(s) is/are used. The angular velocity of the object can be measured by gyro. And Arduino translates it into estimated degree of angle shift of the object. Now we have the next alternatives for the new matter which side of gimbal the gyro is attached to.

(1) Attaching gyro to the "camera side" (attaching it to the camera mount)

(2) Attaching gyro to the "support side" (attaching it to the handle base)

:

The most different point between them is whether the feedback of the intentional rotation of the motor controlling the gimbal is gotten or not. When attaching gyro to (1) camera side, intentional motion is not distinguished from un-intentional one and just the sum of them is measured. On the other hand when attaching gyro to (2) support side, only the un-intentional rotation is measured but intentional one is not. Hence they have good and bad points respectively as below.

(1) Attaching gyro to the camera side (attaching it to thetop (or rotor) of the motor)

  • Strategy: When the camera rotates a little bit, drive the motor to cancel out it immediately.
  • Merits: It is not needed to estimate the angle correctly. (So it is not needed to know how much the motor rotates its spindle.)
  • Demerits: The camera vibrates easily unless the motor is controlled adequately.

(2) Attaching gyro to the support side (attaching it to thebase (or stator) of the motor)

  • Strategy: When the support rotates, estimate the degree and rotate motor as much as that to the reverse direction correctly.
  • Merits: Vibration caused by the feedback of motor rotation never occurs.
  • Demerits: The correct estimates are needed for both rotation of the support and camera.

:

These differences are important for motor choice. When the gyro is attached to the (2) support side, both degrees of angles of the top and the base of the motor have to be estimated correctly. Therefore Servo or Stepper Motor is likely to be used, which could control the angle directly.

On the other hand, when the gyro is attached to the (1) camera side, just the rotation of the top of the motor should be restricted from the fixed viewpoint at somewhere outside. Then the degree of this rotation does not have to be estimated necessarily. So the cheap Brush DC Motor might work.

Now it appears that the (1) camera side is better to attach gyro to, from point of view of either freedom of motor choice or less efforts needed to estimate the correct degrees of angles.

Step 2: Can Be Cheap Brush DC Motor Applied to Gimbal?

Some cheap Brush DC Motor might work for the gimbal when the gyro is attached to the (1) camera side. But the spindle of this kind of motor would turn at higher speed for gimbal. Therefore gear or pulley is needed to reduce speed properly.

Here a simple inverted pendulum robot ever made is used like a single axis gimbal to see whether Brush DC Motor could be applied to camera gimbal. With a modified program for gimbal this robot can give rough compensation against the rotation of its support. Though it is not so bad, large vibration occurs, which cannot be resolved by the standard countermeasure. You can see detail in DOCUMENTARY (1) below.

:

[DOCUMENTARY (1)] Single Axis Gimbal with Brush DC Motor

:

Backlash of the reduce gears causes this persistent vibration. It is needed to know at every moment whether gears mesh or not to resolve it. But it is not easy to know it in real time.

As lowering sensor sensitivity this vibration is able to be weakened. (See DOCUMENTARY (2) below.) But the gimbal is left uncontrolled while gears do not mesh. Hence a precision reduce gears such as no backlash is felt is needed to apply cheap Brush DC Motor to camera gimbal. But it seems too hard to get such gears in this project.

:

[DOCUMENTARY (2)] Modified Single Axis Gimbal with Brush DC Motor

Step 3: Making Single Axis Servo Gimbal (Part 1)

In this step and the next, Servo Motor is tried out for a single axis camera gimbal.

In Step 1 it is described that Servo Motor could work in either case where gyro is attached to (1) camera side or (2) support side of gimbal. In this step gyro is attached to the (1) camera side. Though it is not required to know the correct degrees of angles in this case necessarily, two alternative strategies were adopted respectively. The results observed are as follows.

  • The strategy, "turning motor as much as estimated degree of rotation of the support of gimbal to the reverse direction," cannot cancel out the rotation enough.
  • The other strategy, "turning motor until cancelling out camera rotation," results in delayed compensation or vibration of camera mount.
  • Therefore it is not easy to decide how much Servo turns.

:

The former strategy above is prepared for the gyro attached to the (2) support side. Though it is thought to work as well for the gyro attached to the (1) camera side intuitively, it compensates only the half of rotation on reflection.

On the other hand the latter strategy is prepared for the case where gyro is attached to (1) camera side. Here Servo Motor receives directly the degree of angle to turn. So it is not easy to control angular velocity or acceleration.

By changing the degree to turn gradually, we can control angular velocity to some extent. But we would meet with vibration in higher speed or delayed compensation in lower speed easily.

The advantage of Servo Motor is correct turning with the degree received. Therefore when using Servo Motor it should be better that the gyro is attached to the (2) support side from the viewpoint of efficiency of control, where the vibration caused by feedback could not be observed.

Step 4: Making Single Axis Servo Gimbal (Part 2)

In the previous step we have learned that it is not better attaching gyro to (1) camera side when using Servo Motor. So Servo Motor is tried out again with attaching gyro to (2) support side. The results observed are as follows.

  • Servo Motor is not good where quick acceleration or deceleration is needed
  • Especially it needs more time upon deceleration to stop
  • It is difficult to change acceleration or deceleration of each Servo Motor

:

The figure above shows the change in the angular velocity of a Servo Motor from start to finish. There four different angles with 8, 15, 30 and 60 degrees are given and four lines in this figure represent these angles respectively. The slope of each line shows angular acceleration. We can know acceleration from start and deceleration to stop. So the figure tells us as follows.

  • The acceleration from start to maximum speed is almost constant and common to all angles given.
  • On the other hand the deceleration to stop is dropping stepwise but the pattern is similar to each other angle given.
  • Therefore the time required to stop from maximum speed is about two or three times longer than the time needed to reach maximum speed from start.
  • When the given angle is less than 15 degrees, the maximum speed of this motor is never reached from start to finish.

:

The first three points above mean that Servo Motor executes stopping motion more carefully than to starting. And the last point above means that Servo Motor cannot respond quickly enough to irregular change of angle. So it tells us that rotating speed (as maximum speed in steady turning), one of the most popular performance measure of Servo Motor, is not so critical in this project.

The careful deceleration of Servo Motor to stop is thought to intend to avoid risk of vibration. But this careful deceleration spoils quick response needed for camera gimbal. We can see both delayed starting and dropping deceleration to stopping of Servo Motor in the DOCUMENTARY (3).

:

[DOCUMENTARY (3)] Testing Tracking Speed of Servo Motor

:

Camera gimbal must compensate against irregular rotation of its support. Hence the motor driving it is required not only higher maximum speed but also enough acceleration and deceleration for quick tracking.

From this point of view Servo Motor is thought to be too much careful for avoiding the risk of vibration at the expense of acceleration and deceleration. Though the extent of this trade-off depends on each model of Servo Motor, none provides enough compensation which I have tested. In the DOCUMENTARY (4) below the best Servo Motor among them is used, which has smaller body, higher speed and quicker response. But we cannot recognize that it works adequately in the video.

:

[DOCUMENTARY (4)] The Final Test of Single Axis Servo Gimbal

Step 5: The Articles of DIY Brushless Gimbal in Web

In the previous step it has been made clear that Servo Motor would hardly provide enough compensation for gimbal. So Brushless Motor is considered to be applied to gimbal instead of Servo Motor.

But I had never seen Brushless motor and no special knowledge about it at that time. So I bought a relatively inexpensive one ($22.75) for a research. But I found no paper like manual but a motor in the package. Then I got little information added to use it.

:

Now that things had come to this pass, I referred to websites to search useful information to use Brushless Motor. I found a considerable number of articles and videos about DIY with Brushless Motor. And I knew that special device named ESC or Gimbal Controller is used to drive each Brushless Motor in general.

On the other hand no special device would be used in this project as described in Introduction. Only Arduino should be used to control gimbal. Hence I focused on a rare article featured in Instructables in which neither ESC nor Gimbal Controller is used. Its title "Brushless Gimbal with Arduino" hits the mark of my project. But it is a pity that the gimbal shown in it does not seem to work adequately so the authors say, "we never got the gimbal we were looking for”.

However, their article introduces some other articles consulted. And one of them shows how to rotate Brushless Motor using Arduino (by eLABZ). It gave my project the starting point at that time. The detail of the consulted article will described in the next step. Here the first article referring to it is mentioned.

:

This article in Instructables describes an earlier project executed by two students belong to a university in US. There seems to be three points in common between their project and mine.

  • Both of us want to make a camera gimbal with Brushless Motor work well without special Gimbal Controller.
  • In short we would use only Arduino to control gimbal.
  • But we cannot find no similar project which meets either of these two requirements except ours.

On the other hand their project is different from mine as follows.

  • They use GoPro as mounted camera.
  • They use ready-made set on the market as frame and motors
  • They use the program provided in other website to rotate Brushless Motor
  • They use a special device as gyro module (a MPU6050 carrier)
  • They use the program provided by others to exploit this module

:

Both of us share a goal (Driving Brushless Motor Adequately by Using Arduino Alone without Special Controller) and a situation recognition (Finding No Article Achieving This Goal for Camera Gimbal). And they use rather positively both existing programs provided by others and ready-made set sold on the market.

This approach seems like a strategy such as "Achieving a Unique Objective with Help of Others" or "Getting a General Function with Special Materials or Methodologies". At that time I brought the term in my mind impressively, Horizontal Divisions of Labor (*).

(*) I had heard that Horizontal Divisions of Labor harass Japanese Industry which has advantage in Vertical Integration. The third policy described in Introduction, "Bootstrap: Refer to less websites and finish with no imitation", is felt nearer Vertical Integration than Horizontal Divisions of Labor.

:

Back to topic, in the article in Instructables introduced here a special gyro module is used, which has MPU6050 sensor. This sensor has a special and very powerful function named DMP (Digital Motion Processor). This function provides not only greater noise reduction than standard gyro sensor but also estimate of 3D rotary coordinate system (*1) in real time (*2).

(*1) It is not a rotation around a fixed axis on gyro but a rotation of 3D coordinate system in the fixed system.

(*2) This is not an easy calculation. Hence a famous freeware working in PC, Processing, is used not in real time in my earlier project.

Though the sensor with DMP is amazing, it would be "special device" at the present moment. Therefore I decided not using the module with this sensor in this project. By the way a popular motor driver, L298, is used in this project, which is employed in the article above. I am grateful to the authors of this article.

Step 6: Rotating Brushless Motor Using Existing Programs

Going back to my project, "How to ..." is described here for the first time in this instructable.

In the article mentioned in the previous step authors rotate Brushless Motor by using Arduino. There they refer to an earlier article written by eLABZ. And they use the program provided in it. In the consulted article the author eLABZ explains how to make a Stroboscope with Brushless Motor took out of an old DVD drive.

As far as I know (*), this is the only article that contains the full array of information to rotate Brushless Motor by using Arduino alone. This article is constructed of 3 sections. (*I found another video right now. It has just the minimum information.)

  1. Learning fundamental knowledge of (3-phase) Brushless Motor
  2. Rotating Brushless Motor by using Arduino
  3. Putting materials together to get Stroboscope

:

In the second section above two alternative programs for Arduino are provided to rotate Brushless Motor. I read them and its commentary with an illustration in the article. And I understood that I should just supply three AC voltages which phases are shifted by 120 degrees to the three wires with Brushless Motor in no particular order. Indeed the Brushless Motor I have bought rotates easily with Arduino and an imitation program, which contains the only lines to supply these three voltages to the motor. The DOCUMENTARY (5) shows the Brushless Motor rotates with Arduino only.

:

[DOCUMENTARY (5)] Rotating 3-Phase Brushless Motor with Arduino and AC Square Wave

:

Here I explain how to rotate Brushless Motor by using Arduino UNO. You need to get a 3-Phase Brushless Motor. I think it has three wires.

  1. Connect these wires to pin 9, 10 and 11 on Arduino UNO in no particular order
  2. Download the two pdf files attached at the end of this step to your PC
  3. Open them in proper reader application
  4. Copy the whole of text in either of them
  5. Paste the copy to IDE for Arduino and correct misprints
  6. Upload corrected program to Arduino using IDE

Each of these programs is based on the original one provided by eLABZ. A high-torque-type motor for gimbal would rotate immediately at upload finished. On the other hand some high-speed-type for RC model might not rotate with the power from Arduino. Then some outer battery and motor driver IC should be used. In the DOCUMENTARY (6) below outer batteries and driver IC are used. In the former half of this video a high-torque-type is rotated and in the latter a high-speed-type is rotated respectively.

:

[DOCUMENTARY (6)] Rotating Two Types of Brushless Motor with Arduino, Outer Batteries and Sine Wave AC

Step 7: Testing a Single Axis Brushless Gimbal Using Existing Program

In the previous step we saw that simple programs uploaded to Arduino can rotate Brushless Motor easily. These programs imitate the core of existing programs written by eLABZ. The uploaded programs can be seen once downloading the pdf files attached to the end of the previous step. We can control rotational speed of motor to some extent by changing the value of the variable motorDelayActual in line 1 in these programs.

Here a test bench as a single axis Brushless Gimbal with Arduino is made. And the program for this test bench is prepared also based on one used in the previous step. Please note that the rotational angle of motor is not measured as well as the case with a cheap Brush DC Motor in Step 2. Hence gyro should be attached to the (1) camera side and some proper countermeasure is required to prevent vibration. The DOCUMENTARY (7) below shows the performance of this test bench controlled by the program with standard countermeasure to vibration.

:

[DOCUMENTARY (7)] Single Axis Brushless Gimbal Using 3-Phase Sine Wave AC

:

The test bench can compensate the rotation of its support (or base) roughly in the video above. But some problems are shown as follows.

  • Delayed starting for compensation
  • Unsteady rotation under compensating (pulsatory motion)
  • Some vibration remaining at stopping

So the program uploaded undergoes repeated improvements and tests to resolve these problems. The DOCUMENTARY (8) below shows the performance of the test bench controlled by the finally improved program.

:

[DOCUMENTARY (8)] Improved Brushless Gimbal Using 3-Phase Sine Wave AC

:

The improved program can weaken the problems above at some extent. But it could not seem to work well for the camera gimbal. Also the gimbal with it could hardly work better than Servo Gimbal in Step 4.

Step 8: Copernican Revolution and Brushless As Servo

In Step 5 an article in Instructables is introduced, which describes a challenge to get a 2-axis Brushless Gimbal controlled by Arduino. This challenge is supported by an existing program provided by eLABZ. But as authors recognizing, it is a pity that the gimbal gotten there does not seem to work adequately.

In the previous step I imitated the same original program provided by eLABZ and applied it to the single axis Brushless Gimbal. But it has never worked well in spite of executing any improvements I could think of.

Indeed it is written in the article about the original program that "this circuit was designed for a rather simple application (...) – the load is so light (...). If (...) your motor does not have Hall-effect sensors (many BLDC motors do), then this simplified circuit is not suitable for your application."

:

At the end of my resources, as dejectedly gazing at the gimbal working, it seemed to be quite unreliable as yet. I almost gave up. Then an idea hit me, "The most important here is not to rotate the motor quickly or smoothly but to keep it stopping tightly at the point".

It was felt a revolutionary shift of the goal for me. So I drew a figure simplifying Brushless Motor, and based on it I calculated the best operation to maximize the stopping power of motor at arbitrary angle (*1). Next, I prepared a whole new program to execute the operation and uploaded it to Arduino. Then I saw the Brushless Motor was kept stopping at the objective angle very strongly as never seen (*2). And changing the angle given, the Brushless Motor rotated immediately and stopped at the changed angle tightly again.

(*1) I learned fundamental knowledge of Brushless Motor by referring to an article in the site of Ijima-san (in Japanese). Though it is similar to the article by eLABZ in Step 6, an additional topic is mentioned about alternative connections, Y or Delta. Every Brushless Motor used in this project has Y connection. (At first I had the wrong idea that each motor had Delta connection. But later I found Y connection in the motor disassembled. I appreciate Ramirez_MecaUPQ's question.)

(*2) The earliest calculation was based on the assignment of slots (coils) explained in the site of Ijima-san. But no torque was gotten. After research I found a manual to build Brushless Motor kit (in Japanese). It taught me that there are alternatives among Y or Delta connections.

:

The new operation and program could make a Brushless Motor work like as a Servo Motor. So they were modified to be able to cooperate with gyro. The DOCUMENTARY (9) shows they work well on the test bench and suggests much better performance could be expected than Servo Gimbal.

:

[DOCUMENTARY (9)] Brushless Motor Made Work Like as Servo Motor

Step 9: Making a Precision Single Axis Brushless Gimbal With Arduino

The new operation introduced in the previous step would make it possible to get a Brushless Gimbal with Arduino of practical use. Now a Brushless Motor can work like as a Servo.

In this operation gyro can be attached to the (2) support side. The test bench prepared in Step 7 becomes a new single axis Brushless Gimbal under this operation. In the DOCUMENTARY (10) below the new gimbal equipped with a camera is tested.

:

[DOCUMENTARY (10)] The First Brushless Gimbal Operated by the New Program

:

In the video above we can see the performance of the new single axis Brushless Gimbal from two viewpoints like DOCUMENTARY (4) in Step 4 with Servo Gimbal. Now we can recognize that the new Brushless Gimbal works better than Servo Gimbal in Step 4 though the new one has some rough compensations as yet. Fortunately we have still several rooms for improvement such as value selection for parameter set in the program.

Also we can get some additional data by attaching another gyro to the (1) camera side of the gimbal. Indeed comparing data from both gyros I have understood there are three matters remaining.

  • Time lag at the start or the end of compensation
  • Attenuating shake at the start or the end of compensation
  • Angular shift after compensation: Uncompensated shift remaining

Among these three matters the second would be resolved by the standard PD control using the added gyro in the operation newly. Also the third is thought to be resolved by giving proper values for parameter set or using the added gyro. In the DOCUMENTARY (11) below we can see the effectiveness of exploiting the added gyro in the operation.

:

[DOCUMENTARY (11)] Effectiveness of Exploiting Added Gyro in the New Operation

:

In the video above we can recognize that each of the three matters seen in the previous video (10) can be much improved respectively by exploiting the gyro added. And we have still other rooms to improve.

For example the power supplied to the motor is about 5V in these videos above though the recommended voltage is 11 to 15V. In the DOCUMENTARY (12) below four more AA batteries are added to supply enough power to the motor and the values of parameter set are adjusted.

:

[DCUMENTARY (12)] Effectiveness of Adequate Power Supply to Motor

:

In the video above we can see that the first problem, "Time lag at the start or the end of compensation", is weakened so much under the enough power supplied. Now we should move from the stage using the test bench as single axis gimbal to the next stage making 2-axis gimbal of practical use.

Step 10: How to Make the Single Axis Brushless Gimbal With Arduino

Before moving the next stage where 2-axis gimbal is made, I show here how to get the DIY single axis Brushless Gimbal with Arduino which works in the DCUMENTARY (12) in the previous step. To avoid the long recipe I suppose readers here have enough experience with Arduino and gyro such as my earlier project.

:

[Materials]

  • 3-phase Brushless Motor for gimbal (x1): Limited to 14-pole, 12-slot (Though both Y and Delta connection are acceptable, assignment of slots have to be same as the figure shown in this manual.)
  • Arduino UNO (x1)
  • L3GD20 gyro chip carriers (x2): SPI interface with 4 lines (*1)
  • AA batteries (x4-8)
  • L298 motor driver (x1)
  • Plates (x2): For the support of gimbal and the camera mount
  • Others: Popular stuff for work with Arduino

(*1) I used Akizuki’s carrierhere. I know another L3GD20 carrier produced by Pololu. The latter is available also outside Japan. If it were used instead of the former, the picture with schematic above should be viewed.

:

[Program (or Sketch)]

  • Download the pdf file attached at the end of this step
  • Open it in a proper reader application
  • Copy the whole of text in it
  • Paste the copy to IDE for Arduino and correct misprints
  • Upload corrected program to Arduino using IDE
  • Though this sketch is optimized for Delta connection, it is applicable for Y connection
  • The sign of output of the secondary gyro at the (1) camera side depends on the manner to attach it
  • If the gimbal does not stop nor compensate but rotates the wrong direction (*1), try the last point of "Wiring" below first
  • If the gimbal still does not work well, the two lines commented out in this program should be made effective instead of commenting out the alternative two lines, A and B
  • If the gimbal still does not work well, try the last point of "Wiring" below again

:

[Wiring]

  • See the figure at the top of this step and follow it
  • Three wires with Brushless Motor are connected to pin 3, 5 and 6 on Arduino UNO in arbitrary order
  • If the gimbal does not stop nor compensate but rotates the wrong direction (*2), change this connection appropriately

(*1, *2) To make the gimbal work well, both of outputs of gyros and wiring have to be set correct. Sometimes the output of gyro might become abnormal in spite of correct setting. Then cut the power off to Arduino and gyros once.

:

[Calibration]

  • Reset Arduino
  • Don't touch the gimbal for 6-10 seconds: Keep both gyros still

:

The rough flow of the program in the attached pdf file below could be understood by seeing it on a block-by-block basis. On the other hand the details of some blocks might be not so clear. It needs much more steps to explain them. If many requests were gotten in future they might be told in another story.

Step 11: Making the 2-Axis Brushless Gimbal With Arduino

We have gotten the single axis Brushless Gimbal with Arduino on a test bench, which works as expected at the start of this project. Now the multi-axis gimbal of practical use should be made. Here 2-axis Brushless Gimbal with Arduino is made and tested.

It compensates un-intended rotation around two axes: TILT (looking up/down) and ROLL (rotating horizontal line). It needs two motors and six pins with PWM. So in this step a richer Arduino board, MEGA, is used instead of UNO. The main materials to build the frame of this gimbal are plastic plates and stainless steel brackets. The former plate is a goods for hobby named "Universal Plate". It has many regular pinholes and needs no special tool to be cut and so on.

:

The next two points take much time to build the frame.

  • Hunting good material for camera mount
  • Installing a pair of pin and pinhole for the TILT axis

In the former, some steel flat bar with regular pinholes is looked for, which is suitable both to the center of gravity of the camera and to the existing pinholes on the frame. On the other hand the latter work is required to be equipped with a camera bigger than GoPro.

Generally a Brushless Motor works as a good pair of pin and pinhole on arbitrary axis. It supports a cantilever by itself. So an ultra-lightweight camera like GoPro could be mounted on a cantilever with few problems. But cantilever could not support a bigger camera well. Hence a pair of pin and pinhole should be installed on the axis at the opposite side of the motor across the camera. The pin, pinhole and the motor should provide a good pair of fulcrums on the TILT axis to rotate camera smoothly without little backlash.

:

Once the frame is built, the 2-axis Brushless Gimbal with an augmented program for two axes becomes available to test. This naive gimbal has two problems as follows. The detail and the cause of them, and the countermeasures to these problems are described in the final step.

  • Chattering of the frame
  • Biased output from gyro to Arduino: Disturbance on SPI interface

Most of electrical components of the gimbal made here are plugged into a solderless breadboard and connected to Arduino, gyro or motors by jumper wires as yet.

In the DCUMENTARY (13) below we can see the 2-axis gimbal tested here is working, which is given some countermeasures to the problems above and allowed intentional TILTing additionally. In this video the gimbal seems to work well.

:

[DCUMENTARY (13)] 2-Axis Brushless Gimbal with Arduino Working (1)

:

On the other hand, in the DCUMENTARY (14) below, we can observe not only the gimbal working but also film shot by the camera on the gimbal in one picture. This video shows that there remains some room to improve for the compensation to ROLL (rotating horizontal line).

:
[DCUMENTARY (14)] 2-Axis Brushless Gimbal with Arduino Working (2)

Step 12: Making the 3-Axis Brushless Gimbal With Arduino

The two problems met in making the 2-axis gimbal in the previous step, Gimbal Chattering and SPI Disturbance, are able to be weakened by some conventional symptomatic treatments. Their details are described in the final step. And the room to improve observed in DCUMENTARY (14) could be resolved or reduced by adjusting values of parameter set in the program.

So here, the third Brushless Motor is attached additionally to the top of the frame of the gimbal, which could compensate un-intentional rotation around the axis for PAN (looking at right/left) newly. Next, electrical components are moved from a breadboard to a DIY Shield for Arduino MEGA.

At the same time, the program is augmented again to compensate the un-intentional PAN and to allow the intentional PANing. And the values of parameter set in the program are adjusted to reduce the room for improvement observed in DCUMENTARY (14). Now the DIY 3-axis Brushless Gimbal with Arduino for practical use has been gotten. Its performance can be seen in the DCUMENTARY (15).

:

[DCUMENTARY (15)] 3-axis Brushless Gimbal with Arduino Working

:

In the video above the camera mounted on the 3-axis gimbal shoots itself in front of a mirror. We can see both the gimbal working and the stability of mounted camera. As comparing this video with the DCUMENTARY (14) in the previous step, it is clear that the compensation for un-intentional ROLL is much improved in this step. This is the moment to go out with the gimbal and shoot various scenes to see its performance.

Step 13: Shooting With DIY 3-Axis Brushless Gimbal

We can see new matters in outdoor shooting, which are met with hardly in indoor testing. Therefore the values of parameter set are needed to be adjusted repeatedly again by shooting after shooting. We can see the films shot for this adjusting in the DCUMENTARY (16) below. There we should remember that a gimbal cancels out some rotation but it does not compensate any parallel shifts. Hence the vertical (up-and-down) motion in walking is not subject to compensation in the videos below.

:

[MAKING VIDEO (16)] Films Shot in Outdoor for Fine Adjusting

:

In the adjusting above, the main issue is the adequate compensation for the un-intentional ROLL. Watching a horizontal line in distant view in the video above, the degree of its rotational stability is different between scenes (shot under different values for parameter set).

The DCUMENTARY (17) below is a film shot in the adjusting also. It is good to see the performance of the gimbal adjusting here, because it has more stable compositions where the motion of horizontal line is observed well and it has a scene of battery is dead suddenly.

:
[DCUMENTARY (17)] Film Shot in Outdoor for Fine Adjusting (Shooting Forward/Backward)

:

On the other hand the six videos below are films shot with some adjusted values for parameter set. In the first one, SAMPLE (1), intentional PANing is used so frequently that we can see its effect well. The second SAMPLE (2) is uncut video shot by going up and down the stairs at a quick pace. And the rest videos, SAMPLE (3) to (6), have scenes shot under so various conditions that they would give us good information to estimate the efficiency of the DIY camera gimbal gotten in this project.

:

[SAMPLE (1)] Effect of Intentional PANing (Turning 540 Degrees)

:

[SAMPLE (2)] Up and Down Stairs (From Running to Quick Steps: Uncut)

:

[SAMPLE (3)] Walking in a Park (Flowers and Persons)

:

[SAMPLE (4)] Walking on Dirt Path in Woods

:

[SAMPLE (5)] Uncut of the Gimbal Working from Power On to Off

:

[SAMPLE (6)] Low Angle Shooting

Step 14: Room for More Improvement

I have shown a story getting the DIY 3-axis Brushless Gimbal with Arduino of practical use. As searching web, there are few sites which describe driving Brushless Motor using only Arduino without other special devices. And it is a pity that the rare program provided in a precious article describing it has turned out to be unsuitable for the camera gimbal. (See Step 7.) Therefore I have prepared a new program independently and developed the DIY gimbal in order of single, two- and three- axis while augmenting the program.

The policies shown in Introduction, finishing this project with no imitation and no special device, seem to be kept finally. On the other hand I don't know the merits and demerits of this DIY gimbal well because I have not seen camera gimbal except for it. Here I describe the left room for improvement at the end of story.

:

(1) High Frequency Noise

The program prepared in Step 8 makes Brushless Motor have strong torque in stopping or rotating. But the operated motor generates noise around 500Hz continuously. This noise has little negative effect to the picture of video. But recorded sound is so contaminated by it.

(* Added: )
It was found that the coils in Brushless Motor generate this noise by PWM pulse applied. The noise can be shifted into non-audible range (31kHz) with making the frequency of the pulse higher. It can be done in Step10 by correcting two points below. I appreciate the comments of EricL50 and ThaddeusW3.

Change Arduino-pin assignment in both the wiring and the sample program.
 Pin8 > 5
 Pin9 > 6
 Pin5 > 9
 Pin6 > 10

Add four lines below in “setup { }” in the sample program.
 TCCR1B &= B11111000;
 TCCR1B |= B00000001;
 TCCR2B &= B11111000;
 TCCR2B |= B00000001;

The video Sample(7) below was shot with the modified sketch. The high-pitched loud noise cannot be heard in it. The values of parameters in the sketch should be adjusted again to keep good compensation in this modification. There seems to be room for it still. The next video Sample(8) was shot with adjusted parameters. We can recognize higher stability even though shot in a high wind.

:

[SAMPLE (7)] Noise Eliminated

[SAMPLE (8)] Parameter Adjusted for Noise Eliminated Version

And long Shots for 15 minutes: TEST(1), TEST(2), TEST(3)

:

(2) Chattering of the Gimbal Frame

I met with the persistent chattering of frame in the stage where the 2-axis gimbal of practical use was made from the single axis test bench. In contrast to the noise above, this chattering negatively effects picture. In the video shot with this chattering, the shape of object undulates. Though I do not know the accurate frequency of the chattering it is felt like about 50Hz. As touching some point of the frame by a finger, this chattering stops immediately. But it would disturb gimbal working.

:

[DCUMENTARY (18)] Disturbed Picture Caused by Gimbal Chattering

:

Though the root cause of this persistent chattering is not clear, the function of vibration damper in the sketch to compensate unintended tilting causes it. In this project the chattering is reduced by some conventional symptomatic treatments as follows. But more drastic measures are required for the fundamental solution such as improving frame rigidity and so on.

  • Adjusting values for parameter set in the program: Loosening compensation a little
  • Lowering power: Decreasing supply voltage to motor (7.5V) at two thirds of the lower level recommended one (11 to 15V)
  • Increasing size of the handle and attaching some brackets to it: Absorbing the vibration by the palm or changing the natural frequency of the gimbal by clutching bigger handle with brackets tightly.

:

(3) Un-intentional ROLL Still Remaining

When seen from the outside, the DIY gimbal seems to compensate enough against the un-intentional rotation of its support. But seen from the mounted camera, the rotational stability of a horizontal line is not perfect. It is thought important to improve it that the following matters are resolved.

  • Inappropriate values for parameter set in the program: Loosening compensation to reduce the gimbal chattering
  • Insufficient power supply: Decreasing supply voltage to motor at two thirds of the recommended one to reduce the gimbal chattering
  • Discrepant coordinate system between gyros and frame of gimbal

The first two matters come from the conventional countermeasure against the gimbal chattering. Then the fundamental solution to the chattering is required here also. On the other hand the last matter concerns the calibration of gyro.

The program prepared to control the gimbal in this project is assuming that all four gyros and frame of gimbal have the same coordinate system (or the same three orthogonal axes). But in reality, each of them should be thought specific (*) and the three axes of each system would not be orthogonal strictly. It is possible to know the posture of each system of gyros comparing with the system of the frame. But it does not seem to be so easy and its cost-effectiveness is not clear. Hence it has not been executed in this project as yet.

(*) No special measuring or adjusting has not been done when the four gyros were attached to the frame of the 3-axis gimbal.

:

(4) Disturbance on SPI interface

The outputs of gyros are transmitted to Arduino by SPI interface in this project. Though it is used for a short range communication between digital devices, there ought to be no problem within three feet of distance. Indeed few matters has been met with while the electrical materials are plugged into a breadboard and connected to Arduino by jumper wires. But after replacing these jumper wires with ribbon cables, the behavior of the gimbal has become abnormal.

For a while (some days) the cause has not been unknown at all. Through a considerable process of trial and error it was made clear that SPI interface is sometimes disturbed when some special lines is put close. Especially the disturbance occurs very often when Clock-line (SCK) is brought near Output-line (MISO). No article which describes such a phenomenon has been able to be found. Hence it is thought that this is a specific problem between Arduino and the gyro sensor used here. Though the true cause has not been known, the problem can be resolved by choice the proper combination of bundled wires.

<p>Hello ArduinoDeXXX,<br>I've read your wonderful instructable on making a gimbal brushless, and I have been able to make one working on two axis (x and y). But I have come across a problem that I can't solve :</p><p>My start position for having setup leveled is different than yours, and when I modify the following lines in void calibrate :</p><p>analogWrite(motorPin1, 217);</p><p>analogWrite(motorPin2, 0);</p><p>analogWrite(motorPin3, 255);</p><p>with my values (0, 210, 255 for x-axis motor and 255, 188, 0 for y-axis motor)</p><p>it goes to the correct position for the calibration but returns to the previous position after that. <br>(see in the video, the calibration position (0, 210, 255) 00:01-00:03<br>and then the return to &quot;standard position&quot; (217, 0, 255) when in the main loop 00:04-00:07.)</p><p></p><a href="https://www.youtube.com/watch?v=kCzqO0uaX04" rel="nofollow">https://www.youtube.com/watch?v=kCzqO0uaX04<br><br></a><p>I feel like I need to change something in the nLinePwm calculations but despite reading the comment you made to &quot;game123&quot; I don't really know what to change to make it keep the new start position.<br><br>Thanks for the help!</p>
<p>In &ldquo;void loop( )&rdquo; in the sample sketch in Step10, the degree to rotate BLDC is decided by variable &ldquo;deg1000&rdquo; in the first function &ldquo;chkAndCtl( )&rdquo;. And the value of &ldquo;deg1000&rdquo; decides PWM output as variable &ldquo;variPwm&rdquo; in the the second function &ldquo;calcPwms( )&rdquo;. The angle of BLDC rotating can be shifted by adding a constant to &ldquo;deg1000&rdquo; between these two functions. See below.</p><p>chkAndCtl( );<br>deg1000 = deg1000 + 12345;<br>calcPwms( );</p>
<p>Oh yes I didn't thought of adding a constant there...<br>Now the position is correct !<br>Thank you so much =)</p>
<p>hi ArduinoDeXXX!</p><p>i see your project is very good, and i like it</p><p>so i made my own, but i am using other sensor</p><p>i just don't understand with deg1000 's value, if this value from reading the sensor</p><p>what kind of that value? is it degree or RAW data?</p><p>i'm sorry for my english, thanks before</p>
<p>Variable deg1000 represents 1000 times of the degree to rotate BLDC. You can find some topics about it in the comments below.</p>
<p>thanks for your reply!</p><p>so that you mean value from deg1000 is the actual angle*1000?</p><p>for example the value of reading sensor is 90 degree, so deg1000 now is 90000?</p>
<p>Yes. See the comments of EricL50 and replies for them posted about 2 years ago. You can know more detail.</p>
<p>i see thank you very much!</p><p>and i think your program is fixed program, i mean fixed constant value</p><p>when i use your program, i just get a little bit something error, so i try to setting with change the value of that constant value, like LnLvl10 and slope1000 and the other. But it didn't make a change. Actually where is the value that i can setting or tuning in your program? </p><p>like if i use PID control, that i can tuning by set the value of Kp,Ki, or Kd</p>
<p>Two sample sketches attached in Step6 could work with any 3 phase BLDC motors. On the other hand, the sample sketch attached in Step10 should be limited to 3 phase BLDC motors with 14-pole/12-slot. Though it could work with many 14-pole/12-slot BLDC motors, it might not work with a special Delta connection. However I have never been told such one. See Step8 and early comments of Ramirez_MecaUPQ and replies which contain pictures.</p>
<p>here i using same motor with 14P12S</p><p>and when i upload your program in step10 without any load,it work so well</p><p>but when the load is placed, it won't stop at the point and also make a little shake</p><p>it has same result when i reduce the load with the thing that not heavy enough like the load before.</p>
<p>If your BLDC is the same model shown in Step5 or its successor model, the sample sketch in Step10 ought to work well. It holds rotator of BLDC strongly at a point when three PWM values are kept constant like &ldquo;217, 0, 255&rdquo;. If not, breaking of wire in BLDC is suspected. See earlier comments about this topic.</p>
<p>thank you</p><p>i will try to fix it</p>
<p>Hi ArduinoDeXXX!</p><p>I bought this motor: </p><p><a href="http://www.hobbyking.com/hobbyking/store/__45366__Turnigy_HD_3506_Brushless_Gimbal_Motor_BLDC_.html" rel="nofollow">http://www.hobbyking.com/hobbyking/store/__45366__...</a></p><p>But when I use your code (DOCUMENTARY 6) my motor behave like on movie:</p><p><iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/3A-7pYXajS0" width="500"></iframe></p><p>(it isn't smooth)</p><p>Can you help me and say why it is so?<br><br>Thanks! :)</p>
<p>It is hard to make BLDC rotate slowly and smoothly with the sample sketches attached to Step6. You will execute it with the sample sketch attached to Step10. See the comments of <a href="https://www.instructables.com/member/vonkross" rel="nofollow">vonkross</a> and the replies to them (*).</p><p>(*) The hyper link to earlier comment (under &ldquo;More Comments&rdquo; button) doesn&rsquo;t work well.</p>
<p>Hi! Thanks for your reply! :)</p><p>I made some progress, now my &quot;gimbal&quot; works like your in DOCUMENTARY 9 (its shaky)<br><iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/iVfkgJo3eFQ" width="500"></iframe></p><p>But i can't understand how you improved gimbal by adding second gyro,<br>with single gyro I know that I need eg. 10degree, currenty is 50, my error is 40degree so a need to compenaste this, but how is it works with two gyros?<br><br>Have you done some other improvements?<br><br>Thank you! :)</p>
<p>Hello Tomasz, </p><p>would you please upload the sketch you used for this video :) Thank you!!!</p>
<p>In your video, a small shake of camera is observed at the end of compensation (such as 0:04-0:06). The shake of camera is observed in the video, DOCUMENTARY (11), in Step9 at 1:51-1:58 also. There the secondary gyro attached to the camera-mount does not work. On the other hand, the shake does not appear in the same video at 2:14-2:24. There the secondary gyro attached to the camera-mount works to counteract the shake.</p><p>I think you can get good answer by yourself when you complete your gimbal and execute trials and error in practice.</p>
<p>I finally go it!<br>Thank you very much ArduinoDeXXX! :)</p>
<p>Wow, a great effort and very detailed report! Thanks!<br>Once we made a similar project, but it turned out that atmega328 isn't enough to handle 3-axis stabilization at proper speed (it wasn't able to compensate for really fast vibrations), so we switched to stm32 instead. Gimbal chattering was almost completely gone (appeared only in some very special positions) when we managed to complete feedback cycle in less than 1 millisecond. On atmega it was around 6 milliseconds, and I'm almost sure it isn't possible to completely get rid of chattering at such speed.</p>
<p>Thank you for your good comment. I also have suspected that Arduino Mega with ATmega2560 does not have enough power for my DIY gimbal. Hence I have gotten Arduino Due which has ARM Cortex-M3 CPU in AT91SAM3X8E.</p><p>I have corrected the original sketch for Mega to work with Due. Though it works well with default PWM frequency, the loud noise is heard. I am searching a good code for Due which can change PWM frequency higher to shift the noise into non-audible range (31kHz) with no trouble.</p>
<p>Due is fast enough, but I highly doubt you can find good enough PWM library for it (actually I don't know a good library even for atmega328, have to write registers directly anyway). Your best shot is to go through its datasheet, and find out how to switch timers into PWM mode using their registers. But it is quite complicated, I just took a look here: <a href="http://www.atmel.com/Images/Atmel-11057-32-bit-Cortex-M3-Microcontroller-SAM3X-SAM3A_Datasheet.pdf" rel="nofollow">http://www.atmel.com/Images/Atmel-11057-32-bit-Cor...</a> - and pages from 970 describe its PWM module, can't even really understand how to make it (on page 996 there is &quot;simple 19-step guide&quot; and pages 1003-1006 describe &quot;user interface&quot; registers).<br>STM32 is so much easier with their HAL library! After stm32Cube makes all initialization code for you, controlling timer takes just a few rather intuitive lines. I really recommend to try it (there are a lot of Nucleo and Discovery boards with stm32F0, F1, F3 and F4 series processors, here F1 is optimal, F4 is much more powerful, but also somewhat more complicated)</p>
<p>Thank you. I appreciate your suggestion. I get a good alternative.</p><p>I have looked for topics in web about changing PWM frequency of Due. Then I found <a href="https://forums.adafruit.com/viewtopic.php?f=25&t=52859" rel="nofollow">a forum about it</a>. A very simple way is described in it. It tells that all we should do are simple changes in <strong>variant.h</strong> in the Arduino library.</p><p>However I cannot find variant.h in my old IDE or the latest version in web. I have downloaded earlier versions between the former and the latter. At last I found it in IDE 1.6.0 and 1.6.1. Why it cannot be found in the later versions?</p><p>I felt something disquieting. I stopped and left it for other new projects. I am going to come back to variant.h when these new projects are finished.</p>
<p>I'm finding it difficult to source the L3GD20 sensor. You mention the MPU6050 sensor in your instructable. These are much more readily available in my area. If I were to replace the L3GD20 sensors with MPU6050 sensors, would the gimbal require any additional components or amendments to your code? Or would it be a straightforward exchange?</p>
<p>MPU6050 has a powerful engine called &ldquo;DMP&rdquo;. See Step5. It does not seem as simple as described in Introduction. Hence I did not use it in this project.</p><p>Though you can use it as a simple gyro module without activating DMP, I think you will get a problem. It seems that the protocol for MPU6050 is restricted to I2C, and only two addresses, 0x68 and 0x69, are allowed for MPU6050. A pair of gyro modules is required for each axis in this project. It means that you can make only single axis gimbal if you use a MPU6050 as a simple gyro module.</p><p>I think you should activate DMP if you use MPU6050. However you have to learn how to use DMP additionally, and I have never used it.</p>
<p>Hi :D</p><p>I'm trying to reply your project using my hardware but I don't understand how to change the phases of brushless motor according to the angle detected by the gyro. I've read your program but I didn't understood the meaning of your operation.<br>Thanks!</p>
<p>Hi,<br>I have gotten several comments like you ever. <a href="https://www.instructables.com/member/Abil%20FidaA" rel="nofollow">Abil FidaA</a>, <a href="https://www.instructables.com/member/ericlo_00" rel="nofollow">ericlo_00</a>, <a href="https://www.instructables.com/member/EricL50" rel="nofollow">EricL50</a>, <a href="https://www.instructables.com/member/vonkross" rel="nofollow">vonkross</a>, <a href="https://www.instructables.com/member/KhalilY3" rel="nofollow">KhalilY3</a>, <a href="https://www.instructables.com/member/AndreaM157" rel="nofollow">AndreaM157</a> and others posted them. See these earlier comments and replies to them.</p>
<p>Hey!</p><p>Where can I find the modified sketch for the 3 axis gimble?</p><p>I can only seem to find and download the sketch for single axis gimble.</p><p>Thanks!</p>
<p>Hi, <br>My DIY 3-axis gimbal is very special for my own development. And its sketch is special, too. However the core of the program of multi-axis gimbal here is not different from the single axis one. See Introduction. All sketches I can provide at present are attached here.</p>
<p>Hi ArduinoDeXX,</p><p>At the first happy new year and more wonderful project here!! :-)</p><p>I wish to know how are the possible issues to apply your project on a large DSLR camera gimbal. </p><p>Thank you for a reply.</p><p>GianK</p>
<p>Happy New Year,</p><p>I think this article would work for making a DIY large DSLR camera gimbal. However it would need several points to be reinforced.</p><p>(1) Replace BLDC motor(s) with more powerful one.<br>Heat sink(s) might have to be attached to driver IC(s).</p><p>(2) Build a more rigid frame with aluminum or carbon fiber plates.</p><p>If you are NOT a very DIY Hobbyist, I think you should buy a suitable gimbal on the market.</p>
Thank you for your quick reply.<br>I'm an R/C hobbyst and i know the building difficulties too! :-)<br>Your suggestions are appreciated thank you! :-)<br>
<p>hi, ArduinoDeXXX</p><p>can you describe your PID control please?</p><p>I have a job from my collage to make that project, can you help me</p>
<p>Hi,</p><p>See the earlier comments of <a href="https://www.instructables.com/member/edward.chamberlain" rel="nofollow">edward.chamberlain</a> and its reply.</p>
<p>sry,</p><p>but i want to ask, i use MPU 6050 for make a project stabilizer servo dynamixel robotis.</p><p>i had fusion gyro and accelerometer use complementary filter and than i had problem to use PID for servo.</p><p>do you have PID formula for my problem? :)</p>
<p>I feel that it is not easy to drive servo motor with PID control. See Step 3 and 4 in this article.</p><p>And I have posted two articles for making a self-balancing robot with a gyro. See my page in Instructables.</p>
<p>do you have code for self balancing pwm servo?</p>
<p>No, sorry.</p>
<p>thank you for fast respon than another</p>
<p>Hi, ArduinoDeXXX</p><p>for this holiday i decided to create this project. and this is my first time doing arduino project. so far i learned so much stuff from your project (arduino ide,brushless and sensor). and btw im completely begginer in electronic diy</p><p>i want to ask about my motor, i tried your test code</p><p>------------------------------------------------------------------------</p><p>void setup () {<br>pinMode(9, OUTPUT);<br>pinMode(10, OUTPUT);<br>pinMode(11, OUTPUT);<br>}<br>void loop (){<br>analogWrite(9, 0 );<br>analogWrite(10, 255 );<br>analogWrite(11, 0 );<br>delay(1000);<br>analogWrite(9, 0 );<br>analogWrite(10, 255 );<br>analogWrite(11, 255 );<br>delay(1000);<br>}</p><p>------------------------------------------------------------------------</p><p>my motor http://rctimer.com/product-1075.html spin when i upload the test sketch even without external voltage supply. but when i upload your sketch</p><p>at documentary six &quot;BLDC_with_3phase_square.pdf&quot;, my motor wont spin,it only jerk a little. my motor also have 12N14P , i thought the code will work but it doesnt. can you help me about this?</p><p>i've only learn about matlab programing, so im clueless about your BLDC3phasecodesquare.</p>
<p>Only the output of pin 11 changes from ON to OFF with 2-second cycle in your sketch. You can view what it means by seeing <a href="http://elabz.com/brushless-dc-motor-with-arduino/" rel="nofollow">eLABZ&rsquo;s site</a>.</p><p>Assume that terminal A (red), B (blue) and C (green) of BLDC are connected to pin 9, 10 and 11 in arduino respectively. The slots with red line continue N-(or S-)poles, while the slots with blue line continues S-(or N-)poles. Only the slots with green line change N-poles to S-poles cyclically. It looks like &ldquo;thin out&rdquo;.</p><p>Your BLDC may turn with the sample sketch in Step 6 increasing the value of &ldquo;<em>motorDelayActual</em>&rdquo; such as 500 or 1000.</p>
<p>Hi! I was wondering if you could give me a brief description of what you are expecting from the gyros during your calibration on the single axis stabilization? I am trying to use your instructable to create my own but I am working with I2C rather than SPI</p>
<p>The gyroscope chip L3GD20 used here has temperature sensor in itself also. Hence it could output zero in a static state automatically. But a little bias remains in practice. The function &ldquo;void calibrate(){ }&rdquo; detects it. The first three lines give the initial position to the BLDC at the zero output.</p>
<p>OK so it is essentially finding the angular velocity error in the gyro?</p><p>I have another question regarding the later routines. What sort of values are you expecting for deg1000? The reason I ask is that I am using a Adafruit breakout board with the same gyroscope built in, and this produces angles to two decimal places. Therefore have edited your code to produce</p><p><strong>void getAngle() {</strong></p><p><strong> omega = 0;</strong></p><p><strong> i = 0;</strong></p><p><strong> for (i = 0; i &lt; 4; i++) {</strong></p><p><strong> gyro.read();</strong></p><p><strong> omega = omega + gyro.data.z;</strong></p><p><strong> delayMicroseconds(25);</strong></p><p><strong> }</strong></p><p><strong> omega = (omega - Z) / 4;</strong></p><p><strong>// Serial.print(&quot;Angular Velocity: &quot;); Serial.print(omega); Serial.print(&quot;\n&quot;);</strong></p><p><strong> timeElapsed = micros() - timeElapsed;</strong></p><p><strong>// Serial.print(&quot;Time: &quot;); Serial.print(timeElapsed); Serial.print(&quot;\n&quot;);</strong></p><p><strong> theta = theta + ((omega - prevOmega) * timeElapsed) / 1000000;</strong></p><p><strong>// Serial.print(&quot;Angle Turned: &quot;); Serial.print(theta); Serial.print(&quot;\n&quot;);</strong></p><p><strong> timeElapsed = micros();</strong></p><p><strong> prevOmega = omega;</strong></p><p><strong>}</strong></p><p>Which should do the same job as your chkAndCtl() routine. Unfortunately I can't make calcPwms() as I feel that we are using different scales (I am using floats for omega here where deg1000 is a long for you). Thanks ArduinDeXXX!</p>
<p>To keep the computation speed higher, &ldquo;int&rdquo; or &ldquo;long&rdquo; is used as data type instead of &ldquo;float&rdquo; in the sample sketch. And to keep accuracy higher, each data is increased by 10, 1000, &hellip; or 1000000 as necessary. The variable &ldquo;deg1000&rdquo; expresses the increased degree of angle to rotate by 1000.</p><p>Though I don&rsquo;t know the scale or data type of the output of your gyro module, I think that the correction below should be tried in your sketch.</p><p>&ldquo;<strong>theta = theta + ((omega + prevOmega) * timeElapsed) / 2000000</strong>&rdquo;</p>
<p>Hi ArduinoDeXXX,</p><p>In your code</p><p><strong>thetaMa = thetaMa + ( - (omegaDa+recOmegaDa)/20 ) * recMicros; // Line A</strong></p><p>May I ask why the average of omegaDa and prevOmegaDa needs to be divided by 10?</p><p>Thanks</p>
<p>As it is feared that floating point arithmetic needs longer time, Integer is used here. Hence scale-up is needed for some variables to keep good precision. &lsquo;D&rsquo; means &ldquo;deca&rdquo; by ten times up.</p>
<p>Hi, I managed to get my gimbal operating on one axis, thanks so much for your help!</p>
<p>Hi,</p><p>Thanks a lot for sharing this awesome project !</p><p>However I didn't manage to find the sketch for the 3 axis gimbal if you uploaded one. Did you ?</p><p>Thanks for your help :)</p>
Hi, ooboob<br> As described in the introduction &ldquo;<em>How to make &hellip;</em>&rdquo; is told just about the single axis gimbal. That is because &ldquo;<em>the core of the program of multi-axis gimbal here is not different from the single axis one</em>&rdquo;. The former is much depends on the body of gimbal you make. I hope you get your own multi-axis one referring to my story.
Alright I see!<br>i'll let you know about my build when I will get it to work thanks for your hints.

About This Instructable

147,614views

414favorites

More by ArduinoDeXXX:A Levitating Sphere Rotates Glows and Blinks with Arduino Arduinoで作る浮遊光球 Another Easier Inverted Pendulum Robot 
Add instructable to: