loading

Let's make a simple inverted balancing robot, and operate it.
You need only half a day to do them, if you have an arduino and some materials.

[a video of a robot you would make]


introduction:
After a few work with arduino, I have thought of making an inverted pendulum. Then I had two policies for the project.

  • simple as possible
  • bootstrap (without referring to website)

Though they has been kept (*1), it has demanded more than whole a week to make my robot balance itself. So simplicity of my robot seems to be held in its body, circuit and program (called "sketch"). It has only an analog gyro-module (at $4 (*2)), two plane motors (at $1.5) and two analog ICs (at $1.5) to drive these motors.

(*1) I have referred websites for two matters; a formula for inverted pendulum and a troubleshooting the gyro-module I used.
(*2) 100 JPY = 1 USD I use as exchange rate.

A solderless breadboard in a picture above would show its simplicity. And a video thereunder shows it works well enough.

One who has made a LED blink with arduino ever could assemble her/his inverted robot in half a day or less according to my recipe below. But I think it is similar to solving a puzzle to make it balance on its wheels. Thus I show a solution in three steps not to spoil a puzzle. I wish videos and pictures could cover my poor English.

* A Japanese version of this instructable is available also.

** Additional information, Aug. 20 2014:
A simpler alternative program, ver2.0, has been available in Step 5.

*** Another version has been published later, in which a digital output gyro sensor produced by STMicroelectronics is used instead of two analog output sensors. It is easier to get the digital gyro outside Japan. And the fine soldering in Step 2 is not required for the digital gyro.

Step 1: Gather Materials

Body (using TAMIYA's Educational Construction Series)


Electrics


[tutorial for Step 1]


[commentary 1]
I have felt that analog gyro-module listed above has individual difference. So I think it better to purchase two or three modules together. And as showing in Step 11, an additional module could make robot work more stably.

[commentary 2]
If it is hard to get the gyro-module listed above, similar one with the same analog sensor (ENC-03R) might be substituted. For example a module sold online would be available. (Its price is near 4 times to Akizuki's one.) Though it seems to have op amp, the factor scale to amplify I cannot find.

Step 2: Solder Wires to Some Components

First you should solder wires to some electrical components.

  1. solder wire to each point of 2 motors (4 points in all)
  2. cut 4 jumper wires in half (8 half jumpers gotten)
  3. solder these half jumpers to 8 wires of 2 motors and 2 battery snaps
  4. cover each point soldered with chip of tape for insulation
  5. solder header pins to an Akizuki's gyro-module
  6. solder a fine wire to either point of a capacitor "C6" on this module


[tutorial for Step 2]


[note 1]
An Akizuki's gyro-module listed above has 2 analog gyro-sensors on its surface. Either sensor is "ENC-03R" made by Murata-seisakusyo. Only one of them is used for inverted robot. This sensor outputs 0.67mV per unit angular velocity (1deg/sec) and it is amplified to ten times with a op amp on the reverse face of the module. (Vo at pin 1 of this module is 6.7mV/dig/sec.)

But this module picks up not only angular velocity but also angular acceleration by its filter (HPF). Capacitor C6 on this module is a main element of HPF. To avoid picking up the latter, soldering a wire to this capacitor is done.

Step 3: Assemble a Body of Robot

To build a body of inverted robot, TAMIYA's Educational Construction Series are used.

  1. make two V-shaped cuts to a Universal Plate
  2. attach 4 L-angles included Universal Arm Set to this Plate
  3. assemble Double Gearbox to make its gear ratio 114.7:1
  4. mount 2 motors with 4 wires to this Gearbox
  5. attach this Gearbox to Universal Plate above
  6. assemble Slim Tire Set (two 55mm Dia. wheels gotten)
  7. attach these wheels to shafts of Gearbox above


[tutorial for Step 3]

 

Step 4: Put Electrical Components Together

Put electrical components together and attach them to the body built in the former step. Then a robot without program is gotten.

  1. referring to a picture of breadboard above, plug a gyro-module and two motor driver ICs at your breadboard
  2. wind some rubber bands around the breadboard and attach it on the lower L-angles of body of robot
  3. according to a wiring diagram above, plug jumper wires at the breadboard
  4. and plug either wire of the battery snap which would be connected to a 4AA battery holder
  5. wind a small rubber band around arduino and attach it on the upper L-angles of body of robot
  6. according to a wiring diagram above, plug jumper wires at arduino
  7. insert four AA batteries to 4AA battery holder
  8. wind a bigger rubber band around the body of robot and fix the battery holder to the back side of robot


[tutorial for Step 4]


[note 2]
The robot gotten here has no power switch. To turn on (off) power, battery snap is connected (disconnected).

Step 5: Upload a Sample Sketch to Arduino

Using IDE a sample Sketch for inverted robot is uploaded to arduino.

  1. if you cannot find MsTimer2 library in IDE, install it from website(*)

    (* Another simpler sketch, ver2.0, has been available since Aug. 2014. It does not need MsTimer2.)

  2. connect arduino to PC via a USB cable
  3. disconnect the battery snap from 4AA battery holder
  4. lay down robot on desktop or floor and leave at rest
  5. download(*) a pdf file attached at the last line in this step (* you get a corrupted program if you open this file in web browser and copy its contents)
  6. open the file in proper reader and copy the whole of text in the file
  7. paste the copy to IDE and correct misprints
  8. upload corrected sketch to arduino using IDE


[note 3]
To make an inverted pendulum balance itself, motor torque is controlled dynamically. This control method is expressed as a plane formula with 4 variables related to the state of pendulum.
"motor torque = k1 * angle of pendulum
+ k2 * angular velocity of pendulum
+ k3 * velocity of the lower end of pendulum
+ k4 * displacement of the lower end of pendulum from a reference point"

k1,k2,k3 and k4 are static coefficients with appropriate values. In a sample sketch in pdf file below, a long equation at line 72 expresses this formula. To make inverted robot balance itself, we have to select proper values for these 4 coefficients respectively and know right value of each of these 4 variables in real time.

A gyro-sensor gives the second variable value, angular velocity of pendulum, dynamically as a voltage at its output pin. And arduino estimates the first variable value, angle of pendulum, contemporaneously by integrating the second variable.

On the other hand, the third or the fourth variable value cannot be measured by gyro-sensor. So another kind of sensor or meter should be used to get them in real time. But our inverted robot has no more device than a gyro-module. Thus it becomes a puzzle to estimate these 2 variables values dynamically. In a sample sketch in pdf file below, 2 masked equations at lines 76 and 77 should be used to estimate them. Here they are left masked not to spoil solving this puzzle.

[note 4]
If some other gyro-module than listed one in Step 1 is used, 2 constants at lines 10 and 11 in the sample sketch in the pdf file would be changed. These constants express k1 and k2 respectively in the formula above. For example if an ENC-03R, gyro-sensor on listed module, is used without op amp, input voltage to arduino becomes 1/10 times. Then the constants at lines 10 and 11 in the sketch should be change to ten times scale respectively.

[a sample sketch (program) for inverted robot]
Copy whole text of "invertedRobot.pdf" or "invertedRobot_v20_noTimer.pdf" below, paste it to IDE and upload it to arduino.

(*1) With some language parameters on the site, an icon of the pdf file is not shown below (at the end of line of this step). Then you should type "https://www.instructables.com/id/A-Simple-and-Very-Easy-Inverted-Pendulum-Balancing/?ALLSTEPS" in address bar of your browser or refer a Japanese version of this Instructable.

(*2) Save the pdf file in your PC and open it in proper pdf-reader. Or you get a corrupted program by opening it in web-browser.

(*3) If "; //72" is not shown at the end of a equation at line 72, substitute whole a equation below for it.
powerScale = ( kAngle * thetaI / 200 ) + ( kOmega * omegaI / 78 ) + ( kSpeed * vE5 / 1000 ) + ( kDistance * xE5 / 1000 ); //72

(*4) Pasting the copy to IDE or editor, misprints such as "/ /" as "//" (an obstacle space inserted) might happen, then correct them.

(*5) An analog gyro-module used here is influenced by temperature. If your robot cannot balance itself well in summer, constant values (45, 85, 57) at lines 10 to 12 in the original sample sketch "invertedRobot.pdf" should be changed such as "52, 95, 53" (added on Aug. 20 2014).

(*6) A simpler alternative sketch "invertedRobot_v20_noTimer.pdf" has been added as ver.2.0 on Aug. 20 2014. Though it does not contain timer library, MsTimer2, for interrupt handling, it could make robot balance better.

(*7) Copyright (C) 2014 ArduinoDeXXX All Rights Reserved.

Step 6: Get an Inverted Following Robot

After a sample sketch uploaded to arduino in the former step, you ought to get an inverted following robot. Though it needs your finger for standing, it follows your finger.

  1. leave robot still laid for 5 seconds after the upload finished (see picture 1)
  2. hold the body of your robot and pick it up (see picture 2)
  3. connect battery snap to battery holder fixed on the back side of robot
  4. wheels of robot start spinning
  5. hold both wheels tight and stop spinning (see picture 3)
  6. set both wheels on desktop or floor and keep static standing to be made center of gravity of robot to be located on its wheel shafts
  7. after a few second motor torque becomes down and faint noise or chirping "miii" is listened
  8. then release your hands from robot gently (see picture 4) and put your finger on the top of the body of robot softly
  9. move your finger forward and backward and see your robot following
  10. release your finger and see your robot trying to balance but failing

[tutorial for Step 5 and 6]


[note 5]
The signal voltage, which the analog gyro-sensor used here outputs in static state, is not set in advance and is not constant. It depends on conditions and drifts over time. Thus after turning on or resetting arduino, do not touch robot and leave it laid for 5 seconds. During the seconds arduino estimates the signal voltage in static state now.

[note 6]
After the seconds in note 5, as picking up the robot it perceives state changing and spins its wheels. Then the robot has to study proper posture (angle of its body) in well inverted state. This robot is programmed that if it has been in static state for 0.05 seconds it deems itself well inverted.

Hence as picking up the robot and its wheels starting spinning, you should hold both wheels tight and stop spinning. And execute Step 6 since its line 6.

Further if you do not feel changes at line 7 in Step 6, torque down and faint noise of motors, for 10 seconds, arduino might have failed the estimation in note 5. Then you should push reset button on arduino to stop wheels spinning. And after pushing the same button again, execute Step 6 since its line 1.

[troubleshooting 1]
If wheels of robot do not start spinning at line 4 in Step 6, some faulty wiring must be suspected first. Go back Step 4 and verify wiring carefully. Another doubt is a defective gyro-module. Indeed the module I have used first was it.

On the other hand, if your robot does not follow your finger in spite of wheels starting spinning at line 4 in Step 6, four kinds of faulty wiring must be suspected: (1) wires of a motor are set opposite, (2) gyro-module is set reversed, (3) wiring to digital pins of arduino is wrong or (4) analog pin is unplugged. Go back Step 4 and verify wiring carefully.

Step 7: Challenge to Solving a Puzzle

Let's make your "following inversed robot" balance itself without your finger by modifying the sample sketch in Step 5. It might be a puzzle.

  1. consider why it fails balancing
  2. get plausible idea and modify the sample sketch
  3. make your inverted robot try balancing
  4. if it balances itself you have solved a puzzle and your robot has become an inverted pendulum (congratulation!)
  5. or else back to line 1 or hesitate to see a solution in Step 8

Step 8: How to Get an Inverted Balancing Robot

Here you see how to get an inverted balancing robot. You need to modify only two lines in the sample sketch in Step 5.

  • copy 3 lines below and paste them over lines 76 and 77 in the sample sketch (overwriting them)

vE5 = sumPower; //76a
xE5 = sumSumP / 1000; //77a
// Copyright (C) 2014 ArduinoDeXXX All Rights Reserved.

  • execute Step 6 (without a finger support in lines 8 to 10)
  • if center of gravity of robot is located on near its wheel shafts, your robot moves back and forward for a few seconds and gets well inverted posture
  • see it keeps balancing itself
  • if it moves with forward or backward bias, add to or submit from proper integer after "power" at the end of line 74 in the original sample sketch


[tutorial for Step 8]


[troubleshooting 2]
If your robot can not balance itself well in spite of executing Step 6 well, “low battery” in the battery holder on the back of robot should be suspected first. If it is not observed, constant values at lines 10 to 13 in the sample sketch should be changed. I think that line 12 is most critical.

Step 9: Operate Inverted Robot Via Serial Monitor

Now you have an inverted balancing robot. Then let’s control it by serial monitor. You could make it turn right/left and go forward/back.

  1. update the modified sample program gotten in Step 8 according to the details below
  2. upload the updated one to arduino using IDE
  3. after the upload end, start serial monitor from IDE
  4. select ‘Newline’ and “115200 baud” at bottom right of serial monitor
  5. leave robot still laid for 5 seconds
  6. make inverted robot balance itself according to Step 6 (without a finger support in lines 8 to 10)
  7. input numerical values in upper left window of serial monitor and push the [Enter] key
  8. see action or change of action of your robot


[tutorial for Step 9]


[note 7]
You can control your robot dynamically by serial monitor from PC via USB cable. For example you input "00" in window of serial monitor and push the [Enter] key, then robot receive ‘0’ and ‘0’ separately. Hence it turns right at a regular angle below twice without stopping.

  • a ‘0’ sent makes robot turn right at a regular angle on the spot
  • a ‘1’ sent makes robot turn left at a regular angle on the spot
  • a number (n) of ‘2’ sent make robot accelerate forward in proportion to the number (n)
  • a number (n) of ‘3’ sent make robot accelerate backward in proportion to the number (n)


[an update on the sample sketch (for 4 places)]

(1) Copy the following 5 lines and paste them between lines 17 and 18 in the modified sketch gotten in Step 8.

volatile int drct = 0;
volatile boolean right = false;
volatile boolean left = false;
volatile int fwdBck = 0;
// Copyright (C) 2014 ArduinoDeXXX All Rights Reserved.

(2) Copy the following 26 lines and paste them over line 32 in the modified sketch gotten in Step 8, viz. substitute these lines for “if ( power > 0 ) {”.

if ( Serial.available() ) {
drct = Serial.read();
Serial.println(drct);
}
if( drct == 48 ) { right = true; }
else if ( drct == 49 ) { left = true; }
else if (drct == 50 ) { fwdBck++; drct = 0; }
else if (drct == 51 ) { fwdBck--; drct = 0; }
if ( right == true ) {
analogWrite( 6, 140 );
digitalWrite( 4, HIGH );
digitalWrite( 5, LOW );
analogWrite( 9, 140 );
digitalWrite( 7, LOW );
digitalWrite( 8, HIGH );
delay(40);
} else if ( left == true ) {
analogWrite( 6, 140 );
digitalWrite( 4, LOW );
digitalWrite( 5, HIGH );
analogWrite( 9, 140 );
digitalWrite( 7, HIGH );
digitalWrite( 8, LOW );
delay(40);
} else if ( power > 0 ) {
// Copyright (C) 2014 ArduinoDeXXX All Rights Reserved.

(3) Copy the following 4 lines and paste them between lines 55 and 56 in the modified sketch gotten in Step 8.

drct = 0;
right = false;
left = false;
// Copyright (C) 2014 ArduinoDeXXX All Rights Reserved.

(4) Copy the following 2 lines and paste them over line 74 in the modified sketch gotten in Step 8, viz. substitute these lines for “sumPower = sumPower + power;”.

sumPower = sumPower + power + fwdBck * 4; // 74a
// Copyright (C) 2014 ArduinoDeXXX All Rights Reserved.

Step 10: Unplug the Cable

Substitute a buttery (9V) for USB power (5V) for power supply to arduino. Then arduino is unplugged and your robot stands with no outer wire.

  1. eject a USB cable from arduino
  2. connect the second battery snap to a battery (9V)
  3. attach the battery on the back of robot by rubber band with a battery holder 
  4. plug the positive wire of this snap to Vin pin of arduino
  5. plug the negative wire of this snap to GND pin of arduino
  6. your robot starts spinning its wheels if the first snap is connected to battery holder
  7. make your robot balance itself according to Step 6 (without a finger support in lines 8 to 10)
  8. see it stands with no outer wire as a completed inverted pendulum


[tutorial for Step 10]

 

Step 11: Develop Robot Further

Let’s make your inverted robot or your knowledge evolve further. Here three ways are shown briefly. It would be hard to finish the second or the third way within half a day.
 

(1) Double Sensors

Add another gyro-module on the breadboard of your robot and investigate whether its stability in balancing is improved.
 

[a record of a robot with double sensors]



(2) Remote Operation with No Wire

In Step 9 your robot is operated via USB cable. Now your robot is unplugged. So let’s operate it with no wire. In terms of simplicity, an infrared module would be the first choice.
 

[a demonstration of operating robot by a TV remote]



(3) Simulating the Action of an Inverted Robot with Excel

Our inverted robot could be thought constructed from three parts: head, body and wheels. In this simplifying, an equation of motion of the robot can be written with a physics learned at High School. As getting it, the action of robot can be simulated using Excel. The near-proper values of two coefficients in note 3 in Step 5, k1 and k2, could be gotten by this simulation.

<p>I have a SMAKN gyroscope with an ENC-03RC sensor which I believe is the same as your ENC-03R sensor. The one thing I do not see in your instructions is what the pins on this module are. The module I have is seen below. Which wires will I put where?</p>
<p>I found a web site for your gyro module, and saw a schematic attached.<br><a href="http://www.ebay.com/itm/Single-axis-Gyroscope-Analog-Gyro-Module-ENC-03RC-Module-For-Arduino-MWC-/361089046045?_ul=BO" rel="nofollow">http://www.ebay.com/itm/Single-axis-Gyroscope-Anal...</a></p><p>It seems that &ldquo;C1&rdquo; in it works as &ldquo;C6&rdquo; in my gyro module. Hence you may have to invalidate &ldquo;C1&rdquo;. See Step2.</p><p>Though I do not know your module well, I think you should connect &ldquo;VCC&rdquo;, &ldquo;GND&rdquo; and &ldquo;OUT&rdquo; in your module to &ldquo;5V&rdquo;, &ldquo;GND&rdquo; and &ldquo;A5&rdquo; in Arduino UNO respectively. However &ldquo;REF&rdquo; is connected to none.</p><p>See the earlier comments and pictures of <a href="https://www.instructables.com/member/xgiantsios" rel="nofollow">xgiantsios</a> and my replies to them to know more.</p>
<p>I have a MPU 6050, which pins would I have to connect to make this work? The pins on your diagram are not listed for which pins are voltage, ground, and signal.</p><p></p>
<p>An analog output gyro module is used in this project, though MPU6050 is a digital output module. Another digital output gyro module, L3GD20 carrier, is used in the later version of this project. See &ldquo;*** &hellip;..&rdquo; in the bottom part of Introduction above.</p>
<p>Whay gyro module can be used? The link in comment 2 is no longer available. I am trying to compile my list of part now. </p>
<p>I cannot understand well what you tell. Sorry. I think you may know more in the later version of this project. See &ldquo;*** &hellip;..&rdquo; in the bottom part of Introduction above.</p>
Hello, could you please post the schematic of cabling for the robot functioning. Thank you in advance!
<p>See the top picture in Step4.</p>
<p>how can we get code of this robot??</p>
<p>See Step5 in this article. And click &ldquo;<strong>invertedRobot_v20_noTimer.pdf</strong>&rdquo; attached to the end of the step.<br>Now another version has been published. See the end of <strong>Introduction</strong> in this article.</p>
<p>Yes sorry may be a was unclear ! </p><p>to begin i try to drive the DC motor .</p><p>I can use the sketch of this projet as a basis ? </p>
<p>At the start of your project I think you had better learn using both motor driver IC and gyro-module you have. Search with the <em><strong>model number</strong></em> of the IC or the module as key-word in the web. You could get the basics with adequate information.</p><p>The Arduino sketch attached in this article presupposes using specific IC and module described in Step1. I <strong>do not</strong> recommend you to start with this sketch if you want to make not inverted robot but camera gimbal.</p>
<p>Thank you again for your precious help ! ( i informing me about my component)</p><p>You said that it is very difficult to drive a BLDC it mean that each user of gimbal are using a specific board to drive it ? like Alexmos ? we can't recovered the same kind of code ? ( sorry for the english .. ) </p>
<p>I do not know such topic well because I want to make One-off by my own efforts. I enjoy myself to solving puzzle without seeing answer.</p><p>I search with &ldquo;open source project brushless gimbal&rdquo; and find a related web-site&rdquo;brushless-gimbal-BruGi&rdquo;.</p><p>In any case a simple inverted robot with cheap brush DC motors is described here, not brushless gimbal.</p>
<p>hi it's me again!</p><p>I'll start as you advise it by learning how to drive DC brush motor.</p><p>some questions :</p><p>if I understand the system: the engine is running at maximum speed here?</p><p>HIGH or LOW commands are given to the motor drivers, and it sending the right PWM motor?</p><p>this program is not used to control the frequency of the PWM?</p><p>could we send message to the motor drivers to control the pwm? (to control engine speed)</p><p>with your gyro angle you recover the value or the angular velocity?</p><p>thank you !!</p>
<p>Nnn??<br>Did you describe brushless gimbal in your earlier mail messages I have received? Have you changed article or posted wrong one carelessly? The reply below is written keeping your earlier message about BLDC in mind.</p>
<p>Hi, I get your open comment now.</p><p>&gt; HIGH or LOW commands are given to the motor drivers, and it sending the right PWM motor?<br><br>I attached three sketches to rotate BLDC via Arduino. See Step6 and 10. In the first one of them, &ldquo;<strong><em>digitalWrite( pin , HIGH or LOW)</em></strong>&rdquo; is used to generate square wave. There is no PWM in it.<br><br>&gt; the engine is running at maximum speed here?<br><br>If &ldquo;engine&rdquo; means BLDC motor, none of these sketches drives BLDC at the maximum speed.<br><br>&gt; this program is not used to control the frequency of the PWM?<br><br>We can change frequency of PWM pulse. See the earlier comment from EricL50. But it has little effect to the single axis brushless gimbal described in Step10.<br><br>&gt; I'll start as you advise it by learning how to drive DC brush motor.<br><br>If you do not have enough knowledge, information and skill about Arduino to rotate motor and to use gyro-module, I think that you had better try to control standard &ldquo;<em><strong>blush</strong></em>&rdquo; DC motor with driver IC first, and next to get angular velocity with using gyro-module.</p>
<p>will this code works with ADXL335 accelerometer too?</p>
<p>I have posted two instructabes in English. Each of them shows how to make simple inverted pendulum robot. One who wants to make it can download PDF file in Step5 freely. It contains whole of code to make robots balance itself.<br>The code should be applied to the robot with gyroscope. The robot with accelerometer instead of gyro would require hard correction in the code.</p>
<p>can you please tell me what should I scaled my accelerometer values to get my robo balanced?</p>
<p>I have not made any inverted robot without gyroscope. Hence I do not have the answer to your question. Sorry.</p>
<p>can i use AdXL335 only to balance the robot, can you please share me the code </p><p>Thanks</p>
<p>AdXL335 seems to be an <em><strong>accelerometer</strong></em>. I think that though it is not impossible to make a self-balancing robot with only an accelerometer, it would be very hard to do it. The robot with a cheap <strong><em>gyroscope</em></strong> could balance itself more easily.</p><p><a href="https://www.instructables.com/id/Another-Easier-Inverted-Pendulum/" rel="nofollow">Another version of this article</a> has been posted. The whole code in pdf file is shared in Step5 in it. You can download it and you could get a digital output gyroscope made by Pololu on line.</p>
<p>May I use the MPU 6050 instead the k-04912?</p>
<p>I have posted <a href="https://www.instructables.com/id/Another-Easier-Inverted-Pendulum-in-Japanese/" rel="nofollow">another version of this instructable</a> in Japanese site. Here a digital output gyro module similar to MPU 6050 is used <br>instead of analog output module K-04912. You could see it in English or others with machine translation of your browser.<br>https://www.instructables.com/id/Another-Easier-Inverted-Pendulum-in-Japanese/</p>
I appreciate the effort you have put into your project, and your intention of sharing your knowledge with thers.
<p>Thank you so much for a nice instructions!</p><p>I followed your instructions with the same materials, and code</p><p>but I have some problems, help me plz</p><p>1. my wheel only rotate in one direction</p><p>that means...</p><p>if I tilt my robot in front, wheel does not response, anything!</p><p>but if I tilt it in back, wheel works. what's wrong??</p><p>I checked directions of motors and wires many times..</p><p>Is there a possibility that the problem of gyro module?</p><p>When I soldering C6 in gyro module ( the exactly same</p><p>model with yours), it it too small that I cannot solder it clearly..</p><p>2. Plus at STEP6, after I upload code in Arduino,</p><p>and connect battery, the wheels does not rotate like yours.</p><p>My one only react to when it is &lt;tilting in back&gt;</p><p>And when I connect a battery snaps to batterys, an arduino reacts</p><p>(sounds like miii~) but the wheel does not move until I tilt it.</p><p>3.I cannot understand some parts of your code,</p><p>for example, what is chkAndCtl(); , recOmegaI , zeroOmegaI</p><p> and countS ??</p><p>there are so many questions.. sorry ^^..</p><p>again, it was really nice instructions and I really appreciate you.</p><p>happy new year!</p>
<div> <p> Happy new year!</p> <p> I have got many comments with successful cases in <a href="https://www.instructables.com/id/%E5%8D%8A%E6%97%A5%E3%81%A7%E4%BD%9C%E3%82%8B%E5%80%92%E7%AB%8B%E6%8C%AF%E5%AD%90/" rel="nofollow">the Japanese version of this instructable</a>. But none in this English version. I guess the difference would be due to a difficulty to get the gyro-module used here outside Japan. Now you have the same model of this module. Good!</p> <p> When we take into account your Point1 and Point2 (in Step6), it seems that little power is supplied to motors just tilting in front. I think your gyro-module would work. If so, wrong wiring or misprint in sketch is suspected.</p> <p> I have got <a href="https://www.instructables.com/id/%E5%8D%8A%E6%97%A5%E3%81%A7%E4%BD%9C%E3%82%8B%E5%80%92%E7%AB%8B%E6%8C%AF%E5%AD%90/?comments=all#CIA2455HYJ8770C" rel="nofollow">a similar comment</a> to yours with failure case in Japanese version from <strong><em>tokumikatu</em></strong>. To her/him I asked to <a href="https://cdn.instructables.com/F1H/7Q6X/HYJ0TJ1W/F1H7Q6XHYJ0TJ1W.LARGE.jpg" rel="nofollow">capture and show</a> time series of two state variables. Can I ask you to capture them?</p> <p> (1) Use the sketch in &quot;invertedRobot.pdf&quot; in Step5.</p> <p> (2) Keep comment-out in line 76 and 77.</p> <p> (3) Add the 3 lines below between line 75 and 76.</p> <p> &nbsp; Serial.print(thetaI);</p> <p> &nbsp; Serial.print(&quot;,&quot;);</p> <p> &nbsp; Serial.println(omegaI);</p> <p> &nbsp; //vE5 = ??? //76</p> <p> &nbsp; //xE5 = ??? //77</p> <p> (4) Upload this sketch to Arduino.</p> <p> (5) Open serial monitor and select &quot;115200 boud&quot;.</p> <p> (6) Tilt your robot in front to 90 degrees and back -90 degrees gradually.</p> <p> (7) Copy series in serial monitor and paste it to some text editor (*1-3).</p> <p> (8) Save it as a CSV file and open it in MS Excel.</p> <p> (9) Draw line graphs using two series in Excel.</p> <p> &nbsp; (*1) select all: &quot;Ctrl&quot;+&quot;a&quot;</p> <p> &nbsp; (*2) copy: &quot;Ctrl&quot;+&quot;c&quot;</p> <p> &nbsp; (*3) paste: &quot;Ctrl&quot;+&quot;v&quot;</p> <p> <strong><em>tokumikatu</em></strong> uploaded <a href="https://cdn.instructables.com/FWY/7ZR0/HYLZFUVI/FWY7ZR0HYLZFUVI.LARGE.jpg" rel="nofollow">the graphs</a>. So she/he put all components again from the beginning and got <a href="https://www.instructables.com/id/%E5%8D%8A%E6%97%A5%E3%81%A7%E4%BD%9C%E3%82%8B%E5%80%92%E7%AB%8B%E6%8C%AF%E5%AD%90/?comments=all#C6ZM8BNHYQDRPE0" rel="nofollow">a good robot</a>.</p> <br> To your Point3:<br> <p> chkAndCtl...check and control,</p> <p> omega...a Greek character represents angular velocity,</p> <p> omegaI...input value in proportion to omega,</p> <p> recOmegaI...recorded value of omegaI,</p> <p> zeroOmegaI...input value for omega at rest,</p> <p> countS...number of observations at near rest in balancing.</p> </div>
<p>hello I have some issues here.. I have this gyromodulehttp://www.elecrow.com/2axis-analog-gyro-moduleenc03-p-712.html but I cant understand how you find the variables and the k coefficients can you expain this to me please? Thank you</p>
<p>Hi vasoula I think that the past comments and replies could help you. </p><p>(1) The formula in note 3 in step 5 is found in many website. See &quot;<strong>(*1)...</strong>&quot; in the <strong>introduction</strong> of this Instructable first.</p><p>(2) An interpretation of this formula as &quot;<strong>PID control</strong>&quot; has been shown in a reply to <strong><em>BigMig</em> </strong>below. And it is described in a reply to <strong><em>Erik_D</em></strong> how to decide the values for 4 coefficients in this formula. </p><p>(3) A gyro module in a website you told looks like the same model of <em><strong>aristos92</strong>'s</em> and a near model of <em><strong>xgiantsios</strong>'s</em> below. So I recommend that you would see their comments and my replies.</p>
<p>I expect you are using state-feedback by the look of the equation but you give little information. If it is state-feedback then your gains are found from some matrix algebra. If it is state feedback then it isn't PID, it is PD however. It's too vague for me to comment without a decent diagram with angles etc.</p>
<p>Hi I think you are right in the sense of <em>linear system theory</em>. It is easy to find the formula used in <strong>Step 5</strong> on the web. It could be interpreted as a two-variables-PD, if we got these two variables dynamically.</p><p>But here we can observe only one of them, angular velocity. The other should be estimated by exploiting it. This is a puzzle described in <strong>Step 5</strong>. And I show an answer in <strong>Step 8</strong> as an<em> indirect integration </em>of observed one.</p><p>Though the original formula in <strong>Step 5</strong> is two-variables-PD, a modified formula gotten in <strong>Step 8</strong> could be interpreted as single-variable-PID. This is the point of <a href="https://www.instructables.com/id/A-Simple-and-Very-Easy-Inverted-Pendulum-Balancing/?comments=all#CGWZQISHT5CPRA0" rel="nofollow">the reply to BigMig</a>. There I don&rsquo;t use &ldquo;PID&rdquo; in its strict sense. I am glad to know what call this modified one in strict sense in the theory.</p>
<p>Information:</p><p>To select values for 4 coefficients in the formula in Step 5, I have made Excel analysis first. There I have relied on numerical method without using the analytical method or solution. See the end of <strong>Step 11</strong>.</p>
<p>[Additional information, Aug. 20 2014]<br>A simpler alternative program, ver2.0, has been available in Step 5. Though it does not contain timer library, MsTimer2, for interrupt handling, it could make robot balance better.</p>
<p>Hi i have this gyro module <a href="http://www.elecrow.com/sensors-c-111/motion-c-111_114/1axis-analog-gyro-moduleenc03-p-711.html" rel="nofollow">http://www.elecrow.com/sensors-c-111/motion-c-111_...</a> which capacitor is for the HPF?</p><p>Can you tell me?</p>
Without data sheet of your module, I have no correct answer. I can just tell you where is <strong>pin 4</strong> of ENC-03 sensor on your module (circled in red line). In a sample schematic for ENC-03 sensor, the capacitor for HPF is connected to pin 4 of the sensor.<br> It seems that 3 capacitors, <strong>C2</strong>, <strong>C3</strong> and <strong>C5</strong> are near pin 4 on your module. <strong>Pattern</strong> on its either face might tell you more information. (As seeing a picture in the site, C3 seems to be most plausible.)<br> Incidentally, the sensor is set <strong>at right angles to</strong> line of header pins on your module. So some improvement would be needed to be set it parallel to the line. For more detail see the 2nd reply to <strong>peraz91</strong> below.
<p>I find an easy way to know the capacitor <br>for HPF.</p><p>If HPF in your module is based on a sample <br>schematic for ENC-03 sensor. This capacitor is connected to pin 4 of the <br>sensor. So a simple continuity check between them tells us which is the <br>capacitor for HPF.</p><p>I have executed this check using a <br>multimeter and known it in practice.</p>
<p>i did it but it doesn't work again</p>
<p>I got it. I would like to know several points about your gyro-module.</p><p>1. Which capacitor is used for HPF on your module?</p><p>2. How did you know it to be used for HPF?</p><p>3. How did you attach the module to be right position to your robot?</p><p>4. Can you upload pictures below?</p><p>(a) Close-up picture(s): soldered a fine wire to the capacitor for HPF on your module</p><p>(b) Portrait(s): whole body of your robot with gyro-module on a breadboard</p>
<p>i found it with a polumeter</p>
<p>Thank you for pictures. It seems that a fine wire is soldered to capacitor 2 (C2) and a breadboard is set in portrait orientation (not in landscape) from the front, OK?</p><p>If it is set in portrait orientation, your gyro-module is set correctly. But I cannot say any correct about HPF, because I don't know whether capacitor 2 is an element of HPF. (I don't know polumeter, sorry.) I could tell some check points.</p><p>(1) Do wheels start spinning at 1:07 in tutorial video for Step 5 and 6?</p><p>(2) Do wheels change its direction of spinning as tilting robot front or back at 1:09 - 1:14 in the video above?</p><p>(3) Is a faint noise &quot;miiii&quot; is listened at 1:14 - 1:24 in the video above?</p><p>(4) Are wheels still stopping as battery snap is connected and arduino is reset at 1:10 - 1:30 in tutorial video for Step 8?</p><p>If some answer is 'No', faulty wiring or failure or malfunction of gyro-module should be suspected.</p>
<p>I have cancel the HPF but it doesn't work again </p>
<p>Hi ArduinoDeXXX i have this gyro module <a href="http://www.elecrow.com/sensors-c-111/motion-c-111_114/2axis-analog-gyro-moduleenc03-p-712.html" rel="nofollow">http://www.elecrow.com/sensors-c-111/motion-c-111_...</a> and i can't make it works with it. I paste the code and it moves arround like crazy...I use the x -axe.</p><p>Can you help me?</p>
<p> Hi aristos92<br> Please let me know some points. First,</p> <p> (1) Is your module &quot;<a href="http://www.elecrow.com/sensors-c-111/motion-c-111_114/2axis-analog-gyro-moduleenc03-p-712.html" rel="nofollow">2-Axis Analog Gyro Module-ENC03</a>&quot;?</p> <p> (2) Is a small black chip, an op amp like '<a href="http://www.goldmine-elec-products.com/prodinfo.asp?number=G396S" rel="nofollow">LM358</a>', attached on the reverse face of your module?</p> <p> (3) Do you have a data sheet of this <strong>module</strong> (not <a href="http://www.elecrow.com/download/ENC-03.pdf" rel="nofollow">of a sensor</a>) <strong>with</strong> 2 sensors and an op amp?</p> <p> (4) Have you cancelled <strong>HPF</strong> in this module in the way like described in <strong>Step 2</strong> of the Instructable?</p>
<p>(1) &amp; (2) Yes. I don't have the data sheet and i could't find it so i haven't cancel HPF filter .</p>
<p>I see. I think that your module would have HPF for each ENC-03 sensor. And a HPF would contain a 4.7uF capacitor as shown in a sample schematic(*) in the site you tell above. It is important to find out this capacitor on your module.<br>Though 3 pictures of this module are shown in the site, I cannot see the reverse face of the module. I have prepared a sheet below. Can you give a detail view of the reverse face?</p><p>(*)http://www.elecrow.com/download/ENC-03.pdf</p>
<p>i hope that the photo will help you</p>
<p>Thank you.<br>In the sample schematic above, the 4.7uF capacitor of HPF is connected to pin 4 of ENC-03. In a picture below, the pin 4 is circled in red line. And capacitors near the pin 4 are surrounded with blue line.</p><p>Though I cannot know which of them is the capacitor of HPF, it seems that C4 or C6 is most plausible. A way to know it is soldering a fine wire to one you suspect as trial, following note 1 or picture in Step 2.</p>
<p>I find an easy way to know the capacitor <br>for HPF.</p><p>If HPF in your module is based on a sample <br>schematic for ENC-03 sensor. This capacitor is connected to pin 4 of the <br>sensor. So a simple continuity check between them tells us which is the <br>capacitor for HPF.</p><p>I have executed this check using a <br>multimeter and known it in practice.</p>

About This Instructable

104,913views

376favorites

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