HW4

Homework 4: Build and Validate

Due at beginning of lecture on Thursday Feb. 8. Each pair should turn in one assignment.

Build Instructions:

a) Build hardware: Build complete structure for optimization Challenge. Pick some reasonable gear ratio and mass as a starting point. We suggest using your preliminary optimization results. Note that each pair should need four ball bearings and two bushings maximum.

• Make sure you carefully assemble the hardware to minimize friction.

• See this document for tips: Friction Minimization

HARDWARE: IF YOU HAVE MORE THAN THE PARTS LISTED, PLEASE RETURN THEM TO EBU II 311

• 5 hubs (used to attach fishing line pulleys and geared pulleys)

• 3 shafts

• 6 shaft collars (used to keep shafts from sliding)

• 2 aluminum pulleys

• 4 acrylic pulleys (when you swap one out, please return it to the stacks in EBU II 312)

• 4 ball bearings (if you have three shafts, use 4 ball bearings and 2 bronze bushings)

b) Attach unpowered 2nd motor & encoder to 3rd shaft. We will use this encoder to measure the output shaft.

Connect encoder but not motor power

• Green: ground

• Blue: +5v

• Yellow: pin 18

• White: pin 19

c) Conduct tests to characterize friction.

• Use the code above to help you characterize friction. (hint: look at the steady state velocity value)

• You will need experimental friction values for the homework.

• Again, we suggest using MotorEnc.ino to measure friction.

• Use this results for your theoretical optimization below.

Homework Assignment:

You are only asked submit three plots, a brief summary, and documented Matlab code. If you are ambitious, feel free to do more characterization and optimization.

1) Optimization: Modify HW3 optimization code for up and down motion and experimental friction. Plot the optimization curve using mesh() and submit your documented Matlab code.

• Use experimental friction values

• You may choose to use a counterweight or not, but simulate what you plan to use in your hardware.

• If you are struggling with the mesh plot, consider simulating ratios 1:2 to 1:20 and masses between 10g and 500g

• Example:

2) Validation: Pick the best gear ratio your theory predicts and lift a mass from your optimization. Run the optimization challenge going up and then down (there can be a pause and new data file between up and down). Plot as shown below, and use separate plots for up and down.

1. Plot the experimental and simulated angle of the 3rd shaft on the same plot (~2 seconds).

2. Plot the experimental and simulated velocity of the 3rd shaft on the same plot (~2 seconds).

3. Briefly describe the reasons for the differences between simulation and experimental results (half page).

4. Write the value of the friction you determined from your friction characterization.

5. Write the value you get for your optimization function (including time for both up and down).

Notes:

• Please use MotorEnc.ino code and change the encoder pins to 18 and 19 so it reads the 3rd shaft (this provides more accurate measurement).

• Example:

Bonus Code: (these codes are not polished, so use at your own risk)

MotorEncFiltered: Outputs filtered velocity data in rad/s

OptCodePlot: Runs the full optimization challenge. Stops when masses reach .75m

Make sure you hook up both encoders

Update your mass to get an accurate optimization score

Outputs two matrices: dataUp = [time (ms), motor counts, output counts] and dataDown = [...]

NOTE: you will probably need to switch the sign of theta. I suggest just correcting it in matlab rather than in the arduino.

At the end it prints out:

%Lift Time: 1547.00

%Drop Time: 1476.00

%Total Time (s): 3.023

%Total Theta of motor (rad): 838.94

%Energy: 20.171

%Score: 0.00131