Notebook 05


Lab Notebook

Image of the focus of the lesson

Date: 01/03 2012
Group members participating: Falk and Jakob
Duration of activity: 3 hours


The goal is to build a self balancing robot inspired by the "NXTway" by Hurbain [3] and the Legway by Hassenplug [1]. Experiment with communication between NXT and a computer via bluetooth.


  1. Built the NXTway robot
  2. Connect to the robot by bluetooth and transfer a program
  3. Run the NXTway programm


Building the NXTway robot

The robot was constructed according to the pictures in [1] (with just one minor variation because of the big battery pack).


Following the guidelines [2] connecting to the robot and transfering a program just worked (it just took some more time compared to USB connection).


Compared to the original code [4] some changes were done in our

  1. First, the way of accessing the motors was changed to make it use the MotorPort.
  2. Next, the PID constants were set to be float instead of int.
  3. Button listeners for the right and left button were used to adjust the offset at running time. On the LCD offset and current error are shown to make it easier to find the right offset value.
  4. Eliminate the int_error from the computation by setting KI to 0
  5. Setting KI = 4 again and introducing the alpha-calculation as described in [6].
    • int_error = ((int_error + error) * 2)/3; changed to: int_error = (1-alpha)*int_error + alpha*error;
  6. Tweak the constants to improve the robot's ability to hold it's balance


  1. Without changing any constants the NXTway was falling backwards. It is very important to set it to have the right balance on startup.
  2. The higher accuracy in the computation did not noticably change the behaviour of the robot. It was still dependent on a exactly balanced start position and tends to fall backwards.
  3. Beeing able to adjust the offset eliminates the human error at the setup. The NXJway is able to balance for a few seconds.
  4. Setting KI = 0 made the robot a little more stable. It seems like the int_error is not that important for the NXTway
  5. Trying alpha values of 0.1 and 0.3 the robot still fell.
  6. The desired result was to make the robot accelerate faster and by that increase it's stability.
    • Increasing KP to make the robot accelerate faster did not work. The robot just oscillated more.
    • Increasing KD made the NXTway more unstable.


When the robot falls a bit to one side it can regain its balance, but once it falls too much it can not get back from this and falls.
A possible explanation for the NXJway's tendency to fall backwards could be the heavy battery pack used. The robot can not accelerate fast enough to compensate for the battery pack and so once it starts falling there is no way back.
Changing the constants made the balance a little better, but the robot always fell after a short time.
Adding arms to to the robot to compensate the weight of the battery did not help much.
If there were more time further experiments could have been done with changing the wheels and trying to change the robot's point of balance.


Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License