Open Source Mobile
Inverted Pendulum

    Keywords: balancing robot, LabVIEW, inverted pendulum

    This website is dedicated to my proposed Master’s thesis project. The goal is to create a mobile inverted pendulum i.e. balancing bot.  Going through the design process, this website will describe my implementation of a mobile inverted pendulum. The objective is to design and construct one that is to be completely open-sourced. This means that users will be able to input their own controllers, or rather control code easily such that it will balance the robot. Ideally this will be done using LabVIEW and also will come with a 3D model using SolidWorks for validation. The idea is to use this device as a teaching aid or lab project for a control system related course.

  • Gantt Chart

    To complete my thesis within the next 9 months, I propose that the next three terms will be broken down into the following schedule:

    • Fall Term - Robot Construction
      • List Design Requirements (based on others previous work/research)
      • Trade Study – Motors/Controller/Sensors (also include on-hand components)
      • Evaluation on in house motors/controllers/sensors
      • Select motors/Controller/Sensors
      • Design Chassis / Build Model
      • Construct Chassis
      • Mount Motors
      • Mount Electronics
      • Mount Sensors
      • Finish Construction
      • Controlling Motors
      • Read Sensor Data

    • Winter Term - Implement Control Algorithms
      • Research Controllers
      • Simulate Controllers
      • Program 1st Control Algorithm
      • Test 1st Control Algorithm
      • Program 2nd Control Algorithm
      • Test 2nd Control Algorithm

    • Spring Term - Write & Defend Thesis
      • Write Thesis
      • Finish Thesis
      • Make Presentation
      • Defend

    The goal is complete the construction of the balancing bot by the end of Fall term.  
    Here is the scheduled breakdown of how the construction will progress through the term:

    Fall Term Gantt Chart

  • Design Requirements/Considerations

    • Considerations:

      • Motors/Servos
        • Resolution (@ which can be controlled)
        • Torque
        • Power
        • Input Signal - PWM?
        • Mounting of Wheels

      • Sensors
        • Noise
        • Rate (Highest angular rate that can be measured)
        • Resolution
        • Power
        • Input/Outputs – Communication Protocol

      • Controller:
        • Programming Language, preferably  LabVIEW
        • Input/Outputs – Digital or Analog?
        • Output PWM signals (if using servoss)
        • Weight/Size
        • Power

      • Chassis
        • PlatformDesign
        • Material

    • Design Requirements:

      • Audience: Control Students
      • Cost: Approximately $200
      • Footprint: Small, mobile, transportable by students i.e. microcontroller
      • Flexibility:
        • Implement (easily) multiple control systems (at least 2) + PID control
        • Programming Language: preferably LabVIEW or C-related/object-oriented
      • Simulation
        • Platform must be able to be simulated, using either MATLAB or LabVIEW, consider SolidWorks as 3D visualization tool for modeling platform for testing/validation

  • Trade Study

    • Microcontrollers:
  • Manufacturer
    Part #
    Price ($)
    I/O
    Language
    Project 
    MIT HC11 
    $139.99
    26 C nBot
    Atmel Mega32 $8.64 69 C EquiBot/Tip/Crunch
    Atmel AVR ATMEGA16 $6.45 32 C ARTIST
    AVR ARC 1.0 N/A 8 C GyroBot
    CHS DAVID N/A 100 FPGA JOE
    Freescale MPC555 $104.47 18 MATLAB NONE
    Lego RCX N/A 3 BrickOS LegWay
    Lego Mindstorm NXT $134.99 4 LabVIEW/C NXT-way/NXT-way-G
    Microchip  PIC18F452 $7.22 34 C Bender
    Motorola MMC2001 N/A Unk FPGA/C Blind-man
    Olimex LPC2106 60MHz ARM7 $102.00 30 C bk-bot
    Olimex LPC2129 $11.75 19 FreeRTOS/C Hielke
    Parallax  Basic Stamp $29.00 14 Basic  Parallax
    Parallax  Basic Stamp 2 $79.00 16 LabVIEW NONE
    ADS N/A Unknown Unknown Bitsy StrongArm
    • Motors:
    Manufacturer Part # Price ($) Weight Torque Input  Power Project 
    Pittman GM8712-31
    $93.33
    202 g 
    1.4 N-m
    Analog
    19.1 V
    Lego DC Motors 9 V LegWay
    MicroMo Permanent magnet gearhead motors uBot
    Pittman  GM8513 24 V bk-bot
    • Sensors:
    Manufacturer Model Type Price ($) Project 
    MicroStrain FAS-G Inclinometer
    $795.00
    nBot/Hielke
    HiTechnic EOPD EO Proximity N/A LegWay
    Tokin CG16DO Gyro Quote Bender/Tip
    Memsic MXD2125-GW Accelerometer $9.95 Bender
    Systron AQRS Gyro N/A GyroBot
    Analog Devices ADXL202 Accelerometer $8.50 GyroBot/Tip/Crunch
    Analog Devices ADXRS150 Gyro $30.00 Crunch/Hielke
    HiTec GY 130 Gyro $119.95 BallyBot
    Seika N3 Inclinometer
    Potentiometer Blind-Man
    Rotomotion 2DOF IMU $299.99 Tip/uBot
    FreeScale MMA6xxx Accelerometer N/A bk-bot
    Analog Devices ADXRS401 Gyro $22.50 bk-bot
    Silicon Sensing / BAE Systems CRS03-02 Gyro $300.60 ARTIST
    FreeScale MMA2260D $5.69 ARTIST
    HiTechnic NXT Gyro Gyro $48.99 NXTway-G
    • Commercial Balancing Robots: BalBots

    • Related Papers

      • Ahmad, Nawawi S.W, et. al. "Controller Design for Two-wheels Inverted
        Pendulum Mobile Robot Using PISMC
        ". 4th Student Conference on Research
        and Development (SCOReD 2006), Shah Alam, Selangor, MALAYSIA, 27-28 June, 2006.

      • Charais, John & Lourens, Ruan. "Software PID Control of an Inverted Pendulum Using the PIC16F684". Microchip Technology, Inc. 2004.

      • Chee, Ong Yin. "Design And Development of Two Wheeled Autonomous Balancing Robot".
        4th Student Conference on Research and Development (SCOReD 2006),
        Shah Alam, Selangor, MALAYSIA, 27-28 June, 2006.

      • Deegan, Patrick, Thibodeau, Bryan J. & Grupen, Roderic. "Designing a Self-Stabilizing Robot For Dynamic Mobile Manipulation".

      • Gans, Nicholas R. & Hutchinson, Seth A. "Visual Servo Velocity and Pose Control of a
        Wheeled Inverted Pendulum through Partial-Feedback Linearization
        ". Proceedings of the 2006 IEEE/RSJ International Conference on Intelligent Robots and Systems
        October 9 - 15, 2006, Beijing, China.

      • Grasser, Felix et. al. "JOE: A Mobile, Inverted Pendulum". IEEE Transactions on Industrial Electronics, Vol. 49, No. 1, February 2002. pp. 107-114.

      • Kang, Ming Tao et. al. "Control System Design for a Mobile Inverted Pendulum via Sliding Mode Technique". Proceedings of International Conference on Mechatronics. Kumamoto Japan, 8-10 May 2007.

      • Lauwers, T. B. , Kantor, G. A. , and Hollis, R. L. "A Dynamically Stable Single-Wheeled
        Mobile Robot with Inverse Mouse-Ball Drive
        ". Proc. IEEE Int’l. Conf. on Robotics and
        Automation, Orlando, FL, May 15-19, 2006.

      • Lauwers, Tom, Kantor, George, & Hollis, Ralph. "One is Enough!". 12th Int’l Symp. on Robotics Research. San Francisco, October 12-15, 2005.

      • Li, Jingtao et. al. "Mechanical Design and Dynamic Modeling of a Two-Wheeled Inverted Pendulum Mobile Robot". Proceedings of the IEEE International Conference on Automation and Logistics; August 18 - 21, 2007, Jinan, China.

      • Pathak, Kaustubh et. al. "Velocity and Position Control of a Wheeled Inverted
        Pendulum by Partial Feedback Linearization
        ". IEEE Transactions on Robotics,
        Vol. 21, No. 3, June 2005. pp. 505-513.

      • Radcliffe, Clark J. "The BASIC Stamp II® and LabVIEW®".

      • Shimada, Akira & Hatakeyama, Naoya. "High-Speed Motion Control of Wheeled Inverted Pendulum Robots". Proceedings of International Conference on Mechatronics; Kumamoto Japan, 8-10 May 2007.

      • Yang, Yansheng Yang & Ren, Junsheng. "Adaptive Fuzzy Robust Tracking Controller Design
        via Small Gain Approach and Its Application
        ". IEEE Transactions on Fuzzy Systems, Vol. 11, No. 6, December 2003. pp. 783-795.

      • Yu, Zheng et. al. "Control Parallel Double Inverted Pendulum by Hierarchical Reinforcement Learning". ICSP '04 Proceedings.

  • NXTway-G+NI - Proposed Platform

    After reviewing the assorted components and projects that have been completed and matching them to the design requirements. I found that one of the best platforms based on price, versatility, cost, and with on hand components would be the Lego NXT Mindstorm. As a proof of concept, I quickly replicated Philippe E. Hurbain's NXTway. Instead of a light sensor, the best sensor would be the HiTechnic NXT Gyro, seen in Ryo Watanabe's NXTway-G. The performance is much better and ideally suits all the requirements. Reviewing other projects, the more reliable robots can be attributed to a reliable sensor suite; unlike, my previous attempt that included the very noisy SparkFUN 5 DOF IMU.  However, at the same time this also increases cost since most of said sensors are well above the $200 dollar range.



  • Added 10/11/07: Video of my implementation NXTWay

    Looking past the lack of sophistication of Legos, the NXT platform meets all of the design requirements. The motor control and sensor interface with the NXT is simplified. In addition, the NXT can be easily programmed with LabVIEW. The NXT can also be programmed with other languages including C. I plan creating a virtual instrument (VI) that would allow students/end-users to input any controller programmed in LABVIEW. For simulation/validation purposes, LabVIEW can also interface with SolidWorks and fortunately, most NXT components have been modeled. Using these models, the construction of a SolidWorks model is streamlined. The cost of using a NXT platform would include ideally a NXT kit ($249.99) and a HiTechnic Gyro ($48.99), bringing the total to $298.99. However, since the lab already has a few NXT kits on hand the only extra component needed would be the gyro, bringing the cost to $48.99.

    Overlooking the simplicities of a Lego-based system, a NXT platform would minimize cost, is designed for mobility, provides flexibility through LabVIEW, can be modeled in SolidWorks, and most importantly easily for students to use.

  • SolidWorks Model

    After receiving final approval from Dr. Oh, I've put in the order for the NXT Gyro from HiTechnic. While I wait for the part to come in, the next step is to design. To take care of the SolidWorks model as well, I have found models of most of the Lego parts online. I plan to also get the gyro working with LabView concurrent with the design process.

    Here are the models that I've made so far. This isn't my final design but as least I figured out how to use SolidWorks.


  • DASL NXTWay
  • With the gyro on hand, I began trying to code with LabVIEW with much difficulty. To avoid getting bogged down, I started to port the NBC code to NXC. But realizing the difficulties of trying to learn NXC, I decided to work with RobotC a more familiar version of C. Using Ramin’s RobotC code as a guideline, I began coding in RobotC. The key feature that was added was the obstacle avoidance using the ultrasound sensor. The chassis has been modified such that the wheelbase is wider to aid in turning. With significant amount of tuning, the balancing works! In addition, adding a constant velocity the robot moves forward and avoids obstacles by simply turning right away from the object. The current code uses a running average to compensate for any drift that may occur in the gyro. It also employs a simple PD controller for both angle and velocity of the robot. Here is the picture of the new chassis:

    Video of the balancing act can be found here.
    Note: There is also footage of it going up and down a slope.

    The next step is to begin to port this code to LabVIEW.

  • LabView Code

    The port from RobotC to LabView was much more time consuming than I anticipated. The code was ported rather quickly but having it run properly required extensive debugging. The first thing was that the RobotC firmware must be removed before using LabVIEW's NXT Toolkit. The LabVIEW program will not run if the NXT is still using the RobotC firmware. The ported code can be found here. The gyro sensor did not have it's own VI so I was forced to make low level changes to other sensor VI's to get the gyro to return data to the NXT using LabVIEW. The other major concern is that LabVIEW does not support floating point values which may decrease the accuracy of the system. Lastly, the main approach to debugging is the flow of the program. In LabVIEW, some what unlike traditional text-based languages, the flow of data values is not completely apparent, at least to me. I have a feeling that data values are being re-written or not being written to memory properly so the system will balance.

    This program does not work completely yet but has been updated with a brief explaination on the gain values used to balance the robot. Here is the GyroSensor.vi file that is used, it can be added to /LabVIEW 8.x/vi.lib/addons/NXTToolkit/Library/GyroSensor/. All it is is a stripped down sensor file that reads the raw value of the gyro. To properly use it, you must determine the bias value which can be done with the VI in the following section.

  • Gyro Test

    It was requested that I perform experiments to detail the HiTechnic gyro being used for the NXTway. As a comparison, I will also test the Sparkfun 5DOF IMU using a NI USB-6211 DAQ board as a comparison. To do the test, Compumotor's turntable will be used as a control to compare the test results.

    Here is another vi file to test your gyro, test_sensor.vi. This is used to determine the Gyro Bias value used in the NXTWay.vi.

  • Modeling/Simulation

    One major challange is how to properly model this system i.e. a specific transfer function. To identify the system, I first began but re-designing the model in SolidWorks to find the robot's Center-of-Mass and Moment-of-Inertia to use in plant designs of mobile inverted pendulums.

  • Assembly Instructions

    Here are some detailed assembly instructionsin multiple formats:

  • Useful Links
    • Contact me