Preliminary Report November 18 2011 A balancing robot provides several benefits compared to standard three or more wheeled models, the main being a more closely holonomic robot. Throughout the report, an in depth analysis will be carried on the design, simulation to be able to arrive at a functional prototype. Balancing Robot Design and Development Author: Miguel Bernardo Student number: 41235 Unit co-ordinator: Dr Alan Hewitt Supervisor: Dr Djamel Azzi Unit: M586L University of Portsmouth School of Engineering Meng Electronic and Electrical Engineering
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Preliminary Report
November 18
2011 A balancing robot provides several benefits compared to standard three or more wheeled models, the main being a more closely holonomic robot. Throughout the report, an in depth analysis will be carried on the design, simulation to be able to arrive at a functional prototype.
Balancing Robot Design and Development
Author: Miguel Bernardo Student number: 41235 Unit co-ordinator: Dr Alan Hewitt Supervisor: Dr Djamel Azzi Unit: M586L
University of Portsmouth
School of Engineering
Meng Electronic and Electrical Engineering
Preliminary Report – Balancing Robot Design and Development CONTENTS
Preliminary Report – Balancing Robot Design and Development RESEARCH
14
�4 ∗ -4! = 5-� − �
�4 ∗ /4! = 5/� − 0 −�4 ∗ �
14 ∗ �4! = � ∗ 5-� − "
(7)
Where set of equations 6 represent the body equations applying Newton’s Second law with x
axis being parallel to Fxg, y axis parallel to Fyg and z axis perpendicular to both x and y axis.
And equations set 7 are the wheel equations. When combined with the assumptions that the
wheels will always stay in contact with the floor and no slippage will occur between the
wheels and the floor Vamfum is able to achieve the following state equations.
��! = 6(−721 − 722) ∗ 91 + (711 + 712) ∗ 92):
79;
�! = 6−721 ∗ 91 + 711 ∗ 92):79;
(8)
With:
711 = 14 + (�4 +�) ∗ �<
712 = � ∗ � ∗ � ∗ .=>�
721 = � ∗ � ∗ � ∗ .=>�
721 = � ∗ � ∗ � ∗ .=>�
722 = 1 + � ∗ �<
79; = 711 ∗ 722 − 712 ∗ 721
91 = � ∗ � ∗ � ∗ >?@� ∗ ��< − "
92 = � ∗ � ∗ � ∗ >?@� ∗ +"
(9)
The controllability options for the two wheeled balancing robot are immense, they vary from
LQR to simple matching the position of the wheel with the position of the centre of the body
by the use of nothing more than the difference operation. Since the controllability of this
model is easier to achieve, similar to the ballbot equations but with less complexity and
various methods exist a more in-depth analysis will be undertaken if the path chosen is based
on the TWR.
Preliminary Report – Balancing Robot Design and Development RESEARCH
15
2.2.3 Cost of components for a similar TWR model
The two wheeled inverted pendulum robot appears to have a very consistent approach in
design and drive throughout all the research done. The model proposed consists of creating a
very basic yet durable frame of a material still to be confirmed, can be wood like MBF or
acrylic sheets. And will consist of a tall parallelepipeds shaped body with the
microcontrollers inside and the wheels on the side. This way in a later date a modular
approach can be taken if extra functions are required to be added to the robot. The proposed
model will be similar to the one with Figure 16 and the location of the components has been
placed in the rear view.
Components
Module Name Price
Unit
Quantity
Drive Servo - Medium Full Rotation £9.06 2 Drive Tamiya 70193 Slim Tire Set (4 tires) £6.80 1 Microcontroller Arduino uno £19.98 1 Microcontroller Xbee Wireless Bluetooth Transceiver Module RS232 / TTL £9.39 0 Microcontroller Triple Axis Accelerometer Breakout - ADXL335 £15.53 1 Microcontroller Triple-Axis Digital-Output Gyro ITG-3200 Breakout £31.10 1 Power BT04065 - 4AA Extra-High Capacity Batteries £7.16 1 Power 4 AA Battery case £0.00 1 Total: £98.69
Figure 16 – Proposed TWR
Preliminary Report – Balancing Robot Design and Development ELECTED DESIGN ANALAYSIS
16
2.3 Research conclusions
Being the ballbot an evolution from the two wheeled robot and due to the lack of knowledge
in inverted pendulum mechanics and although the ballbot presents a more challengeable and
exciting project due to the budget constraints the decision of which project to follow is clear.
Also both ballbot models were built by a team of electronic and mechanical engineers which
allowed them to create a better prototype using each members field of expertise.
The decision to build a two wheeled inverted pendulum robot is not the preferred but it is
however the better option to provide knowledge and understanding of the inverted pendulum
control problem. In the future the author would like to proceed with the creation of a
prototype with dimensions similar to a person because the benefits presented are not only
crucial to a robot that can easily interact in human environments but also presents a very
economically profitable business aimed at several industries.
3 ELECTED DESIGN ANALAYSIS
This topic will try to divide the project into smaller blocks allowing better time management
and easier overall design. Since the robot proposed for simulation and building is the two
wheeled inverted pendulum robot the initial division into modules will be the following.
The Drive, this will include motors (and motor drivers if required) as well as the required
analysis and measuring of the components properties. Frame, which will consist in design
and material analysis for the robot, also, the equations of motion and control will fall under
this category. Microcontroller, being the brain of the robot this module will possibly overlap
with other modules but will be considered individual because a final composition of all the
sketched codes for each module will be required. Finally, the sensing module, which will
consist in creating an accurate measuring unit to be easily interfaced with the microcontroller.
3.1 Sensing Module
3.1.1 Introduction
Most systems which are dynamically unstable require a method to determine their orientation
before they are able to be controlled. A good example is UAVs (Unmanned Air Vehicles) due
to the fact that they do not have a pilot who would be able to percept/acquire data, say from
looking out of the cockpit window to be able to then take the required action to compensate
Preliminary Report – Balancing Robot Design and Development ELECTED DESIGN ANALAYSIS
17
the direction or altitude to bring the aeroplane to the required position they will require a set
of sensors to be able to do that inferring automatically in a lack of a person.
Applied to the project the required measurements will be the ability to detect the direction of
the movement, the speed of the vehicle and how fast it is rotating or falling, depending on the
plane. With this in mind a set of basic movements will be analysed in order to determine the
problem and required sensing module. Based on the proposed model at the end of the
research the demonstration and analysis of three conceivable situations the robot will
encounter will be set forth to better understand the sensing requirements.
In scenario 1 the robot is still. However, due to the fact that it is on top of two wheels it will
be impossible to keep upright position. Thus, it will be required to detect how many degrees
per time frame it is falling to be able to feed that value to the control algorithm. Because, of
the two wheels we can assume the robot will always fall in the same plane. The direction of
the fall will need to be identified to compensate the motors in the right direction.
For the second scenario the robot will require to turn on its own z axis. However, if we can
always maintain the position in scenario 1 we can neglect having to detect motion in another
plane saving the requirements of having to measure an extra acceleration.
Centre
of mass
Centre
of mass
Centre
of mass
Figure 17 - Possible scenarios the robot will face
Scenario 1 - balancing position Scenario 2 - rotate on z axis Scenario 3 – move
Preliminary Report – Balancing Robot Design and Development ELECTED DESIGN ANALAYSIS
18
In the last scenario, when the robot moves we will need to detect the fall while preventing it
from going to the upright position, so that is always in a permanent fall state allowing for the
movement to occur. For this we will need to detect the displacement of the wheel, thus an
accelerometer that detects movement in a plane perpendicular to plane z and the wheels will
be required. Henceforth, that plane will be regarded as x plane and we can consider it as
parallel to the surface the robot will be on. All scenarios assume that the wheels will never
lose contact with the floor.
3.1.2 Accelerometers and gyro analysis
To be able to have the required measurements an accelerometer would suffice. However,
research in building robots that need to know their position in space indicates that it alone
does not provide accurate readings; this is due to motor oscillation that introduces noise into
the readings.
An Inertial Motion Unit (IMU) compensates those inaccuracies introduced by the false
readings. It consists in combining a gyroscope with and accelerometer (and sometimes a
magnetometer to detect magnetic orientation) to provide a reliable reading. In addition the
values read are passed through a Kalman filter, it basically consists of inferring present
values based on previous readings and estimations of future values, this allows us to have a
smoother output of values with less discrepancies.
The accelerometer for the IMU (Figure 18) will read the inertial and gravitational force, so if
we have a three axis accelerometer like the one chosen in the components and it is still, we
will measure one g-force in the z axis according to the datasheet, as this will be the earth
gravitational pull. The output of data is analogue and the resolution will value depending on
the reference voltage which is equal to the supplied voltage and can swing from 1.8 to 3.6
volts. The sensing capability is from +3g to -3g.
Figure 18 - Accelerometer
Preliminary Report – Balancing Robot Design and Development ELECTED DESIGN ANALAYSIS
19
The gyro (Figure 19) will measure the disturbances in the current axis, measuring the rotation
in that axis. For the selected component the interface uses the I2C protocol which simplifies
communication. For example, to read a certain rotation axis value, we only need to specify
the address of the register we would like to get (it needs to be read twice because the values
are 16bit 2s complement). The sensing capability goes from -2000°/s to +2000°/s and it has
separate input voltage and reference voltage, able to go from 2.1 to 3.6v.
3.1.3 Building and simulating the IMU
The IMU will be the gyroscope and the accelerometer attached to the microcontroller,
Arduino board. Following the datasheet the diagram in Figure 20 shows how they have been
connected to the microcontroller.
Figure 19 - Gyro
Figure 20- Sensor Diagram
Preliminary Report – Balancing Robot Design and Development ELECTED DESIGN ANALAYSIS
20
A small sample code was also created to test interfacing with the sensors (see Appendix 7.2),
following this a Matlab® model was designed to be able to analyse the readings from the
sensors and help towards creating a model for developing the control algorithm.
The Simulink® model in Figure 21 connects to the serial port of the connected Arduino
board with the attached sensors, which transmits a vector of the three rotations, as in Figure
20 and displays the values in the three boxes, one for each of the axis. It is also being
attempted to get a visualisation of the actual rotation in the 3D model feeding of the parsed
vector read from the serial link (Figure 22).
Figure 21- Matlab® Simulink® designed model
Figure 21- Matlab® Simulink® designed model
Preliminary Report – Balancing Robot Design and Development PROJECT BREAKDOWN
21
4 PROJECT BREAKDOWN
4.1 Plan & Milestones
The project will span over two semesters with the final goal of achieving a balanced and
controlled two wheeled robot. A Gantt was created to depict in detail the tasks taken and yet
to be done as well as the project milestones assigned by the lecturers and self-assigned
milestones such as decisions and estimated prototype readiness (See Appendix 7.1 for more
detail).
Preliminary Report – Balancing Robot Design and Development CONCLUSION
22
5 CONCLUSION
At this stage with the research done the selected type of design to follow is the two wheeled
inverted pendulum. Some initial design analysis and the assembly of the sensing unit is
complete. For the next step I will work on perfecting the sensing to give accurate readings by
simulating real value readings and displaying them on the modelled 3D Matlab® Simulink
model.
After, the frame design with the drive module will be assembled so the equations of motions
and afterwards the control can be designed, as they mass of body and some other values of
the final prototype.
Preliminary Report – Balancing Robot Design and Development REFERENCES
23
6 REFERENCES
Ballbot balancing in the CMU motion capture lab, with Ralph Hollis looking on. (2006). Retrieved November 7, 2011, from http://www.msl.ri.cmu.edu/projects/ballbot/images/Ballbot_Goldfein_small.jpg
Masaaki Kumagai BallIP. (2008). Retrieved November 7, 2011, from http://a1.twimg.com/profile_images/688323178/ballip_rev20.jpg
Battlestar Galactica Comic Con Exclusives. (2009). Retrieved November 7, 2011, from http://everyjoe.com/files/2009/07/serge-usb-keychain.jpg
Anderson, D. P. (2002, December 12). nBot Balancing Robot. Retrieved November 6, 2011, from Geology SMU: http://www.geology.smu.edu/~dpa-www/robo/nbot/
EPFL. (2000, January 25). EPFL - Joe the pendulum. Retrieved November 3, 2011, from EPFL: http://lei.epfl.ch/page-36905-fr.html
Hollis, R. (2011, January 4). Microdynamic Systems Laboratory. Retrieved October 11, 2011, from Dynamically-Stable Mobile Robots in Human Environments: http://www.msl.ri.cmu.edu/projects/ballbot/
Justin Fong, S. U. (2009, May 22). TGU Drive. Adelaide.
Kumagai, M., & Ochiai, T. (2009, September 29). Development of a Robot Balanced on a Ball. Tohoku, Japan.
Lauwers, T. B., Kantor, G. A., & Hollis, R. L. (2006). A Dynamically Stable Single-Wheeled. Proc. IEEE Int’l. Conf. on Robotics and Automation,, 3.
Steve. (2004, April 6). Steve's LegWay. Retrieved November 6, 2011, from Team Hassen Plug: http://www.teamhassenplug.org/robots/legway/
Vamfun. (2007, August 20). Modeling a Two Wheeled Inverted Pendulum Robot.
Watzman, A. (2006, August 9). Carnegie Mellon Researchers Develop New Type of Mobile
Robot That Balances and Moves on a Ball Instead of Legs or Wheels. Retrieved October 15, 2011, from http://www.msl.ri.cmu.edu/projects/ballbot/text/BallbotAugustFinal.pdf
Preliminary Report – Balancing Robot Design and Development APPENDIX
24
7 APPENDIX
7.1 Detailed Gantt chart
Preliminary Report – Balancing Robot Design and Development APPENDIX
25
Preliminary Report – Balancing Robot Design and Development APPENDIX
26
Preliminary Report – Balancing Robot Design and Development APPENDIX
27
Preliminary Report – Balancing Robot Design and Development APPENDIX
28
Preliminary Report – Balancing Robot Design and Development APPENDIX
29
Preliminary Report – Balancing Robot Design and Development APPENDIX
30
Preliminary Report – Balancing Robot Design and Development APPENDIX
31
Preliminary Report – Balancing Robot Design and Development APPENDIX
32
7.2 Arduino code for the IMU
8 //The Wire library is used for I2C communication
9 #include <Wire.h>
10 //ITG3200 sensitivity is 14.375 LSB/(degrees/sec) 11 #define GYROSCOPE_SENSITIVITY (1 / 14.375) 12 //Voltage reference for the ADC 13 #define V_REF 3.3 14 //Number of calibration samples 15 #define CALIBRATION_SAMPLES 128 16 //Number of samples per value returned 17 #define SAMPLES 4 18 //16bit 2s complement range 19 #define G_RESOLUTION 32767 20 //Accelerometer pins 21 #define PIN_X 0 22 #define PIN_Y 1 23 #define PIN_Z 2 24 25 //This is a list of registers in the ITG-3200 26 char WHO_AM_I = 0x00; 27 char SMPLRT_DIV= 0x15; 28 char DLPF_FS = 0x16; 29 char TEMP_OUT_H = 0x1B; 30 char TEMP_OUT_L = 0x1C; 31 char GYRO_XOUT_H = 0x1D; 32 char GYRO_XOUT_L = 0x1E; 33 char GYRO_YOUT_H = 0x1F; 34 char GYRO_YOUT_L = 0x20; 35 char GYRO_ZOUT_H = 0x21; 36 char GYRO_ZOUT_L = 0x22; 37 38 //Calibration variables for g_ == gyro and a_ == accelerometer 39 long g_xBias = 0, g_yBias = 0 , g_zBias = 0; 40 long a_xBias = 0, a_yBias = 0, a_zBias = 0; 41 float a_sensitivity=0; 42 int a_0g=0; 43 44 45 //This is a list of settings that can be loaded into the registers. 46 //DLPF, Full Scale Register Bits 47 //FS_SEL must be set to 3 for proper operation 48 //Set DLPF_CFG to 3 for 1kHz Fint and 42 Hz Low Pass Filter 49 char DLPF_CFG_0 = (1<<0); 50 char DLPF_CFG_1 = (1<<1); 51 char DLPF_CFG_2 = (1<<2); 52 char DLPF_FS_SEL_0 = (1<<3); 53 char DLPF_FS_SEL_1 = (1<<4); 54 55 //I2C devices each have an address. The address is defined in the datash
eet for the device. The ITG-
3200 breakout board can have different address depending on how
56 //the jumper on top of the board is configured. By default, the jumper is connected to the VDD pin. When the jumper is connected to the VDD pin
the I2C address
57 //is 0x69. 58 char itgAddress = 0x69; 59
Preliminary Report – Balancing Robot Design and Development APPENDIX
33
60 //In the setup section of the sketch the serial port will be configured, the i2c communication will be initialized, and the itg-
3200 will be configured.
61 //Calibration for the itg3200 and adxl335 62 void setup() 63 { 64 //Create a serial connection using a 9600bps baud rate. 65 Serial.begin(9600); 66 67 //Initialize the I2C communication. This will set the Arduino up as
the 'Master' device.
68 Wire.begin(); 69 70 //Read the WHO_AM_I register and print the result 71 char id=0; 72 id = itgRead(itgAddress, 0x00); 73 Serial.print("ID: "); 74 Serial.println(id, HEX); 75 76 //Configure the gyroscope 77 //Set the gyroscope scale for the outputs to +/-2000 degrees per