quiz preparation

23
Quiz Preparation Quiz 4 sheet provided. Fill in your Name, etc. Date is 9/11/12 Answer questions during lecture. Section Section Fri. 1:00 12 Lab Day/Time Section Number Mon. 1:00 8 Mon. 3:00 9 Tue. 2:00 36 Wed. 1:00 10 Wed. 3:00 11 Thu. 2:00 35

Upload: kreeli

Post on 14-Feb-2016

17 views

Category:

Documents


0 download

DESCRIPTION

Quiz Preparation. Quiz 4 sheet provided. Fill in your Name, etc. Date is 9/11/12 Answer questions during lecture. Lego Car Project. Wirelessly driven Lego car Left and right channels/motors for steering Goal is to navigate and finish course as quickly as possible - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Quiz Preparation

1

Quiz Preparation

Quiz 4 sheet provided. Fill in your Name, etc. Date is 9/11/12 Answer questions

during lecture.

Lab Day/Time Section Number

Mon. 1:00 8Mon. 3:00 9Wed. 1:00 10Wed. 3:00 11Fri. 1:00 12

Lab Day/Time Section Number

Mon. 1:00 8Mon. 3:00 9Wed. 1:00 10Wed. 3:00 11Thu. 2:00 29Fri. 1:00 12

Lab Day/Time Section Number

Mon. 1:00 8Mon. 3:00 9Tue. 2:00 36Wed. 1:00 10Wed. 3:00 11Thu. 2:00 35Fri. 1:00 12

Page 2: Quiz Preparation

2

Lego Car Project

Wirelessly driven Lego car Left and right channels/motors for steering Goal is to navigate and finish course as

quickly as possible Penalty of 1 second for each 0.5 V over

10V in voltage regulator output

Page 3: Quiz Preparation

3

Lego Car Overview

Receiver

R1, R2

PPM

PWM

PWM

Page 4: Quiz Preparation

START/FINISH

BLOCK

Required Gates

Optional Gates

(+5 sec. penalty if missed)

Push block across finish line or incur a +30 sec.

penalty

Each floor tile is 1 foot × 1 foot square

Page 5: Quiz Preparation

5

Penalties

Penalties are a way to introduce “cost” into the design and cause the team to make tradeoff decisions.» Incurring a penalty should not be considered unethical or “wrong” in any

sense. 5 second penalty for missing an optional gate 30 second penalty if the block is not pushed across the finish line Penalty of 1 second for each 0.5 V over 10V in voltage regulator

output (Vo). Voltages rounded to nearest 0.1 V.» Vo ≤10.0V = no penalty» 10.0V < Vo ≤10.5V = 1 second penalty» 10.5V < Vo ≤11.0V = 2 second penalty» etc.

Page 6: Quiz Preparation

6

Competition Grading

Fastest time = 100 points » Fastest time ever (Spring 11) was 7 sec. =“World Record”

30 seconds = 75 points

Other times linearly interpolated between fastest time and 30 sec.

Maximum time is 60 seconds

Page 7: Quiz Preparation

7

Preliminary Design Report Due week of Lab 10, in lab. Describe design decisions

» Output voltage» Power supply» Wheel size/gears, etc.

Justify your decisions. Explain any disadvantages, and why you’ll

tolerate them. Include supporting drawings, figures, and

tables if needed.

Page 8: Quiz Preparation

8

Lego Car Design Output voltage

» Higher output voltage increases speed» Penalties apply above 10V

Power supply (batteries)» One 9V battery (light, but less than 10V)» Two 9V batteries (≥10V, but heavy)» Watch batteries (very light, but drain quickly)

Wheel size and gears» Torque vs. speed tradeoff

Drive strategy» Front wheel vs. rear wheel drive

Course path» Passing through all gates vs. missing gates» Pushing block vs. not pushing block

Body» Light vs. heavy

Page 9: Quiz Preparation

9

Today’s Topics

Introduction to MATLAB

MATLAB graphics

Image processing

Page 10: Quiz Preparation

10

MATLAB MATLAB® allows us to work with large

amounts of data easily.» The basic data structure in MATLAB is a

vector.» A vector is a convenient way to store a

sequence or array of numbers, such as sensor readings.

We can also manipulate sounds and images from within MATLAB.

Page 11: Quiz Preparation

11

MATLAB Basics

Assign a value to a variable>> a=3

a =

3

>> a=3;>> a

a =

3>>

Semicolon suppresses echo

Typing a variable name displays the value

Be careful!!

Page 12: Quiz Preparation

12

MATLAB Basics Vectors

>> v=[1,3]v = 1 3

>> v=[1;3]v = 1 3

>> v'ans = 1 3

>> v=1:0.5:3v = 1.0000 1.5000 2.0000 2.5000 3.0000

Comma delimits columns

Semicolon delimits rows

Apostrophe means transpose(turn rows into columns andvice versa)

start value : increment : end value

Page 13: Quiz Preparation

13

Sine wave:

is the frequency of the sine wave. Sample the waveform every T seconds.

» Let » We get a sequence » Let n=0,…,N to get sequence corresponding to

a duration of NT seconds.

Generating Sine Waves

tftx 02sin)( 0f

nTt Tnfnx 02sin)(

Page 14: Quiz Preparation

14

MATLAB

>> f0=100;>> T=.0008;>> n=0:62;>> x=sin(2*pi*f0*T*n);>> stem(n,x)

Tnfnx 02sin)(

start value : end value (assumes increment of 1)

10 20 30 40 50 60-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0.04 0.045 0.05-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

stem(n,x) plot(n,x)

Page 15: Quiz Preparation

15

MATLAB vs. C C code to create a sine wave:#include <stdio.h>#include <math.h>

main(argc,argv)int argc;char *argv[];{ int i,n; double *sv, f0;

n=5000; f0=100;

sv = (char *) calloc(n, double);

for (i = 0; i < 50000; i++) { sv(i) = sin(2*3.1415927*f0*I/44100); }}

Page 16: Quiz Preparation

16

Other MATLAB Abilities

Many built-in functions Can easily add your own functions Immediate results without compiling Can solve systems of equations easily All kinds of plotting methods Simulink Maple Symbolic Math Toolbox

Page 17: Quiz Preparation

17

Example – Large Array

M file “multiplies.m” creates a 1000 x 1000 array, and then computes inverse.

Performs order of one billion FLOPS in a few seconds.

Page 18: Quiz Preparation

18

Example – 3D Plots

M-file “surfaces.m” creates a 3D “landscape” using the function

z=cos(.05*x).*sin(.1*y)

This can be rotated in 3D with the mouse.

Page 19: Quiz Preparation

19

Example – Image Processing

Start with photo “office.jpg”

Convert to grayscale image

Detect edges

Page 20: Quiz Preparation

20

Image processing commands

i=imread('office.jpg'); % convert to MATLAB format igray=i(:,:,1); % keep only one color channel bw=edge(igray,'canny'); % perform Canny edge detection

Page 21: Quiz Preparation

21

Playing Sounds in MATLAB

Can play sounds directly from MATLAB:» sound(x,44100)

– x is the sequence of values in a vector– 44100 is the output sampling rate

» soundsc(x,44100)– Same as sound() but auto-levels before playing– Each sound played at the same level

Page 22: Quiz Preparation

22

Playing Sounds in MATLAB

Can read or write WAV files:» y = wavread(‘fast.wav’);

– y is the sound sequence read in as a vector– fast.wav is the name of the file to be read.

» wavwrite(y,44100,’fast.wav’)

Page 23: Quiz Preparation

23

Stereo in MATLAB

If x is an Nx2 vector, the left column will be played as the left channel, and the right column will be played as the right channel.» fl=200;» fr=300;» t=[0:1/44100:8];» xl = sin(2*pi*fl*t);» xr = sin(2*pi*fr*t);

sound([xl’ xr’],44100)