real time orientation control and analysis of a...

24
REAL TIME ORIENTATION CONTROL AND ANALYSIS OF A REMOTELY OPERATED VEHICLE USING INTERFACE OF MATLAB AND MICROCONTROLLER TAN CHONG KAI This report is submitted in partial fulfillment of the requirements for the award of Bachelor of Electronic Engineering (Computer Engineering) With Honours Faculty of Electronic and Computer Engineering Universiti Teknikal Malaysia Melaka April 2010

Upload: vanquynh

Post on 27-Mar-2019

213 views

Category:

Documents


0 download

TRANSCRIPT

REAL TIME ORIENTATION CONTROL AND ANALYSIS OF A

REMOTELY OPERATED VEHICLE USING INTERFACE

OF MATLAB AND MICROCONTROLLER

TAN CHONG KAI

This report is submitted in partial fulfillment of the requirements for the award of

Bachelor of Electronic Engineering (Computer Engineering) With Honours

Faculty of Electronic and Computer Engineering

Universiti Teknikal Malaysia Melaka

April 2010

ii

UNIVERSTI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER

BORANG PENGESAHAN STATUS LAPORAN PROJEK SARJANA MUDA II

Tajuk Projek : Real Time Orientation and Analysis of a Remotely Operated Vehicle Using Interface of MATLAB and Microcontroller.

Sesi Pengajian : 2009/2010 Saya TAN CHONG KAI mengaku membenarkan Laporan Projek Sarjana Muda ini disimpan di Perpustakaan dengan syarat-syarat

kegunaan seperti berikut:

1. Laporan adalah hakmilik Universiti Teknikal Malaysia Melaka.

2. Perpustakaan dibenarkan membuat salinan untuk tujuan pengajian sahaja.

3. Perpustakaan dibenarkan membuat salinan laporan ini sebagai bahan pertukaran antara institusi

pengajian tinggi.

4. Sila tandakan ( √ ) :

SULIT*

(Mengandungi maklumat yang berdarjah keselamatan atau kepentingan Malaysia seperti yang termaktub di dalam AKTA RAHSIA RASMI 1972)

TERHAD* (Mengandungi maklumat terhad yang telah ditentukan oleh

organisasi/badan di mana penyelidikan dijalankan)

TIDAK TERHAD

Disahkan oleh:

__________________________ ___________________________________ (TANDATANGAN PENULIS) (COP DAN TANDATANGAN PENYELIA)

Alamat Tetap:

Tarikh: ……………………….. Tarikh: ………………………..

iii

I hereby declare that I have read this project report and in my opinion this project

report is sufficient in terms of scope and quality for the award of the Bachelor

Degree Honour of Electronic & Computer Engineering.

Signature :

Name : Madam Wong Yan Chiew

Date : 30 April 2010

iv

I declare that this project report entitled “Real Time Orientation and Analysis of a

Remotely Operated Vehicle Using Interface of MATLAB and Microcontroller” is

the result of my own research except as cited in the references. The project report has

not been accepted for any degree and is not concurrently submitted in candidature of

any other degree.

Signature :

Name : TAN CHONG KAI

Date : 30 April 2010

v

Specially.

To my beloved parents

To my kind brothers and sisters

And not forgetting to all friends

For their

Love, Sacrifice, Encouragements, and Best Wishes

vi

ACKNOWLEDGEMENTS

First at all, I would like to admire and express my thankfulness to our God

because I can finish this 40 weeks or two semester long period final year project at

Universiti Tecknikal Malaysia Malaka (UTeM) and the report is submitted exact on

time. Base on that, I already fulfill the requirement of the BENU4583 and

BENU4983.

Next, I would like to state my gratitude to all people that have assist and

guide me in this final year project or Project Saujana Muda (PSM). My PSM

supervisor, Madam Wong Yan Chiew does help me a lot to scheduling mile stone

and increasing my spirit strange to accomplish the work. She is brilliant who color

the PSM group under her guidance, which consists of 6 students in the same course.

Madam Wong had patiently guides me to the actual way to finish this project.

She is the person who masters the knowledge of Genetic Algorithm, which brings

and provides us a lot of extra knowledge. Moreover, I am also indebted to UTeM for

their encouragement and facilities support during my research. Not forgetting to all

fellow postgraduate students and friends for their moral support and helping me

during this entire two semesters. Without their continued support and interest, this

project would not have been realized.

Last but not least, my gratitude also goes to all my family members for their

continuous encouragement and financial support. Thanks you all.

vii

ABSTRACT

This thesis presents the design and development of real time interface

communication system of Remotely Operated Vehicle (ROV). Communication

interface is to transmit and receive the data from source to destination to perform the

tasks or motions in real time. Interface communication of ROV is based on the

connection between Microcontroller PIC16F877A and Matrix Laboratory

(MATLAB) to perform in real time orientation control and analysis. Universal Serial

Bus - Recommended Standard 232 (USB-RS232) is used as an interface cable to join

the connection by transferring and receiving the data to ROV and MATLAB. The

data transferring and receiving are executed in series connection. Programmable

Integrated Chip (PIC) uses Analog Digital Converter (DAC) to receive data from

accelerometer and convert the data to digital before transmits to MATLAB. PIC

collects the data of X-axis, Y-axis and Z-axis from accelerometer sensor in ROV,

which represent the current position or angle of ROV. MATLAB receive and display

the data through Graphical User Interface (GUI), the data will save in .mat format for

further analysis. Based on the setting, the motors will perform accordingly to balance

and stabilize the ROV in real time. The validation of interface communication is

identified by collect 100 times data sets from accelerometer in 3-axes for different

angles or degrees. The accuracy and precision of based on the data transfer from

accelerometer is identified. The error percentages for each axis are less than 5% from

the measured voltages. Therefore, MATLAB GUI performs the valid and acceptable

data for ROV in real time operation.

viii

ABSTRAK

Laporan akhir Projek Sarjana Muda ini dikaji sebagai projek perancangan dan

pembangunan interface komunikasi Remotely Operated Vehicle (ROV) sistem yang

mempunyai masa yang nyata. Komunikasi interface adalah process yang menghantar

dan menerima data dari sumber ke desitinasi dengan tujuan melakukan tugas atau

gerakan ROV. Komunikasi interface ROV adalah berdasarkan hubungan antara

Microcontroller PIC16F877A dan Matrix Laboratory (MATLAB) untuk melakukan

orientasi kawalan masa nyata dan analisis. Universal Serial Bus - Recommended

Standard 232 (USB-RS232) digunakan sebagai kabel interface untuk

menyambungkan sambungan dengan memindah dan menerima data ke ROV dan

MATLAB. Programmable Integrated Chip (PIC) menggunakan Analog Digital

Converter (DAC) untuk menerima data dari accelerometer serta menukarkan data ke

digital sebelum menghantar ke MATLAB. PIC mengumpulkan data di paksi-X,

paksi-Y dan paksi-Z dari sensor accelerometer ROV di mana mewakili keadaan

ROV yang terkini. MATLAB menerima dan memaparkan data terkini melaui

Graphical User Interface (GUI), data yang dipapar akan disimpan dalam database.

Berdasarkan tatacara, motor akan bergerak untuk menyeimbangkan dan

menstabilkan ROV secara masa nyata. Validasi di komunikasi interface dikenalpasti

dengan mengumpulkan 100 kali set data dari accelerometer secara pelbagai sudut

atau darjah. Ketepatan berdasarkan pemindahan data dari accelerometer dikenalpasti.

Peratus kesalahan untuk setiap paksi adalah kurang 5 peratus daripada ukuran voltan.

Oleh kerana itu, MATLAB GUI menunjukkan data yang sah dan nyata serta diterima

dalam operasi ROV.

ix

TABLE OF CONTENT

CHAPTER TITLE

PAGE

PROJECT TITLE i

PROJECT STATUS FORM ii

DECLARATION iii

DEDICATION v

ACKNOWLEDGEMENTS vi

ABSTRACT vii

ABSTRAK viii

TABLE OF CONTENTS ix

LIST OF TABLES xiii

LIST OF FIGURES xiv

LIST OF ABBREVIATIONS

LIST OF APPENDICES

xvi

xvii

I INTRODUCTION

1.1 Introduction 1

1.2 Objective 2

1.3 Problem Statement 3

1.4 Scope of Work 3

1.5 Thesis Structure 4

II LITERATURE REVIEW

2.1 Introduction 6

2.2 Interface Communication 6

x

2.2.1 Serial Communication, RS232 and MAX232 7

A. 2.2.2 USB-RS232 Converter Communication 9

B. 2.2.3 Parallel Communication 10

C. 2.2.4 Interfaces Cable 14

D. 2.2.5 Transmitted Voltage 15

2.3 Microcontroller PIC16F877A 16

2.4 Stability Orientation Control 17

2.4.1 Accelerometer 17

2.5 MATLAB 18

2.5.1 Test and Measurement Tool (TMTOOL) 19

2.5.2 MATLAB Graphical User Interface 19

2.6 Hyperterminal 20

2.7 Conclusion 22

III PROJECT METHODOLOGY

3.1 Introduction 23

3.2 Flow Chart 25

3.3 Methodology 26

3.4 Conclusion 28

IV GENETIC CIRCUIT OPTIMIZER DEVELOPMENT

4.1 Introduction 29

4.2 Initial Analysis of System 29

4.2.1 Serial Port 29

4.2.2 Parallel Port 30

4.2.3 USB-RS232 Converter 31

4.2.4 Comparison between Interfaces 31

4.3 Self Test Result for USB-RS232 Converter 32

xi

4.3.1 Interrupt and Shake on USB-RS232 Converter using

MATLAB Test and Measurement Tool (TMTOOL)

32

4.3.2 Fast Data Transfer using Hyperterminal Test 35

4.4 Test Result for AUV Interface Design Circuit 36

4.4.1 Motor Response Testing using Data Transfer from

MATLAB to PIC

37

4.4.2 Accelerometer Response using Data Transfer from

PIC to MATLAB

40

4.5 Result from MATLAB GUI 43

4.6 Conclusion 43

V VALIDATION OF INTERFACE COMMUNICATION

5.1 Introduction 45

5.2 Potential Problem 45

5.3 Data Validation 46

5.3.1 Zero Degree Position 46

5.3.2 90 Degree Position 50

5.3.3 180 Degree Position 54

5.3.4 270 Degree Position 58

5.4 Conclusion 62

VII CONCLUSION

6.1 Conclusion 63

6.2 Future work 64

REFERENCES

65

APPENDICES A 67

xii

APPENDICES B 68

APPENDICES C 69

APPENDICES D 70

APPENDICES E 73

APPENDICES F 81

APPENDICES G 97

APPENDICES H 107

xiii

LIST OF TABLES

TABLE NO. TITLE PAGES

2.1 Serial Communication Equipment RS232 Pin Definition 7

2.2 25 pins DB Male Parallel Port Connector 11

2.3 Price and Data Transfer of Interfaces 15

4.1 USB-RS232 Versus Other Interface 31

4.2 Three Cycles of Motion for Motor After PIC Receive

Data from MATLAB

39

4.3 Percentage Error for Left Motor and Right Motor 39

4.4 Motion Test for Motor After PIC Receive Data from

MATLAB

42

5.1 100 Times of Data Received from Accelerometer in Zero

Degree.

47

5.2 100 Times of Data Received from Accelerometer in 90

Degree.

51

5.3 100 Times of Data Received from Accelerometer in 180

Degree.

55

5.4 100 Times of Data Received from Accelerometer in 270

Degree.

59

xiv

LIST OF FIGURES

FIGURE NO. TITLE

PAGES

2.1 RS232 DB9 Pinout 7

2.2 Pinout of IC MAX232 8

2.3 Connection between PC DB9, MAX232 and PIC 9

2.4 USB to RS232 Serial 9Pin Converter Model UC1052 10

2.5 8 Bit Data Transfer for Parallel Communication 11

2.6 Pinout of Parallel 25 Pin Connector 12

2.7 Pinout of parallel 36 Pin Connector 13

2.8 Connection between Microcontroller and Parallel Port 13

2.9 Noise for Different Cable Lengths 14

2.10 40 Pin PIC16F877A 16

2.11 Accelerometer ADXL330 with 3 Axes 18

2.12 TMTOOL in MATLAB 19

2.13 Example of GUI Design 20

2.14 Connection Description of Hyperterminal 21

3.1 Flow Chart 25

3.2 Block Diagram for Interface Communication 26

3.3 Basic Circuit Testing for Interface Communication 27

3.4 Connection for Accelerometer and Motors in Circuit 27

3.5 MATLAB GUI for Real Time Orientation of ROV 28

4.1 Instrument Control Toolbox in TMTOOL 32

4.2 Status to COM1 after Connected 33

4.3 Connection of TxD and RxD 33

4.4 Data Transmit and Receive using TMTOOL 34

4.5 COM 1 Properties 35

xv

4.6 ASCII Setup 35

4.7 Hyperterminal Screen with Fast Typing 36

4.8 Overall Basic Circuit Design for Low Cost ROV

Interface

37

4.9 Connection of Two Motors in the Circuit 38

4.10 MATLAB Datatrasmit.mat for Motor Response 38

4.11 Circuit and Connection of Accelerometer 40

4.12 The Rotation Axes of An Accelerometer, Roll, Pitch,

and Yaw

41

4.13 Result for Accelerometer Test at MATLAB

Datareceive.mat File

42

4.14 The Real Time Result from MATLAB GUI 43

5.1 Zero Degree Position 46

5.2 Statistic Analysis for Zero Degree 50

5.3 90 Degree Position 50

5.4 Statistic Analysis for 90 Degree 54

5.5 180 Degree Position 54

5.6 Statistic Analysis for 180 Degree 58

5.7 270 Degree Position 58

5.8 Statistic Analysis for 270 Degree 62

xvi

LIST OF TABLES

TABLE NO. TITLE PAGES

2.1 Serial Communication Equipment RS232 Pin Definition 7

2.2 25 pins DB Male Parallel Port Connector 11

2.3 Price and Data Transfer of Interfaces 15

4.1 USB-RS232 Versus Other Interface 31

4.2 Three Cycles of Motion for Motor After PIC Receive

Data from MATLAB

39

4.3 Percentage Error for Left Motor and Right Motor 39

4.4 Motion Test for Motor After PIC Receive Data from

MATLAB

42

5.1 100 Times of Data Received from Accelerometer in Zero

Degree.

47

5.2 100 Times of Data Received from Accelerometer in 90

Degree.

51

5.3 100 Times of Data Received from Accelerometer in 180

Degree.

55

5.4 100 Times of Data Received from Accelerometer in 270

Degree.

59

xvii

LIST OF FIGURES

FIGURE NO. TITLE

PAGES

2.1 RS232 DB9 Pinout 7

2.2 Pinout of IC MAX232 8

2.3 Connection between PC DB9, MAX232 and PIC 9

2.4 USB to RS232 Serial 9Pin Converter Model UC1052 10

2.5 8 Bit Data Transfer for Parallel Communication 11

2.6 Pinout of Parallel 25 Pin Connector 12

2.7 Pinout of parallel 36 Pin Connector 13

2.8 Connection between Microcontroller and Parallel Port 13

2.9 Noise for Different Cable Lengths 14

2.10 40 Pin PIC16F877A 16

2.11 Accelerometer ADXL330 with 3 Axes 18

2.12 TMTOOL in MATLAB 19

2.13 Example of GUI Design 20

2.14 Connection Description of Hyperterminal 21

3.1 Flow Chart 25

3.2 Block Diagram for Interface Communication 26

3.3 Basic Circuit Testing for Interface Communication 27

3.4 Connection for Accelerometer and Motors in Circuit 27

3.5 MATLAB GUI for Real Time Orientation of ROV 28

4.1 Instrument Control Toolbox in TMTOOL 32

4.2 Status to COM1 after Connected 33

4.3 Connection of TxD and RxD 33

4.4 Data Transmit and Receive using TMTOOL 34

4.5 COM 1 Properties 35

xviii

4.6 ASCII Setup 35

4.7 Hyperterminal Screen with Fast Typing 36

4.8 Overall Basic Circuit Design for Low Cost ROV

Interface

37

4.9 Connection of Two Motors in the Circuit 38

4.10 MATLAB Datatrasmit.mat for Motor Response 38

4.11 Circuit and Connection of Accelerometer 40

4.12 The Rotation Axes of An Accelerometer, Roll, Pitch,

and Yaw

41

4.13 Result for Accelerometer Test at MATLAB

Datareceive.mat File

42

4.14 The Real Time Result from MATLAB GUI 43

5.1 Zero Degree Position 46

5.2 Statistic Analysis for Zero Degree 50

5.3 90 Degree Position 50

5.4 Statistic Analysis for 90 Degree 54

5.5 180 Degree Position 54

5.6 Statistic Analysis for 180 Degree 58

5.7 270 Degree Position 58

5.8 Statistic Analysis for 270 Degree 62

xix

LIST OF ABBREVIATIONS

3D

ADC

DCE

DTE

EMI

GA

-

-

-

-

-

-

Three Dimension

Analog Digital Converter

circuit-terminating equipment

data terminal equipment

Electromagnetic Interference

Genetic Algorithm

GUI

IMU

-

-

Graphic User Interface

Inertial Measurement Unit

MATLAB

MAX232

-

-

Matrix Laboratory

Maxim232

ROV - Remotely Operated Vehicle

PIC

RXD

-

-

Programmable Interface Controller

Receive Data

SCI - serial communications interface

TMS

TMTOOL

TXD

-

-

-

Tether Management System

Test and Measurement Tool

Transmit Data

USB-RS232 - Universal Serial Bus-Recommended Standard 232

xx

LIST OF APPENDICES

APPENDIX TITLE PAGES

A Interface Schematic 67

B PCB Layout 68

C Hardware for Real Time Interface Communication circuit 69

D C Programming 70

E MATLAB GUI Programming 73

F Journal Under Review 1 81

G Journal Under Review 2 97

H Develop Interface Communication for Low Cost

Autonomous Underwater Vehicle

107

CHAPTER I

INTRODUCTION

1.1 Introduction

Interface communication is used to communicate between Remotely

Operated Vehicle (ROV) and matrix laboratory (MATLAB) computer for data

transmitting and data receiving purpose. Data from ROV is transmitted to or received

from MATLAB via interface communication during the operation. ROV and

MATLAB response and take action after data is successful received through

interface communication.

From the previous researches or projects, the interface methods applied in

ROV such as tether or umbilical cable [1][2][3]. ROV systems universally employ

tether or umbilical cables to provide power to and communication with the vehicle.

Tethers supply the vital link from the ROV to the surface or control module via the

tether management system (TMS) through the main lifts umbilical. The services

provided by the tether include power, coaxial cables, twisted pairs and quads, and

even optical fiber for data transmission. High bandwidth sensors such as high

definition cameras and 3D multibeam imaging acoustics are portable through the

tether of the ROV due to the miniaturization of Ethernet-based components. Fiber

optic multiplexers and Ethernet extenders allow both light-waves as well as copper-

based high-bandwidth data transmission for sensor throughput [4]. The price for a

tether normally is cost RM3000 [5].

2

However, due to the high cost and multipurpose used of the interface above,

those interfaces are not suitable for low cost interface design. Low cost interface only

required transfer and receive data between ROV and MATLAB. Therefore, interface

such as serial port connection, parallel port connection and Universal Serial Bus -

Recommended Standard 232 (USB-RS232) converter cable are compared based on

the cost, data transfer rate, size and quality of cable length. Low cost interface, faster

data transfer rate, stable and less noise are suitable for low cost ROV design.

Several types of interface such as serial port connection, parallel port

connection and USB-RS232 converter port are compared based on the cost, data

transfer rate, size and quality of cable length. Low cost interface, faster data transfer

rate, stable and less noise are suitable for low cost ROV design. The quality and

performance of the USB-RS232 is tested using loopback method. Cable interruption

and fast data transfer are tested and observed using Test and Measurement Tool

(TMTOOL) and Hyperterminal methods. Voltage of cable is measured and compared

before and after cable is disturbed and shakes, and overload data transfer during data

transferring. At the initial stage, potentiometer is used to transmit data to MATLAB,

which act as a sensor transmit data to MATLAB by adjusting the resistance from 0kΩ

to 20kΩ via pin 25 of PIC16F877A. While receive data at pin 26 after MATLAB

send data to PIC and light on the LEDs. Besides that, Graphical User Interface (GUI)

provides a very convenient tool to control the ROV and to display data of an ROV.

Various tasks that can be performed by the GUI include display condition of ROV

such as speed of thruster, accelerometer and sonar sensor.

1.2 Objectives

The main purposed of this project are to design an interface for MATLAB

and ROV System. Therefore, the objectives as below should be achieved.

i. To identify the suitable low cost interface communication between ROV and

MATLAB.

ii. To create an interface for the ROV between microcontroller and MATLAB.

iii. To develop orientation control using accelerometer sensor.

3

1.3 Problem Statement

Generally, an autonomous underwater vehicle (ROV) is a robot which travels

underwater with many types of sensors and propulsion system with unman control.

ROV passed the information received from sensors and pass it on the computer to

analyze this information. The communication between the ROV and computer is

achieved via interface communication.

However, for existing ROV project, the cost for conventional interface

communication such as interface card and communication devices are very

expensive to perform underwater operations. Many small and medium type

companies or researchers are not able to afford the high technology interface

communication cost. Installation sensors for orientation control of ROV such as

gyrosensor or inertial measurement unit (IMU) is very expensive and unsuitable for

research and study purpose. Besides that, many research centers use low quality

interface communication for researching and exploring, data transmission will be

affected by environmental factor such as noise and obstacles influence their findings.

For this situation, USB-RS232 used as low cost interface communication

between MATLAB and ROV, which able to transmit and receive data in real time

orientation control. Accelerometer sensor used as stability sensor to perform the

stability of ROV during real time orientation control. MATLAB GUI is designed to

display and save the instant data from accelerometer to control the speed of motor.

1.4 Scope of Work

The scope of Real time orientation and analysis of ROV includes interface,

microcontroller, stability orientation control and MATLAB design. Low cost

interface ROV uses USB-RS232 cable as communication between ROV and

MATLAB to send and receive data in real time operation. Microcontroller

PIC16F877A is the main core of ROV which detect stability and position of ROV

and control output for motor thrusters. Accelerometer sensor is stability sensor to

4

detect the balancing and stabilizing of orientation ROV. MATLAB GUI displays the

current data of accelerometer and monitors speed of motors underwater.

1.5 Thesis Structure

It consists of six chapters. Following is a chapter-by-chapter description of

information in this thesis.

Chapter 1 gives reader a basic introduction to how the idea of this project

generated. The chapter contains introduction, objective of the project, problem

statement, scopes of work, brief methodology, and report structure.

Chapter 2 is a literature review on theoretical concepts applied in this project.

The chapter concludes the background study of serial, USB-RS232 converter and

parallel cable. Besides that, this chapter also explains maximum cable lengths for

interface, what is MATLAB, what is Test and Measurement Tool, what is

Hyperterminal and application of others component such as PIC16F877A,

Accelerometer and Gyrosensor. Then, why choose the specific interface, MATLAB,

Hyperterminal and related components.

Chapter 3 introduces the methodology of the project. The chapter contains the

flow chart which explains the overall method taken along the project carry out.

Besides that, this chapter also introduces the construction of the project, which

involves hardware development and software development. Basically, the hardware

development for the project concludes with ROV accelerometer sensor, thruster, and

block diagram design. Besides, the software development of project will discuss

what graphical programming is, how to use the MATLAB and C programming, and

how to implement it on this project.

Chapter 4 will be covered all the result from designing process. It will also

include a discussion about the project. The chapter concludes with discussion on

front panel of virtual instrument and control circuit for the system.