4
Lego Mindstorms NXT Balancing robot Ondˇ rej Herman, Ondˇ rej Hlouˇ sa, Vladislav Malynyˇ c May 11, 2014 Abstract The aim of our project is to design a Segway-like, self-balancing robot, using Lego NXT 2.0. To achieve the best results a gyroscope is usually used. However, to make the project more interesting (and because we don’t have a gyro- scope), we will use two ADXL312 accelerometers to derive the orientation of the robot in space. 1 Overview The gyroscope is an instrument which measures the change in angular velocity. To approximate the same information using two accelerometers, which measure the change in linear velocity, we used the following method. One of the accelerometers is aligned with the axis of the wheel shaft, so the rotation of the robot around this axis has no effect on the acceleration data obtaned from this sensor. On the other hand, the second sensor, which is mounted near the top of the robot, is influenced by the rotation – we can take the difference of these accelerations and obtain the rate of rotation around the wheels. In theory, this information is enough to keep the robot upright, but in prac- tice the solution diverges very fast and it is necessary to measure the orientation of the robot directly. The accelerometers have three axes, so the angle respective to the gravitational force vector can be easily calculated. Software controller manages robot by the PID control scheme. 2 Implementation The project targets the Lejos firmware, which implements a rich subset of the Java platform on the Lego Mindstorms. Apart from ROBOTC, this seems to be the only firmware which supports the 100 kbaud I 2 C mode. The regular firmware can only communicate at 9600 baud. At this speed, the link budget is exhausted very soon. Another reason for using Lejos is its use of a regular and widely used lan- guage. 2.1 Accelerometer interface We have used two ADXL312 accelerometers connected to the NXT brick using the serial I 2 C interface. The final schematic can be seen in the Figure 3. 1

Lego Mindstorms NXT Balancing robot · 2014. 5. 16. · Lego Mindstorms NXT Balancing robot Ond rej Herman, Ond rej Hlou sa, Vladislav Malyny c May 11, 2014 Abstract The aim of our

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lego Mindstorms NXT Balancing robot · 2014. 5. 16. · Lego Mindstorms NXT Balancing robot Ond rej Herman, Ond rej Hlou sa, Vladislav Malyny c May 11, 2014 Abstract The aim of our

Lego Mindstorms NXT Balancing robot

Ondrej Herman, Ondrej Hlousa, Vladislav Malynyc

May 11, 2014

Abstract

The aim of our project is to design a Segway-like, self-balancing robot,using Lego NXT 2.0.

To achieve the best results a gyroscope is usually used. However, tomake the project more interesting (and because we don’t have a gyro-scope), we will use two ADXL312 accelerometers to derive the orientationof the robot in space.

1 Overview

The gyroscope is an instrument which measures the change in angular velocity.To approximate the same information using two accelerometers, which measurethe change in linear velocity, we used the following method.

One of the accelerometers is aligned with the axis of the wheel shaft, sothe rotation of the robot around this axis has no effect on the accelerationdata obtaned from this sensor. On the other hand, the second sensor, which ismounted near the top of the robot, is influenced by the rotation – we can takethe difference of these accelerations and obtain the rate of rotation around thewheels.

In theory, this information is enough to keep the robot upright, but in prac-tice the solution diverges very fast and it is necessary to measure the orientationof the robot directly. The accelerometers have three axes, so the angle respectiveto the gravitational force vector can be easily calculated. Software controllermanages robot by the PID control scheme.

2 Implementation

The project targets the Lejos firmware, which implements a rich subset of theJava platform on the Lego Mindstorms.

Apart from ROBOTC, this seems to be the only firmware which supportsthe 100 kbaud I2C mode. The regular firmware can only communicate at 9600baud. At this speed, the link budget is exhausted very soon.

Another reason for using Lejos is its use of a regular and widely used lan-guage.

2.1 Accelerometer interface

We have used two ADXL312 accelerometers connected to the NXT brick usingthe serial I2C interface. The final schematic can be seen in the Figure 3.

1

Page 2: Lego Mindstorms NXT Balancing robot · 2014. 5. 16. · Lego Mindstorms NXT Balancing robot Ond rej Herman, Ond rej Hlou sa, Vladislav Malyny c May 11, 2014 Abstract The aim of our

Figure 1: Detail of accelerometer ADXL312

The circuit is split into three subboards: two of them carry the accelerom-eters themselves and the third board contains auxiliary power and signal con-ditioning circuitry: the 4.5 V from the NXT is regulated down to the 3.3 Vneeded by the integrated circuits using a Zener diode. The I2C pullups are alsolocated on this board.

Both of the accelerometers are connected to the same I2C bus of the NXT,one of them is configured with an alternate address. The only other componentslocated on these boards are the power supply bypassing capacitors.

2.2 Software controller

The core functionality is provided by two threads: the MotorThread and theSensorThread. The SensorThread configures the accelerometers and readsand preprocesses their data, which is then stored in variables shared with theMotorThread. This thread executes the control loop and interfaces with themotors.

Meanwhile, the main thread waits for a keypress, after which the programis terminated.

2.3 Evaluation

We didn’t manage to satisfy our original specification. The accelerometer in-terface works well, but the robot isn’t able to keep the balance for more than ashort while. We believe this is due to the mechanical imprecision in the motorgearing and the dependence of their speed on the remaining energy stored inthe batteries.

This, combined with the low power and speed provided by the motors, makesfinding the constants necessary for the proper operation of the PID controlscheme difficult, if not impossible.

2

Page 3: Lego Mindstorms NXT Balancing robot · 2014. 5. 16. · Lego Mindstorms NXT Balancing robot Ond rej Herman, Ond rej Hlou sa, Vladislav Malyny c May 11, 2014 Abstract The aim of our

Figure 2: The upper part of ”Segway” with accelerometer

3 Team

• Ondrej Herman - team leader, idea and physical construction of accelerom-eter cicuit, implementation of series of (un)balancing methods, testing,project report

• Ondrej Hlousa - implementation of series of (un)balancing methods, test-ing, project report

• Vladislav Malynyc - project abstract, testing, presentation

• Adam Tresnak - no communication from his side during whole semester

Bibliography

1. Maia R. Bageant: Balancing a Two-Wheeled Segway Robot, Massachusettsinstitute of technology, June 2011.

2. HTWay – A Segway type robot, online at http://www.hitechnic.com/blog/gyro-sensor/htway/, 2010.

3. Dennis Jin: Development of a Stable Control System for a Segway, RoyalInstitute of Technology, July 2013.

4. NXT SEGWAY with Hitechnic Gyro Sensor,online at forum http://www.robotc.net/forums/viewtopic.php?p=11549,2010.

5. PID controller, online at http://en.wikipedia.org/wiki/PID controller, May2014.

3

Page 4: Lego Mindstorms NXT Balancing robot · 2014. 5. 16. · Lego Mindstorms NXT Balancing robot Ond rej Herman, Ond rej Hlou sa, Vladislav Malyny c May 11, 2014 Abstract The aim of our

VD

Dio

1

NC

2

NC

3

SC

L/S

CLK

4

NC

5

SDA/SDI/SDIO 6

SDO/ALTADDR 7

nCS 8

INT

29

RE

SE

RV

ED

10IN

T1

11R

ES

ER

VE

D12

GN

D13

Vs14RESERVED15

GND16

U1

AD

XL3

50

+3.

3V

1234

P1CONN_4

+C

3

10uF

C2 0.1u

F

+3.

3V

+3.

3V

+5V

VD

Dio

1

NC

2

NC

3

SC

L/S

CLK

4

NC

5

SDA/SDI/SDIO 6

SDO/ALTADDR 7

nCS 8

INT

29

RE

SE

RV

ED

10IN

T1

11R

ES

ER

VE

D12

GN

D13

Vs14RESERVED15

GND16

U?

AD

XL3

50

+3.

3V

+C

? 10uF

C? 0.1u

F

+3.

3V

+3.

3V

+3.

3V+

5V

R1R

R2R

D?

1.8

V

+3.

3V+

3.3V

Dis

trib

utio

n bo

ard

Acc

eler

omet

er b

oard

AA

ccel

erom

eter

boa

rd B

Fig

ure

3:A

ccel

erom

eter

inte

rface

sch

emati

cd

iagra

m

4