Waterproofed MaxBotix Sonar w/ Arduino

In order to get a better picture of the environment the submersible is working in we will be adding sonar sensors to different parts of the submersible. These sonars will not only be able to sense the submersible's altitude from the sea floor, but also any unidentified objects in its blind spots. After doing some research on different sensors we settled on using the XL-Series MaxBotix sonar with a 10 meter range. A picture of the sonar is below:

Before we setup the Sonar, there are a few things we should cover:

  1. You should first read the data sheet to get acquainted with the sensor. 
  2. From the data-sheet find the specific mV/cm or µS/cm (for analog and digital readings)
  3. Realize that this sonar will NOT detect objects closer than 20 cm. With the sealant we used this was altered to 31 cm≈1 foot (µS/cm constant changed respectively).
  4. Using the Analog option on this sensor will only give a max of 700 cm
  5. For waterproofing (rather than just water resistance) the transducer needs to be sealed. To do this we used a silicone sealant. This allows the transducer to work while still giving accurate readings. 
  6. In water sound will travel approximately 4 times faster (will be different in salt water!). This means that we will get 4 times the max distance, but also 4 times the min distance. Unfortunately this does not give us the close quarters detection we were hoping for, but will work fine for a shallow-water altimeter.   
    • Max: ≈ 40 meters         Min: ≈ .8 meters

To seal the sonar spread the silicone sealant (clear silicon caulking or RTV derivative) around the edge of the transducer to make sure no water can enter the PVC housing. We did not seal the pin-outs as the threaded PVC housing will allow us to easily make this sensor module, thus no need for waterproofing. Our sealed transducer is pictured below:

Next is the code. We used an Arduino to read the pulses coming from the sensor. Using the information we found on the datasheet above each pulse read by the Arduino will be divided by 58uS giving a specific distance in cm (changed for sealed sensor). We then multiplied this by 4 (which is roughly the amount of times faster sound travels through water than air) to get our distance in an underwater environment.

MaxBotix also recommends using a median or mode test to ensure accurate readings. To use the mode test store an odd number of values into an array (we used 9). Then use the Bubble Sort algorithm to sort values from least to greatest. Pull out he 5th value (arr[4]) and you have your median! An image of the code printing to the Arduino's serial console is below:

The code can be found here in the MaxBotix_Sonar folder.

Unfortunately this sensor did not have the short-range capabilities we were hoping for (our fault for not reading the data sheet more closely...), but will, as we said above, work perfectly for a 40-meter altimeter.

Although the sealant skewed our values we were able to account for that by adding our own constant. Similarly we accounted for the speed of sound by using the density of different liquids.


Float Prototype: Physical Design, Part 1

Before building the submersible we decided to create a prototype of our float as it is simpler to make for a number of reasons.

To begin we created a rectangular, dock like structure out of pressure treated 1" x 6" boards. After trying a few sizes we settled on a 16" x 24" float. This allowed us to have enough room for the spool, spooling mechanism, batteries, and electronics. We added 2" sunken platform on the far ends  of the 24" length. These boards create two shelves that will hold batteries and electronics. A 12" gap is left in the middle for the spool and spooler.

After we finished constructing the platform we created our tether. The wire, which was generously donated by Horizon Solutions is 500' of 1032  strand 10 AWG wire. We took the two 250' lengths and twisted them together to make one, two stranded 250' tether. We then wrapped it on a plastic spool purchased on McMaster. Once the tether was on the spool we found two issues: one it seemed weak, and two the advertised hole size of the spool was not the actual hole size (weird!?). Thus we decided to create our own spool. We used 3" PVC pipe as the center, and then cut circles out of plexiglass for the two ends. We purchased threaded male caps for the PVC onto which we put the plexiglass end pieces. We then screwed on a nut (female PVC end piece) to hold the plexiglass in place.

PVC center w/male & female attachments

End piece for spool

Finished Spool

The next dilemma was creating a new spooler that could easily transfer power to the wire on the spool. At first we decided to power an aluminum rod and a metal sheet using brushes. We decided against that as there would be too much power running through the spool without any protection. We then tested using the metal ball bearings. Although a good idea, transferring power through the power through the bearings dropped out voltage by 1/12 which is unacceptable. We ended up using the aluminum rod and bearings, but not powering them. We decided to power the float using two small metal plates on the outside of the plexiglass.

The spool itself has a 3/4" aluminum rod and bearings with an OD (outer diameter) that almost fit inside the PVC and an ID (inner diameter) that almost fit the aluminum rod. As neither quite fit the bearings, we filed the PVC ends so they were a little larger and sanded the aluminum rods so they were a little smaller. Once both fit with the bearings we assembled them and moved to the last piece of the spool integration onto the float: the stands. We created two blocks of wood with holes at equal heights and added them to either side of the float. This allowed us to push the aluminum rod through the two uprights and the spool to create our spooling mechanism.

Spool on Float

After purchasing bi-polar stepper motors to control the spooling, we needed to find a way to attach them to the float. We first added plexiglass plates using the mounting bolts on the front of each motor. We made the plexiglass rectangles so that one side would stick out beyond the motor. This allowed us to create a slot in the shelf to hold the motor steady. We cut the slot out of the shelf using a router. We then needed a way to keep the motor from coming out of the slot, for which we used a U-bolt. We went through this process for two motors: one for spinning the spool and the other for spooling the wire on the PVC.

Motor under spool
Motor on shelf

The next step in making a prototype of our float was to add pulleys for the belt driven spooler. The first pulley we added was to the end of the spool itself. We took the (corrosive resistant) metal pulley off of an old bilge pump motor and cut a hole in the center so that it would fit around the male PVC end. We then secured it in place with four bolts extending through the plexiglass ends of the spool. While doing things we were careful to keep the pulley centered on the spool so that it would unwind the tether without any irregularity. We found that the nuts couldn't actually fit onto the end of the bolts due to the width of the PVC. Luckily we were able to tighten the bolts on the pulley and add a hose-clamp to hold everything in place. The setup is very strong and will work perfectly for our spooling mechanism.

Pulley for belt drive

After attaching the pulleys to the motor and to the spool we finished the "winding" mechanism. This is located underneath of the spool and will help us spool the tether more efficiently. We created a variable tension pulley opposite the motor located underneath of the spool. The belt attached between the motor and the tension pulley allows us to wind the tether on the spool efficiently. The tension pulley is circled in red:

Tension pulley
We also added timing belts to finish off the spooling mechanism. We purchased two timing belts from McMaster: one for the spool and another for the "winding" mechanism. Images of the finished spool, with the belts and pulleys attached, are below:

Spool timing belt

Entire spooling mechanism

After finishing most parts of the above water float we moved onto the pontoons that will keep it floating. We got 8" DWV PVC piping for the pontoons as well as four end caps (one for each end of two pontoons). We also got 1-3/8" PVC to act as stilts. We bolted each leg onto the float in two places. After we cut holes in the pontoons so that the legs could extend all the way through them. We tried to drill holes only just larger than the pipe so that we wouldn't need to do a lot or waterproofing, but didn't have the right bit size so we will have to find a way to water proof them. We have the legs go through the pontoons so that they will be more sturdy and less apt to break off or bend.

Leg attachment

Pontoons without end caps


GPSd, Java, and the Raspberry Pi

The float for RoboGoby will have a Global Positioning System, or GPS, onboard for real-time tracking. GPSs are readily available and extremely easy to interface into your project. There are various different GPS module from Sparkfun, Adafruit, Mouser, and other distributors. They come with different antennas, although a custom fit ceramic antenna is the most common.

Ceramic antenna

GPSs also come with different update rates (in Hz) and different channels. Channels represent the number of satellites a receiver can receive data from at the same time. And Hz, or hertz, is the speed of your module. If you're not sure which GPS is right for your project, check out SparkFun's GPS Buying Guide

The awesome thing about GPS receivers is that soon after they receive power, they continuously output a string of ASCII characters through a serial cable/UART connection. The string contains coordinates, altitude, time, speed, directional degrees, etc.  In order to read the data from a GPS you need to download a GPS parser which can decode the GPS ASCII and then implement in your code (in our case a simple Java program). 

We are currently using a pre-constructed USB GPS (image below -- you can see the ceramic antenna inside). Other GPSs (like the Ultimate GPS from Adafruit) can be wired to an Arduino or Pi using UART (more info found here).

USB GPS Reciever

To test the GPS, we used a generic python setup from Adafruit (found here). The following quick steps make sure the GPS is working (our USB GPS was located on /dev/ttyUSB0). After making sure the GPS is working, you can add the python code, gps.txt file, and Java code we used to read the GPS data (we had to write the data to a file using python and then read it using Java. Although this means switching platforms it is ten-fold easier than using Java directly -- trust us, we tried).

If you type in the following you will see a bunch of unknown characters. This is because the Pi cannot decipher the ASCII strings. You'll need to download GPSd to do that.

1. Download GPSd and the python library needed to read GPS data:

2. Tell GPSd where to look on the Pi for the data stream (in our case /dev/ttyUSB0)

3. Make sure that your GPS is using GPSd and receiving data from your module:

GPS Data

...and using the same cat command above you now see recognizable data (somewhat recognizable...)!

The next step is parsing the data into a usable form. For this, we are going to use Java. (make sure you have Java installed ---> sudo apt-get install openjdk-7-jre). The Java code will read the data written to a text file using Python. The python code uses the TPV-Class to read the lat and lon data (check out the link for the full set of data available using TPV).

All of the code can be found in the GPS folder located on our download site. Below is a quick explanation of what the code does.

1. The python code (gpsPi.py) reads the data from the GPS and parses it into recognizable latitude and longitude values. It then writes this data to gps.txt and then immediately runs gps.jar. The Java file (gps.jar) reads the data from gps.txt and converts it into a DD°MM.M'SS.SSS" format. Pictures of the code are below:

***do not name your python file gps.py as the method it uses to call the GPS module will NOT work.



…and this is the data output on the Pi!

To make sure your coordinates are correct check out this sweet website.