8.28.2013

Razor IMU: Serial Outputs to Raspberry Pi

We want to use the outputs from the Razor IMU for multiple reasons. We are envisioning an ROV with the AUV capabilities of station keeping (being able to hold the sub in one place/orientation). To station keep we need to make sure that for every movement of the vehicle the motors kick in and create an equal and opposite reaction, keeping the ROV stationary. To do this we need to use the outputs from the Razor in an algorithm which will then tell our motors what to do. To get these outputs we are currently using the serial port output and the USB connection through the FTDI on the Razor.

This post is very similar to one of our other posts which told you how to use the Arduino UNO to send serial outputs to a Raspberry Pi. This will be very similar. Please refer to that blog post to download and compile Pyserial-2.6. After doing that follow these easy steps to see the YPR outputs from the Razor.

    1. Find which device is the Razor when the USB is plugged into the Pi. Ours was /dev/ttyUSB0.

/dev/ttyUSB0
    2. Next open up IDLE on the Raspberry Pi and type in these commands (baud=57600!!)
command

YPR outputs!
...and voila! Comment with any questions or suggestions regarding our data transfer technique for the Razor IMU.

Arduino UNO: Serial Outputs to Raspberry Pi

Our Submersible is not only going to have "eyes" (which would be our camera setup); it is going to have an array of sensors to test its physical surroundings. We want sensors to test such things as water temperature, salinity, and depth. We know that Raspberry Pi's are not designed for this type of work and therefore purchased an Arduino UNO. We chose the UNO for a couple of reasons.

  1. There is extensive documentation on the Arduino webpage as well as all over the internet.
  2. Arduino is great micro-controller that is known for its numerous sensor capabilities. 
  3. The UNO is one of the more basic, but still powerful boards
  4. We have experience using the UNO from smaller projects. 
Arduino UNO with USB


Knowing that we wanted to use the UNO for a data collection device, we also know that we need to find a way of transferring this data off of the submersible and to the user. Naturally we decided to channel this data through the Raspberry Pi. To do this we can use a simple serial port command on the Arduino which can then be received by the Pi through a USB connection. To do this follow the steps below:

    1. Download Pyserial-2.6 and unzip it on your laptop. Then forward it using this ssh command (make sure you cd into the correct file-path for "pyserial-2.6" on your laptop; i.e. Desktop) :

Similar to sshing into the Raspberry Pi
    2. Next cd into the new folder on your Raspberry Pi and compile pyserial-2.6.

Navigate to pyserial-2.6 
Compile 

    3. Open up the Arduino Software and plug in the Arduino. Choose the correct board under
        Tools ----> Board and the correct serial port by going to Tools ----> Serial Port.

    4. Next use code similar to the following and upload it to the Arduino.
Arduino sketch
    
      5. Now attach the Arduino to your Raspberry Pi using the same USB cable used to attached it to one's computer. Try to locate which device name is given the to Arduino. Look for the device under /dev/tty. Do this by typing in ls /dev/tty*:

no /dev/ttyACM0


and then unplug the Arduino and again type in ls /dev/tty*. Device which device has disappeared. Whichever device disappeared is the Arduino UNO. Our Arduino was located under the name: /dev/ttyAMC0.

/dev/ttyACM0 appears

    6. Make sure that the Arduino is plugged in to the RPi. Now the Raspberry Pi has to "read" the serial data streaming from the Arduino. To do this use a simple Python command. Open up Idle and type in the following commands, making sure that both the baud rate and file path for the Arduino are correct.

code

Serial output

Done! Now one can write your own code to transfer readings such as temperature using the serial output on the Arduino! One can customize the Arduino code to output salinity, temperature, and depth readings easily!


Razor 9DOF IMU: Setup

Our idea for a submersible is one that is both an ROV (remotely operated vehicle) and an AUV (autonomous underwater vehicle). We want an ROV with AUV capabilities because it allows the user a diverse array of capabilities. The user could choose to explore a fishery with the ROV, but then anchor the robot, and have it stationed overnight. To do this we need an Inertial Measurement Unit (IMU) to accurately measure the direction and angle of submersible in many different directions. We chose to use the Razor IMU which is going to measure the difference in Yaw, Pitch, and Roll for the submersible. That information will then be relayed to the Raspberry Pi (or any other computer) which will be able to compensate for said movement. Before doing any of this we needed to setup the IMU. The following materials are needed to setup your own Razor IMU.
The IMU we chose to use is the Razor 9DOF IMU from SparkFun Electronics. We chose to use this board because it has a lot of documentation on the internet and free code showing how to set it up. The Razor was $125.00 and therefore we had to do a lot of research before buying this product (one should also look at the other choices and what works best for their project), but we concluded that the Razor gave us the most bang for our buck. The Razor also needs a FTDI Basic Breakout (3.3v) board, a Mini USB cable, and a JST Jumper Wire for power (which, unfortunately, has to come from SparkFun or it will not fit). Pictures of the hardware are below:

JST to power, Razor, FTDI, and Mini USB

After buying these products we followed this very useful tutorial  (the one we used to get our Razor working). One can either continue following our tutorial or refer to the site mentioned above.

After buying all of the hardware, downloading both the Arduino/Processing applications and the necessary firmware you only need to follow these steps to setup the Razor to give accurate Yaw, Pitch, and Roll readings.

The first thing we did was solder some pins onto the Razor for easy FTDI (if you are wondering, FTDI is just a brand name) connection. One can then plug in the FTDI 3.3v breakout board (make sure that that the pin inputs/outputs on the breakout are matched up to the right ones on the Razor!!) and the USB cable. Open the Arduino software and chose the Arduino board in the following picture. You should also open the Razor AHRS firmware package you downloaded from the link above (in the background).

Selecting the correct board with the Arduino AHRS file open in the background
Once one has done this one can plug the Mini USB into the computer. Then choose the correct serial port by going to Tools ----> Serial Port.

FYI...the USB is able to supply power to the Razor...a battery or power source is not needed if plugged into a computer.

Next read up on the software (try to understand it and read through the beginning of the program. This is where the calibration data will be going).

Then one can upload the code and open the serial monitor from Tools ----> Serial Monitor and then choose a baud rate of 57600. One should see some uncalibrated degree measure for YPR displayed like this:
Serial Port (Yaw, Pitch, and Roll)


Next comes the calibration of the IMU. To do this enter  #oc in the serial window. This will show the accelerometer data. the accelerometer data. To calibrate it move the sensor very slowly in every direction. This will account for gravity (do NOT move it quickly or the accelerometer will give you very large numbers). Record the min/max for each value and save it for later.

example: not calibrated correctly

Next enter #on into the serial window. This will give one another calibration output. These numbers are the magnetometer readings. Now move the board in every direction as much as one wants and record the min/max values for the magnetometer (be careful doing this around laptops and other objects with magnetic fields...it may disrupt your data).

example: not calibrated correctly


Lie the sensor on the table and enter #on in the serial window to get ones final reading. These numbers are the average "noise" sensed by the gyroscope on all three axises (x, y, z). Record these min/max numbers.

example: not calibrated correctly


If you would like to restart the calibration data type in #oc and navigate back to the respective window by using the #on command.

Once one is satisfied with that data a second magnetometer calibration must take place. To use this calibration method quite he Arduino software and open up Processing 2.

Navigate to Razor AHRS ----> Processing ----> Magnetometer Calibration and then open the .pde file.



Now put the IMU exactly where you will have it while using it to collect your data. This is very important because you need to calibrate the sensor in the same environment that it will be used in. After starting this software you should see something similar to this:

extra Magnetometer calibration

After you finish moving around the magnetometer as much as you can you'll have an image similar to this (the shape and size of the spheres/ellipses will depend on the amount of interference involved):

Calibrating the magnetometer
Once satisfied with your shape press the space bar, then exit the above window.  Look at the serial output window at the bottom of the Magnetometer_Calibration window. Scroll through and look for outputs similar to these:

Magnetometer Calibration data

Record them and then re-open Arduino and the Razor AHRS program.

Scroll down until you see commented lines for each of your data inputs (accel, mag, gryo, mag#2). Enter the numbers and then save and upload your changes to the Razor.† This should calibrate the Razor to your respective environment. You can easily recalibrate and we recommend doing it multiple times until you're sure that it's perfect.

If you would like to see the visual output of the IMU do the following.

  1. Quit Arduino
  2. Start Processing
  3. Open up Razor_AHRS_test through the Processing folder in the downloaded firmware package.
  4. Run the program. You should see an image similar to this:
Processing Razor_AHRS_test
This image is not perfect...it will lag at some points. It's just cool to see an example of a visual output you can create using the Razor.



† The numbers should be relatively close to the example min/max values commented out in the .pde file. If they are greatly skewed in any way we recommend that you re-calibrate the sensor.

8.18.2013

Mechanical Testing: Designing our own Watertight Capsule

Choosing the Container:

Before we could test our motors and props we had to create a way to allow us to submerge both of them underwater. Although some of our motors are waterproof (Johnson) not all of them are. By creating waterproof capsules we have a constant size to deal with and therefore constant data that does not rely on the volume or surface area of the motor.

The creation of these capsules was a long and arduous process. Not only did it take us a while to choose what container to use, but many of our attempts did not even work. Before going into this we knew that we wanted to create a container that could be used for multiple motors and therefore had to have a removable top that was watertight. We also knew that we wanted a PVC running into the top of the container so that our power source could be above the water. Finally, we knew to create a watertight seal we needed to attach a sheet of plexiglass with a seal to the end of the capsule where the shaft would protrude.

The first container we tried to use was a ®Tupperware container. We thought that using a pre-made container would allow us to make a few small changes and have a working watertight container that also has an easily accessible inside. After attaching a PVC pipe and plexiglass sheet to our container we realized that it wouldn't work. To our dismay this container was neither big enough nor strong enough to stay watertight with a motor inside. In fact, trying to attach the plexiglass caused the container to break.

Failed ®Tupperware container (w/ broken side)

Our second idea was to use a few sections of larger PVC. We would attach them by press fit and then silicone where they attach. This would give us a stronger container, and one that was still watertight. For the removable "top" of the container we thought that using a latch and rubber seal to make it watertight. This option would have worked, but it was expensive and did not allow us to view our motor while it was inside of the container.

After much trouble we were able to finally find a package of acrylic containers from Bed, Bath, and Beyond. They are cylindrical containers that are just the right size for our motors. They have a latched and sealed top, viewable insides, and are made of strong plastic, all are reasons to use these acrylic containers.


Building the Container:

Building the container took a lot longer than expected. Like in any project, we had to go through multiple designs to ensure that the final product worked properly.

The first step was to reinforce the bottom, or the "working" end, of the container. To do this we cut out a piece of plexiglass and screwed it on after pre-drilling both pieces. We were careful to not drill all the way through the plexiglass, avoiding extra holes in the container. We also siliconed the area between the plexiglass and container before screwing them together. A picture of this is below. We then drilled a hole in the new top of our container (old side) which is where the PVC with electrical cords will go. We reinforced that with wood and silicone. Pictures of this are below.

Plexiglass Seal in "working end"
PVC Seal





















After finishing the containers our next challenge was to create a way to fasten our motors inside of them. We knew that we needed some sort platform and decided on making a removable plexiglass shelf  that slides into the acrylic containers. After creating the shelf we added half of a mousepad for increased friction (and therefore reduced movement inside the container) and two belts created from fabric and D-rings which we sewed together. Finally we attached the shelf to our container by fastening them with bolts and more watertight seals. A picture of this shelf is below:

Plexiglass bolted down
Plexiglass w/ shelf






















Shelf with straps





Mechanical Testing: Motors and Shafts

Choosing our Motors:

Choosing motors was somewhat of a dilemma. On one side there are very expensive ROV thrusters which would be the best motors we could get, but as one can see they are very expensive. On the other side there are non waterproof R/C  motors, but we have to design a waterproof housing for them. As one might imagine we were not happy with either of the choices and therefore looked into two unorthodox ways of powering a submersible. First we looked into a waterproof motor because a waterproof container would be unnecessary. The water proof motor we ended up buying was a Johnson bilge pump motor cartridge. We also thought that using motors from rechargeable drills showed a lot of potential. They have both high rpm and high torque. We thought that this would allow us to attach large props and have a large amount of thrust with a relatively small motor. The only drawback to this type of motor would be the need for a watertight container. We ended up having a total of 4 different motors:

  •  Johnson (small motor cartridge) – bought
  • Rule (small motor cartridge) – donated
  • Jabsco bilge motor – donated
  • Dewalt drill motor – donated


Extending our Motor Shafts:

One problem with the motors we chose was that each of them had short shafts of different sizes that wouldn't allow us to attach propellors easily. In order to fix this we decided to buy/create a universal shaft. We ended up buying a 3/8" aluminum rod to fit inside the seal in our containers. We cut 5 sections of metal rod into 4" pieces. Tapping one end with a 10-32 tap and drilling a hole on the other end for its respective motor. The threaded end will allow us to easily switch out props sizes while testing. To attach the new shafts to the original motor shafts we used an 8-32 tap and set screws.  Pictures below:


Shaft attached to RULE with set screw
Propellor on 10-32 threaded rod in shaft






















Jasbson w/ extended shaft and propellor
10-32 tapped end


All 4 motors with extended shafts

8.09.2013

Mechanical Testing: Constructing our Testing Tank

Our "testing tank" is actually an old fish-tank refurbished with a wooden frame to support our motor testing. From this frame the motor capsule hangs in the water on a short electrical PVC pipe which is attached to the frame by pivoting axis. A Vernier Force Sensor  is attached next to one side of the pipe. When the motors are powered the end of the PVC will be forced into the sensor which will then give us data to help compare motors and propellors. This data will be collected on Logger Pro and compared on through regression analysis using voltage as the independent variable and force as the dependent. A few pictures of our testing tank are below:


Fish tank + wooden frame

Nick screwing attaching the pivoting axis


The pivoting axis (metal brace + rod) and the Vernier Force Sensor (black box and stopper)












8.07.2013

Mechanical Testing: Propellor Research


We know that Robo Goby will need certain props and that props are chosen because of their different capabilities. Naturally we needed to do some research in order to pick these props. After we had an idea of what we wanted for props we would test them with an array of motors chosen for the same reason. We first compiled a list of online sources to research. After reading through multiple websites we would recommend reading this webpage:  modelpowerboat.com. It has basic information on prop pitch/diameter as well as useful boat terminology. Below are the definitions we found most useful:

  • Diameter: the diameter of the prop; distance from blade tip to blade tip
  • Pitch: a difficult calculation, but it given for most/all props. Pitch is the amount of forward distance for each rotation of the prop (this number should be decreased by 5-30% due to slippage in the water).
  • Aspect Ratio: Pitch divided by diameter (P/D). This is an easier way to compare data while keeping both diameter and pitch in mind
Basically a higher pitch or diameter requires a stronger motor because it means more water is moved. We're trying to find the perfect aspect ratio and diameter for our specific motors (check out the Motors... page).

After reading this page we had a pretty good idea of what we wanted for propellors, but it was impossible for us to be 100% positive until we tested our props with our motors. We ended up buying a total of 11 props with a range of 38mm 70mm diameter. We bought relatively cheap molded plexiglass props from OffShoreElectronics.com because of their pricing, but also because they seemed like good testing propellors – our final product will most likely have better, stainless steel propellors. We also chose to use this website because all the shaft diameters were 3/16" which made out lives a whole lot easier. Unfortunately the aspect ratio of our propellors are constant. We used the diameter and blade number for our variable tests.

A chart of the propellors we purchased, their aspect ratio,  diameter, and blade numbers is below:


We will be testing these props with the different motors mentioned on the Motors... page. Stay updated to see our results.

Mechanical Testing Overview

While working on the Communications and Controls aspect of Robo Goby we were also working on testing various mechanical aspects. This is the second part of our summer work. The posts for Mechanical Testing will include:
  • Propellor Research
  • Choosing our Motors
  • Testing Tank Construction
  • Waterproof Container Construction
  • Collecting/Interpreting Data
Stay updated by checking in weekly for new posts about current work.

8.02.2013

Raspberry Pi: VNC Viewer

VNC Viewer:

As you already know the Raspberry Pi is a small, credit-card sized computer. Although it is a computer one of the biggest differences between it and a PC is that the PC is easier to use. You buys it with a  screen a keyboard and a trackpad/mouse. As you already might know the Raspberry Pi lacks these components which makes other computers easily accessible. Therefore, we needed a software program which would allow us to connect and access the command line wirelessly, but also to visually see the desktop of the Raspberry Pi.

We decided to use Real VNC to do this.  We chose this software because it is well documented on the internet and fairly straight-forward. Below are the steps to setup your own VNC Viewer on a Raspberry Pi:



  1. First, download Real VNC Server using this command on the Pi's terminal 
      • for some reason tightvncserver on images other than Occidentalis has an (almost) eternal gooey screen which you do not want. 

for Occidentalis image


                             

                                               or

for Raspbian or Debian


 


   2.  Second, download Real VNC Viewer from here (correct version for your operating system).


   3. Start VNC server by either typing in the following:

for Occidentalis

for Raspbian/Debian







 4.   Then to setup VNC Server on boot (RPi boot). Do this by following these directions:

Enters directory /home/pi/.config


Creates file "autostart"

Edits "autostart"-(works on all images)

Sets up VNC on boot


These commands first entered a directory that runs on boot and then created a file called "autostart". Inside that file it tells VNC to start on port 1. This allows us to plug the Pi in anywhere and view the "screen" with a known IP. 

Now press control-X and then Y to save changes. Then:

By setting up VNC Viewer on the Raspberry Pi and opening a few ports in my home network anybody in the world (with internet of course) can log onto and control the Raspberry Pi. This is especially useful for our project because it allows us to only buy one computer and run it at a set location, but have others edit it from anywhere. The next step on the Communications and Controls part of this project is to setup a wireless webcam video feed. Check out the next post for more do-it-yourself tips.

Now log onto VNC viewer by typing in the static IP of you Raspberry Pi:1 (ex. 10.0.1.201:1). The following is an example of the login screen and the view of the RPi through VNC. 

VNC Verification

Raspberry Pi over  VNC