1D Angular Motion with different velocity stages

Click For Summary

Homework Help Overview

The discussion revolves around a kinematic problem involving 1D angular motion with varying velocity stages. The original poster is tasked with determining the position of a rotational joint over a specified time interval, accounting for acceleration, constant velocity, and deceleration phases.

Discussion Character

  • Exploratory, Assumption checking, Mathematical reasoning

Approaches and Questions Raised

  • The original poster attempts to calculate the joint's position using kinematic equations for three distinct time intervals. They raise questions about the accuracy of their results and the potential for rounding errors in their MATLAB calculations.

Discussion Status

Participants are engaged in clarifying the original poster's approach, particularly regarding the use of velocity and acceleration in their calculations. Some suggest reconsidering the equations used for updating velocity and position, while others question the execution of conditional statements in the MATLAB code.

Contextual Notes

The original poster notes that the calculations are sensitive to the time intervals chosen, with larger intervals yielding smaller errors. There is also a mention of potential confusion regarding the number of iterations executed in the MATLAB code.

Darkbound
Messages
22
Reaction score
0

Homework Statement


I am solving a kinematic problem, where I have a link that is attached to a rotational joint. I need to find the position of the joint for t=0..8, and I need to do it for every 0.01s. The problem comes from the fact that I have three stages for the velocity, during t = 0..0.1 it is accelerating, during t = 0.1..7.7 it maintains a constant velocity, and in t = 7.7..8 it is decelerating until it reaches 0.
I know:
initial θ = 20° = 0.3491 rad
The constant velocity for the second interval which is 0.1666667 rad/s

Homework Equations


1) a = v/t
2) x = x0 + vt + 1/2 * a * t^2
3) v = v0 + a*t
I will use x instead of theta in the equations bellow

The Attempt at a Solution


I used 1) to find the acceleration at the end point of the first time interval and the acceleration at the end point of the 3rd interval.
The way I approached it is, I know that in 0.1 seconds I need to reach the given velocity, so I just divided the velocity by the time
a_t1 = v/t = 1.6666667 rad/s^2
And the same for the deceleration, a_t3 = v/t = 0.55556 rad/s^2
Then I used these three equations to find the final angle:
x1(t) = x0 + v * t1 + 1/2 * a * t1^2 = 0.3491 + 0 * 0.1 + 1/2 * 1.666667 * 0.1^2 = 0.3574 rad
x2(t) = x1 + v * (t2 - t1) + 1/2 * a * (t2 - t1)^2 = 0.3574 + 0.166667 * (7.7 - 0.1) + 1 / 2 *0 * (7.7 - 0.1)^2 = 1.6241 rad
x3(t) = x2 + v * (t3 - t2) + 1/2 * a * (t3 - t2)^2 = 1.6241 + 0.166667 * (8 - 7.7) - 1/2 * 0.55556 * (8 - 7.7)^2 = 1.6491 rad
Or in degrees 94.485 degrees (I am calculating it with matlab, so allow for a tiny rounding error)

My first question is if that number is correct.

My second issue is, as I mentioned in the beginning, I need to be able to do it for a given time delta for the full motion, like every 0.01 second, and I should still arrive at the same number in the end, its after all the same motion just broken down into many tiny motions.
The way I tried to approach this is to again use three equations for the three time periods, but I also recalculated the velocity for every moment, since after the initial t=0 I have initial and final velocities, so the equations I used are:
v1(tnew) = v1(tnew - told) + a * (tnew - told)
x1(tnew) = x1(told) + v1old*(tnew - told) + 1/2 * acc * (tnew - told)^2

x2(tnew) = x2(told) + v2*(tnew - told)

v3(tnew) = v3(tnew - told) - 1/2 * acc * (tnew - told)^2
x3(tnew) = x3(told) + v3old*(tnew - told) - 1/2 * acc * (tnew - told)^2

The angle that I get after these calculations is 1.6474 radians or 94.387 degrees, which is very close to my other calculation. I am doing these calculations with MATLAB, so I don't know if there's simply some rounding error that adds up and causes the answer to be off by a little, theta is being recalculated 800 times, or if there is some issue with my formulas.
If I compare the results for both of my calculations I get:

x1 with t = 0.1 and my x1(tnew) when it reaches t=0.1, they both are the same
x2 with t = 7.7 and x2(tnew) when it reaches t = 7.7, I get 1.62406585... vs 1.62403807... or 93.052111 vs 93.0505273... degrees
x3 with t = 8 and x3(tnew) when it reaches t = 8, 1.6473714... vs 1.6490658... or 94.48451... vs 94.387482...
And most of the calculations happen with x2, so i am suspecting that mostly the error is in my final equation for x3

This is my MATLAB code
w2real = 0.1/6;
theta0 = deg2rad(20); % Initial angle of joint 2
t = [0 0.01:0.01:8]; % Time vector for the full motion
a2acc = w2real / 0.1; % Acceleration of joint 2
a2dec = w2real / 0.3; % Deceleration of joint 2

theta = zeros(size(t));
w2theta = zeros(size(t));
% Populating the first elements of d and theta with the initial conditions
theta(1) = theta0;

% Calculating theta at 3 points - t = 0:0.1, t = 0.1:7.7, t = 7.7:8
ntheta1 = theta0 + a2acc * tacc^2 / 2;
ntheta2 = ntheta1 + w2real * tnorm;
ntheta3 = ntheta2 + w2real * tdec - 1/2 * a2dec * (tdec)^2;

for n = 2:size(t, 2)
m = n - 1;
if (t(n) >= 0 && t(n) <= 0.1)
% acceleration
w2theta(n) = w2theta(n - 1) + a2acc * (t(n) - t(m));
theta(n) = theta(m) + (w2theta(m))*(t(n) - t(m)) + (1 / 2) * a2acc * (t(n) - t(m))^2;
elseif (t(n) > 0.1 && t(n) <= 7.7)
% no acceleration
w2theta(n) = w2real;
theta(n) = theta(m) + w2real * (t(n) - t(m));
elseif (t(n) > 7.7 && t(n) <= t(end))
% deceleration
w2theta(n) = w2theta(m) - a2dec * (t(n) - t(m));
theta(n) = theta(m) + (w2theta(m))*(t(n) - t(m)) - (1 / 2) * a2dec * (t(n) - t(m))^2;
end
end

disp('Ntheta1 vs Discrete theta1')
[ntheta1 theta(11)]
disp('Ntheta2 vs Discrete theta2')
[ntheta2 theta(771)]
disp('Ntheta3 vs Discrete theta3')
[ntheta3 theta(end)]

Is my approach and signs correct and is this simply a rounding error that builds up, or is there something that I am doing wrong?

EDIT: I have tried with different times, 1s acceleration, 5s maintaining, 2s deceleration and the error for the final value was much, much smaller, so I am guessing that the differences that I get are simply due to the rounding that MATLAB does on each of the iterations.
1.432399183732219
vs
1.432399183732199
 
Last edited:
Physics news on Phys.org
Darkbound said:
My first question is if that number is correct.
Looks ok if the two accelerations are constant, but I do not see that given.
Darkbound said:
v1(tnew) = v1(tnew - told) + a * (tnew - told)
This looks weird. Are you confusing factors with subscripts? On the face of it, you are multiplying velocities by times (to produce displacements), then adding acceleration x time (so a velocity). Similarly the next line.
I guess you mean v1new=v1old+ a * (tnew - told). That seems to match the code.
Correcting that:
Darkbound said:
v1new=v1old + a * (tnew - told)
x1new=x1old + v1old*(tnew - told) + 1/2 * acc * (tnew - told)^2
I think you'll find that what this comes down to is calculating the change in displacement as time interval times average speed: (tnew - told)(v1old+v1new)/2.
Darkbound said:
if (t(n) >= 0 && t(n) <= 0.1)
So how many times will it execute this case?
 
  • Like
Likes   Reactions: midoriya
Thanks! And yes, this is what I mean about the velocity.

The first if will execute 11 times, starting from 0 until 0.1 at every 0.01 second, the second interval is 770 times and the final interval is 30 times. When I changed it to 1s, 5s, 2s which is 101, 500, 200 times for the intervals that is when I got the negligible error.

As for the average speed equation, you're saying that I can use it instead of my x(t) equations after I recalculate the velocity? I did not think of that :)
 
Darkbound said:
The first if will execute 11 times, starting from 0 until 0.1
That seems once too often. There should only be 10 intervals, no?
But I am unfamiliar with Matlab, so I am not sure what the initialiser for t[] does.
Darkbound said:
t = [0 0.01:0.01:8]
At a guess, t[0]=0.01, t[10]=0.11.
If so, the 10th iteration has wandered into the constant speed domain.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
Replies
2
Views
2K
Replies
3
Views
2K
Replies
26
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 17 ·
Replies
17
Views
3K
Replies
9
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 3 ·
Replies
3
Views
1K