ii DEVELOPMENT OF A COMPUTER CONTROLLED REMOTELY OPERATED

Shared by: dffhrtcv3
Categories
Tags
-
Stats
views:
96
posted:
12/24/2011
language:
pages:
107
Document Sample
scope of work template
							                                                         ii




DEVELOPMENT OF A COMPUTER CONTROLLED REMOTELY OPERATED
                  UNDERWATER VEHICLE




                  CHEONG YEW HOONG




             UNIVERSITI TEKNOLOGI MALAYSIA
                                                                                                        iii

                                                                               PSZ 19:16 (Pind. 1/07)

                        UNIVERSITI TEKNOLOGI MALAYSIA

 DECLARATION OF THESIS / UNDERGRADUATE PROJECT PAPER
                   AND COPYRIGHT
  Author’s full name : CHEONG YEW HOONG
  Date of birth             : 08 JULY 1986

  Title                      : DEVELOPMENT OF A COMPUTER CONTROLLED

                              REMOTELY OPERATED UNDERWATER VEHICLE
  Academic Session          : 2009/2010

  I declare that this thesis is classified as:



                    CONFIDENTIAL                 (Contains confidential information under the
                                                 Official Secret Act 1972)*



                    RESTRICTED                   (Contains restricted information as specified by
                                                 The organization where research was done)*



                    OPEN ACCESS                  I agree that my thesis to be published as online
                                                 open access(full text)

    I acknowledged that Universiti Teknologi Malaysia reserves the right as follows:

       1. The thesis is the property of Universiti Teknologi Malaysia.
       2. The Library of Universiti Teknologi Malaysia has the right to make copies for the
          purpose of research only.
       3. The Library has the right to make copies of the thesis for academic exchange.

                                                                         Certified by :


     __________________________                                   ____________________________
            SIGNATURE                                              SIGNATURE OF SUPERVISOR

     _____860708-05-5139_____                               DR. SHAHRUM SHAH BIN ABDULLAH
    (NEW IC NO. /PASSPORT NO.)                                       NAME OF SUPERVISOR
  Date :  23 April 2010                                           Date : 23 April 2010

NOTES :         *       If the thesis is CONFIDENTAL or RESTRICTED, please attach with the
                       letter from the organization with period and reasons for
                       confidentiality or restriction
                                                                                         ii




      “I hereby declare that I have read this thesis and in my
opinion this thesis is sufficient in terms of scope and quality for the
    award of the degree of Bachelor of Electrical Engineering
                  (Instrumentation and Control).”




     Signature                  : ....................................................
     Name of Supervisor         : Dr. Shahrum Shah Bin Abdullah
     Date                       :              23 April 2010
                                                           iii




DEVELOPMENT OF A COMPUTER CONTROLLED REMOTELY OPERATED
                    UNDERWATER VEHICLE




                     CHEONG YEW HOONG




               A thesis submitted in fulfillment of the
             requirements for the award of the degree of
                 Bachelor of Electrical Engineering
                   (Instrumentation and control)




                  Faculty of Electrical Engineering
                   Universiti Teknologi Malaysia




                             MAY 2010
                                                                                              iv




I hereby declare that this thesis entitled “Development of a Computer Controlled Remotely
Operated Underwater Vehicle “is the result of my own research except as cited in the
references. The thesis has not been accepted for any degree and is not concurrently
submitted in candidature of any other degree.




                Signature    : ............................................................
                Name         : CHEONG YEW HOONG
                Date         :          23 April 2010
                                                                                     v




Dedicated, in thankful appreciation for support, encouragement and understandings to my
beloved mother, father, brothers, sisters and all my friends
                                                                                               vi




                                ACKNOWLEDGEMENTS




        First and foremost, I would like to express my heartily gratitude to my supervisor,
Dr SHAHRUM SHAH BIN ABDULLAH for the guidance given throughout the progress of
this project.




        My appreciation also goes to my family especially my beloved father and mother
who always supports me all these years. Thanks for their encouragement, love and
emotional supports that they had given to me. Without their support, I can’t pass my degree
as Electrical – Control and Instrumentation Engineer.




        During the process of this final year project, there are many difficulties that I
face during the process of constructing the prototype of my ROV. But, with the guidance
and supported from my beloved friends Gan Chiu Ting, Chee Pei Song, Ho Chun kit,
and all other SEI course mates, finally I was able to finish my final year project smoothly.
                                                                                     vii




                                      ABSRACT




       Nowadays, due to the advance of the technology, many robots were created to
reduce human works and increase the efficiency of works. Remotely operated vehicle
(ROV) is one of the tethered underwater robots that is often used at the hostile
environment or deepwater industries such as offshore hydrocarbon extraction. ROV
have become an essential part of the operations and have become not only capable, but
highly reliable. With ROV working as deep as 3048 meter in support of offshore oil and
other tasks, the technology has reached a level of cost effectiveness that allows
organizations from police departments to academic institutions to operate vehicles that
range from small inspection vehicles to deep ocean research systems. Currently, most of
the ROV implement static dive using thrusters. The purpose of this project is to develop
a loss cost ROV that implement static dive using ballast tank concept. Besides, the
development of a Graphic User Interface (GUI) is essential to increase the efficacy of
the ROV which has also been done in this project.

.
                                                                                  viii




                                     ABSTRAK




       Pada zaman sekarang, teknologi telahpun menjadi lebih maju, banyak robot telah
dicipta untuk mengurangkan kerja manusia dan meningkatkan kecekapan kerja tersebut.
Remotely operated vehicle (ROV) adalah salah satu robot yang sering digunakan dalam
tempat-tempat yang berisiko tinggi atau industri yang terlibat dalam air ataupun laut
contohnya industri yang terlibat dalam penggalian hidrokarbon di luar pesisir. ROV
telah memainkan peranan yang penting dalam sesuatu operasi dan boleh diharapkan.
Dengan ROV yang kerja dalam air/laut sebanyak 3048 meter dapat dilakukan untuk
memberi bantuan kepada minyak petroleum di luar pesisir and kerja-kerja lain.
Teknologi telahpun mencapai satu tahap yang kos keberkesanan untuk membolehkan
organisasi dari jabatan polis hingga institusi akademik untuk menjalankan operasi dari
pemeriksaan yang kecil sehingga pemeriksaan yang terlibat dalam sistem penyelidikan
laut. Biasanya, ROV melakukan penyelaman statik dengan menggunakan motor yang
disambung dengan kipas. Objektif projek ini adalah untuk mencipta ROV kos rendah
dan melakukan penyelaman dengan menggunakan konsep ballast tank. Selain daripada
itu, Graphic User Interface (GUI) juga penting demi meningkatkan kerberkesanan ROV
dalam projek ini. Satu GUI yang mudah telah berjaya pada akhir projek ini.
                                                            ix




                        TABLE OF CONTENTS




CHAPTER                             TITLE            PAGE


          DECLARATION                                  ii
          DEDICATION                                   v
          ACKNOWLEDGEMENTS                            vi
          ABSTACT                                     vii
          ABSTRAK                                     viii
          TABLE OF CONTENTS                           ix
          LIST OF TABLES                               xii
          LIST OF FIGURES                             xiii
          LIST OF ABBREVIATIONS                       xvi
          LIST OF APPENDICES                          xvii


  1             INTRODUCTION                            1
          1.1   Remotely Operated Vehicle (ROV)         1
          1.2   Ballast Tank                            3
          1.3   Review of Previous Project              5
          1.4   Problem Statement                       7
          1.5   Objective and Scope of the Project      7
          1.6   Extra Scope of the Project              8
                                                                     x

2   LITERATURE REVIEW                                           9
    2.1    Submarine Diving Technology                          9
    2.2    Types of Ballast Tank                                11
           2.2.1 Piston Ballast Tank                            11
           2.2.2 Membrane Ballast Tank                          12
           2.2.3 Bellows Ballast Tank                           13
           2.2.4   Gas Operated Ballst Tank                     14
           2.2.5 Compressed Ballast Tank                        16
    2.3   Ballast Tank Concept RC Submaine Model                17
           2.3.1 1941 GATO and REVELL U212                      17
           2.3.2 1/72 Russian Kilo Class Submarine Model        18
    2.4    ROV Submersible (PVC)                                19
    2.5   Jason Rollette’s Underwater ROV Submarine             20
    2.6    Summarize of the Literature Review                   21




3   METHODOLOGY                                                 22
    3.1   Project Timeline                                      22
    3.2   Project Methodology                                   23
           3.2.1 Designing and Developing                       24
                   3.2.1.1 Software Programming                 25
                           3.2.1.1.1 mikroC Programming         25
                           3.2.1.1.2 Visual Basic programming   27
                   3.2.1.2 Electronic Hardware Construction     29

                   3.2.1.3 Mechanical Hardware Construction     32

    3.3 Project Overview                                        33
    3.4 Waterproofing Technique                                 35
                                                        xi

4   RESULTS AND DISCUSSION                            36
    4.1    Electronic Hardware                        36
    4.2    Graphic User Interface (GUI)               40
    4.3    Mechanical Hardware (ROV - prototype)      43
    4.4    Ballast Tank System                        46
           4.4.1 Ballast Tank Modification            47
    4.5    Propellers Speed Analysis                  49
    4.6    ROV Movement Control                       51


5   CONCLUSION AND FUTURE RECOMMENDATION             52
    5.1 Conclusion.                                   52
    5.2 Future Recommendation                        53




    REFERENCE                                         54




    APPENDIX A-F                                   56 - 88
                                                                          xii




                   LIST OF TABLES




TABLE NO.                       TITLE                               PAGE


  2.1       Summarize of literature review                           21
  3.1       FYP 1 Gantt Chart                                        22
  3.2       FYP 2 Gantt Chart                                        23
  3.3       3 main components                                        34
  3.4       3 main cable connections                                 34
  4.1       All available control in main GUI form                   41
  4.2       All available buttons in main GUI form 3                 43
  4.3       Calculation readings base on the mikroC C program        49
  4.4       Relationship between propellers and the ROV movements    51
                                                                xiii




                       LIST OF FIGURES




FIGURE NO.                             TITLE              PAGE


    1.1        Remotely Operated (Sub Sea) Vehicle          2
    1.2        Eyeball ROV                                  3
    1.3        Different location of the ballast tank       4
    1.4        Previous prototype                           5
    1.5(a)     ROV submerges                               6
    1.5(b)     ROV floats                                   6
    2.1        Submarine Diving Method                      9
    2.2        Piston type ballast tank                    11
    2.3        Membrane type ballast tank                  12
    2.4        Bellows type ballast tank                   13
    2.5        Gas operated ballast tank                   14
    2.6        Compressed air ballast tank                 16
    2.7        1941 GATO                                   17
    2.8        REVELL U212                                  17
    2.9        Piston ballast tank used in RC submarine     17
    2.10 (a)   Submarine model “kilo”                       18
    2.10 (b)   Interior ballast tank                        18
    2.11       Kilo ballast system operation                18
    2.12(a)    ROV prototype                                19
    2.12(b)    Control block diagram                        19
    2.13(a)    ROV submarine                               20
                                                         xiv

2.13(b)   Water leakage detector                        20
2.14      Visual Basic ROV GUI                          20
3.1       Project flowchart                             24
3.2       mikroC                                        25
3.3       Main program flowchart                        26
3.4       Visual Basic 6.0                              27
3.5       Visual Basic 6.0 program flowchart            28
3.6       keyboard control                              29
3.7       Proteus 7.1                                   29
3.8       Microcontroller chip                          30
3.9       Motor driver chip                             31
3.10      Max 232 chip                                  31
3.11      PVC pipe                                      32
3.12      Rubber bellows                                32
3.13      System block diagram                          33
3.14      Waterproofing parts                           35
3.15      Araldite epoxy and selleys sealant            35
4.1       ROV electronic hardware design                36
4.2       Serial communication circuit design           37
4.3       Voltage regulator circuit                     37
4.4       Controller box overview                       38
4.5       Electronic hardware overview                  38
4.6       External remote controller                    39
4.7       LED(ROV status indicator)                     39
4.8       Graphic User Interface (Main Form – Form 1)   40
4.9       Graphic User Interface (Form 2)               41
4.10      Graphic User Interface (Form 3)               42
4.11      ROV overview                                  43
4.12      ROV underwater inspection with lamp           44
4.13      ROV on board camera testing                   44
4.14      Dimension of ROV                              45
                                                                  xv

4.15   Bellows type ballast tank model                           46
4.16   External bellows type ballast tank model                  47
4.17   Concept of the external bellows type ballast tank model   48
4.18   Relationship between voltage and PWM parameters           49
4.19   Relationship between time and PWM parameters              50
                                                   xvi




       LIST OF ABBREVIATIONS




ROV    -    Remotely Operated Vehicle
ROUV   -    Remotely Operated Underwater Vehicle
DC     -    Direct Current
PIC    -    Programmable Interface Controller
RAM    -    Random Acces Memory
PWM    -    Pulse Width Modulation
RC     -    Regulator Circuit
I/O    -    Input/Output
CO²    -    Carbon Dioxide
USB    -    Universal Serial Bus
GUI    -    Graphic User Interface
RC          Remote Control
                                                                   xvii




                  LIST OF APPENDICES




APPENDIX                      TITLE                          PAGE


 A         Main Program of mikroC for the PIC 16F877          56
 B         Visual Basic main GUI programming                  64
 C         Visual Basic programming of picture capture GUI    77
 D         Visual Basic programming of video recording GUI    80
 E         PIC 16F87X Pin Diagram and I/O Description         84
 F         Introduction to Pulse – width modulation (PWM)     88
                                                                                        1




                                       CHAPTER 1




                                      INTRODUCTION




1.1    Remotely Operated Vehicle (ROV)




       Remotely Operated Vehicles (ROV) are electrically powered and controlled via
an umbilical, maneuvering themselves in response to human commands with either
hydraulically or electrically driven thrusters.




       ROVs are classified roughly by the nature of the task they do. They are found on
offshore platforms, support vessels, in nuclear power plants, in reservoirs, and salvage
projects, and even submarine rescue situations. ROVs have the ability to “hover” and
stay on location to perform a task.




       The range of tasks carried out by the offshore industry that require the use of
ROVs can be defined by considering the life-cycle of an oil and gas field, from
exploration drilling (seabed inspection, valve operation, riser inspection, BOP hydraulics
                                                                                          2

operation, etc.), to field development and production (platform and pipeline inspection,
sub   sea   hardware     installation,   infrastructure   repair   and   maintenance)    to
decommissioning.




       Work-class ROVs are equipped with manipulators and can have a variety of
tools available (cutting disks, saws, etc.) via a removable “tool-skid” to suit a particular
job. There are some ROV classed as heavy-duty due to increased payload and power
availability, and also a “survey and inspection” class. The personnel operating and
maintaining work-class ROVs must be highly trained as the technology involved can be
complex.




                 Figure 1.1: Remotely Operated (Sub Sea) Vehicle


       Eyeball class ROVs normally are all-electric powered and have no manipulators
or payload capacity. They are used solely for inspection duties. Eyeball systems are
smaller, cheaper and simpler than the larger work-class systems, but are widely used in
situations outside the offshore industry.     They perform inspection tasks inside the
cooling systems of nuclear power stations, investigate problems inside reservoirs and
large tanks, and can be fitted with other sensors appropriate to the situation if required.
Some eyeball ROVs shown in figure 1.2 are mounted on large work-class systems that
                                                                                        3

they use as a local base, and for which they provide extra viewing capability during
complex operations.




                              Figure 1.2: Eyeball ROV




1.2    Ballast Tank




       A ballast tank is a compartment at the bottom of a ship/vessel or on the sides
which are filled with liquids for stability and to make the ship seaworthy.          Any
shipboard tank or compartment on a tanker normally used for carrying salt water ballast.
When these compartments or tanks are not connected with the cargo system they are
called segregated ballast tanks or systems. A large vessel typically will have several
ballast tanks including double bottom tanks, wing tanks as well as forepeak and aft peak
tanks. Adding ballast to a vessel lowers its centre of gravity, and increases the draft of
the vessel. Increase draft may be required for proper propeller immersion.




       A ballast tank can be filled or emptied in order to adjust the amount of ballast
force. Ships designed for carrying large amounts of cargo must take on ballast water for
                                                                                        4

proper stability when travelling with light loads and discharge water when heavily laden
with cargo.   Small sailboats designed to be light weight for being pulled behind
automobiles on trailers are often designed with ballast tanks that can be emptied when
the boat is removed from the water.




       To control its buoyancy, the submarines have ballast tanks and auxiliary, or trim
tanks, which can be alternately filled with water or air. When the submarine is on the
surface, the ballast tanks are filled with air and the submarine's overall density is less
than that of the surrounding water. As the submarine dives, the ballast tanks are flooded
with water and the air in the ballast tanks is vented from the submarine until its overall
density is greater than the surrounding water and the submarine begins to sink (negative
buoyancy).




                     Figure 1.3: Different locations of the ballast tank
                                                                                        5

1.3    Review of Previous Project




       In Salleh[1,2008], a ROV prototype was built having a body of 60cm on its
length. The total cost used in his project was around RM 522.65. He chose a food
container as the material to construct the body of ROUV with several reasons:
           a. Light - containers is light and easy to carry.
           b. Transparent - can show the mechanism of the piston ballast tank concept.
           c. Low Cost - container is cheap and easy to get.
           d. Easy Installation - easy to combine between containers because the body
               is easy to drill and attached.
           e. Water resistance and well protected




       The Figure 1.4 below shows his ROV prototype:




                                   Figure 1.4: Previous prototype

       He applies a very impressive method to push and pull the piston of all the 6
syringes. Three components that are driller, circle nut and screw were used in this
operation. At the normal situation, which 6 syringes are at the 0 ml position and the
ROV prototype will bouyance freely in the water. To make the prototype submerge in
the water, the driller will turn anti-clockwise and the alignment shaft that attach to the
driller will rotate and the circle nut will move backward and pull the piston. Hence, the
                                                                                         6

syringes will drag a water into it and after the density of the prototype is much higher
than the density of the water, the prototype will sink into the water. This process change
the bouyancy value from positive to negative.




       When the driller turn clockwise, the alignment shaft that attach to the driller will
rotate and the circle nut will move forward and push the piston. Therefore, water will be
thrust out and the density of the prototype is much lower than the density of the water,
the prototype will float at the surface of the water. This process change the bouyancy
value from negative to positive again.




       Figure 1.5(a): ROV submerges                  Figure 1.5(b) ROV floats
                                                                                         7

1.4      Problem Statement




      There are some problems that arise from salleh’s project which are:


       Wrong material was chosen to construct the body of the ROV because ordinary
         container cannot withstand pressure of the water and water leakage might
         happen.
       The size of the prototype is very big and heavy.
       Amount of water drag into syringes is not enough for the ROV to submerge into
         the water.
       The prototype is just able to move forward and backward.




1.5      Objective and Scope of the Project.




         The objective of the project is to design a static diving and ballast tank concept
remotely operated underwater vehicle.




         There are three main scope of this project which are to continue with all the
previous ROV project:


             a. to control the movement of ROV by vary the speed of motors .
             b. to implement a suitable ballast tank for static diving of the ROV.
             c. to control 3 or more motors using single PIC microcontroller.
                                                                                       8

1.6      Extra Scope of the Project.




There are several scope added to construct a more reliable and commercial ROV:
      1. Add in webcam to the ROV prototype for inspection purpose.
      2. Instead of just controlling the ROV by using an ordinary controller, the author
         decided to create a computer control GUI to make a user friendly interface for
         the ROV.
      3. Add in light source that allows the ROV to run inspection process in a dark
         environment.


More features will be added if time is adequate, this will bring benefit to the author to
gain more technical knowledge. Besides, a more advance ROV project can be made.
                                                                                          9




                                         Chapter 2




                                LITERATURE REVIEW.




2.1 Submarine Diving Technology.




         When the submarine is travelling on the surface, it is operated like any other boat
with one major exception; it has flood ports along the bottom that are open to the sea.
The sea is prevented from filling the ballast tanks because they are closed at the top,
much like holding a drinking glass upside down under water. There is no place for the
air to escape because vents along the top of the tank are kept closed. The surfaced
submarine maintains positive buoyancy by riding on a bubble captured in the ballast
tanks.




                            Figure 2.1: Submarine Diving Method
                                                                                        10

       Diagram A in figure 2.1 represents a submarine on the surface. The main ballast
tanks are filled with air and the center of gravity (G) is above the center of buoyancy
(B). The water displaced (the area within the heavy line) equals the weight of the
submarine. Diagram B in figure 2.1 represents a submerged submarine. The ballast
tanks are filled with water and the centers of gravity and buoyancy are reversed. The
displaced water, the area inside the pressure hull, has decreased and the weight of the
displaced water now is the same as or less than the weight of the submarine.



       The submarine achieves a dive by opening the vents and allowing the air to
escape and water to fill the ballast tanks. The bow planes are lowered and angled down
to drive the submarine below the surface. Once submerged, the boat is trimmed, or
balanced, by pumping water between trim tanks.           Over-all trim is the process of
attaining neutral buoyancy; final trim is the establishment of fore and aft equilibrium, or
zero bubble, with neutral buoyancy. The submerged submarine is operated at neutral
buoyancy and control of the vessel is obtained by the rudder and the bow and stern
diving planes. A zero bubble should be maintained without excessive angles on the
diving planes. The primary effect of the bow planes is on the depth, and the primary
effect of the stern planes is on the angle of the submarine.




       Negative buoyancy for a quick dive is achieved by flooding the negative tank
which is located at the keel slightly forward of the center of the boat, adding a slight
down angle to the submarine. The negative tank is blown free of water once submerged.
Pressure on the hull increases with depth, the total pressure that the hull must be able to
withstand is measured by the difference between interior hull pressure and the external
pressure at a given depth. When the maximum depth is passed, the pressure hull will be
crushed.
                                                                                     11

2.2    Types of Ballast Tank.




       There are many types of alternative for the ballast tank concept that can be
applied to the submarine. After conducting a study regarding to several types of ballast
tank system, 5 type of ballast tank was found to be useful for this project:


       1. piston ballast tank
       2. membrane ballast tank
       3. bellow ballast tank
       4. Gas operated ballast tank
       5. Compressed air ballast tank




2.2.1 Piston Ballast Tank.




                          Figure 2.2: Piston type ballast tank



       This system is only recommended for small or medium models (if use syringe).
The piston ballast tank consists of cylinder (or syringe) and a movable piston. These
                                                                                           12

syringes however require a consequent motorization in ratio with the moved water
volume. The outer end of the cylinder is directly connected to the surrounding water. In
the piston ballast tank no air is present. Just like the flexible tank the pressure inside the
boat increased if the piston tank is filled with water. This system has the advantage to
be of an excellent progressiveness allowing a precise control of the submarine when it
dives. This syringe is commanded by electronic relays. It is necessary to use two ends
of run switches to stop the piston at the extreme positions of its course. During filling of
the tank with water, the axial centre of gravity of the boat is affected. For example if the
boat is balanced to run horizontally with a full ballast tank, the angle of the boat is no
longer zero with an empty tank. This drawback can be overcome by using two piston
tanks in the aft and bow section of the boat.




2.2.2 Membrane Ballast Tank.




                       Figure 2.3: Membrane type ballast tank

       The membrane ballast tank is a simplified version of the piston tank. It consists
of a rigid disk that can be moved up and down with a thread connected to a motor, just
                                                                                         13

like the piston and the tank elastic membrane made of natural rubber or silicone. The
body of this ballast is shaped like a cylinder and the top is closed by an elastic sealed
membrane. At the bottom there is a hole to suck water and a threaded rod is stuck on the
membrane. The threaded rod, by means of an adapted mechanism, will be enabled to
move upwards and conversely. When the membrane moves upwards, water is sucked
and the ballast is filling up. When the membrane moves downwards, the ballast is
emptied of its water. This ballast, which can be quite thin, will easily find its place in a
little diving saucer. A nice aspect of the membrane ballast tank is that the water tight
sealing is very easy. As long as the rubber membrane is properly attached to both disk
and tank, leaking is not possible. Drawback of the membrane tank is that the stroke of
the piston is not very large so the change in buoyancy of the submarine is not very large
but is ideal for small, or micro, model submarines. To make optimal use of the
membrane tank, the diameter of the cylinder should be rather large compared to its
height. The system is however ideal for small, or micro, model submarines.




2.2.3 Bellows Ballast Tank.




                    (a)                                            (b)

                            Figure 2.4: Bellow type ballast tank
                                                                                        14



       Bellows of various sources can be used like ballast tanks. The most commonly
met bellows come from children bicycles' horns, birdcalls or oilcans. To use these
bellows, it is necessary to associate a mechanism to compress and to slacken them.
Once the bellows is compressed enough, let it slacken so that it finds its initial form and
suck the water. To drain the water, compress the bellows again. The mechanism used
can be a simple servo which compresses the bellow by means of an arm, an endless
screw driven by a reduced gear motor as shown in figure 2.4 (b).




       These bellows do not enable to store a large volume of water and are appropriate
for small units or submarines without a large volume emerged on the surface. Under
pressure, the zigzag wall of the membrane may pop out, resulting in a sudden increase of
the ballast volume (and sinking of the sub). To prevent this, it is recommended to fit the
bellow inside a cylinder as shown in figure 2.4(a).




2.2.4 Gas Operated Ballast Tank




                         Figure 2.5: Gas operated ballast tank
                                                                                          15

         This system resembles the ballast system of a real submarine very closely. The
liquid gas system consists of a storage cylinder with pressurized gas. To flood the tank,
the vent valve is opened and water is allowed into the tank via the opening in the
bottom. The tank can be emptied by forcing pressurized gas into the tank by opening the
blow valve. If we want the model boat to be able to blow the ballast tank a number of
times, the stored amount of gas should be sufficient. Carbon dioxide (CO2) is an option
because cylinders with this gas are relatively cheap and readily available from Paint ball
shops.



         In the gas ballast system the electric valves used in the gas line (the blow valves)
can be standard solenoid valves used in laboratory equipment. To prevent draining of
the batteries, valves that are normally closed should be used. Using CO2 with a pressure
reduction valve or liquid gas, the pressure at which they remain closed should be about 5
bars.




         The vent valves that let air out of the ballast tank to submerge the boat are
different. The pressure difference between the air in the tank and that of the ambient air
is only a couple of cm water. Therefore the opening of the vent valve should be quite
large to let our air at a sufficient flow rate to get a realistic dive. Because the pressure
difference is also quite small when the vent valve is closed, and thus the boat is
submerged, we can make these valves ourselves.             Note that many of the above-
mentioned solenoid valves have an opening of less than 1 mm and do usually not like
water getting in to it; these types of valves are not very suited for the purpose.
                                                                                      16

2.2.5 Compressed Air Ballast Tank




                         Figure 2.6: Compressed air ballast tank




       The ballast tank system that uses compressed air is identical the one used in real
submarines. This system is similar to the gas operated ballast tank but in this case the
gas bottle is replaced by a cylinder that is filled with a compressor. Small compressors
can be found in car accessories shops. They sell small 12 volt compressors that are
intended to inflate car tires. These compressors are capable of compressing air to about
6 to 8 bar. These pressures are high enough to be careful with the storage cylinder. The
pressure is however relatively low pressure if you consider the amount of gas that can be
stored. If we would assume that the compressed air cylinder is half the size of the MBT,
we can only blow the MBT two to three times. This is not much compared to CO2 or
liquid gas systems. In general, boats with on board air compressors refill the air supply
each time they run on the surface after a dive. Special care should be taken to prevent
water being sucked into the compressor. To prevent this, the air intake should be fitted
with a valve that closes if the boat is submerged.
                                                                                       17

2.3    Ballast Tank Concept RC Submarine Model




2.3.1 1941 GATO and REVELL U212 (reference no: 11)




        Figure 2.7: 1941 GATO                     Figure 2.8: REVELL U212




                  Figure 2.9: Piston ballast tank used in RC submarine


       Both RC submarine models have a proportional controlled ballast tank and it is
able to float and submerge using the concept of ballast tank (piston type). Beside that,
these designs are small in size and relatively light. However, there are some drawbacks
of these designs. During filling of the tank with water the axial center of gravity of the
boat is affected but drawback can be overcome by using two piston tanks in the aft and
bow section of the boat.
                                                                                     18

2.3.2 1/72 Russian Kilo Class Submarine Model (reference no: 10)




Figure 2.10(a): Submarine model “kilo”       Figure 2.10(b): Interior ballast tank

       This RC submarine design consists of 2 piston type ballast tanks as shown in
figure 2.10(b), which is one forward and one aft. This design make the axial center of
gravity of the boat is not or less affected when the submarine drag in water into the
ballast tank. Furthermore, this makes it so user can exactly trim the boat underwater to
the desired attitude as shown below:




                       Figure 2.11: Kilo ballast system operation
                                                                                     19

2.4    ROV Submersible (PVC) (reference no: 9)




  Figure 2.12(a): ROV prototype              Figure 2.12(b): Control block diagram



       The author of this DIY ROV use PVC plastic to construct ROV’s body. In this
ROV deign consists of waterproof video camera and waterproof lamp. The ROV is light
because power supply is put outside of the ROV. Although the author use propeller to
submerge and float the ROV instead of using ballast tank, but this design give a lot of
ideas on what material are suitable to construct ROV’s body. Besides, the author also
shows how he construct ROV, waterproofs the camera, motors and lamp.
                                                                                        20

2.5    Jason Rollette's Underwater ROV Submarine (reference no: 9)




          Figure 2.13(a): ROV submarine            Figure 2.13(b): Water leakage detector


       This ROV design is the most impressive DIY ROV project found in website,
because it contains many function such as water leak detection, temp/pressure sensors,
depth, compass, AVI video recorder and picture frame grabber. Moreover, the ROV is
computer controllable. The authors create a computer control form to control his ROV
by using visual basic programming.




                       Figure 2.14: Visual basic ROV GUI

       At the website, the author also explains the whole process to construct this
project. His work is the main motivation to create a computer interface for this project.
                                                                                        21

2.6    Summarize of the Literature Review




          Author                    Diving Concept                   Main Ability
         puremtc                   piston ballast tank              RC controllable
         rpmtech                   piston ballast tank              RC controllable
       instructables             vertical axis propeller       built in lamp, camera
       Jason Rollette            vertical axis propeller     GUI interface, water leak
                                                              detection, temp/pressure
                                                              sensors, depth, compass,
                                                              AVI video recorder and
                                                               picture frame grabber.



                        Table 2.1: Summarize of literature review

       Table 2.1 shows the diving concept implemented and the main ability of the
models. The ROV model made by Jason Rollete was the most impressive and can be
use as an important reference of this ROV project.
                                                                                  22




                                   CHAPTER 3




                                METODHOLOGY




3.1 Project Timeline.




                          Table 3.1 FYP 1 Gantt Chart




       Figure 3.1 shows the FYP1 gantt chart. All the electronic circuit and software
design was conducted. After analyze the design, components like motor driver, Max
232 chip was purchase to construct the ROV model.
                                                                                     23




                          Table 3.2    FYP 2 Gantt Chart


       Figure 3.2 shows that the mechanical construction of the ROV prototype was
done in FYP2. After the testing and improvement, author will continue on thesis report
writing and etc.




3.2    Project Methodology.




       As shown in section 3.1, FYP 1 will more on electrical and software
development. FYP 2 will be more on mechanical testing and development. Flow
diagrams below have shown the project planning for the whole process of FYP 1 & 2.
                                                                             24




                        Figure 3.1: Project flowchart




3.2.1   Designing and Developing




        For designing & developing part of this project, it consists of software
programming, electronic and mechanical hardware construction.
                                                                                           25

3.2.1.1 Software Programming




       This project involved 2 type of programming skill which is C language and
Visual Basic 6.




3.2.1.1.1 mikroC Programming




                                    Figure 3.2: mikroC


mikroC is one of the powerful and easy to use software for programming PIC
microcontrollers in embedded C. mikroC is a powerful, feature rich development tool
for PICmicros. It is designed to provide the customer with the easiest possible solution
for developing applications for embedded systems, without compromising performance
or control. Applications can be developed quickly and easily using mikroC for PIC
microcontrollers. It provides a simple windows based point-and-click environment for
developing applications. PIC and C fit together well: PIC is the most popular 8-bit chip
in the world, used in a wide variety of applications, and C, prized for its efficiency, is the
natural choice for developing embedded systems. mikroC provides a successful match
featuring highly advanced IDE, ANSI complaint compiler, broad set of hardware
libraries, comprehensive documentation, and plenty of ready-to-run examples.
                                                                                        26

C program flowchart




                            Figure 3.3: Main program flowchart



       Figure above is the main programs that were loaded into the PIC 16F877, the
example of the programs can be found in appendix A. i and j is a PWM parameter used
in mikroC as the PWM duty cycle control variables which i is for left motor and j is for
right motor that connected to propellers. When the button at the external remote
controller is pressed, the input pin of the PIC will be ground. If this changing of voltage
level from 5V to 0V is detected, the PIC will run the program and send signal to the
motor driver to move the ROV. The same process will happen if a user clicks on the
ballast tank control button at the external remote controller.
                                                                                  27

3.2.1.1.2 Visual Basic 6.0 Programming




                              Figure 3.4: Visual basic 6.0



       Visual Basic (VB) is the third-generation event-driven programming language
and integrated development environment (IDE) from Microsoft for its COM
programming model. VB is also considered a relatively easy to learn and use
programming language, because of its graphical development features and BASIC
heritage.

       Visual Basic was derived from BASIC and enables the rapid application
development (RAD) of graphical user interface (GUI) applications, access to databases
using Data Access Objects, Remote Data Objects, or ActiveX Data Objects, and creation
of ActiveX controls and objects. Scripting languages such as VBA and VBScript are
syntactically similar to Visual Basic, but perform differently.

       A programmer can put together an application using the components provided
with Visual Basic itself. Programs written in Visual Basic can also use the Windows
API, but doing so requires external function declarations.
                                                                                       28

Visual Basic program flowchart




                     Figure 3.5: Visual Basic 6.0 program flowchart



       Visual Basic 6.0 is used to create a Graphic User Interface (GUI) to make this
project more advance. This GUI is not only for controlling the ROV movement but also
include other features such as picture taking, video recording, ROV status indicator and
etc. By using Visual Basic 6.0, some extra feature is added. User can control the
movement of ROV by just pressing the keyboard instead of just clicking on the mouse.
Signal (ASCII code) will be send to the PIC when user pressing the keyboard. If PIC
detects the ASCII code, it will run the program that is already loaded into the PIC.
                                                                                      29


                                                   W         FORWARD
                                                   A         TURN LEFT
                                                   D         TURN RIGHT
                                                   S         BACKWARD
                                                   Q         FORWARD LEFT
                                                   E         FORWARD RIGHT
                                                   Z         BACKWARD LEFT
                                                   X         BACKWARD RIGHT
                                                   J         OPEN CAMERA AND LAMP
                                                   K         THRUST WATER
                                                   L         DRAG WATER

                              Figure 3.6: keyboard control



3.2.1.2 Electronic Hardware Construction




       Before starting with the electronic hardware construction, the circuit is designed
first by using Proteus 7.1.




                                 Figure 3.7: Proteus 7.1


       This software was extremely useful because the user can input the C program
hex file to simulate with the electronic circuit design. The Proteus Design Suite is
wholly unique in offering the ability to co-simulate both high and low-level micro-
controller code in the context of a mixed-mode SPICE circuit simulation. With this
                                                                                      30

Virtual System Modelling facility can transform the product design cycle, reaping huge
rewards in terms of reduced time to market and lower costs of development.




       If one person designs both the hardware and the software then that person
benefits as the hardware design may be changed just as easily as the software design. In
larger organisations where the two roles are separated, the software designers can begin
work as soon as the schematic is completed; there is no need for them to wait until a
physical prototype exists.



       After the literature review and components testing that available in Proteus 7.1,
the components that will be used in this project are as follows:




1) PIC 16F877 microcontroller




                             Figure 3.8: microcontroller chip

       PIC 16F877 microcontroller is chosen because it is easily available in the lab and
it contains PWM function. Besides, it also provide sufficient I/O pin for ROV project.
                                                                                  31

2) L298 (DUAL FULL-BRIDGE DRIVER)




                        Figure 3.9: motor driver chip


      L298 (DUAL FULL-BRIDGE DRIVER) was used as a motor driver to drive the
dc motor that is attached to the propeller. The reason L298 has chosen because it can
support higher current and voltage compare to L293D motor driver.




3) MAX 232 (DUAL DRIVER/RECEIVER)




                       Figure 3.10: MAX 232 chip


      MAX 232 (DUAL DRIVER/RECEIVER) is used to construct the serial
communication circuit. This chip can convert signals from an RS-232 serial port to
signals that are compatible with PIC.
                                                                              32

3.2.1.3 Mechanical Hardware Construction




1) Polyvinyl chloride pipe




                                Figure 3.11: PVC pipe

Used to construct the body of the ROUV because it has several benefit:
           1. Can overcome water pressure.
           2. Light & not expensive.
           3. Easy available.
           4. The shape can be varying by choosing different PVC connector.




2) Bellows Type Ballast Tank




                             Figure 3.12: rubber bellows
                                                                                       33




      There are several reason of this type of ballast tank was chosen:
      •   Parts and components are widely available.
      •   Space consuming is less compare to the piston/syringe.
      •   Easy construction. The operation principle of a bellows ballast system is fairly
          straightforward.




3.3       Project Overview




          Figure 3.13 shows the flow diagram that describes the flow of the system in this
project.




                                Figure 3.13: System block diagram
                                                                                          34

There are 3 main parts in this project; these parts are computer, controller box and ROV.
     COMPUTER                     CONTROLLER BOX                         ROV
- Tool to control ROV.          - contain all electronic      - An underwater vehicle
- Contain GUI that control      components that used to       that has built in webcam,
all the operation of ROV        control ROV .e.g. PIC,        motors, ballast tank system
.e.g. movement, ballast         motor driver, serial          and etc.
tank, picture and video         communication port and
recording and etc.              etc.

                               Table 3.3: 3 main components

Besides, there are also 4 umbilical that are used to link between the ROV, computer and
controller box. The air tube is necessary to pump air to the ballast tank. This will be
explained in section 4.4.1.




      RS - 232                TELEPHONE PHONE JACK           POWER SUPPLY CABLE
- Cable that is used to    - Used to extend the cable        - A power supply cable for
establish an               length between computer and       motors, lamp and etc.
interfacing connection     webcam that is built inside the
between computer and       ROV.
controller box.



                           Table 3.4: 3 main cable connections
                                                                                     35

3.4 Waterproofing Technique




                           Figure 3.14: waterproofing parts



       By reviewing the Sea Perch Construction Manual given by supervisor, author
decided to implement the same waterproofing technique from this manual.             The
waterproofing technique was very simple and loss cost because it just used of wax to
bury all the electrical part such as dc motor, webcam, power supply cables and etc. This
technique is useful because wax is a non-conductive element. After fill in the wax, a
layer of epoxy or sealant is essential to protect the wax from decompose.




                  Figure 3.15: Araldite epoxy and Selleys sealant
                                                                        36




                                   CHAPTER 4




                         RESULTS AND DISCUSSION




4.1   Electronic Hardware




                    Figure 4.1: ROV electronic hardware design


      Figure 4.1 shows the main ROV circuit design using proteus 7.1.
                                                                                          37




                    Figure 4.2: Serial communication circuit design

       Figure 4.2 shows the circuit design of the serial communication between the
computer and the electronic hardware.




                         Figure 4.3: Voltage regulator circuit

       Figure 4.3 shows the circuit design of the 5volt regulator circuit. This voltage
regulator provide 5V supply to PIC, motor driver, and serial communication port.
                                            38




Figure 4.4: Controller Box overview




 Figure 4.5: Electronic hardware overview
                                                                                      39

       Figure 4.5 is the electronic hardware in controller box that was constructed based
on the design using proteus 7.1.




                      Figure 4.6: external remote controller


       This external remote controller consists of 6 momentary switch buttons that used
to control ROV instead of computer control. All green circled buttons is to control ROV
to forward, backward, turn left and turn right. Yellow circled button used to control
ballast tank. Upper is for compress (ROV buoyancy) the bellows and lower button for
decompressing the bellows (ROV submerge). User can also turn on the ROV’s lamp by
pressing the upper green circled button followed by lower green circled button and vice-
versa. The LED at the controller is act as an indicator; if there is an operation of the
ROV, the LED will turn on to indicate that the ROV is operating otherwise the LED is
keep blinking to indicate that the ROV now is idle.




                   Figure 4.7: LED (ROV status indicator)
                                                                                   40

       This ROV status indicator is to indicate the status of the ROV. When ROV is not
operating or idle, red circled LED will turn ‘ON’ but when ROV is operating, greed
circled LED will turn ‘ON’. If the ballast tank is operating, yellow circled LED will
turn ‘ON’. Besides, when propeller achieved maximum speed the orange circled LED
will start blinking.




4.2    Graphic User Interface (GUI)




                   Figure 4.8: Graphic User Interface (Main Form - Form1)

       This GUI was created by using visual basic 6. The purpose of this GUI is for
control and monitoring ROV.      The GUI consists of several controls like “serial
                                                                                          41

communication control”,” lamp control”, “ballast tank control”, “ROV movements
control”, “camera control” and “ROV status bar”.




             type of control                                    function
      serial communication control          turn on/off the serial communacation port
              lamp control                                turn on/off the lamp
           ballast tank control                          control the ballast tank
        ROV movements control                        control the movement of ROV
             camera control                    turn on/off the on board camera, take
                                                   picture, video recording, resolution
                                                     adjustment and camera setting
             ROV status bar                           display all the status of ROV

                    Table 4.1: All available controls in main GUI form




                    Figure 4.9: Graphic User Interface (Form2)

       If user click on the “Image Capture” on the GUI main form, the camera will
automatically capture 6 snapshot and display on another GUI form. User is able to
                                                                                     42

choose which photo needs to save or skip. This feature is needed because sometimes the
movement of the object will cause unclear picture to be taken. All pictures will save to
this location in computer C:\test.




                     Figure 4.10: Graphic User Interface (Form3)



       If user click on the “Video Recording” on the GUI main form, the main form
will disappear and another GUI form3 will appear. This GUI form3 is shown as above
figure. In this GUI form3 has few control buttons like “capture video”, “Comp DLG”,
“preview video”, “Autoscale”, “AutoCenter” and “Exit Video Record”.
                                                                                        43

             type of buttons                                 function
              capture video                    to start capture video in AVI format
               Comp DLG                        adjust the quality of the output video
              preview video                  choose to preview video while recording
                Autoscale                         control the movement of ROV
               AutoCenter                             adjust the video flame
            Exit Video Record                            to close the form

                   Table 4.2: All available buttons in GUI form3




4.3    Mechanical Hardware (ROV - prototype)




                                Figure 4.11: ROV overview

        Figure above shows the ROV model of this project, the ROV is built in lamps,
propellers, webcam and a ballast tank.
                                                                                      44




                       Figure 4.12: ROV Underwater Inspection with lamp


       Figure above shows that the ROV model is tested in a pool at marine lab. The
depth of the pool is about 9 feet. This ROV was able to submerge until the bottom of
the pool but due to the torque of the dc gear motor used to compress the bellows is
insufficient to press the bellows when the depth more than 5 feet, the dc gear motor will
stuck and resulting the ROV failed to float due to the water pressure is increasing.
Therefore, the depth limitation of this ROV model is about 5 feet which is equavalent to
1.524 meter. This drawback can be overcome if the current dc gear motor is replaced by
higher torque dc gear motor.




                     Figure 4.13: ROV on board camera testing
                                                                                     45

       Author put in a hand into the pool to test the on board camera in the ROV.
Figure above shows that this ROV can observe the object in the water.




                  TOP VIEW                           FRONT VIEW




                         Figure 4.14: Dimension of ROV



       The size of the ROV is relative small compare to the previous ROV project.
Figure 4.14 shows the dimensions of this new creation of ROV. Besides, the weight of
this ROV model is only about 2 kg. Therefore user can just hold it using one hand and it
can be easily carried
                                                                                        46

4.4 Ballast Tank System




                       Figure 4.15: bellows type ballast tank model


         Figure 4.15 shows the bellows type ballast tank model by using 4 bellows. But
this model is very difficult to construct due to the air and water pressure, these pressure
will easily damage the wall of the ballast tank when the thrust and drag process is
operating. Therefore, it is impossible to construct the bellows type ballast tank unless
the model is not hand-made. Besides, it was also found that both piston and bellows type
ballast tank is not suitable to use for ROV because the depth that the ROV can submerge
is very limited (about 4 to 10 cm depend on the size of piston and bellows) and
obviously this type of ballast tank cannot use for deep sea industry. Therefore, the
conclusion is both piston and bellows type ballast tank is only suitable for submarine
model.
                                                                                      47

4.4.1 Ballast Tank Modification




                   Figure 4.16: external bellows type ballast tank model



       Figure 4.16 shows that author modify the bellows type ballast tank into the
external bellows type ballast tank model. This model apply almost the same concept of
the Gas operated ballast tank, the only different is the gas container is replaced by the
external bellows compressor. This approach overcome the depth limit that face before,
there is no limitation of depth of this model. But unfortunately, this model need an
external air tube which usually can get from aquarium, hence will affect of the ROV
movements. Anyways, this drawback will only cause a small problem if the prototype of
ROV is big enough.
                                                                                         48




          Figure 4.17: concept of external bellows type ballast tank model


       Figure above shows the how the external bellows type ballast tank model work.
The quantities of oxygen in bellows are inversely proportional to the quantities of
oxygen in the ballast tank. Assume initially the ROV is in stage 1, to submerge the
ROV, a user just need to decompress the bellows. As a result, the ROV now will be on
stage 2 (submerge into the water) because the quantities of oxygen in ballast tank is
decreased causing the water drag into the ballast tank. To make the ROV submerge
further, user just need to further decompress the bellow and finally the ROV will be on
stage 3 because the quantities of oxygen in ballast tank is further decrease causing the
water drag into the ballast tank increase. To float the ROV, user just need to compress
the bellows, as a result the quantities of the oxygen in ballast tank increase and the water
is pulling out from ballast tank. The whole floating procedure is a reverse of the
submerge procedure.     The total quantities of oxygen that the external bellows ballast
tank system can supply is about 477.13 cm3, due to the ROV prototype does not built in
depth sensors, the measurement of the depth of submerge cannot be calculate.
                                                                                        49

4.5    Propellers Speed Analysis




       The rotation speed of the ROV is directly proportional to the duty cycle of the
PWM, the higher the duty cycles D, the higher the rotation speed of the propellers. The
dc motor used to rotate the shaft that is connected to the propeller start to rotate if the
input voltage is about 3V. 12V 1A power source is plug into the motor driver L298 to
drive the dc motor; therefore 12V 0.5A is the maximum voltage and current for each dc
motor. Table below shows the data that can help to analyze the speed of the ROV.


  PWM parameter (i and j)                 voltage (V)                    time (s)
              80                            3.7647                           0
             110                            5.1765                           3
             140                            6.5882                           6
             170                              8                              9
             200                            9.4118                          12
             230                           10.8235                          15
             255                              12                           17.5

           Table 4.3: Calculation readings base on the mikroC C program




                   Figure 4.18: relationship between voltage and PWM parameters
                                                                                    50

       The initial value of i and j is 80, when the user continue pressing the ROV
movements button on external remote controller or the main GUI, the value of i and j
will increase by 1 in every 0.1 second. The relationship between the ∆ and ∆      ∆ is
shown below:
                                      ∆
                                                  = 0.047
                                  ∆       ∆
This mean that every increment in i or j will cause an increment of voltage by a factor
of 0.047.




            Figure 4.19: relationship between time and PWM parameters



       The figure above shows that the relationship between time and PWM parameters
is:


                                      ∆       ∆
                                                   = 10
                                          ∆
       This mean that every increment in time ∆ will causing an increment of PWM
parameters ∆    ∆ by a factor of 10. Therefore, in order to achieve maximum speed,
the user need to keep on pressing the ROV movement buttons about 17.5 seconds.
                                                                                             51

4.6       ROV Movement Control




                                                       Direction
 ROV movement                 left propeller (lp)                  right propeller (rp)
         forward                   clockwise                          anticlockwise
        backward                 anticlockwise                          clockwise
           left                      stop                             anticlockwise
          right                    clockwise                               stop
       forward left       clockwise(1/2 speed of rp)                  anticlockwise
      forward right                clockwise                anticlockwise(1/2 speed of lp)
      backward left      anticlockwise(1/2 speed of rp)                 clockwise
      backward right             anticlockwise                clockwise(1/2 speed of lp)


             Table 4.4: relationship between propellers and the ROV movements


          Table 4.4 shows how author control the movements of the ROV by varying the
speed and direction of the dc motor that is attached to the shaft of the propellers. This
approach is easy because author just need to set the value of the PWM control parameter
i and j when write the program using mikroC.
                                                                                         52




                                      CHAPTER 5




               CONCLUSION AND FUTURE RECOMMENDATION




5.1    Conclusion




       This project involves not only electrical and electronic skills but also includes
programming and mechanical skills. ROV project is usually a team project in other
local or overseas university; therefore the sensors part is not built into this ROV project.
Anyway, this project can help to train undergraduate to tackle the problem faced in the
future of engineering life.


       Piston and bellows type ballast tank is not suitable for the ballast system of ROV
because the limitation of depth. External bellows type of ballast tank used in this project
was successfully overcome this limitation but need a higher torque dc gear motor. The
ballast tank model used in this project use 2 layers of plastic bag to fill the oxygen from
the bellows, this approach has a drawback that the depth of the ROV cannot accurately
adjust due to the water pressure can easily affect the quantities of oxygen in the plastic
bag.
                                                                                       53

       There was some good comments from the panels during the FYP presentation, all
the panels agree that this ROV project has a big step compare to previous ROV project.
Besides, some important skills like the computer interfacing with the ROV, picture
capture and video recording programming skill was learned during this projects.


       In short, the project scopes and objectives have been fulfilled. The ROV is able
to do several movements, computer controllable using graphic user interface (GUI) and
most important is the ROV was able to submerge and float with the control of the
external bellows ballast tank system.




5.2    Future Recommendation




       There are some recommendation and suggestion that can be applied in order to
construct a solid structure and multifunctioning ROV in the future which are :


       I.      Implement depth, pressure and water leakage sensor to protect the ROV
               and having more efficacy for underwater research.


       II.     The external remote controller of this project can be modify become a
               wireless remote controller to make it more efficient.


       III.    Implement a robotic arm to increase the efficiency of the ROV by able to
               pick up object during the underwater operation.


       IV.     Use of Universal Serial Bus (USB) extension device that can extend the
               length of USB for the webcam to 150ft (45.72 meter).
                                                                                     54




                                   REFERENCES




1. Muhamad Syazwan bin Mohd Salleh (2008), “Ballast Tank Prototype for Remotely
Operated Underwater Vehicle”, UTM

2. KASHIF (2009), “Intelligent Control of Diving System of an Underwater Vehicle”,
UTM

3. Isharizal Bin Ishak (2005) “Remotely Operated Underwater Vehicle (ROUV)”
Fakulti Kejuruteraan Elektrik Universiti Teknologi Malaysia : Tesis Sarjana Muda.

4. Imran Ali Namazi (2005) “Submarine Control System” Chennai : KCG College Of
Technology, Anna University.

5. Donald P. Brutzman (1994) “A Virtual World For An Autonomous Underwater
Vehicle” California : Naval Postgradute School, Monterey.

6. Mohd Nazafat Bin Kassim (2006) “Remotely Operated Underwater Vehicle (ROUV)
Prototype” Fakulti Kejuruteraan Elektrik Universiti Teknologi Malaysia.

7. Visual basic 6 tutorial. http://www.vbforums.com

8. Visual basic 6 camera detection .http://www.codeproject.com

9. How to overcome USB length limitation. http://www.instructables.com

10. A new conception of ROV. http://www.abcm.org

11. How to waterproof motor .http://members.tripod.com/robomaniac_2001/id197.htm

12. Jason Rollette's underwater ROV submarine. www.rollette.com

13. ROV submersible (PVC).http://www.instructables.com/id/SK3UPBQFNNKD6NL/

14. 1/72 Russian kilo class submarine model. http://www.rpmtech1blog.com/172-
    russian-kilo-class-submarine-model
                                                                                      55

15. RC submarine model .http://puremtc.com/index.htm

16. Diving technology .http://www.heiszwolf.com/subs/tech/tech01.html

17. ROV ballast tank system .http://pierreyerokine.perso.sfr.fr/Ballast_EV.htm

18. Ballast tank introduction .http://en.wikipedia.org/wiki/Ballast_tank

19. Introduction of ROV
    http://en.wikipedia.org/wiki/Remotely_operated_underwater_vehicle

20. Several kinds of ROV design .http://www.homebuiltrovs.com/

21. Report of ROV construction from overseas university. http://www.mpcfaculty.net/

22. Information of mikroC . http://ssecganesh.blogspot.com/2008/06/what-is
     mikroc.html
                                            56




                               APPENDIX A




Main Program of mikroC for the PIC 16F877




 #define UP    PORTB.F0
 #define DOWN PORTB.F1
 #define LEFT PORTB.F2
 #define RIGHT PORTB.F3
 #define THRUST PORTB.F4
 #define DRAG PORTB.F5
 #define CLKWISE_LEFT     PORTD.F0
 #define ANTICLKWISE_LEFT PORTD.F1
 #define CLKWISE_RIGHT     PORTD.F2
 #define ANTICLKWISE_RIGHT PORTD.F3
 #define CLKWISE_BALLAST     PORTD.F4
 #define ANTICLKWISE_BALLAST PORTD.F5
 #define LED_OPERATE      PORTA.F0
 #define LED_BALLAST      PORTA.F1
 #define LED_WAITING      PORTA.F2
 #define LED_MAX        PORTA.F3
 #define LED_LIGHT      PORTA.F5
 #define LED_CONTROLLER     PORTD.F6

 unsigned short j, i;
 unsigned short k,l;

 void TURNLEFT(void);
 void TURNRIGHT(void);
 void FORWARD(void);
 void BACKWARD(void);
 void WATERIN(void);
 void WATEROUT(void);
 void STOP(void);
 void InitMain(void);
 void PWM(void);
 void PWM_LEFT(void);
 void PWM_RIGHT(void);
                                                                   57

void PWM1(void);
void PWM2(void);

void main(void)
{
  TRISB = 0b11111111;
  TRISD = 0b00000000;
  ADCON1 = 6;        // All ADC pins to digital I/O
  TRISA = 0b00000000;
  LED_WAITING = 1;
  Usart_Init(9600);
  LED_LIGHT=0;
  LED_CONTROLLER=1;Delay_ms(200);LED_CONTROLLER=0;Delay_ms(200);

while(1)
{      j = 80;
      i = 80;
  while(Usart_Data_Ready()) // If data is received
  {
    {
     //stop();
     k = Usart_Read();       // Read the received data
     l='h';
     Usart_Write(l);       // Send data via USART
    }
    while(k=='a')     // Compare the received data
    {
    FORWARD();
     PWM();
    LED_OPERATE = 1;
      LED_WAITING = 0;
    k = Usart_Read();
    }
     while(k=='b')     // Compare the received data
    {
       BACKWARD();
       PWM();
       LED_OPERATE = 1;
       LED_WAITING = 0;
       k = Usart_Read();
    }
    while(k=='c')     // Compare the received data
    {
    TURNLEFT();
    PWM_LEFT();
    LED_OPERATE = 1;
    LED_WAITING = 0;
                                                  58

k = Usart_Read();
}
while(k=='d')     // Compare the received data
{
TURNRIGHT();
PWM_RIGHT();
LED_OPERATE = 1;
LED_WAITING = 0;
k = Usart_Read();
}
 while(k=='e')     // Compare the received data
{
 FORWARD();
 PWM1();
 LED_OPERATE = 1;
 LED_WAITING = 0;
 k = Usart_Read();
}
while(k=='f')    // Compare the received data
{
FORWARD();
PWM2();
LED_OPERATE = 1;
LED_WAITING = 0;
k = Usart_Read();
}
while(k=='g')     // Compare the received data
{
BACKWARD();
PWM1();
LED_OPERATE = 1;
LED_WAITING = 0;
k = Usart_Read();
}
while(k=='h')     // Compare the received data
{
 BACKWARD();
 PWM2();
 LED_OPERATE = 1;
 LED_WAITING = 0;
k = Usart_Read();
}
while(k=='x')     // Compare the received data
{
WATEROUT();
LED_BALLAST = 1;
LED_OPERATE = 1;
                                                      59

    LED_WAITING = 0;
    k = Usart_Read();
    }
    while(k=='y')     // Compare the received data
    {
    WATERIN();
    LED_BALLAST = 1;
    LED_OPERATE = 1;
    LED_WAITING = 0;
    k = Usart_Read();
    }
    while(k=='o')     // Compare the received data
    {
    LED_LIGHT = 1;
    k = Usart_Read();
    }
     while(k=='p')     // Compare the received data
    {
    LED_LIGHT=0
    k = Usart_Read();
    }
     stop();
}
     while(DOWN==0)
    {
      BACKWARD();
      PWM();
      LED_OPERATE = 1;
      LED_WAITING = 0;
      LED_CONTROLLER=1;
      if(UP==0)
      {
      LED_LIGHT=0;
      }
    }
     while(UP==0)
    {
    FORWARD();
    PWM();
    LED_OPERATE = 1;
    LED_WAITING = 0;
    LED_CONTROLLER=1;
    if(DOWN==0)
    {
    LED_LIGHT=1;
    }
    }
                          60

        while(LEFT==0)
  {
      TURNLEFT();
      PWM_LEFT();
      LED_OPERATE = 1;
      LED_WAITING = 0;
      LED_CONTROLLER=1;
  }

   while(RIGHT==0)
   {
     TURNRIGHT();
     PWM_RIGHT();
     LED_OPERATE = 1;
     LED_WAITING = 0;
     LED_CONTROLLER=1;
   }
    while(THRUST==0)
   {
    WATEROUT();
    LED_BALLAST = 1;
    LED_WAITING = 0;
    LED_CONTROLLER=1;
   }
    while(DRAG==0)
   {
    WATERIN();
    LED_BALLAST = 1;
    LED_WAITING = 0;
    LED_CONTROLLER=1;
   }
       STOP();
  }
}
void TURNLEFT(void)
{
   ANTICLKWISE_LEFT=0;
  CLKWISE_LEFT=1;
}
 void TURNRIGHT(void)
{
  CLKWISE_RIGHT=1;
   ANTICLKWISE_RIGHT=0;
}

 void FORWARD(void)
{
                                                                61

  CLKWISE_LEFT=1;
  ANTICLKWISE_LEFT=0;
  CLKWISE_RIGHT=1;
  ANTICLKWISE_RIGHT=0;
 }
  void BACKWARD(void)
 {
    ANTICLKWISE_LEFT=1;
   CLKWISE_LEFT=0;
    ANTICLKWISE_RIGHT=1;
   CLKWISE_RIGHT=0;
 }
  void WATERIN(void)
 {
   CLKWISE_BALLAST=1;
    ANTICLKWISE_BALLAST=0;
}
  void WATEROUT(void)
 {
    ANTICLKWISE_BALLAST=1;
   CLKWISE_BALLAST=0;
 }

 void STOP(void)
{
   CLKWISE_LEFT=0;
   ANTICLKWISE_LEFT=0;
   CLKWISE_RIGHT=0;
   ANTICLKWISE_RIGHT=0;
   CLKWISE_BALLAST=0;
   ANTICLKWISE_BALLAST=0;
   LED_OPERATE = 0;
   LED_BALLAST = 0;
   LED_WAITING = 1;
   LED_MAX = 0;
   Pwm1_Stop();Pwm2_Stop();
   LED_CONTROLLER=1;Delay_ms(200);LED_CONTROLLER=0;Delay_ms(200);
}
void PWM(void)
 {
      Pwm2_Init(611);   // Initialize PWM module
      Pwm1_Init(611);   // Initialize PWM module
      Pwm1_Start();Pwm2_Start();
      if (j&&i < 255) {
        Pwm1_Change_Duty(j);Pwm2_Change_Duty(i);
        j++;i++;
        Delay_ms(100);
                                                        62

      }
    if (j&&i == 255)
      {
       l='m';
      Usart_Write(l);
      j=254;i = 254;
      LED_MAX = 1;
      Delay_ms(500);
      LED_MAX = 0;
      Delay_ms(500);
      }
}
void PWM_LEFT(void)
{
      Pwm1_Init(611);        // Initialize PWM module
Pwm1_Start();
      if (j < 255) {
        Pwm1_Change_Duty(j);
        j++;
        Delay_ms(100);
        }
      if (j == 255)
        {
        l='m';
        Usart_Write(l);
        j=254;
        LED_MAX = 1;
        Delay_ms(500);
        LED_MAX = 0;
        Delay_ms(500);
        }
}
void PWM_RIGHT(void)
{
Pwm2_Init(611);         // Initialize PWM module
Pwm2_Start();
if (i < 255) {
        Pwm2_Change_Duty(i);
        i++;
        Delay_ms(100);
        }
      if (i == 255)
        {
        l='m';
        Usart_Write(l);
        i = 254;
        LED_MAX = 1;
                                                      63

      Delay_ms(500);
      LED_MAX = 0;
      Delay_ms(500);
      }
}
void PWM1(void)
{
     Pwm2_Init(611);       // Initialize PWM module
     Pwm1_Init(611);       // Initialize PWM module
     Pwm1_Start();Pwm2_Start();
     if (j<200 && i < 100) {
       Pwm1_Change_Duty(j);Pwm2_Change_Duty(i);
       j=j+2 ;i++;
       Delay_ms(50);
       }
     if (j == 200)
       {
       j = 198;
       }
     if (i == 100)
       {
       i = 99;
       }
}
void PWM2(void)
{
     Pwm2_Init(611);       // Initialize PWM module
     Pwm1_Init(611);       // Initialize PWM module
     Pwm1_Start();Pwm2_Start();
     if (i<200 && j < 100) {
       Pwm1_Change_Duty(j);Pwm2_Change_Duty(i);
       i=i+2;j++;
       Delay_ms(50);
       }
     if (i == 200)
       {
       i = 198;
       }
     if (j == 100)
       {
       j = 99;
       }
}
                                                                             64




                                 APPENDIX B


Visual Basic main GUI programming


Option Explicit
Private Const WM_USER As Long = &H400
Private Const WM_CAP_DRIVER_CONNECT As Long = (WM_USER + &HA)
Private Const WM_CAP_DRIVER_DISCONNECT As Long = (WM_USER + &HB)
Private Const WM_CAP_SET_PREVIEWRATE As Long = (WM_USER + &H34)
Private Const WM_CAP_SET_PREVIEW As Long = (WM_USER + &H32)
Private Const WM_CAP_GET_STATUS As Long = (WM_USER + &H36)
Private Const WM_CAP_DLG_VIDEOFORMAT As Long = WM_USER + 41
Private Const HWND_TOP As Long = 0
Private Const SWP_NOMOVE As Long = &H2
Private Const SWP_NOZORDER As Long = &H4
Private Const SWP_NOENDCHANGING As Long = &H400
Private Const WM_CAP_START As Long = WM_USER
Private Const WM_CAP_GET_MCI_DEVICEA As Long = (WM_CAP_START + 67)
Private Const WM_CAP_DLG_VIDEOSOURCE As Long = (WM_CAP_START + 42)
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Private Declare Function SendMessage_2 Lib "user32.dll" Alias "SendMessageA" ( _
ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByRef lParam As CAPSTATUS) As Long
Private Declare Function SetWindowPos Lib "user32.dll" ( _
ByVal hWnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal cx As Long, _
ByVal cy As Long, _
ByVal wFlags As Long) As Long
Dim i As Long
Dim l As Integer
Dim m As Integer
Dim ret As Long
                                                                              65



Private Sub Check5_Click()

End Sub

Private Sub Command1_Click()

Timer1.Interval = 50
Timer1.Enabled = True
For i = 0 To 5

Form2.Picture1(i).Picture = Form1.Picture1.Image
Form2.Picture1(0).Visible = True

Next

Timer1.Interval = 50
Timer1.Enabled = True

End Sub

Private Sub Command2_Click()
Text1.Text = "ON"
MSComm1.Output = "p"
Text2.Text = ""
Unload Me
End Sub

Private Sub Command3_Click()
If Command3.Value = True Then

Dim pCS As CAPSTATUS, ret As Long, mcistr As String
Dim res As Long, pich As Long
Timer1.Enabled = False
On Error Resume Next
hCapWin = capCreateCaptureWindow("CaptureWindow", WS_CHILD Or
WS_VISIBLE, 200, 37, w, h, Me.hWnd, 0)
If Not hCapWin = 0 Then
For res = 0 To 9 'find webcam all examples i found used 0 but mine was on 1
ret = SendMessage(hCapWin, WM_CAP_DRIVER_CONNECT, res, 0)
If ret = 1 Then Exit For
Next
If ret = 0 Then MsgBox "no webcam found", vbCritical: Exit Sub
  ' select webcam or other settings from dialog
 SendMessage hCapWin, WM_CAP_SET_PREVIEWRATE, 66, 0
 SendMessage hCapWin, WM_CAP_SET_PREVIEW, True, 0
 SendMessage_2 hCapWin, WM_CAP_GET_STATUS, Len(pCS), pCS
                                                              66

'Command3.Visible = False

w = pCS.uiImageWidth
h = pCS.uiImageHeight
SetWindowPos hCapWin, HWND_TOP, 0, 0, w, h, SWP_NOMOVE Or
SWP_NOZORDER Or SWP_NOENDCHANGING
  w = w + 10
  h = h + 40

End If
On Error Resume Next
End If
Command3.Value = False

End Sub

Private Sub Command4_Click()
SendMessage hCapWin, WM_CAP_DLG_VIDEOSOURCE, 0, 0
End Sub



Private Sub Command5_Click()

Dim temp As Long
temp = SendMessage(hCapWin, WM_CAP_DLG_VIDEOFORMAT, 0&, 0&)
End Sub

Private Sub Command6_Click()
Form1.Visible = False
Command9.Value = True
frmCapTest.Visible = True

End Sub

Private Sub Command9_Click()
'WM_CAP_DRIVER_DISCONNECT
ret = SendMessage(hCapWin, WM_CAP_DRIVER_DISCONNECT, 0, 0)
End Sub

Private Sub Command7_Click()
Dim i As Long '' to get port number
If MSComm1.PortOpen = True Then
MSComm1.PortOpen = False
End If
If Text3.Text = "0" Then
   Text4.Text = "ERROR !"
                                                                 67

   Text4.BackColor = vbRed
   Beep
   Else
i = Text3.Text
End If

On Error Resume Next
  'use comm port 1
 MSComm1.CommPort = i
  ' 9600 baud, no parity, 8 data bits, 1 stop bit
 MSComm1.Settings = "9600,N,8,1"
 MSComm1.RThreshold = 1
 MSComm1.InputLen = 1
  ' Disable DTR
 MSComm1.DTREnable = False
  'open the port
 MSComm1.PortOpen = True


  If MSComm1.PortOpen = True Then            'usb status check

  Text4.Text = "USB standby"
  Text4.BackColor = vbGreen


  Else
  Text4.Text = "ERROR !"
  Text4.BackColor = vbRed

  Beep
  End If
End Sub

Private Sub Command8_Click()
If MSComm1.PortOpen = True Then

'Text4.Text = "~ sent"
Text4.BackColor = vbGreen
MSComm1.PortOpen = False
End If
Text4.Text = "USB close"
Text4.BackColor = vbBlue
End Sub


Private Sub BACKLEFT_Click()
BACKLEFT.Font.Bold = BACKLEFT.Value = vbChecked
                                                    68



   If BACKLEFT.Value = Checked Then
'BACKLEFT.BackColor = &HFF&
' Send Out Data
MSComm1.Output = "g"
Text1.Text = "SUPERBOT BACKWARD LEFT"


Else: BACKLEFT.Value = Unchecked
'BACKLEFT.BackColor = &H8000000F
Text1.Text = ""

Text2.Text = ""
MSComm1.Output = "s"
End If
End Sub

Private Sub BACKRIGHT_Click()
BACKRIGHT.Font.Bold = BACKRIGHT.Value = vbChecked

   If BACKRIGHT.Value = Checked Then
'BACKRIGHT.BackColor = &HFF&
' Send Out Data
MSComm1.Output = "h"
Text1.Text = "SUPERBOT BACKWARD RIGHT"


Else: BACKRIGHT.Value = Unchecked
'BACKRIGHT.BackColor = &H8000000F
Text1.Text = ""

Text2.Text = ""
MSComm1.Output = "s"
End If
End Sub

Private Sub DOWN_Click()
DOWN.Font.Bold = DOWN.Value = vbChecked

   If DOWN.Value = Checked Then
'DOWN.BackColor = &HFF&
' Send Out Data
MSComm1.Output = "x"
Text1.Text = "SUPERBOT SUBMERGE"


Else: DOWN.Value = Unchecked
                                                  69

'DOWN.BackColor = &H8000000F
Text1.Text = ""

Text2.Text = ""
MSComm1.Output = "s"
End If
End Sub

Private Sub FORLEFT_Click()
FORLEFT.Font.Bold = FORLEFT.Value = vbChecked

   If FORLEFT.Value = Checked Then
'FORLEFT.BackColor = &HFF&
' Send Out Data
MSComm1.Output = "e"
Text1.Text = "SUPERBOT FORWARD LEFT"


Else: FORLEFT.Value = Unchecked
'FORLEFT.BackColor = &H8000000F
Text1.Text = ""

Text2.Text = ""
MSComm1.Output = "s"
End If
End Sub
Private Sub FORRIGHT_Click()
FORRIGHT.Font.Bold = FORRIGHT.Value = vbChecked

   If FORRIGHT.Value = Checked Then
'FORRIGHT.BackColor = &HFF&
' Send Out Data
MSComm1.Output = "f"
Text1.Text = "SUPERBOT FORWARD RIGHT"


Else: FORRIGHT.Value = Unchecked
'FORRIGHT.BackColor = &H8000000F
Text1.Text = ""

Text2.Text = ""
MSComm1.Output = "s"
End If
End Sub
Private Sub RIGHT_Click()
RIGHT.Font.Bold = RIGHT.Value = vbChecked
                                                  70

   If RIGHT.Value = Checked Then
'RIGHT.BackColor = &HFF&
' Send Out Data
MSComm1.Output = "d"
Text1.Text = "SUPERBOT TURN RIGHT"


Else: RIGHT.Value = Unchecked
'RIGHT.BackColor = &H8000000F
Text1.Text = ""

Text2.Text = ""
MSComm1.Output = "s"
End If
End Sub
Private Sub BACKWARD_Click()
BACKWARD.Font.Bold = BACKWARD.Value = vbChecked

   If BACKWARD.Value = Checked Then
'BACKWARD.BackColor = &HFF&
' Send Out Data
MSComm1.Output = "b"
Text1.Text = "SUPERBOT BACKWARD"


Else: BACKWARD.Value = Unchecked
'BACKWARD.BackColor = &H8000000F
Text1.Text = ""

Text2.Text = ""
MSComm1.Output = "s"
End If
End Sub
Private Sub FORWARD_Click()

  FORWARD.Font.Bold = FORWARD.Value = vbChecked

   If FORWARD.Value = Checked Then
'FORWARD.BackColor = &HFF&
' Send Out Data
MSComm1.Output = "a"
Text1.Text = "SUPERBOT FORWARD"


Else: FORWARD.Value = Unchecked
'FORWARD.BackColor = &H8000000F
Text1.Text = ""
                                            71



Text2.Text = ""
MSComm1.Output = "s"
End If

End Sub
Private Sub UP_Click()
UP.Font.Bold = UP.Value = vbChecked
' Send Out Data

   If UP.Value = Checked Then
'UP.BackColor = &HFF&
' Send Out Data
MSComm1.Output = "y"
Text1.Text = "SUPERBOT ROV FLOAT"


Else: UP.Value = Unchecked
'UP.BackColor = &H8000000F
Text1.Text = ""

Text2.Text = ""
MSComm1.Output = "s"
End If
End Sub

Private Sub LEFT1_Click()
LEFT1.Font.Bold = LEFT1.Value = vbChecked

   If LEFT1.Value = Checked Then
'LEFT1.BackColor = &HFF&
' Send Out Data
MSComm1.Output = "c"
Text1.Text = "SUPERBOT TURN LEFT"


Else: LEFT1.Value = Unchecked
'LEFT1.BackColor = &H8000000F
Text1.Text = ""

Text2.Text = ""
MSComm1.Output = "s"
End If
End Sub


Private Sub Form_Terminate()
                                                                 72

SendMessage hCapWin, WM_CAP_DRIVER_DISCONNECT, 0, 0
End Sub


Private Sub Option1_Click(Index As Integer)
MSComm1.Output = "o"
Text1.Text = "LED ON"
End Sub

Private Sub Option2_Click(Index As Integer)
MSComm1.Output = "p"
Text1.Text = "LED OFF"
End Sub



Private Sub Timer1_Timer()
Static i As Long
CapFrame i
i=i+1
If i > 5 Then Timer1.Enabled = False: i = 0: Form2.Show

End Sub

Private Sub Form_Load()
'On Error Resume Next
 ' 'use comm port 1
  ' MSComm1.CommPort = 9

   ' 9600 baud, no parity, 8 data bits, 1 stop bit
  ' MSComm1.Settings = "9600,N,8,1"
   'MSComm1.RThreshold = 1
'MSComm1.InputLen = 1

  ' Disable DTR
' MSComm1.DTREnable = False


   'open the port
 ' MSComm1.PortOpen = True
   Text1.Text = "STANDBY"
   Text2.Text = "STANDBY"


End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
                                 73

On Error Resume Next

Select Case KeyCode

  Case vbKeyW

    FORWARD.Value = Checked
    l=1+l
    If l = 2 Then

    FORWARD.Value = Unchecked
    l=0
    End If


  Case vbKeyS

    BACKWARD.Value = Checked
    l=1+l
    If l = 2 Then

    BACKWARD.Value = Unchecked
    l=0
    End If

  Case vbKeyA

   LEFT1.Value = Checked
   l=1+l
    If l = 2 Then

    LEFT1.Value = Unchecked
    l=0
    End If


  Case vbKeyD

    RIGHT.Value = Checked
    l=1+l
    If l = 2 Then

    RIGHT.Value = Unchecked
    l=0
    End If

  Case vbKeyQ
                                74



  FORLEFT.Value = Checked
  l=1+l
  If l = 2 Then

  FORLEFT.Value = Unchecked
  l=0
  End If


Case vbKeyE

  FORRIGHT.Value = Checked
  l=1+l
  If l = 2 Then

  FORRIGHT.Value = Unchecked
  l=0
  End If

Case vbKeyZ

  BACKLEFT.Value = Checked
  l=1+l
  If l = 2 Then

  BACKLEFT.Value = Unchecked
  l=0
  End If


Case vbKeyX

  BACKRIGHT.Value = Checked
  l=1+l
  If l = 2 Then

  BACKRIGHT.Value = Unchecked
  l=0
  End If


Case vbKeyJ
Command3.Value = True

Case vbKeyK
UP.Value = Checked
                                                                     75

          m=m+1
           If m = 2 Then

            UP.Value = Unchecked
            m=0
            End If

          Case vbKeyL
          DOWN.Value = Checked
          m=m+1
            If m = 2 Then

            DOWN.Value = Unchecked
            m=0
            End If


      End Select
 If FORWARD.Value = Unchecked And BACKWARD.Value = Unchecked And
LEFT1.Value = Unchecked And RIGHT.Value = Unchecked And FORLEFT.Value =
Unchecked And FORRIGHT.Value = Unchecked And BACKLEFT.Value = Unchecked
And BACKRIGHT.Value = Unchecked And UP.Value = Unchecked And
DOWN.Value = Unchecked Then

  MSComm1.Output = "s"
  End If


    End Sub
Private Sub Form_Unload(Cancel As Integer)
     'Close the COMM port
MSComm1.Output = "s"
End Sub


Private Sub MSComm1_OnComm()
Dim f As String
Dim n As String

n = "m"

' If comEvReceive Event then get data and display
If MSComm1.CommEvent = comEvReceive Then
      f = MSComm1.Input              'get data
      If n = f Then
      Text2.Text = " MAXIMUM SPEED"
      End If 'convert to ASCII and display
                    76

Else

Text2.Text = "no"
End If
End Sub
                                                  77




                               APPENDIX C


Visual Basic Programming of Picture Capture GUI


Private Sub Command1_Click()
Picture1(0).Visible = False
Save1.Visible = False
Picture1(1).Visible = True
Save2.Visible = True
Command2.Visible = True
End Sub

Private Sub Command2_Click()
Picture1(1).Visible = False
Save2.Visible = False
Picture1(2).Visible = True
Save3.Visible = True
Command3.Visible = True
End Sub

Private Sub Command3_Click()
Picture1(2).Visible = False
Save3.Visible = False
Picture1(3).Visible = True
Save4.Visible = True
Command4.Visible = True
End Sub

Private Sub Command4_Click()
Picture1(3).Visible = False
Save4.Visible = False
Picture1(4).Visible = True
Save5.Visible = True
Command5.Visible = True
End Sub

Private Sub Command5_Click()
Picture1(4).Visible = False
Save5.Visible = False
Picture1(5).Visible = True
Save6.Visible = True
Command6.Visible = True
                                                                          78

End Sub

Private Sub Command6_Click()
Picture1(5).Visible = False
Save6.Visible = False
Unload Form2
End Sub

Private Sub Form_Load()
Save2.Visible = False
Save3.Visible = False
Save4.Visible = False
Save5.Visible = False
Save6.Visible = False
Picture1(1).Visible = False
Picture1(2).Visible = False
Picture1(3).Visible = False
Picture1(4).Visible = False
Picture1(5).Visible = False
Command2.Visible = False
Command3.Visible = False
Command4.Visible = False
Command5.Visible = False
Command6.Visible = False
End Sub

Private Sub Save1_Click()
Dim img As Image

MsgBox "picture 1 saved"

SavePicture Picture1(0).Picture, "C:\test\" & Hour(Now) & Minute(Now) &
Second(Now) & ".bmp"
Picture1(0).Visible = False
Save1.Visible = False
Picture1(1).Visible = True
Save2.Visible = True
Command2.Visible = True
End Sub


Private Sub Save2_Click()
MsgBox "picture 2 saved"
SavePicture Picture1(1).Picture, "C:\test\" & Hour(Now) & Minute(Now) &
Second(Now) & ".bmp"
Picture1(1).Visible = False
Save2.Visible = False
                                                                          79

Picture1(2).Visible = True
Save3.Visible = True
Command3.Visible = True
End Sub

Private Sub Save3_Click()
MsgBox "picture 3 saved"
SavePicture Picture1(2).Picture, "C:\test\" & Hour(Now) & Minute(Now) &
Second(Now) & ".bmp"
Picture1(2).Visible = False
Save3.Visible = False
Picture1(3).Visible = True
Save4.Visible = True
Command4.Visible = True
End Sub

Private Sub Save4_Click()
MsgBox "picture 4 saved"
SavePicture Picture1(3).Picture, "C:\test\" & Hour(Now) & Minute(Now) &
Second(Now) & ".bmp"
Picture1(3).Visible = False
Save4.Visible = False
Picture1(4).Visible = True
Save5.Visible = True
Command5.Visible = True
End Sub

Private Sub Save5_Click()
MsgBox "picture 5 saved"
SavePicture Picture1(4).Picture, "C:\test\" & Hour(Now) & Minute(Now) &
Second(Now) & ".bmp"
Picture1(4).Visible = False
Save5.Visible = False
Picture1(5).Visible = True
Save6.Visible = True
Command6.Visible = True
End Sub

Private Sub Save6_Click()
MsgBox "picture 6 saved"
SavePicture Picture1(5).Picture, "C:\test\" & Hour(Now) & Minute(Now) &
Second(Now) & ".bmp"
Picture1(5).Visible = False
Save6.Visible = False
Unload Form2
End Sub
                                                  80




                                  APPENDIX D


Visual Basic Programming of Video Recording GUI


Option Explicit
Private Sub chkAutoSize_Click()
  If chkAutoSize.Value = 1 Then
     ezVidCap1.AutoSize = True
  Else
     ezVidCap1.AutoSize = False
  End If
End Sub

Private Sub chkCenter_Click()
  If chkCenter.Value = 1 Then
     ezVidCap1.CenterVideo = True
  Else
     ezVidCap1.CenterVideo = False
  End If
End Sub


Private Sub chkPreview_Click()
  If chkPreview.Value = 1 Then
     ezVidCap1.Preview = True
  Else
     ezVidCap1.Preview = False
  End If
End Sub


Private Sub cmdCapture_Click()
  Call ezVidCap1.CaptureVideo
End Sub

Private Sub cmdCompDlg_Click()
  'From Beta2 the syntax has changed here
  'ezVidCap1.ShowDlgCompressionOptions = True
  ezVidCap1.ShowDlgCompressionOptions
End Sub

Private Sub cmdSaveAs_Click()
                                                                               81

  Dim filename As String
  If mCmnDlg.VBGetSaveFileNamePreview(filename, _
                 FileMustExist:=False, _
                 filter:="AVI files (*.avi)|*.avi", _
                 InitDir:=App.Path, _
                 DlgTitle:="Save AVI File", _
                 DefaultExt:="avi", _
                 Owner:=Me.hWnd) _
                                 Then
     On Error Resume Next
     Call ezVidCap1.SaveAs(filename)
     If Err Then
        MsgBox Err.Description, vbInformation, App.Title
     End If
  End If

End Sub


Private Sub ezVidCap1_StatusClear()
  lblStatusCode.Caption = ""
  lblStatusString.Caption = ""
End Sub

Private Sub Command1_Click()
Unload frmCapTest
Form1.Visible = True
Form1.Command3.Value = True
End Sub

Private Sub ezVidCap1_CaptureYield()
  'Setting Yield = True will allow this event to be generated
  'but will slow down performance
  Debug.Print "yield"
  DoEvents
End Sub

Private Sub ezVidCap1_ErrorMessage(ByVal ErrCode As Long, ByVal ErrString As
String)
  If ErrCode <> 0 Then
     'Debug.Print ErrString
     lblStatusString = "Error " & ErrString
     lblStatusString.Refresh
  End If
End Sub

Private Sub ezVidCap1_FrameCallback(ByVal lpVHdr As Long)
                                                                                    82

Debug.Print "Video frame: " & lpVHdr

Call MessWithVidBits(lpVHdr)

End Sub

Private Sub ezVidCap1_PreRollComplete()
  Dim userRet As Long

  userRet = MsgBox("Using precise capture controls." & vbCrLf & _
                    "PreRoll complete - Click OK to start capture immediately." _
                    , vbOKCancel, App.Title)
  If userRet = vbOK Then
     ezVidCap1.PreciseCaptureStart
  Else
     ezVidCap1.PreciseCaptureCancel
  End If
End Sub

Private Sub ezVidCap1_StatusMessage(ByVal StatCode As Long, ByVal StatString As
String)
lblStatusCode.Caption = "StatusCode: " & StatCode
lblStatusCode.Refresh
If StatCode <> 0 Then
   'Debug.Print StatString
   lblStatusString.Caption = StatString
   lblStatusString.Refresh
End If
End Sub
Private Sub EnableButtons()

  cmdCapture.Enabled = False
  cmdCompDlg.Enabled = False

  With ezVidCap1
    If .NumCapDevs > 0 Then
       cmdCapture.Enabled = True
       cmdCompDlg.Enabled = True
    End If
  End With
End Sub

Private Sub ezVidCap1_VideoStreamCallback(ByVal lpVHdr As Long)
Debug.Print "Video stream: " & lpVHdr
End Sub

Private Sub ezVidCap1_WaveStreamCallback(ByVal lpWHdr As Long)
                                                                                         83

Debug.Print "Wave stream: " & lpWHdr
End Sub

Private Sub Form_Load()

'THE FOLLOWING 2 LINES ARE UNNECESSARY AFTER BETA2
'Me.Show 'control will not connect to capdevice until it is shown
'    'it must be initialized by being shown before you can read some of the properties
'DoEvents 'allows driver to connect

Dim i As Long

Call EnableButtons 'check device caps and enable appropriate btns
Me.Show 'show form
Me.Refresh
If 0 < ezVidCap1.NumCapDevs Then
   For i = 0 To ezVidCap1.NumCapDevs - 1

  Next

Else

  MsgBox "No Video Capture Device!", vbInformation, App.Title
End If

'init form with current properties
lblStatusCode = "Status Panel"
lblStatusString = ezVidCap1.GetDriverVersion()

chkAutoSize.Value = -(ezVidCap1.AutoSize)
chkCenter.Value = -(ezVidCap1.CenterVideo)
chkPreview.Value = -(ezVidCap1.Preview)

End Sub

Private Sub Form_Resize()
'this is just to provide a nice status bar with no control
With picStatus
   lblStatusCode.Move 0, 0, .Width * 0.25, .Height
   lblStatusString.Move .Width * 0.25, 0, .Width * 0.75, .Height
End With

End Sub

Private Sub Text1_Change()

End Sub
                                             84




                               APPENDIX E


PIC 16F87X Pin Diagram and I/O Description
85
86
87
                                                                                       88




                                      APPENDIX F


Introduction to Pulse-width modulation (PWM)



        Pulse-width modulation (PWM) is a very efficient way of providing intermediate

amounts of electrical power between fully on and fully off. A simple power switch with

a typical power source provides full power only, when switched on.            PWM is a

comparatively recent technique, made practical by modern electronic power switches.


        In the past, when only partial power was needed (such as for a sewing machine

motor), a rheostat (located in the sewing machine's foot pedal) connected in series with

the motor adjusted the amount of current flowing through the motor, but also wasted

power as heat in the resistor element. It was an inefficient scheme, but tolerable because

the total power was low. This was one of several methods of controlling power. There

were others—some still in use—such as variable autotransformers, including the

trademarked Autrastat for theatrical lighting; and the Variac, for general AC power

adjustment. These were quite efficient, but also relatively costly.


        For about a century, some variable-speed electric motors have had decent

efficiency, but they were somewhat more complex than constant-speed motors, and

sometimes required external electrical apparatus, such as a bank of variable power

resistors.
                                                                                      89

       However, there is a great need for applying partial power in other devices, such

as electric stoves, lamp dimmers, and robotic servos. Basically, a PWM variable-power

scheme switches the power quickly between fully on and fully off -- e.g. several times a

minute in an electric stove, 120 Hz in a lamp dimmer, and well into the tens or hundreds

of kHz in a computer power supply (which has a regulated output). In any event, the

switching rate is much faster than what would affect the load, which is to say the device

that uses the power. In practice, applying full power for part of the time does not cause

any problems; PWM is very practical.


       The term duty cycle describes the proportion of on time to the regular interval or

period of time; a low duty cycle corresponds to low power, because the power is off for

most of the time. Duty cycle is expressed in percent, 100% being fully on.


       PWM works well with digital controls, which, because of their on/off nature, can

easily set the needed duty cycle.


       PWM of a signal or power source involves the modulation of its duty cycle, to

either convey information over a communications channel or control the amount of

power sent to a load.

						
Related docs
Other docs by dffhrtcv3
Environmental Wireless Sensing Network
Views: 1  |  Downloads: 0
Energy and Power
Views: 1  |  Downloads: 0
English and its history
Views: 0  |  Downloads: 0
Energy Policy Challenges Caribbean Community
Views: 0  |  Downloads: 0
Energy and the Environment
Views: 0  |  Downloads: 0