0% found this document useful (0 votes)
5 views

Function

This document defines a function f1 that models the motion of a cart-pendulum system. It specifies parameters like the cart and load masses, cable length, displacement, steady velocity, friction force, and gravity. The function defines state variables for displacement, force, velocity, and acceleration. It calculates the acceleration period and time based on these parameters. Forces acting on the system are defined over the acceleration, constant velocity, and deceleration periods. The solver matrix is formed to calculate the accelerations as a function of time, which are returned.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Function

This document defines a function f1 that models the motion of a cart-pendulum system. It specifies parameters like the cart and load masses, cable length, displacement, steady velocity, friction force, and gravity. The function defines state variables for displacement, force, velocity, and acceleration. It calculates the acceleration period and time based on these parameters. Forces acting on the system are defined over the acceleration, constant velocity, and deceleration periods. The solver matrix is formed to calculate the accelerations as a function of time, which are returned.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

function [y] = f1(t,xx)

% Model Parameters
M = 1000; % Cart Mass [kg]
m = 300; % Load Mass [kg]
r = 2; % Cable Length [m]
s0 = 20; % Displacement [m]
vs = 0.5; % Steady Velocity [m/s]
g = 9.81; % Gravity Acc. [m/s^2]
FC = 80; % Friction Force [N]
% State Parameters
s = xx(1);
F = xx(2);
ds = xx(3);
dF = xx(4);
% Motion Function Constant Acceleration
p = 0.2; % Accel. Period Ratio
te = s0/(vs*(1-p)); % Full Motion Time [s]
ta = p*te; % Acceleration Time [s]
tb = te - ta; % Decceleration Time [s]
A = vs/ta;
if (t <= ta)
FX = A*(M+m) + FC;
elseif (t > ta & t <= tb)
FX = FC;
elseif (t > tb & t < te)
FX = -A*(M+m) + FC;
elseif (t >= te)
FX = 0; FC = 0;
end
% Solver Matrix
A11 = M+m;
A12 = m*r*cos(F);
B1 = m*r*(dF^2)*sin(F)+(FX-FC*sign(ds));
A21 = cos(F);
A22 = r;
B2 = -g*sin(F);
Q = inv([A11,A12;A21,A22])*[B1;B2]; % Accelerations Array
y = [ds;dF;Q(1);Q(2)]; % Return Result
function[y]=ff(t,xx)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%
M=1000;
m=300;%
r=2;
FX=100;
FC=80;
s0=50;
g=9.81;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%
s=xx(1);
F=xx(2);
ds=xx(3);
dF=xx(4);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if(s>=s0)
FC=FX;
FX=0;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A11=(m+M);
A12=m*r*cos(F);
B1=+m*r*(dF^2)*sin(F)+(FX-FC*sign(ds));
A21=cos(F);
A22=(r^2);
B2=-g*sin(F);
Q=inv([A11,A12;A21,A22])*[B1;B2];
y=[ds;dF;;Q(1);Q(2)];
close all
clear;
clc;
t0 = 0;
tf = 60;
n = 2000;
h = (tf-t0)/n;
%xot= [s; f; ds; df]
xot = [0; 0; 0 ; 0 ];
i = 0;
for t = t0 : h : tf
i = i + 1;
tt(i) = t;
xx(:,i) = xot;
k1 = h*f1(t,xot);
k2 = h*f1(t+(h/2),xot+(k1/2));
k3 = h*f1(t+(h/2),xot+(k2/2));
k4 = h*f1(t+h,xot+k3);
del = (1/6)*(k1+2*k2+2*k3+k4);
xot = xot + del;
end
s(1,:) = xx(1,:);
ds(1,:) = xx(3,:);
FF(1,:) = xx(2,:) * 180/pi;
dFF(1,:)= xx(4,:) * 180/pi;
figure(1)
subplot(2,2,1)
plot(tt,xx(1,:),'LineWidth',1)
xlabel('Time t[s]')
ylabel('Linear Displacement X[m]');
grid;
subplot(2,2,3)
plot(tt,xx(3,:),'LineWidth',1)
xlabel('Time t[s]')
ylabel('Linear Velocity V[m/s]');
grid;
subplot(2,2,2)
plot(tt,FF(1,:),'LineWidth',1)
xlabel('Time t[s]')
ylabel('Angular Displacement [deg]');
grid;
subplot(2,2,4)
plot(tt,dFF(1,:),'LineWidth',1)
xlabel('Time t[s]')
ylabel('Angular Velocity [deg/s]');
grid;
x = xx';

You might also like