MATLAB Project - Elbow

Site: learnonline
Course: MATLAB
Book: MATLAB Project - Elbow
Printed by: Guest user
Date: Wednesday, 3 July 2024, 3:55 PM

Description

MATLAB Project - Elbow

An “elbow” mechanism

In this project you will use MATLAB to investigate the movement of an “elbow” mechanism. The project combines trigonometry, calculus, MATLAB coding, and an engineering mechanism.

The project is to be done by teams of students – you will be automatically assigned to a team.

The Problem

Consider the following mechanism, consisting of a crank AP and a lever PB loosely hinged at the “elbow” P so that it can bend only to the right. The end A is hinged to a fixed point 8 cm above an origin O. The crank AP has length 5 cm, and the lever PB has length 12 cm. The end B is able to slide back and forth along the x-axis in a harmonic fashion with amplitude 15 cm and period 2 sec, such that

x \left(t\right)=15 \cos \pi t,  t ≥ 0.

At any given instant t ≥ 0, let θ(t) (“theta”) denote the angle of rotation of the crank AP, measured in a clockwise direction from the upper vertical.

Let φ(t) (“phi”) be the angle at the elbow P, as shown.

project image

Project tasks

There are 5 project tasks to be completed as part of this project.

You will be working collaboratively to solve these and will be working in a wiki (and forum) to complete your report.

 

1. Function M-files

(a) Construct a MATLAB function M-file called theta.m, that takes as input the time t≥) (possibly an array of time values), and gives as output the corresponding value(s) of θ(t). your M-file will be of the following form:

% Your names, project name, date

function y=theta(t)

% A function to output the angle theta at any input time t.

% Should allow for the possibility that the input is an array

x = 15*cos(pi*t);

% alpha is angle OAB

alpha = atan(x/8);

% beta is angle BAP

beta =

y= pi - (alpha + beta);

Fill in the blank to complete this function M-file correctly.

(b) Create a similar function M-file called phi.m, that calculates the angle φ(t) given t.

(c) Your project report must include

  • your derivation of the missing formula for the angle beta, and
  • your derivaion of a formula for φ(t).

2. Script M-file

Run a script M-File to see an animated simulation of the movement of the elbow mechanism. Put the following commands into a MATLAB script M-File named simulate.m, and then run it. You will need to have your theta.m function M-File in the same directory. Watch carefully the behaviour of the angles θ(t) and φ(t) during these two cycles.

% This program simulates the mechanical ``elbow'' system

figure(1)

THETA = linspace(0,2*pi,51); % for plotting circle

for t = 0:0.02:4

x = 15*cos(pi*t);

simulate_theta = theta(t);

% find coordinates of P

Xp = 5*sin(simulate_theta); Yp = 8 + 5*cos(simulate_theta);

axis([-15 15 0 25]), axis('equal'), axis manual

hold on

plot([0 Xp],[8 Yp],'r')

plot([Xp x],[Yp 0],'b')

plot(5*cos(THETA),8 + 5*sin(THETA),'k:') % ...(*)

plot([0 0],[0 15],'k:')

text(-8.5,20,'Simulation over two cycles','fontsize',14)

hold off

if t==0

pause(2)

elseif t==4

pause(2)

else

pause(0.1)

end

clf

end

close

3. Explain

Explain some commands used in the M-File simulate.m in Q2.

(a) Explain precisely what the two arrays in the thirteenth line of simulate.m, marked with a (*), represent. What does the command in that line produce?

(b) Does the command for t = 0:0.02:4 produce an array? Explain why or why not.

(c) Why is the command clf included? What would happen if it was omitted?

4. Hand calculations

Calculations by hand (not by MATLAB) of special values of the angles θ and φ, and when these values occur. By closely watching the simulation, you will see that the maximum value of φ(t) is ¼ Π, and that this value occurs when t = 0, 1, 2, 3, 4, . . . sec.

(a) Draw a sketch of the layout when φ(t) is a minimum. Demonstrate that the minimum value of φ(t) is arccos(7/8) ≈ 0:5054, and give the first time that it occurs.

(b) With the aid of diagrams, explain why the minimum value of θ(t) is arcsin 0:6 ≈ 0:6435 and the maximum value is Π + arctan(15/8) ≈ 4:2224. What are the first times that these values occur?

(c) What is the first time the elbow forms a right-angle, meaning φ = Π/2? What is the second time that P lies directly below A, meaning µ = Π? Give your answers in seconds, to four decimal places.

5. MATLAB calculations

MATLAB calculations involving the angles θ(t) and φ(t), the angular velocities θ'(t) and φ'(t), and the midpoint C of PB. Write one long script M-File named mech.m which does all the following tasks.

(a) Use fplot to graph the angles θ(t) and φ(t), on the same axes over two cycles. You must include a legend, labels on the axes and a title.

(b) Use diff in the symbolic toolbox to find the angular velocity θ'(t) of the lever AP (in rad/sec), and then uses ezplot to graph the angular velocity over two cycles. In the main part of your report, write a sizeable paragraph to explain fully the information derived from this graph.

(c) Use fminbnd to determine the minimum value of θ'(t) and the first time it occurs, and then calculates the total distance (in cm) travelled by P in a single cycle.

(d) Use fminbnd to determine the maximum value of the angular velocity of the lever AP and the first time it occurs.

(e) Use fzero to verify the first time when the angle φ is a right angle and the second time the angle θ=π, and then finds the first two times when the angle θ is 60 degrees.

(f) Plot the path travelled by C, the midpoint of the lever PB, during one complete cycle.

You must also include the dotted circle and line shown in the simulation so that the path of C can be seen in context. (Use the same type of plotting commands as in Q2. Do not plot the path point by point in a loop.)

Group spaces

A forum and a wiki exist for your group to work in to complete the project. These spaces are private to you and your group members. The spaces will be ready for your groups to use about a week after you commence your studies.

You will also be able to hold 1 or more real time meetings with your group members using a virtual classroom environment.

The Groups are:

Red Blue Green Yellow
name name name name
name name name name
name name name name

 

Group Forum

Forum

also embedded below.

 

 

Group wiki

Group wiki

 

Assessment Questions?

The project counts for 10% of your grade. The marking will take into account

  • your documentation of the analysis of the problem,
  • your MATLAB programs,
  • your MATLAB output,
  • the correctness of your solutions, and
  • the presentation of the whole report.

If you have any questions about how you will be assessed, please raise them in this MATLAB Project forum, also embedded below.

 

Submission

Your work is to be presented in a group wiki - so instead of submitting, your wiki editing rights will cease to allow your work to be marked.

Wikis are the only way that you can collaboratively generate a product when working at a distance in groups. You are able to add images and other media to the wiki by first giving it a url. An easy way to do this is to make a post to your group forum and add the files as attachments to the forum. You then right click on image to obtain the url, then add to wiki.

The basic layout of the wiki should be

  1. an opening page with the names of the group members and a table of contents,
  2. a full description of the main findings of the project, including the derivations and calculations in Q1 and Q4, explanations in Q3, discussion of the angular velocity of the lever AP, and a neat summary of all of the numerical values determined by Matlab in Q5, with appropriate comments on their significance,
  3. a printout of your properly documented M-Files theta.m, phi.m, mech.m and any other M-Files you have written for the project,
  4. all three required plots, properly labelled, and
  5. a presentable printout of all the answers (the output) found by MATLAB in mech.m.