8
MAE 143c Fall 2012 Assignment 2 The purpose of this assignment is to get you started on assembling MyMip and to get you comfortable using the electronics. As you go through each step it is important to read every substep before you proceed. The reason for this step by step procedure is not just so that you can assemble MyMIP but also to help you understand how everything comes together. This understanding will help you when you run into problems as you will have the require knowledge to debug them. It is recommended that you go through each step carefully making sure that you understand what you are doing and that you also double check all your work. Part a) The first part of the assignment is to go through and read everything that is attached below. When you reach the Putting MyMIP Together section you are expected to follow the steps and begin assembling MyMIP as instructed. Note that you will not be completely assembling MyMIP in this assignment so DO NOT do more than instructed. Part b) Once you have your protoboard with the sensors wired up to the arduino you will be using the raw accelerometer data to measure the orientation (theta) of the board relative to the vertical as depicted in the figure below. Along with this assignment you should have received an accelerometer test code. Step 8 had/will have you upload this test code to the Arduino Nano. Open up the serial monitor in the IDE to view all the data coming from the arduino. The second and third to last columns are of the x and z axis outputs, respectively, from the accelerometer converted to units of g. The assignment for this part is to use these two values along with the atan2() function to calculate the values of theta. I am defining theta as the angle of the arm of your segway-like robot from the vertical as depicted in the figure above. You will need to set up the orientation of the accelerometers x and z output so that theta = 0 is the vertical. Note that this will require you to add some negative signs in the code to account for the orientation of the x output and z output and to correctly use the atan2() function. This does NOT mean unplug the

MAE 143c Fall 2012 Assignment 2 - University of California ...renaissance.ucsd.edu/courses/mae143c/mae143c_hw3_rev1.pdf · MAE 143c Fall 2012 Assignment 2 The purpose of this assignment

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: MAE 143c Fall 2012 Assignment 2 - University of California ...renaissance.ucsd.edu/courses/mae143c/mae143c_hw3_rev1.pdf · MAE 143c Fall 2012 Assignment 2 The purpose of this assignment

MAE 143c Fall 2012 Assignment 2

The purpose of this assignment is to get you started on assembling MyMip and to get you comfortable using the electronics. As you go through each step it is important to read every substep before you proceed. The reason for this step by step procedure is not just so that you can assemble MyMIP but also to help you understand how everything comes together. This understanding will help you when you run into problems as you will have the require knowledge to debug them. It is recommended that you go through each step carefully making sure that you understand what you are doing and that you also double check all your work. Part a) The first part of the assignment is to go through and read everything that is attached below. When you reach the Putting MyMIP Together section you are expected to follow the steps and begin assembling MyMIP as instructed. Note that you will not be completely assembling MyMIP in this assignment so DO NOT do more than instructed. Part b) Once you have your protoboard with the sensors wired up to the arduino you will be using the raw accelerometer data to measure the orientation (theta) of the board relative to the vertical as depicted in the figure below.

Along with this assignment you should have received an accelerometer test code. Step 8 had/will have you upload this test code to the Arduino Nano. Open up the serial monitor in the IDE to view all the data coming from the arduino. The second and third to last columns are of the x and z axis outputs, respectively, from the accelerometer converted to units of g. The assignment for this part is to use these two values along with the atan2() function to calculate the values of theta. I am defining theta as the angle of the arm of your segway-like robot from the vertical as depicted in the figure above. You will need to set up the orientation of the accelerometers x and z output so that theta = 0 is the vertical. Note that this will require you to add some negative signs in the code to account for the orientation of the x output and z output and to correctly use the atan2() function. This does NOT mean unplug the

Page 2: MAE 143c Fall 2012 Assignment 2 - University of California ...renaissance.ucsd.edu/courses/mae143c/mae143c_hw3_rev1.pdf · MAE 143c Fall 2012 Assignment 2 The purpose of this assignment

accelerometer and turn it upside down so that the orientation matches that which is depicted in the figure. As proof that you've completed the assignment successfully I would like to see two plots created from the data that you got from a simple test that you will run. The test that you will run is:

1. Lay your assembled protoboard on the table. 2. Hookup your arduino and open up the serial monitor. 3. Now grab the end that is farthest away from the accelerometer and rotate it up to the vertical

and then continue rotating it till it is laying on its face. See figure below for clarification. Do this 3 to 4 times.

4. As soon as you are done with the test, unplug the arduino from the computer. DO NOT CLOSE THE SERIAL MONITOR!

5. Now use the data from the serial motor to make the following plots that you will turn in. Note the simplest way to plot the values is to copy and paste all the data from the serial monitor into excel and make the plots there.

a. The first plot will be of the x and z outputs in units of g depicting the test you just did b. The second plot will be of the theta values you got during this test in units of degrees. c. Below is an example of what I expect.

Page 3: MAE 143c Fall 2012 Assignment 2 - University of California ...renaissance.ucsd.edu/courses/mae143c/mae143c_hw3_rev1.pdf · MAE 143c Fall 2012 Assignment 2 The purpose of this assignment

Summary of the assignment

Complete part a) of assignment o Read all attached information o Go through and complete all the listed steps in the sections below

Complete Part b) of assignment o Using the provided electronics get raw data from the accelerometer and convert it to

units of g (done for you in test code). o Set up the orientation of the accelerometers so that theta = 0 is the vertical. Note that

this will require you to account for the orientation of the x output and z output and to correctly use the atan2() function. This does NOT mean unplug the accelerometer and turn it upside down.

What to turn in?! o You are required to turn in only two plots. o The first plot will be of the x and z outputs in units of g depicting the test you do in part

b). o The second plot will be of the theta values you got during the part b) test in units of

degrees. o Do not turn any more information in like the raw data. I only expect two plots which

should amount to only 1 page. Anything more and I will take points off.

-0.5

0

0.5

1

1.5

2

1

11

21

31

41

51

61

71

81

91

10

1

11

1

12

1

13

1

14

1

15

1

16

1

17

1

18

1

19

1

20

1

21

1

22

1

23

1

24

1

25

1

g

Data Points

Converted X and Y signal from Acclerometer

X

Z

-50

0

50

100

150

1

11

21

31

41

51

61

71

81

91

10

1

11

1

12

1

13

1

14

1

15

1

16

1

17

1

18

1

19

1

20

1

21

1

22

1

23

1

24

1

25

1

Theta (degrees)

Data Points

Orientation Relative to Vertical

Page 4: MAE 143c Fall 2012 Assignment 2 - University of California ...renaissance.ucsd.edu/courses/mae143c/mae143c_hw3_rev1.pdf · MAE 143c Fall 2012 Assignment 2 The purpose of this assignment

Inventory of Materials Provided in MyMIP Kit:

Take stock of your kit, make sure you have the following items in the large zip-lock bag: USB mini cable, Qty: 1 Jumper wire kit, Qty: 1 Solderless Breadboard, Qty: 1 Wheel, Qty: 2 Wire bag

o 12” M/M jumper cables, Qty: 2 diff colors o 12” M/F jumper cables, Qty: 4, 2 each of 2 diff colors, diff than 6” M/F o 6” M/M jumper cables, Qty: 2 diff colors o 6” M/F jumper cables, Qty: 4, 2 each of 2 diff colors o 9V Battery connector with leads, Qty: 1 o 9V alkaline battery, Qty: 1

Electronics Bag o Arduino nano, Qty: 1 o Accelerometer, Qty: 1 o Gyroscope, Qty: 1 o Motor Driver, Qty: 1 o Switch, Qty: 2 o Motor, Qty: 2

Mechanical Bag o Ski, 1/8” delrin Qty: 2 o Riser, 1/8” delrin, Qty: 1 o Motor Housing, 3D printed, Qty: 1 o 4-40 hex nut, Qty: 4 o 4-40 x 3/8” philips machine screw, Qty: 4 o Adhesive-backed Velcro, Qty: 7”

Encoder Bag o Encoder Insert, 1/8” delrin, Qty: 2 o Encoder disc, 3D printed, Qty: 2 o Male Header pins, Qty: 8 (as one strip) o Double-sided header pins, Qty: 2 (as one strip) o 100 Ohm 1/4W resistor (Brown/Black/Brown/Gold), Qty: 2 o 10k Ohm 1/8 W resistor (Brown/Black/Orange/Gold), Qty: 4 o IR Detector, Qty: 4 o Encoder PCB, Qty: 2 (with IC pre-soldered on)

Tools and Materials Needed: MyMIP Kit purchased from Nick

Wire Strippers

o Can use scissors if you don't have access to wire strippers. Note, that I assembled my

MyMIP using scissors to strip wires so it can be done and it isn't difficult.

Solder Iron

o Temperature controlled best

o Non-temperature controlled one should be around 25 to 30 Watt.

Page 5: MAE 143c Fall 2012 Assignment 2 - University of California ...renaissance.ucsd.edu/courses/mae143c/mae143c_hw3_rev1.pdf · MAE 143c Fall 2012 Assignment 2 The purpose of this assignment

o A cheap option: http://www.radioshack.com/product/index.jsp?productId=2062758#

Note that the store has limited stock but that you can purchase it online and

have it shipped to a nearby store for free. Do it early!

Solder

o Lead Free Rosin Core Solder

o 0.03in diameter (standard) - Can get thinner solder though

Software to install: The Arduino IDE is required to be able to program and use the Arduino Nano. The information

on how to download and install the Arduino software can be found at http://arduino.cc/ under the

Getting Started tab. Please go through the getting started instruction under that tab to install the IDE,

set up your Arduino and run the blink example as shown to make sure that your Arduino has

successfully installed and is working.

Putting Together My MIP (Read all instructions for the numbered step you are on before actually doing anything)

1. Find the Arduino Nano and place it onto the protoboard in the specified location

a. Arduino Nano should be plugged into H36 to H50 and D36 to D50. Refer to figure in

step5 to see location of Arduino on protoboard if you are not sure what I mean by the

protoboard location numbers.

2. Connect the Arduino Nano to the computer

a. Connect the Arduino Nano using the provided usb mini cable

b. When connected to the computer you should see a blue light come on and stay on

indicating that your Arduino is receiving power.

c. Run one of the Arduino examples to make sure that your Arduino is connected and

working correctly.

d. Note that before you freak out about your Arduino not working make sure to check that

you have the IDE connected to the correct board and Com port. To do this go to Tools >

board and select Arduino Nano w/ ATmega328 . Then go to Tools > Serial Port and select

the Com port that your Arduino is connected to.

3. Once you have tested your Arduino and verified that it is working, disconnect it from the

computer. It should be powered off now.

4. Now lets solder the following electronic pieces

a. You will need to either borrow or purchase a soldering iron tool for this part and some

solder.

b. Electronic pieces to be soldered

i. One Gyro

ii. One Accelerometer

iii. One Motor Driver

Page 6: MAE 143c Fall 2012 Assignment 2 - University of California ...renaissance.ucsd.edu/courses/mae143c/mae143c_hw3_rev1.pdf · MAE 143c Fall 2012 Assignment 2 The purpose of this assignment

c. How to solder header pins was shown in class. There are many sources on the web that

show the basics to soldering.

d. Solder the header pins onto the electronics exactly as seen in the figure below. The pins

should be solder on so that when you place the accelerometer and gyro onto the

protoboard the writing should be facing up. When you place the motor driver into the

protoboard the writing should be facing down (you won't be able to see it).

Notice the red circles in the figure above. I did not solder pins there for a reason. You

should not either. We will not be using those pins. You may dispose of the extra header

pin if you have one. If you already solder a pin on that it is very easy to remove. Just heat

up the solder again and pull the pin out with tweezers (the pin will be hot).

5. Place the accelerometer, gyro and motor driver onto protoboard in specified locations.

a. Accel located at G3 to G11

b. Gyro located at G12 to G21

c. Motor Driver at G24 to G31 and D24 to D31

d. Your protoboard should look exactly like the figure below in terms of where the

electronics are located but without the wires yet.

Page 7: MAE 143c Fall 2012 Assignment 2 - University of California ...renaissance.ucsd.edu/courses/mae143c/mae143c_hw3_rev1.pdf · MAE 143c Fall 2012 Assignment 2 The purpose of this assignment

6. Wire the +5volt power and ground to the Accelerometer, gyro and motor driver from Arduino

Nano

a. The arduino nano has a +5volt power regulator and a gnd that can supply power .

b. Make sure to double check and triple check all power connections! If you fry your

electronics then you have to pay for replacements.

i. Hooking up power in reverse will fry everything. None of the electronics have

reverse voltage protection. To clarify, if you hook up +5volt power to Gnd

and/or Gnd to +5volts you will fry your electronics when you turn on power.

ii. Note that plugging in the Arduino to the computer will power the +5volt power

supply on the Arduino.

iii. Make sure you have not short circuited any wires as this will fry your electronics

7. Wire sensor to Arduino

a. We will be wiring the gyro and accelerometer up to analog inputs on the arduino as the

sensors are analog sensors

b. Gyro

i. You will be wiring the X output of the gyro to pin A7 on the arduino

ii. To wire up the gyro connect J15 to J40 using a long green wire. Note that you

will be required to shorten the wire so that the wiring is neat.

c. Accelerometer

i. You will be wiring the Z output and the X output of the accelerometer to pins A6

and A5, respectively, on the arduino.

ii. Using the green wires, connect J8 to J41 and J6 to J42. Shorten the wires as

neccasary.

d. Tom likes and expects a neat wiring job with all the MyMIPs. Spending the time now to

make sure your wires are neat will save you a lot of time later when you are trying to

debug. I have spent a lot of time attempting to make the wires as neat and as easy to

follow as possible.

Page 8: MAE 143c Fall 2012 Assignment 2 - University of California ...renaissance.ucsd.edu/courses/mae143c/mae143c_hw3_rev1.pdf · MAE 143c Fall 2012 Assignment 2 The purpose of this assignment

e. When both sensors are wired up your protoboard should look like the following figure

below.

8. Now lets test the accelerometer to make sure that it is working correctly.

a. I will be providing an accelerometer test code with the code commented.

b. Go through the code to understand what I am doing.

c. You will have to upload this code to your Arduino using the Arduino IDE software that

you installed in the Software to Install section of this document.

d. Now open up the Serial Monitor either by using the shortcut in the top right hand

corner of the IDE or by going to tools and selecting the Serial Monitor.