Thesis Tuvaaq
Thesis Tuvaaq
by
Charles Lee Frey
Bachelor of Science
Ocean Engineering
Florida Institute of Technology
1999
Master of Science
in
Ocean Engineering
Melbourne, Florida
December, 2002
© 2002 Charles Lee Frey
All Rights Reserved
by
Charles Lee Frey
Author:
Charles Lee Frey
Advisor:
Stephen Wood, Ph.D., P.E.
region of the Beaufort Sea, along Alaska’s northern coast. Of particular interest are
the impacts of construction of offshore gravel islands used for oil drilling and
sediment concentrations in the waters of Prudhoe Bay, which may have adverse
This paper discusses the design and construction of the AUV prototype,
Operated Vehicle (ROV) and Towed Instrument Array (Towfish) used in Alaska
iii
First, the overall design concept for the AUV is discussed. Next, modeling
and simulation of the system is performed. Then, the design of the AUV’s various
payload, CPU, power, and software. Finally, results of the simulation and
iv
Table of Contents
1. Introduction 1
v
5. Recommended Future Work 96
References 99
Appendices 101
vi
List of Keywords
Acoustic Navigation
Alaska
ANIMIDA
Arctic
Autonomous Underwater Vehicle (AUV)
AUV Control
Beaufort Sea
Brushless DC (BLDC) Motor
Department of the Interior (DOI)
Department of Marine and Environmental Systems (DMES)
Dynamic Modeling
Florida Institute of Technology
LabVIEW®
MATLAB®
Mineral Management Service (MMS)
North Slope
PC/104
Prudhoe Bay
Simulation
Simulink®
Sliding-Mode Control
Super-Short Baseline (SSBL)
Tuvaaq
Under-Ice
Underwater Robotics
Underwater Technologies Laboratory (UTL)
Underwater Thruster
Underwater Vehicles
vii
List of Figures
viii
3.3.1.4 Assembled AUV (acoustic transducer array not shown) 41
3.3.2.1 Typical Brushed DC motor construction 43
3.3.2.2 Typical Brushless DC motor construction 44
3.3.2.3 Motor fixture with coil, cable, and Hall-Effect sensors 46
3.3.2.4 Finished potted motor coil 47
3.3.2.5 Finished BLDC seal-less underwater thruster 48
3.3.2.6 Block diagram of BLDC Motor Controller circuit 49
3.3.2.7 Block diagram of BLDC Motor Controller PIC firmware 51
3.3.2.8 Final printed BLDC Motor Controller circuit board 52
3.3.2.9 Motor controller housing internals with 2-board stack 53
and cooling fans
3.3.2.10 Sealed motor controller housing 53
3.3.3.1 EZ-Compass 3 digital compass module 56
3.3.3.2 Propagation of hydroacoustic waves across a 57
straight-line transducer array
3.3.3.3 Propagation of hydroacoustic waves across a 59
triangular SSBL transducer array
3.3.3.4 ULB-350 Underwater Beacon 64
3.3.3.5 SX-38 38kHz omnidirectional transducer 65
3.3.3.6 SSBL transducer array mounted on test plate 66
3.3.3.7 Block diagram of SSBL Acoustic Navigator circuit 67
3.3.3.8 Block diagram of SSBL Acoustic Navigator PIC firmware 68
3.3.3.9 Final printed SSBL Acoustic Navigator circuit board 70
3.3.4.1 CTD & LSS instrument package 71
3.3.4.2 CTD sensor mounted on the AUV 73
3.3.5.1 AUV high-level system architecture block diagram 74
3.3.5.2 Main PC/104 CPU Board 75
3.3.5.3 PC/104 serial expansion module 77
ix
3.3.5.4 Linksys WUSB11 802.11b Wireless Ethernet Module 78
3.3.5.5 CPU housing internals with PC/104 stack 80
3.3.5.6: Sealed CPU Housing 80
3.3.6.1 Battery Pod internals with two SLA batteries 82
(parallel wiring)
3.3.6.2 Sealed Battery Pod (1 of 2) 82
3.3.6.3 PC/104 power supply board 83
3.3.7.1 The Tuvaaq AUV desktop, visible on a PC 85
running VNC Client
3.3.7.2 TUVAAQ software architecture block diagram 86
3.3.7.3 TUVVAQ main user interface panel 88
3.3.7.4 Configure Serial Devices panel 89
3.3.7.5 Offsets & Multipliers panel 90
3.3.7.6 Controller Gains panel 91
3.3.7.7 ROV Mode panel 92
x
List of Tables
xi
List of Abbreviations
xii
List of Symbols
x Surge
y Sway
z Heave
φ Roll angle
θ Pitch angle
ψ Yaw angle (also magnetic bearing angle)
α Horizontal acoustic bearing angle (also acoustic absorption factor)
β Vertical acoustic bearing angle
T1 Thrust force from the port-side thruster
T2 Thrust force from the starboard-side thruster
T3 Thrust force from the vertical thruster
F(x,y,z) Force in the (x,y,z) direction
M(x,y,z,) Moment about the (x,y,z) axis
Fext(x,y,z,ψ) External disturbance force in the (x,y,z,ψ) direction
Fd (x,y,z) Linear hydrodynamic drag force in the (x,y,z) direction
Cd Coefficient of drag
ρ Density of seawater
Wauv Weight of the AUV in water
r Radius
Ap Projected drag area
V0 Velocity of drag surface
m Vehicle mass
I(x,y,z) Moment of inertia about the (x,y,z) axis
D Separation between horizontal thrusters
Kt Motor torque constant
K(p,i,d) Proportional, Integral, and Derivative gain constants
xiii
h(1,2) Sliding-Mode controller gain constants
H Altitude above seafloor
Z,d AUV depth
R Range to beacon
Ks Sliding-mode controller maximum signal output
e Error
t(1,2,3) SSBL Transducer detection times
TL(sph,cyl) Transmission loss from (spherical, cylindrical) spreading
∆… Difference in …
xiv
Acknowledgements
xv
Dedication
and…
To my Father, for giving me the intellect and work ethic to achieve them.
xvi
1
1. Introduction:
1.1. The ANIMIDA Project
In the Prudhoe Bay region of the Alaskan Beaufort Sea, oil drilling and
Management Service (MMS), under the Department of the Interior (DOI), has been
tasked with the responsibility of studying the effects of offshore gravel-island based
participant in a large research effort in this region, known as the Arctic Nearshore
As a part of this research effort, studies are being conducted on the currently-
increases may have deleterious effects on marine plantlife, due to decreased light
temperature, depth, (CTD) and turbidity data are collected by Dr. Trefry and his
from a small boat. However, to collect winter data, several holes must be drilled in
the ice, in order to perform sensor casts. This activity is shown below.
Fig. 1.1.2: “Drilling for data” in Prudhoe Bay, near Northstar Island
3
offers poor spatial resolution, confining data collection to a few discreet points over
the entire field of study. To automate and improve this process, Dr. Trefry
recruited the Underwater Technologies Laboratory (UTL) within the Florida Tech
The scope of work for this thesis undertaking is split into two phases. Phase
Vehicle (ROV) and towed sensor array (Towfish) which were used during a data
collection trip in Prudhoe Bay in the summer of 2001. Although this work is not
the primary focus of this thesis, a brief description of these devices is presented in
collection missions under the winter ice sheet that covers Prudhoe Bay. This phase
is the primary focus of this paper, and will be discussed in depth in the following
sections. The list below defines the scope of work that will be addressed in this
thesis.
4
Within this scope of work, the AUV has been designed specifically for use
in the Prudhoe Bay area, though its potential applications far exceed this single site.
The specifications listed in Table 1.2.1 have been used as a basis for design
As mentioned before, the first phase of the project was to design and build a
small ROV and Towfish. These devices were to be used during an ANIMIDA
sampling trip in Prudhoe Bay in the Summer of 2001, after the spring ice break-up.
Since the purpose of this thesis is the development of an AUV, the details of the
design and construction of the ROV and Towfish will not be presented here.
a previous Florida Tech project, the “Stella” ROV. The goal was to quickly create
a small, low-cost ROV for capturing video of the kelp beds in the Boulder-Patch
area near the Liberty Island construction site (Liberty Prospect - See Fig. 1.1.1).
Future uses of the ROV may also include location and recovery of the AUV in the
Figure 2.1: Deploying The Hornet ROV in Prudhoe Bay, Summer 2001
The Hornet consists of two horizontal thrusters, one vertical thruster, a color
CCD camera, and halogen dive-light, mounted to a tubular PVC frame. The video
signal and control voltages for the brushed DC thrusters are fed through an
umbilical via shielded twisted copper wire pairs (STPs). The topside controller
thruster and a line-out video feed to a small monitor. The ROV is powered from a
24VDC, 10-AMP power supply supplied with 110 VAC from the ship’s inverter.
This low-cost ROV served mainly as a controllable underwater video camera for
The second item developed for this expedition was a Towfish, intended to
house the Aanderaa 3231 CTD and 3712 Infrared Light-Scattering Turbidity
7
sensors, used in previous ANIMIDA sampling trips. The goal was to be able to
with the same equipment used for vertical casts in both the winter and summer
months.
down version of the JW Fishers Proton 1 Marine Magnetometer. The sensors are
mounted inside the hull, and connected to power and serial communications via a
tether borrowed from the UTL’s Proton 1. Data is sampled topside using the
Aanderaa Reader, which scans the sensors via a proprietary serial format. The
reader then converts the data to a standard ASCII text string, transmitted over an
RS-232 serial line. This serial line is then connected to a Microsoft® Windows-
based PC via an RS-232 serial port. The data is viewed and stored in a text file
Overall, both the ROV and Towfish performed well during the ANIMIDA data
sampling expedition in the Summer of 2001. Over a dozen casts and tows were
made with the towfish, and the data collected is being used in future publications
by Dr. Trefry. The ROV was deployed four times, and collected video of the kelp
beds in the Boulder Patch area on three of these deployments. On the fourth
deployment, the ROV was sent underneath floating sea-ice fragments, to collect
video of the shape and texture of the submerged portion of the ice.
9
Early-on, it was realized that the most difficult problems to overcome in the
development of this AUV would be navigation, control, and launch & recovery.
The navigational problem presents itself in several forms. First, the use of
Differential GPS is unavailable due to the fact that the vehicle is operating both
underwater and under ice, preventing even periodic surfacing for GPS position
fixes. A reliable DGPS signal simply cannot be assured under these conditions.
difficult for even the most advanced inertial navigation system. Only with periodic
absolute position fixes (i.e. GPS or Acoustic) and fast Kalman Filtering to bound
the accumulated error, could this be achieved [6]. Based on the timeframe and
budget for this project, such a system is well beyond the scope of a single Master’s
Thesis.
ingredient in any AUV, the accuracy of such a system is extremely poor and should
only be used when precise navigation is not important (i.e. when following
have failed.
10
accurate, yet simple, acoustic homing system. This system, discussed further in
section 3.3.3, allows the vehicle to navigate with respect to a fixed acoustic beacon,
Now that the navigational problem had been addressed, it was time to
examine the control, launch, and recovery issues, which are intimately tied
(from: www.soc.soton.ac.uk/OTD/asub/cotdasub.html)
While this basic design offers some payoffs in open water survey and data
environment for this project, it was determined that such maneuvering and control
characteristics were of utmost importance. This is mainly due to the fact that the
6ft-thick sheet of ice, and may have to navigate around random, closely-spaced ice-
spikes (although collision avoidance is beyond the scope of this thesis). This
requires the ability to precisely position the vehicle at low speeds underneath the
exit hole, assuming that the position of that hole is accurately known by the
navigation system.
Such fine control and stationkeeping tasks are virtually impossible for a
and dive planes, as the turning radii for such systems are usually very large and
constant forward motion is required in order to generate lift on the control surfaces.
Since the positioning tolerance for recovery of the Prudhoe Class AUV is so tight,
failing to “catch” a torpedo-shaped vehicle during its first pass to exit would mean
a complete wide turn-around in a decreasing spiral path (see Fig. 3.1.2), rather than
as the vehicle must be turned vertical before it can be lifted from the exit hole.
12
Figure 3.1.2: Flight path of torpedo-shaped AUV for a failed “exit catch”
Beacon
Approach path
It was also determined that the benefits of low hydrodynamic were of little
consequence since this particular AUV would be moving at such low speeds (< 1
m/s).
ease the launch and recovery effort (see Fig. 3.4). This shape was based on the
section 3.3.1. The DOE ROVs work at slow speeds in tubular environments and
(from: www.deepocean.com)
14
SSBL Transducer
Syntactic Foam
Thruster Tunnel
Pressure Housing
(2 for electronics)
(2 for batteries)
Connector Rod
Spacer Plate
Protection Cage
Taking all of these design issues into account, the Prudhoe Class AUV mission
Fig. 3.1.5):
1. Drill a single 2ft. diameter entry hole and one or more exit holes in the
hole, approximately 1ft. below the bottom of the ice (7ft. water depth).
15
3. Deploy the AUV into the entry hole using a simple hand-operated rope
winch. The mission is in a standby mode, and begins when the vehicle
and depth sensor. Data from the on-board CTD & Turbidity sensors is
logged along the way, as the vehicle heads for the homing beacon,
5. Once at the exit hole, the vehicle ascends, positioning itself slightly to
6. The vehicle is retrieved with the use of a simple hook and rope and
concludes its mission once it senses less than 1” of water depth (i.e. it
(Fig. 3.2.1) was created to model plant dynamics, refine controller designs, and
examine the feasibility of the overall design through execution of test missions.
equations of the AUV. In this case, a body-fixed coordinate reference frame will
be used which is described by the following six degrees-of freedom (DOFs) and
φ
x
that y, φ, & θ are all uncontrollable DOFs, based on our thruster configuration.
Furthermore, φ, & θ are of no concern due to their linear, decoupled nature. This
is in fact one of the primary advantages of this design, in that roll and pitch can be
removed from the equations of motion. This of course assumes that T1 , T2 , and T3
20
act at the vehicle’s centroid. In fact this is not the case. However, due to a heavy
keel weight, coupled with a large buoyancy module, and large separation between
the vehicle’s center of buoyancy (Cb) and center of gravity (Cg), we can assume
that the vehicle will possess a high righting moment (GZ), allowing it to remain
sufficiently stable in roll & pitch, so as to incur nominal disturbances in the other
vehicle DOFs. Therefore, we need only be concerned with the 4 DOFs required to
position the vehicle in space: x,y,z,ψ … three of which are controllable: x,z,ψ.
following manner:
Taking the sum of forces in the X, Y, and Z-directions, and solving for acceleration
yields:
Fdy + Fy ext
&y& = + x& ψ& (3.2.3)
m
… where:
…where:
For the purposes of the simulation, these equations of motion yield eight
x1 x
x y
2
x3 z T1 + T2
Fx
ψ D
X = 4 =
x
u = M z = (T2 − T1 ) (3.2.6)
x5 x& 2
Fz
x6 y& T3
x z&
7
x8 ψ&
… where u is a function of T1 , T2 , and T3 , the inputs to the plant model from the
Two blocks in the Simulink model comprise the navigation system. The
“coord_xform” block transforms body-fixed state outputs from the plant model
Cosψ − Sinψ
X BG =
Cosψ
(3.2.7)
Sin ψ
position of the vehicle with respect to the location of the acoustic beacon (set by the
the bearing to the beacon. From this block, the following simulated system states
x1 α
x ψ
2
X nav = x3 = R (3.2.8)
x4 Z
x5 H
23
… where:
The mission planner block is the high-level decision maker on-board the
AUV. It monitors all system states and issues commands to the low-level thruster
controllers. In the case of this simulation, the mission planner observes the states
avoidance system commands and leak detection. Mainly, the mission planner
decides how fast to go, what depth to descend to, what heading to follow, etc.
During simulation trials, the mission planner was set to command the vehicle to go
directly to the beacon (α = 0), dive to two different depths depending on the range
to the beacon, and when close to the beacon, surface and slow down. The mission
planner also issues a flag, which stops the simulation when the vehicle is within 1ft
of the beacon, and at 1ft. depth (below the ice), which is assumed to be within
Mission START
File Load
MISSION
Ascend to
Surface
Vehicle In
No Standby
Water Column?
No
Yes
Vehicle Out of
Descend to Water Column?
Mission Depth 1
Yes
Listen for No
Beacon STOP
MISSION
Yes
Beacon No
Timeout
Acquired? Expired?
Yes Yes
Abort Mission
No Proceed with (Return to
Mission Origin)
Reached
Target?
25
The low-level controller set consists of three controllers, depth, speed and
heading, which are dedicated to receiving commands from the mission planner and
generating thruster outputs based on error between commanded and actual depth
and heading.
The simplest of the three, the depth controller, receives depth commands
from the mission planner, vehicle depth (z) from the navigation system, and issues
a thruster output (T3 ). From equation (3), it can be seen that the relationship
between depth and thrust T3 is simple and linear. Therefore, it was decided that a
…where:
Ki = integral gain
Kd = derivative gain
The speed and heading controllers are a bit more complex, due to their non-
linear, coupled nature. As a result, the two tasks have been combined into a single
when heading error is present and a PID speed controller when the vehicle is on-
course.
which is activated if heading error exceeds the limits of the sliding boundary layer
(+/- 3 degrees). A sliding-mode controller works by driving error (e) and error rate
s = hT e (3.2.9)
… where:
e&
Sliding Trajectory
Boundary Layer
Sliding Line
As can be seen from the Fig. 3.2.4.2, when e and e& fall outside the sliding
line, the controller moves back towards this line by making the control signal
becomes linear and can begin “sliding” towards the origin (along the sliding line).
This is especially useful if little or nothing is known about the non-linear aspects of
the system model. Once on the line, the controller continues to reduce e and e& ,
reduce chattering, by “thickening” the sliding line. In the case of our hybrid
28
degree boundary layer, allowing the PID speed controller to take-over and move
the vehicle forward, based on commands from the mission planner. Thus, heading
control is only initiated when the vehicle is off-course. These two controllers are
… where:
Note that the sliding mode controller in Fig. 3.2.4.3 contains no estimate of non-
linear dynamics in the system, and therefore behaves like a bang-bang controller,
which settles as it drives error (e) and error rate ( e& ) to zero (see [8]).
29
…where:
rate of change in range (R) to the acoustic beacon, the vehicle’s speed cannot
mode. In this case, the PID speed controller is “bypassed” by feeding it a desired
thrust instead of a desired speed. In this mode, there is no settling time and no need
The simulation was run many times, changing the location of the beacon,
adjusting controller gains, etc. Figure 3.2.5.1 shows an overhead view of the
vehicle moving from its starting location (0,0) to the beacon, located approximately
In this simulation, the vehicle adequately navigates to its target location. During
this mission, the vehicle was commanded to descend to two different depths, 20 ft.
31
and 15 ft, respectively, and then surface to 1ft. when within 10 ft. of the target. The
10, Ki = 0, & Kd = 5. As can be seen in Fig. 3.2.5.2, overshoot was minimal, rise
& setting times are relatively short, and there is virtually zero steady-state error.
Although the hybrid heading/speed controller was able to get the vehicle to its
target, it showed poor settling time, and caused the vehicle to oscillate fairly
significantly at first (+/- 45º), eventually smoothing out to a low +/- 5º.
32
Additionally, the PID speed controller had difficulty maintaining speed, because it
continued to move forward at an acceptable rate. Again, speed is not a priority for
this AUV.
33
As a test for robustness, the simulation was re-run, and the location of the beacon
was moved during the simulation to see if the vehicle could easily “chase” the
tests were successful, and the resulting course and depth plots are shown below.
34
It should be noted that the performance of the depth controller was unaffected.
Since the range of the vehicle to the beacon changed as it was moved around, the
mission planner changed its depth command to the controller, resulting in the
Overall, the simulation proved successful, and shows the ability of the
AUV. The hybrid sliding-mode/PID heading controller also performed well, and
36
the sliding-mode controller alters heading by reversing the thrusters to rotate the
AUV. In the case of large heading errors this is acceptable, in order to make quick
between T1 and T2 should provide smoother control, with far less chattering and
first in the “Prudhoe Class” of AUVs at Florida Tech, the vehicle has been dubbed
“beacon hunting” behavior. The following sections discuss in detail all of the
vehicle is shown in Figs. 3.1.4 & 3.3.1.1, and consists of four vertically-mounted
pressure vessels (two for electronics, two for batteries), two parallel horizontal
thrusters, one vertical thruster, externally mounted CTD, turbidity sensor, and
acoustic transducers, and upper & lower protection cages. Detailed drawings can
be found in Appendix A.
38
This design allows the vehicle to fit vertically into a 2ft. diameter hole, simplifying
launch and recovery through the thick ice on the Beaufort Sea. Also, the use and
vertical and horizontal planes and allowing small position corrections at low speed.
This low speed positioning, plus the advantage of being able to make a complete
360° turn within its own body diameter, makes the vehicle extremely maneuverable
The vertical separation of the buoyancy foam and ballast weight (batteries
and additional lead keel weights) enhance roll and pitch stability, allowing the
39
vehicle to move in an upright position. The upper protection cage also serves as a
recovery target, which can be “hooked” in order to catch the vehicle and lift it out
pipe with a welded flat endplate. This sizing was chosen to accommodate the
PC/104 electronics stacks and batteries discussed in later sections, with ample room
for future electronics add-ons. The open end of each housing is then sealed with a
single face-seal o-ring, which is embedded in a flat connector plate. The connector
plate is mated to the sealing flange on the housing by six stainless-steel cap bolts.
The housings have been black anodized for corrosion protection and aesthetics.
The pressure vessels are held in place by three Type-I PVC spacer plates,
which also contain a center hole for a flow tube, used to maintain output from the
vertical thruster. The CTD is mounted between the second and third spacer plates.
transducer array, environmental sensors, and protection cages together into a single
3.3.2: Propulsion
The propulsion system for the Tuvaaq AUV is based around two parallel
horizontal thrusters and one vertical thruster. As shown in section 3.2, this
low speeds is possible because the thrusters, unlike fin-shaped control surfaces,
require no forward motion to generate turning moment. This allows the vehicle to
hold position underneath the exit hole, making small position corrections as it
Early on, it was recognized that one major problem in the design of
seals which often leak and can put significant frictional drag on the motor drive
shaft, causing excess power consumption and accelerated seal wear. Unfortunately,
through electronics, which charge the appropriate coil at the appropriate time in the
rotation cycle, thus creating the necessary rotating magnetic field. Furthermore,
since most BLDC motors utilize a permanent-magnet rotor, coupling between the
rotor and stator is strictly magnetic, with no open-air electrical contacts (brushes).
44
The advantage of this inductive coupling is that it allows the outer motor coils
motor. It was hoped that potting such a motor would negate the need for shaft
seals, allowing the motor to run completely submerged, with water flowing through
aquarium pumps and sump pumps, with much success. The goal was to duplicate
require electronic commutation, the position of the rotor must be known so that the
commutator can energize each coil with the proper polarity at the proper time.
45
commutation was pursued, to avoid the need for extra conductors in the motor
connectors and eliminate the need for potting the sensors with the motor coil
commutation performed poorly at low-RPM and could not adequately handle the
used. This widely used commutation scheme involves three small hall-effect
proven and reliable, and can function at very low RPM (see [2]).
After some searching, the Elcom ST N2312 motor was selected from the
Pittman Motor Company (see Appendix F). This motor was selected based on its
size, construction (for ease of potting), coil-type (3-phase wye-wound), low speed,
Once the motor was chosen, it was disassembled, and a fixture was made
for epoxy-coating the stator and hall-effect sensors. The fixture was then coated
with a synthetic mold release compound, “HMP 4-18B”, from Fluid Polymers, Inc.,
and the coil/cable/sensor assembly placed inside. The fixture, with coil, cable, and
46
hall-effect sensors was then potted using “HMP85-1 Black Slow” 2-part epoxy,
also from Fluid Polymers, Inc. This epoxy was chosen for its workability,
can be found in Appendix F. During initial cure, each motor was run through
approximately 5-10 vacuum cycles to remove air bubbles and fill any small voids
in the assembly.
Figure 3.3.2.3: Motor fixture with coil, cable, and hall-effect sensors
After the epoxy had fully cured and cross-linked (approx. 48 hours), it was
removed from the fixture and faced on an end-mill to ensure a perfectly toroidal
shape.
47
To complete the final motor assembly, the original steel ball-bearings were
rotor magnet and stainless-steel drive shaft, offer corrosion resistance and the added
advantage of water lubrication. The final motor assembly was then outfitted with a
needed. Since a suitable motor controller was not commercially available, it was
designed by the author and Larry Buist, at the Technical Support Lab in the College
of Engineering. The motor controller was designed to support two motors per
board and allow control from a host PC via a standard RS-232 serial port.
The controller board was based around the Motorola MC33035 BLDC
Commutator IC, which provides hall-effect commutation, direction control, and on-
board Pulse-Width Modulated (PWM) speed control (see [2]). The interface
with the Hi-Tech® ANSI C Compiler and MPLAB Software. A block diagram of
the motor controller circuit is shown below. Detailed schematics can be found in
Appendix B.
The PIC microcontroller receives commands via the RS-232 serial port in
… where spdA & spdB are speed commands ranging from 0-255 (0-
100% PWM Duty Cycle), and dirA & dirB are direction commands,
Upon receipt of the “?” character, the PIC replies with a text string
“[spdA,dirA,spdB,dirB]”.
Upon receipt of the “v” character, the PIC replies with a text string
10/29/2002”)
The final board design was manufactured into a printed circuit board (PCB) using
Plus form factor. In the motor controller housing, two boards were used, one for the
52
horizontal thrusters, and one for the vertical thruster and one redundant spare.
3.3.3 Navigation
navigation. Given the nature of the AUV mission plan and operating environment,
Most AUV navigation breaks down into five major categories: GPS,
inertial, visual, acoustic and dead reckoning. As stated previously, GPS was not an
accelerometers and three corresponding gyros. This allows the system to measure
motion in all 6-DOF (see [6]). However, as stated previously, integration of these
fixes, through the use of Differential GPS (DGPS). Such systems are very
this case. Therefore, inertial navigation was ruled-out for use on the Tuvaaq
vehicle.
Visual navigation systems are also available, but due to light attenuation
underwater, are only useful at close range, and are mainly used for object
not chosen due to its unsuitability for long-range navigation, as well as its long
development time.
which will be used on the Tuvaaq AUV. The simplest of the two, dead-reckoning,
from a pressure sensor, ground velocity measurement through the use of a Doppler
Velocity Log (DVL), and distance estimation based on propeller revolutions. This
method is simple, but has the most potential for large errors. Nevertheless, a dead-
reckoning system is a basic requirement for any AUV. Since a DVL was
unavailable and prohibitively expensive for this project, the Tuvaaq vehicle was
outfitted with a depth sensor (contained within the onboard CTD, discussed in
section 3.3.4), and digital compass, which also serves as a roll/pitch sensor. The
roll/pitch sensor is primarily used to correct for vehicle motions in the calculation
of magnetic bearing, and also allows us to examine the true vertical stability of the
In dead-reckoning mode, the AUV uses the compass for bearing and
linear characteristics about the relationship between propeller RPM and forward
vehicle speed. Again, this method is highly error-prone, especially in the Arctic,
where close proximity to the North Pole can cause magnetic compasses to give
specified depth. Furthermore, this system is useful for field testing of the AUV in
Florida, to prove the performance of the vehicle’s mission planning and control
software.
over long distances, due to the high speed of sound underwater (avg. 1500 m/s in
seawater). Several types of acoustic systems are available for AUVs, including
57
Ranging (SONAR), and Acoustic Doppler (ADCPs & DVLs) technologies (see
[4]). Review of these technologies lead to the decision to develop a simple homing
system, which would allow the AUV to find its exit hole by targeting a continually
method, or SSBL. The theory behind this technique is as follows. Sound in water
Fig. 3.3.3.2.
Beacon
∆t13
∆t12
α
∆t23
3 2 1
58
direction of travel, the incoming waves arrive at each transducer at different times.
These time differences can be used to trigonometrically calculate the bearing angle
these transducer elements are placed very close together (on the order of
For our purposes, a similar, larger scale method was chosen … the Super-
except that the transducer elements are placed further apart (on the order of inches),
signal is coming from in the full 360-degree horizontal and vertical planes, a
array was designed, so as to allow this determination (see Fig 3.3.3.3 and [4]).
59
∆tac ∆tab
1
∆tbc
Zone 5 Zone 2
(240º-300º) (60º-120º)
3 2
Zone 4 Zone 3
(180º-240º) (120º-180º)
60
SIDE VIEW
Beacon
∆tac β
3 2 1
∆tac max
As shown in Figure 3.3.3.3, the angle α gives the horizontal bearing to the beacon
and the angle β gives the vertical bearing. These angles are calculated in the
following manner:
1. Logically resolve which 60º zone the beacon is in based on the order in
2. Determine the horizontal bearing angle (α) within the appropriate zone
through time-of-arrival ratios:
∆t
α = bc 60º + X … for odd-numbered zones (1,3,5) (3.3.1)
∆t ac
∆t
α = ab 60º + X … for even-numbered zones (2,4,6) (3.3.2)
∆t ac
…where,
∆t ac
β = Cos −1 (3.3.3)
∆t ac max
… where,
heading, guiding the vehicle towards the beacon. Note that knowing the speed of
62
differences between the transducers. This allows high accuracy in determining this
angle, despite changes in the speed of sound between the beacon and the vehicle.
between the transducers. This assumption is reasonable since the transducers are
The vertical bearing angle (β) is useful for two reasons. If the vehicle depth
and beacon depth are known, the two can be subtracted, giving a vertical offset
(∆d). This vertical offset and the vertical bearing angle can then be used to
∆d
R= (3.3.4)
Tanβ
Secondly, as the vehicle approaches the beacon from below, β approaches zero,
allowing the vehicle to determine when it is directly under the beacon. The vehicle
can then make a simple vertical ascent to the exit hole. In fact this is the most
monitoring this angle as it approaches 90º, the mission planner knows that it is
63
moving towards the beacon. Thus, the mission planner can find the beacon by
driving β towards 90º, and begin making its ascent when β is sufficiently steep.
relatively low-frequency, to increase range, while at the same time offering good
resolution and ease of detection. These design criteria, coupled with a review of
kHz. In order to confirm that this frequency would result in a reasonable power
output requirement from our acoustic beacon, the following calculations were made
10 log I 1 − 10 log I 2
Absorption: α= … in this case, we can use Fig
r 2 −r1
5.2 on p.104 of [5], which gives an absorption coefficient for sound waves at 37
α = 7.0 dB/kyd = 7.0 dB/km = 3.5 dB total absorption (over 500m path)
64
Therefore, our beacon must be able to output enough power to be detectable, with
64dB of loss. The beacon selected for this task is the ULB-350, manufactured by
RJE International. This pinger is often used as a marker beacon for subsea
equipment, and can last on a single 9V battery for up to 40 days. Its output is a
10ms pulse every 1sec at 37kHz, with a power output of 163dB, which is more than
The counterpart to the beacon, the receiving transducers from Sensor Technologies,
These transducers were placed in a triangular array to form the receiving-end of the
SSBL system. Spacing of the transducers is 11.955” on each side (12” nominal),
outlined below and shown in Fig. 3.3.3.7. The boards were also manufactured by
ExpressPCB, and fit the PC/104 form factor. Detailed schematics and PCB layout
which determines if the signal is “loud” enough to be the pinger, and not
5. The result of the tone detector and threshold detector are combined in a
signal at each of the three transducers and computes the horizontal and
vertical bearing angles. The result is then sent to the host PC via an RS-
this system, because the firmware in the PIC microcontroller triggers on the first
detection of the signal by the circuit. As a result, any successive detections due to
multi-pathing will arrive at each transducer after the straight-line signal is received,
and will be ignored. Furthermore, the delay associated with computation of the
bearing angles far exceeds the dissipation time of the acoustic pulse, and can be
for measuring bearing angle, it was determined that based on the geometry of the
SSBL array, the maximum time delay would occur at 60º multiples of bearing
angle offset, and the minimum desired measurable bearing angle offset is 1º. Based
on these limits, it was calculated that time delays between transducers can range
from approximately 3-203µs. Therefore, a faster 20MHz PIC was chosen, which
26,214.4 µs (for the 16-bit timer). Once the bearing angles are calculated, the data
is sent via RS-232 serial port at 9600-8-N-1, in the form of an ASCII text string
which appears as “[α,β,t1 ,t2 ,t3 ]”, where α ranges from 0-360º, β ranges from 0-90º,
and the three transducer detection times (t1 ,t2 ,t3 ) are measured in number of
instruction cycles (0.2µs per count for a 20MHz PIC). The inclusion of the
by the main computer, if the speed of sound is known. A block diagram of the
firmware is shown below in Fig. 3.3.3.9. Detailed source code can be found in
Appendix C.
70
selection of the sensor payload is critical. Ultimately, the vehicle is nothing more
than an autonomous platform, and can be adapted for other data collection missions
simply by changing the sensor payload. Originally, it was thought that the
Aanderaa CTD and Turbidity sensors used in the towfish would be used on the
AUV. However, after some testing, it was determined that these sensors require a
great deal of settling time at start-up (several minutes), and much too low of a
As a result, a new sensor package was researched, and lead to the Smart
As a result of the fast sample rate of the sensor package and high resolution of its
depth sensor, it was determined that the CTD could be used to navigate the vehicle
in the water column without the need for a separate pressure transducer. Therefore
the depth reading from the CTD is also fed to the PID depth controller on board the
The CTD sensor is mounted on the vehicle as shown in Fig. 3.3.4.2, and the
LSS (not shown) is attached on the underside of the vehicle such that it has a clear
The Central Processing Unit (CPU) Housing is the “brain” of the AUV,
running all control, mission planning, and data-logging software. This “command
central” ties all of the vehicle subsystems together. For the Tuvaaq vehicle, the
PC/104 Computer format was chosen. PC/104 and PC/104-Plus are industry-
standard formats for small, embedded computer systems. These standards have the
PC/104 modules, and a wide array of manufacturers and add-ons. Figure 3.3.5.1
shows a high-level diagram of how all of the vehicle subsystems are tied together
The heart of the AUV’s PC/104 stack is the Lippert Cool Road Runner II
keyboard, 2 serial ports, 1 parallel port, 2 USB ports, watchdog timers, 64MB
etc., is achieved through an RS-232 serial network. Given the amount of I/O in the
Tuvaaq vehicle, it was felt that standard RS-232 serial protocol offers the simplest,
without the need for complex industrial control networks or protocols. The main
hub of the RS-232 network is the Xtreme 8-104 PC/104 serial expansion module,
which offers 8 standard RS-232 serial ports (also configurable as RS-485 or RS-
422). This expansion board, shown in Fig. 3.3.5.3, coupled with the CPU’s 2
native ports, offers 10 total serial ports, 5 of which are still unused. Some
advantages of this system include the ability to add additional serial expansion
cards to the PC/104 stack, and ease of interfacing with PIC Microcontrollers (as in
the case of the BLDC Motor Controller Board and SSBL Acoustic Navigation
Board), which in itself opens virtually infinite data acquisition and control
possibilities. This, combined with the use of only standard ASCII text strings for
data transfer, simplifies software and hardware development, and adds to the
overall robustness of the system. Furthermore, commercial devices such as the EZ-
When the PC/104 stack is exposed, the CPU has the ability to directly connect to a
standard keyboard, monitor, and mouse, as well as floppy and CD-ROM drives.
This is the simplest means of communication for making major changes and
debugging problems.
However, when the stack is sealed in the CPU housing, access is limited,
Wireless Ethernet (WLAN) card would be used for communications between the
78
AUV and a host PC. This module, shown in Figure 3.3.5.4, can be configured for
one-to-one communications with another WLAN card installed in a field laptop, for
instance, or with a Wireless Network Access Point (WAP), giving the AUV the
ability to join a Local Area Network (LAN) and gain access to Internet resources.
One of these modules was removed from its casing and mounted in the CPU stack
on the AUV. It is interfaced to the main CPU board via a USB connection. Its
antenna was then routed via coaxial cable to the metal shell on one of the bulkhead
connectors on the endplate of the CPU housing. This transforms the entire housing
into a WLAN antenna, which allows wireless communications with the AUV while
at the surface.
In total, the CPU stack is comprised of the following items, which if not PC/104
compliant, are mounted on to perforated fiberglass boards which have hole patterns
that mount into the PC/104 stack. The components of this housing are shown in
to temperature concerns)
3.3.6: Power
power supply. The lack of an umbilical means that selection of batteries or fuel-
cells is critical.
For this project, the power system is relatively simple. It consists of four
It was estimated that the power requirements of the vehicle are as follows
As a result of this estimate, it was decided that SLA batteries would be the most
Assuming this worst-case scenario for power loss due to cold, the vehicle still
Figure 3.3.6.1: AUV Battery Pod internals, with two SLA Batteries
(parallel wiring)
power supply board. Since there are two battery pods on the AUV, one is used
exclusively for thruster power, and the other is used for electronics. In order to
isolate noise and provide the varied, regulated voltages required by the electronics
(+5V, -5V, +12V, -12V @ 50W), the second battery pod is connected to the power
supply board, which in-turn handles power to all of the electronics and the PC/104
bus. Since the power supply is regulated, this also ensures that as the batteries’
output voltage drops below 12V, all electronics will continue to receive their
least 6V).
functions take place on the main CPU. In the case of the Tuvaaq AUV, the
Windows 98 Operating System was chosen, for ease of use, availablilty, and size
requirements. This choice allowed quick software development time and a familiar
user interface. In the future, the AUV’s software may be ported to a UNIX-type
use of a Wireless Ethernet LAN card whose antenna is electrically connected to the
Computing (VNC), created by AT&T Bell Labs, Tuvaaq’s Windows Desktop can
this, the VNC Server is configured to run as a service under Windows on the AUV.
The VNC Client is run on the field PC, which is connected to the AUV via the
WLAN card. Once the AUV is booted-up, the VNC client can connect to it and
render the logon screen and desktop in a window on the field PC. From this
window, the user can manipulate the AUV as if it were connected directly to a
monitor, keyboard and mouse. The AUV software can then be run and configured,
data files can be transferred, or the vehicle can be operated in ROV Mode
(discussed later).
85
written in National Instruments’ LabVIEW® 6.1, again used for its short
development time and ease of use. Furthermore, LabVIEW offers easy debugging
between its many concurrent Virtual Instrument (VI) threads. A block diagram of
86
this architecture is shown in Fig. 3.3.7.1. These VIs are then compiled into a
eliminating the need to have a licensed copy of LabVIEW® installed on the AUV.
All that is required are installations of the LabVIEW® and NI-VISA® Runtime
Engines, available for free from the National Instruments website (www.ni.com).
Due to its graphical nature, LabVIEW source code (VI block diagrams) consumes
far too many pages when printed. Therefore, source code for this program will not
eliminating lags as threads are spawned and terminated. This also allows each VI
(CTD reader, motor controller, datalogger, etc.) to run at its own speed,
independent of the others (asynchronous operation). For instance, the CTD sensor
is sampled at 15Hz, and the compass is sampled at 4Hz. Generally, the overall
vehicle control loop runs at 4Hz (from raw sensor read to low-level motor
command).
Flags to read sensors and send motor commands, along with mission data
interface between all of the separate processes as they each simply read and write to
and menu selection. This VI also serves as a simple mission planner, which
orchestrates commands to the depth, heading, and speed controllers during the
mission. As shown in Fig 3.3.7.3, the user can select either dead-reckoning mode,
which uses the digital compass, or “Go To Beacon” which uses the acoustic
navigation system. Also, there are settings for depth or altitude following (can be
From the main VI, the user can then start the mission or select from several
1. File
• Quit
2. Configure
• Serial Devices
• Offsets & Multipliers
• Controller Gains
• ROV Mode
3. Data Logging
• Start
• Stop
Configure | Serial Devices: Allows user to change COM Port mapping for sensors
Configure | Offsets & Multipliers: Allows user to change gain & offset factors for
all devices. This panel can be used to compensate for linear scale factors and error
engineering units.
Configure | Controller Gains: Allows user to set gains for depth, heading, and
Configure | ROV Mode: Displays a panel, which allows user to control the vehicle
field tests via the Wireless Ethernet connection (this can be extended through the
use of a single wire umbilical attached to the CPU housing as an antenna for testing
purposes).
92
Datalogging | Start / Stop: These selections start or stop datalogging on the AUV.
When datalogging is started, the user will be prompted for a location and filename
such as Microsoft Excel. Data contained with these files includes both sensor and
93
mission parameters, such as salinity, depth, temperature, motor speed, etc. The
files are written at a rate of 2Hz, to minimize data bloating (this can be changed
within the software if necessary). Upon retrieval of the AUV, the mission planner
will stop the mission, which automatically halts datalogging. The data files can
Prudhoe Bay, Alaska. Throughout this work, much has been accomplished. These
In conclusion, the scope of work set forth for this endeavor has been
fulfilled. The Tuvaaq AUV shows genuine promise as a viable under-ice data
collection system. The design of the Tuvaaq vehicle also allows for the electronics,
the large body of work contained in this thesis, has not only created a new AUV for
use in the Arctic, but has also developed a base technology which can be used for
Tech.
96
there is always room for future improvements. Since the majority of the design and
construction effort has been completed, mostly what needs to be done is testing.
testing, both in open water and under ice. Additionally, there are some refinements
and improvements that could be useful in the future. The following are a list of
suggestions that the author feels would greatly improve the functionality and
References
[2] Gottlieb, Irving M. Electric Motors and Control Techniques. Second Edition.
New York: McGraw Hill, 1994.
[3] Ogata, Katsuhiko. Modern Control Engineering. Third Edition. New Jersey:
Prentice Hall, 1997.
[4] Waite, A.D. SONAR for Practising Engineers. Third Edition. West Sussex,
England: John Wiley & Sons, 2002.
[6] Everett, H.R. Sensors for Mobile Robots: Theory and Application.
Massachusetts: A.K. Peters, 1995.
[8] Olgac, N., Platin, B.E., and Chang, J.-M. “Sliding Mode Control of Remotely
Operated Vehicles for Horizontal Plane Motions.” IEE Proceedings-D.
Vol. 138, No. 5, 1991.
100
[9] Cristi, Roberto, Papoulis, Fotis A., and Healey, Anthony J. “Adaptive Sliding
Mode Control of Autonomous Underwater Vehicles in the Dive Plane.”
IEEE Journal of Oceanic Engineering. Vol. 15, No. 3, 1990.
[11] DeCarlo, R.A., Hak, S.H., and Drakunov, S.V. “Variable Structure, Sliding-
Mode Controller Design.” In The Control Handbook, edited by William S.
Levine. Florida: CRC Press, 1996.
%///////////////////////////////////////////////////////
%Filename: auv_model.m
%
%Description: This file implements
% the dynamics of a 6-DOF
% Autonomous Underwater Vehicle (AUV)
%
%Author: Lee Frey
%///////////////////////////////////////////////////////
% SYS Definitions
% 1-Number of continuous states
% 2-Number of discrete states
% 3-Number of outputs
% 4-Number of inputs
% 5-Flag for direct feedthrough
% 6-Number of sample times
% Definition of inputs
T1 = u(1);
T2 = u(2);
T3 = u(3);
Fxext = u(4);
Fyext = u(5);
Fzext = u(6);
Mzext = u(7);
104
% Definition of states
Xx = x(1);
Yy = x(2);
Zz = x(3);
psi = x(4); %radians
xdot = x(5);
ydot = x(6);
zdot = x(7);
psidot = x(8);
if T2 > 10
T2 = 10;
elseif T2 < -10
T2 = -10;
end
if T3 > 10
T3 = 10;
elseif T3 < -10
T3 = -10;
end
Fdx = 1.0*4.083*1.99*(xdot^2/2);
if xdot > 0
Fdx = -Fdx;
end
%Cd = 1.0
%Ap = 4.083 sq.ft.
Fdy = 1.0*4.083*1.99*(ydot^2/2);
if ydot > 0
Fdy = -Fdy;
end
105
end
function[output] = coord_xform(input)
%///////////////////////////////////////////////////////
%Filename: coord_xform.m
%
%Description: This function converts the body-fixed
% coordinates generated by AUV_model to
% geographical (global) coordinates
%
%Author: Lee Frey
%///////////////////////////////////////////////////////
%///////////////////////////////////////////////////////
%Filename: nav_system.m
%Author: Lee Frey
%
%Description:
%This function converts the x-y, psi location of
%the auv given by the system model to the heading, range,
%magnetic heading, depth and altitude given by the
%acoustic nav system, compass, depth sensor, and
%altimeter
%
%INPUT VECTOR [14]:
%Beacon_X, Beacon_Y = distance from origin to beacon
%Beacon_Z = depth of eacon
%X, Y = distance of vehicle from origin
% (this is what auv_model outputs)
%Z = depth of vehicle
%Psi = absolute heading angle of vehicle
%Xdot,Ydot,Zdot,Psidot = velocities of above
% parameters
%alpha_noise, beta_noise = random noise can be
% introduced into the acoustic nav system
% with these two inputs
%D = overall water depth
%
%OUTPUT VECTOR [6]:
%Alpha = heading angle to beacon (0 -> 360 deg)
%Psi = absolute heading angle (0 -> 360 deg)
%R = range to beacon in the horizontal plane
%Z = vehicle depth
%H = vehicle height from bottom (altitude)
%//////////////////////////////////////////////////////////
%Calculate altitude
H = D-abs(Z);
%-------------------------------------------
%Calculate heading angle to beacon (in degrees) with random
acoustic noise
%-------------------------------------------
Delta = atan(abs(Y_sep)/abs(X_sep))*(180/pi);
%----------------------------------------------------------------
%Convert Alpha & Psi from 0->360deg angles to -180->180deg angles
%----------------------------------------------------------------
if Alpha > 180
Alpha = Alpha - 360;
end
end
stop = 0;
%Depth decision
if R < 10 %Surface
depth_command = -1;
elseif R < 25 %Dive to 15ft.
depth_command = -15;
else %Dive to 20ft.
depth_command = -20;
end
depth_error = depth_command - Z;
heading_error = Alpha - heading_command;
speed_error = speed_command - Xdot;
%Implement the sign function for the sliding mode controller ...
[sgn(s)]
%where the boundary layer = +/- 3 degrees
if (h1*PSIe + h2*PSIedot) <= -3
sgn_s = 1;
flag = 1;
elseif (h1*PSIe + h2*PSIedot) >= 3
sgn_s = -1;
flag = 1;
else
sgn_s = 0;
flag = 2;
end
T1 = u1;
T2 = u2;
e = (input(1) - input(2));
%port_thrust_ratio = .50;
%stbd_thrust_ratio = .50;
%-------------------
%Fuzzy Control Logic
%-------------------
if e < 180
if e < b4
if e > (b1+b2)
%LEFT FUZZY TANK TURN
stbd = (m3*(e-(b1+b2))); %y = m*x
port = -stbd;
elseif e > b1
%LEFT FUZZY SWOOPING TURN
stbd = (50 + m2*(e-b1));
port = (50 - m2*(e-b1));
else
%GO STRAIGHT
stbd = h1;
port = h1;
end
else
113
//Function prototypes
void getCommand(); //parses incoming
//commands
void getStatus(); //gets current motor
//states (RPM, direction)
void runPID(int Kp, int Ki, int Kd); //computes PID control
//action and outputs it
//to motors
void sendStatus(); //sends motor status info
//to user via serial port
void sendVersion(); //sends firmware version
//information
int initPort(int baud); //initializes PIC serial
//port USARTs
void writeByte(char byte); //sends a character to
//PIC serial port
char readByte(); //reads a character from
//PIC serial port
void interrupt ccpInterrupt(); //CCP capture interrupt
//handler
129
/* ///////////////////////////////////////////////////////
// FILENAME: BLDC.C
// DATE: 11/06/2002
// VERSION: 1.3.0
// AUTHOR: LEE FREY
// DESCRIPTION:
// This file implements a
// Dual Brushless-DC Motor Control
// Scheme on the PIC 16F876 series
// microcontroller, for use with the
// MC33035 motor control IC and
// the TLC7528 DAC.
//
// Communication with the PIC
// is performed via an RS-232 serial
// interface at 9600 baud, 8-data bits,
// 1-stop bit, no parity, no flow control.
//
// Motor speed control is achieved
// through the use of a digital
// PID-loop with hall-sensor
// velocity feedback.
//
// COMMENTS:
// [04/30/2002, v1.0.0, L.Frey] - Creation
// [10/10/2002, v1.1.0, L.Frey] - Removed character echos
// [10/29/2002, v1.2.0, L.Frey] - Modified sendStatus()
// function and added
// sendVersion() function
// [11/06/2002, v1.3.0, L.Frey] - Added digital PID
// control lines for
// future use (commented-
// out)
//
//
// COPYRIGHT:
// This program is the property
// of the Florida Insitute of
// Technology and was developed
// by the Underwater Technologies
// Laboratory (UTL) of the Department
// of Marine & Environmental
// Systems (DMES). Reproduction
// or use of this program outside
// of Florida Tech is allowed for
// academic purposes only, provided
// credit is given to the author and
// the Florida Tech UTL. Commercial
// use is prohibited without permission
// from the UTL.
//
/////////////////////////////////////////////////////// */
130
#include <pic.h>
#include <bldc.h>
#include <delay.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Pin definitions
static bit brakeA @ PORTBIT(PORTA, 0); //0 = run, 1 = brake
static bit brakeB @ PORTBIT(PORTA, 1); //0 = run, 1 = brake
static bit dirA @ PORTBIT(PORTA, 2); //0 = rev, 1 = fwd
static bit dirB @ PORTBIT(PORTA, 3); //0 = rev, 1 = fwd
static bit DACwrite @ PORTBIT(PORTA, 5); //0 = write, 1 = hold,
static bit DACselect @ PORTBIT(PORTC, 3); //0 = DAC-A, 1 = DAC-B
static bit speedfbA @ PORTBIT(PORTC, 1); //2 pulses = 1 revolution
static bit speedfbB @ PORTBIT(PORTC, 2); //2 pulses = 1 revolution
/*
//These are used to clock motor RPM
unsigned int timeA = 0;
unsigned int timeB = 0;
char interruptA = 0;
char interruptB = 0;
int uB = 0;
int uB1 = 0;
*/
void main()
{
//setup initial conditions
int init = initPort(9600); //initialize on-board
//serial port USARTs
//to 9600 baud,8,N,1
{
//getStatus();
sendStatus();
}
else //must have been garbage, so ignore
{
RCIF = 0;
}
}
}
else
{
init = initPort(9600); //try again
}
}
void getCommand()
{
//-----------------------------------------------------------------
//NOTE: The command string must be ASCII text, sent in the
//following form:
// <rpmA,dirA,rpmB,dirB>
//Where rpmA/rpmB are the desired motor speeds, and dirA/dirB = 1
//or 0 (fwd/rev)
//The commands must be comma-delimited, and enclosed with "< >"
//-----------------------------------------------------------------
//-----------------------------------------------------------------
//Parse the commands from the string, convert them to integer
//values, and store them in the appropriate variables if they are
//valid commands
//This way, if invalid commands are sent, the motors will stay the
//same
//-----------------------------------------------------------------
133
substring = strtok(incoming,",");
cmd = atoi(substring);
if((cmd <= 255) && (cmd >= 0)) //speed boundaries (%)
{
spdA_desired = cmd;
}
substring = strtok(NULL,",");
cmd = atoi(substring);
if((cmd == 1) || (cmd == 0))
{
dirA_desired = cmd;
}
substring = strtok(NULL,",");
cmd = atoi(substring);
if((cmd <= 255) && (cmd >= 0)) //speed boundaries (%)
{
spdB_desired = cmd;
}
substring = strtok(NULL,",");
cmd = atoi(substring);
if((cmd == 1) || (cmd == 0))
{
dirB_desired = cmd;
}
}
//----------------------------------------------------
//This is the digital PID speed controller for motor A
//----------------------------------------------------
eA = spdA_desired - spdA_actual; //calculate current
//speed error
PORTB = spdA_desired;
DACselect = 0; //Select DAC-A
DACwrite = 0; //Enable writing data to DAC-A
DACwrite = 1; //Hold data at DAC-A
//--------------------------------------------
//This is the direction controller for motor A
//--------------------------------------------
if(dirA != dirA_desired) //Switch direction of motor A
if necessary
{
brakeA = 1; //set brake A
dirA = dirA_desired; //set Direction A
DelayMs(100); //wait a bit to avoid jerking
//on direction change
brakeA = 0; //release brake A
}
/*
//----------------------------------------------------
//This is the digital PID speed controller for motor B
//----------------------------------------------------
eB = spdB_desired - spdB_actual; //calculate current speed
//error
delta_uB = (K0*eB + K1*eB1 + K2*eB2); //calculate control
//signal change
uB = uB1 + delta_uB; //calculate new
//control signal
eB2 = eB1; //shift error and
//control terms in
//time
eB1 = eB;
uB1 = uB;
135
//--------------------------------------------
//This is the direction controller for motor B
//--------------------------------------------
if(dirB != dirB_desired) //Switch direction of motor B
//if necessary
{
brakeB = 1; //set brake B
dirB = dirB_desired; //set direction B
DelayMs(100); //wait a bit to avoid
//jerking on direction
//change
brakeB = 0; //release brake B
}
}
/*
void getStatus()
{
//!!!! NOTE: due to the limitations of the timer1 module,
//motor speed cannot be accurately determined under 240 RPM!
/*
void interrupt ccpInterrupt()
{
if(CCP1IF) //motor B
{
timeB = CCPR1H + CCPR1L;
CCP1IF = 0;
interruptB = 1;
}
if(CCP2IF) //motor A
{
timeA = CCPR2H + CCPR2L;
CCP2IF = 0;
interruptA = 1;
}
}
*/
137
void sendStatus()
{
//send motor speeds and directions (just sends desired speeds
//for now, until getStatus() works)
int j = 0;
char message[15];
sprintf(message, "[%3d,%1d,%3d,%1d]", spdA_desired, dirA,
spdB_desired, dirB);
for(j=0;j<sizeof(message);j++)
{
writeByte(message[j]);
}
writeByte('\r');
writeByte('\n');
}
void sendVersion()
{
//send firmware version information
int j = 0;
char message[24];
sprintf(message, "BLDC v1.3.0 - 11/06/2002");
for(j=0;j<sizeof(message);j++)
{
writeByte(message[j]);
}
writeByte('\r');
writeByte('\n');
}
else
{
BRGH = 0; // low baud rate
}
}
else
{
BRGH = 1; // high baud rate
}
return 0;
}
return;
}
char readByte()
{
while(!RCIF) //this flag is set when the RCREG
register is not empty
continue;
return RCREG;
}
Appendix D:
SSBL Acoustic Navigation Board
(patent pending)
140
141
#ifndef _ANAV_H
#define _ANAV_H
#endif
//Function prototypes
void sendVersion(); //sends firmware version information
//via serial port
int initPort(int baud); //initializes PIC serial port USARTs
void writeByte(char byte); //sends a character to PIC serial
//port
char readByte(); //reads a character from PIC serial
//port
void listenForBeacon(); //polls detection pins for beacon
//signal arrival
void calculateBearings(); //calculates alpha & beta based on
//time-of-arrival delays
void sendResult(); //sends alpha, beta, and arrival
//times (t1, t2, t3) over serial port
145
/* ///////////////////////////////////////////////////////
// FILENAME: ANAV.C
// DATE: 10/30/2002
// VERSION: 1.0.0
// AUTHOR: LEE FREY
// DESCRIPTION:
// This file implements a Super-Short
// Baseline (SSBL) Acoustic Navigation
// System for an Autonomous Underwater Vehicle
// (AUV).
//
// It times the difference between arrivals
// of a SONAR ping at three transducers and
// uses these time differences
// to compute bearing angles to the beacon
// in the horizontal and vertical
// planes.
//
// The result of the computation is then output
// to a host PC via RS-232 serial port
// at 9600-8-N-1, in the form of an ASCII text string
// which looks like "[alpha,beta]", where alpha is
// the horizontal bearing angle (degrees) and beta
// is the vertical bearing angle (degrees).
//
// COMMENTS:
// [10/30/2002, v1.0.0, L.Frey] – Creation (test mode)
//
// COPYRIGHT:
// This program is the property
// of the Florida Insitute of
// Technology and was developed
// by the Underwater Technologies
// Laboratory (UTL) of the Department
// of Marine & Environmental
// Systems (DMES). Reproduction
// or use of this program outside
// of Florida Tech is allowed for
// academic purposes only, provided
// credit is given to the author and
// the Florida Tech UTL. Commercial
// use is prohibited without permission
// from the UTL.
//
/////////////////////////////////////////////////////// */
#include <pic.h>
#include <anav.h>
#include <delay.h>
#include <stdio.h>
#include <math.h>
146
#include <stdlib.h>
#include <string.h>
// Pin definitions
static bit T1 @ PORTBIT(PORTB, 0); //Forward
//Transducer (1)
static bit T2 @ PORTBIT(PORTB, 1); //Starboard
//Transducer (2)
static bit T3 @ PORTBIT(PORTB, 2); //Port
//Transducer (3)
static bit LED1 @ PORTBIT(PORTC, 0);
static bit LED2 @ PORTBIT(PORTC, 1);
static bit LED3 @ PORTBIT(PORTC, 2);
//global variables
#define XDCR_SPACING 12 //length of side of transducer array
//triangle, (inches)
#define XDCR_TIMEOUT 65000 //maximum timer count while waiting
//for transducer detection
int time1 = 0;
int time2 = 0;
int time3 = 0;
int alpha = 0;
int beta = 0;
char gotBeacon = 0;
char gotT1 = 0;
char gotT2 = 0;
char gotT3 = 0;
void main()
{
int init = initPort(9600); //initialize on-board
//serial port USARTs
//to 9600 baud, 8-N-1
if(init==0)
{
sendVersion(); //send version info on startup
DelayMs(250); //wait a bit...
147
void listenForBeacon()
{
gotBeacon = 0;
gotT1 = 0;
gotT2 = 0;
gotT3 = 0;
TMR1L = 0;
TMR1H = 0;
}while(gotBeacon == 0);
}
void calculateBearings()
{
//determine which 60-degree zone the beacon came from
//and calculate its alpha value.
//NOTE: For testing, the alpha value is just set to the zone
//number.
//the trigonometric calculations to resolve alpha to 1-degree
//resolution will be added later
alpha = 6;
}
else //1,2,3 (0-60, Zone 1)
{
alpha = 1;
}
}
}
void sendResult()
{
int j = 0;
for(j=0;j<sizeof(message);j++)
{
writeByte(message[j]);
}
writeByte('\r');
writeByte('\n');
}
151
void sendVersion()
{
//send firmware version information
int j = 0;
char message[24];
sprintf(message, "ANAV v1.0.0 - 10/30/2002");
for(j=0;j<sizeof(message);j++)
{
writeByte(message[j]);
}
writeByte('\r');
writeByte('\n');
}
return 0;
}
return;
}
char readByte()
{
while(!RCIF) //this flag is set when the RCREG
register is not empty
continue;
return RCREG;
}