E80

Experimental Engineering

Lab 1: Go Autonomous

Team size: 4

Learning Objectives

After successful completion of this lab, you will be able to…

  1. Explain the basic operation of your robot including details about the battery powering it.

  2. Demonstrate how to autonomously navigate your robot through an obstacle course.

  3. Explain the limitations and challenges of open loop control and articulate how a closed loop design addresses them


0. Introduction

The objectives of this lab are to transform the ROV (remotely operated vehicle) used in E79 into an AUV (autonomous underwater vehicle). You might remember that cables ran between your control box and your E79 robot. The cables were cumbersome and limited the range of the robot. In E80, you will build an autonomous robot with an on-board microcontroller that controls its motors and collects data from its sensors. This lab should get you acquainted with the microcontroller, and in it you will build your first autonomous robot. In doing so you will come to understand your robot's limitations when only open-loop control is used.

While most AUVs built in Lab 1 will look the same, students will modify these vehicles as the course progresses so that by end of semester, each will be configured and equipped for unique ocean-sampling experiments.

Lab 1 is to be completed in teams of 4. Team members will be assigned by the instructor. It is up to the team to determine which parts of the lab are done by whom, and at what time during the four hours of lab time. A work breakdown showing what each team member intends to work on during the four-hour lab time is required for entry to the lab. The work breakdown will be submitted on paper to a lab instructor or proctor at the start of lab. Here is an example work breakdown. No hardware can be used outside of lab hours and no real data can be processed outside of lab hours. However, writing software or processing simulated data sets is allowed and, in fact, encouraged during the pre-lab period.

A submission sheet is due at the end of the 4-hour lab period. The submission sheet must be uploaded before the end of your lab session at 5:15 pm. Note that only ONE member of each team should access and submit the submission sheet. It is the responsibility of that team member to add the rest of the team’s names to the submission sheet.

For pre-lab purposes, a sample submission sheet that contains all of the questions and requirements on the submission sheet on can be found here.

You will work with some expensive hardware in this lab and in many future labs. This hardware needs to be explicitly checked out from a professor or proctor so that we can track where it is. If any hardware that you checked out breaks, you will need to request a replacement from a professor. You make this request by filling out an error report (paper copies will be in lab). This report needs to be well thought out; professors will reject reports that don't represent sufficient testing or thought. You will keep this hardware with you throughout the semester in your storage box.

1. Battery

Your AUV will need power, and we provide that with a battery pack. The battery pack used in E80 is a 3000 mAh to 3500 mAh, 30 C, 11.1 V LiPo battery pack. Determine the maximum, minimum and nominal voltage outputs of these battery packs. Determine how many cells are in the battery pack. To charge the batteries, we will use a HiTec x1 Mini charger or a UP60AC multi charger. Read the manual on how to use the chargers.

Request a battery and a LiPo safe bag from an instructor. You will need to check out and set up your battery for charging as soon as you start the lab. ASK AN INSTRUCTOR OR PROCTOR TO CHECK YOUR RECHARGE SETUP. Here are some helpful images. Charge the battery up to its nominal voltage, NOT its maximum voltage, which means that you will need to periodically monitor the voltage on the battery and stop the charging at the appropriate time. You will normally charge the battery to its maximum value, but for this lab, you don’t have the time.

Note: Make sure you plug the balancer cable into the balance lead socket (the black wire should align with the minus sign). Failure to do this may cause the battery to explode! Always use a LiPo-safe bag while charging.

Note: You can use the power supply on your work bench to power your board without your battery. However, the bench power supply can’t provide nearly as much current as the battery. Your board has a screw terminal labeled P.S. which can be connected to the power supply. The power supply switch must be set in the P.S. direction for this screw terminal to power the board. Be very careful to get power and ground connections to the P.S. screw terminal correct by following the silkscreen V+ and GND labels on the board.

2. Motherboard Assembly

For E80, a motherboard has been designed to interface the major electrical components of your AUV. Familiarize yourself with the components on the motherboard by reading the Introduction to the E80 Motherboard document. You will add some necessary components to the board in Lab 1. Use this motherboard assembly document as a guide and add the components. Checkout your motherboard from a professor and find the other parts you need in the parts rack on the central table. For reference, the schematic for the motherboard is here , the layout is here , and KiCAD design files are here.

Before you begin assembly, write your section number and team number and board version on your board. This will be version 1 for all of you, you will increment your version if, for example, your board blows up and you have to make a new one.

There are two ways that you can damage your motherboard irreparably during this process. One is soldering components in the wrong position or orientation (e.g., screw terminals facing inward or header on the back side of the board), which is very difficult to rework. Double check that you are using the correct header and try fitting all the pieces together before soldering. The other is attaching your battery or power supply leads backwards or soldering the red and black wires to the incorrect terminals on the motherboard. Have an instructor or proctor check your battery connector. Make sure to heed the warnings in the assembly guide.

Cover the back of your motherboard with insulating foam sheet using these instructions to prevent inadvertent short circuits when you set it down. Also, find a sharpie and color the GND side of your P.S. screw black, so that you don't forget the polarity of the connector.

3. Arduino Programming

You will use the Arduino language to program your microcontroller, the Teensy 4.0. If your computer doesn't have Arduino software installed, go to the Arduino download page and download the latest version of the Arduino software (2.0.3 as of this writing). Since version 2.0.0, the Teensy is supported directly in the Arduino software. Follow the instructions here to add the required board support packages to the Arduino IDE. The Teensy bootloader uploads Arduino programs (aka sketches) onto the Teensy. Note you must use a micro USB cable (see image here) to connect the Teensy to your computer before you can upload sketches.

It is advisable to ensure that you can compile and upload the RGB LED example to the Teensy.

  • The RGB LED example can be found in File -> Examples -> 0.1 Basics -> Blink.

  • Follow the instructions here to compile and upload to the Teensy

Note: you will not have a Teensy for pre-lab, but you can download the necessary software, go through the tutorial and try modifying and compiling the code.

If you have not done so yet, complete the Github Desktop Setup in Lab 0 and clone the E80 codebase.

Make sure to change the Arduino IDE Sketchbook location to the folder you just downloaded under File->Preferences. Open E80_Lab_01.ino. This sketch will be used as starter code to send PWM signals to your motors and to log the output on the SD card. Confirm that you can compile and upload the starter code to your Teensy.

The Teensy creates two files to save data every time it runs: an INF file which contains text and a BIN file which contains your measured data in a binary format. Special programs are required to decode the binary data, and those programs also depend on having a matching INF file. We provide a MATLAB script for reading SD card data: logreader.m. These links provide sample INF and sample BIN files. The sample file is very noisy, so it can't be used to find answers to the questions in Section 4.

Finally, find the loop() function in your sketch where you set the values of the PWM signals sent to motors. Modify the sketch to turn each motor on for 2 seconds in the following sequence: No motors on for 2 seconds, vertical motor on for 2 seconds, no motors on for 2 seconds, port motor on for two seconds, no motors on for 2 seconds, starboard motor on for 2 seconds, no motors on. Upload this code to your Teensy. You will test this code in section 4.

4. Motherboard Validation and IMU Calibration and Error Measurement

Your motherboard has a circuit on it called an inertial measurement unit, specifically an LSM303AGRTR , which allows you to measure acceleration and magnetic fields. This is a very useful sensor that we will explore more later in the course. However, you need to understand the output units of the sensor and the error properties of the data it reports to use the accelerometer for this lab. You also need to be sure that your motherboard is working, and testing the accelerometer is a good way to check the motherboard.

Sign out an SD card from an instructor. Put your Teensy and your SD card into your motherboard and program the Teensy with your code from Section 3 if you have not already done so. Provide power to the Teensy using either your battery or the power supply terminals (be careful with the polarity!). Several lights should turn on, including PWR LED, the IMU LED, the SD LED, and a small blinking LED on top of the Teensy. You have the option of plugging in your USB cable so you can use the serial monitor to watch the Teensy's serial output as it runs. Please be very careful when connecting or disconnecting the micro USB cable to the Teensy!! Pull or push laterally while holding down the connector with your other hand. They are fragile and can be pulled off the board easily. You can put your Teensy into programmer mode manually by pressing the button on top of the Teensy. Note that this is not a reset button but only a way to recover from bad code. The easiest way to reset your board is to power cycle it.

Remove power from your board (you do not need to remove the USB cable if it's plugged in). Take out the SD card and put it into your computer. Take the INF and BIN files off of the SD card and read them. Verify that you are saving the following data to your SD card: acceleration values from your accelerometer, magnetic field strengths from your magnetometer, roll, pitch and yaw angles calculated from your IMU measurements, and motor PWM values.

Use the acceleration due to gravity to figure out the size of one 'accelerometer unit' in your saved data: i.e.: if your accelerometer reports a value of 1, how many m/s^2 of acceleration is the accelerometer experiencing? Figure out the value the accelerometer reports when it is experiencing zero acceleration on each axis. Take ten seconds of accelerometer data and determine the mean, the standard deviation, the standard error, and the 95% confidence bounds for a static acceleration measurement in the z direction.

Verify that your motherboard can drive motors by attaching motors to motor ports A, B and C. If your motors are not yet ready, you may measure the voltages at screw terminals A, B and C to observe whether they are being correctly applied by your software.

5. Penetrator and Motor Assembly

In E80 we use special bolts to make waterproof electrical connections across a robot, and we refer to them as penetrators. This is a picture of a penetrator bolt. Notice that it has three sets of twisted pair encased in epoxy in the center. The penetrator bolts are usually used with a nut and rubber washer in order to make a waterproof seal on a project box. This image shows two important details about using penetrator bolts: the threads must point INTO the box and the washer must be OUTSIDE the box.

These penetrators have six wires passing through them because your AUV will use three motors. Look through the stock of motors and select three motors. You may cut them off the used E79 umbilicals if the standalone motor box does not have any useful motors for you. If necessary, you can prep new motors as you did in E79. Instructions can be found here. Test your motors using a power supply to make sure they work:

  • If the current draw during this test is more than 500 mA, then the friction in your motor is likely to severely limit your top speed; consider debugging it.

  • Selecting motors that have similar current draws may simplify your software because the motors will exert similar thrusts at the same level of applied PWM.

  • Make sure your motors still work when they are submerged in water.

Solder the leads of your three motors to the twisted pair on the non-threaded side of your penetrator bolt (because the motors will be OUTSIDE of your box). Waterproof your solder joints with heat shrink tubing (do you need to put the heat shrink over your wires before or after you solder your motor?). Test that all three motors work when the waterproofed solder joints are underwater.

6. AUV Assembly

Find a waterproof box on the central table of the lab. Attach your penetrator and motor assembly to the box (remember threads are in and washer is on the outside). Hold your box and penetrator combination underwater to check for leaks. DON'T perform this test with any electronics or batteries in the box. If you find leaks, fix them before proceeding.

Dry your box and place your battery, motherboard and Teensy into the box. Use Velcro to attach the box to a PVC robot frame. Make sure to select a frame that has a plastic mesh on the bottom for carrying payloads. If you need to add a plastic mesh, use zip ties to secure it to the robot frame.

You will need to add ballast to your robot to keep it close to neutrally buoyant. For now, you will add mass to the INSIDE of your waterproof box, and you must determine how much mass to add. To do this, it helps to know the mass of your robot, and that the robot (including motors and two 1.25'' foam blocks, but not including the watertight box) has a buoyancy force measured to be approximately 10 N.

When selecting weights for ballasting be mindful that their distribution inside of your payload box could affect the resting pitch, yaw or roll of the robot. It may be useful to adjust the resting buoyancy, pitch, yaw, and roll of your robot with the waterproof box before attempting the obstacle course in section 7.

Many of the weights we use are metal, so they can short the back of your motherboard. Make sure the back of your motherboard is covered with insulating foam or electrical tape before setting it on top of your ballast. We also recommend wrapping your ballast in plastic wrap.

7. Open Loop Control Navigation

A simple obstacle course will be set up in the test tank. The course will require your robot to navigate through 3 hoops as pictured here, here , and here.

Modify the Arduino test program from step 3 to direct your robot to fly through the course so that it ends within the red hoop (3). You can assume your AUV can start in the middle of the yellow hoop (1). Since we don't have absolute measurements of the AUV position, no closed-loop control is used here. Instead, write a sequence of motor actions for the AUV to follow. Be sure to test your code with your robot ahead of time, in air, before you visit the test tank room. It is important to know how to control each motor, including which direction each motor turns. Make sure your code accounts for the time you will need to seal up the waterproof box, attach it to the robot frame, and position it in the water. You will only have 5 attempts in the test tank room.

8. Acceleration and Orientation Data

Plot the AUV acceleration data as a function of sample number from the experiment in step 7. On a different figure, plot the AUV orientation data as a function of sample number. Confirm that positive acceleration is in the correct direction. Confirm qualitatively whether the measured acceleration data matches your expectations, and quantitatively compare the non-spurious peaks of your acceleration against an analytical model of the robot. Use the analytical model of the E79 robot as a starting point. The thrust curves linked here may be helpful in your modeling effort.

9. Deliverables

All labs require two submissions per group. The first submission is a submission sheet in which specific data must be shown. The submission sheet is due at the end of the 4-hour lab period and must be uploaded before the end of your lab session at 5:15 pm. Note that only ONE member of each team should access and submit the submission sheet. It is the responsibility of that team member to add the rest of the team's names to the submission sheet.

For pre-lab purposes, a sample submission sheet that contains all of the questions and requirements on the submission sheet is here.

The second submission is a writing assignment, usually around 1 page in length. Each writing assignment will be based on a prompt and must be completed by each student individually; no collaboration is allowed on the text or figures in these assignments, though you may speak among yourselves about concepts in keeping with the collaboration rules of the course. A first draft of the writing assignment must be uploaded by noon on Friday, and you need to bring a printed copy of your draft to the writing and reflection section on Friday at 1:15 pm. During the first hour of the writing and reflection, you will engage in a peer editing exercise. The second hour of the Writing and Reflection section is reserved for you to edit your draft to produce a final draft of the writing assignment. This final draft must be uploaded before the end of the Writing and Reflection section on Friday at 3:15 pm. The prompt and guided peer feedback worksheet for Lab 1 are linked, note that the rubric is included in the prompt.

Recall that no late work is accepted, we will grade whatever is submitted at the deadlines. Since multiple submissions are allowed, you may want to submit a less-than-perfect draft early as insurance against missing the deadline.

After the writing and reflection section at the end of each week every person (not just one person per team) must submit a team dynamics check-in survey. These are part of your participation grade. The survey link can be found on the home page.

IMPORTANT CLEANUP: Please return the battery charger and ballast weights to the center table. These will be shared among the different lab sections. Also, put your board, Teensy, penetrator bolt (with motors), battery and robot frame in your labelled Tupperware container in the cupboard. Please return SD card and SD card reader to the proctor or Lynn.