- #1
PhysicsLearner2000
- 1
- 0
- Homework Statement
- I need help in MATLAB simulink tool. How do I use Simulink to create a control system to express a 2nd order differential equation?
- Relevant Equations
- D(theta) theta'' + C(theta,theta')theta' + G(theta) + F(theta') = Torque
Equation:
, where matrix D, C, G and F can be represented by
I'm supposed to design a control system that looks like this:
I am given that the dynamic model = fcn(D,C,G,dq) where the dq is the same as 𝑞̇ and d2q in the diagram is the same 𝑞̈. The default initial value of [𝑞(0), 𝑞̇(0)] is [0, 0].
My code is here:
function torque = fcn(D,C,G,theta,omega)
% length of the 2 robotic arms
l1 = 1;
l2=1;
r1=l1/2;
r2=l2/2;
% mass of the 2 robotic arms
m1= 5;
m2=5;
% moment of inertia of the 2 robotic arms
I1= (m1*l1^2)/3;
I2 = (m2*l2^2)/3;
p1= m1*r1^2+m2*l1^2+I1;
p2= m2*r2^2+ I2;
p3= m2*l1*r2;
p4= m1*r1+m2*l1;
p5= m2*r2;
% gravitational field strength
g = 9.81
D(theta) = [p1+p2+2*p3*cos(theta(2)) p2+p3*cos(theta(2)); p2+p3*cos(theta(2)) p2];
C(theta, omega) = [-p3*omega(2)*sin(theta(2)) -p3*(omega(1)+omega(2))*sin(theta(2)); p3*omega(1)*sin(theta(2)) 0];
G(theta) = [p4*g*theta((1))+ p5*g*cos(theta(1)+theta(2)); p5*g*cos(theta(1)+theta(2))];
F(omega) = 0
dthetadt = omega;
domegadt = D(theta)\(tau-F(omega)-G(theta)-C(theta,omega)*omega);
% Define Conditions
theta(1) = linspace(0, pi/2,10);
theta(2) = linspace(0,pi/2,10);
Is my code correct? And how to create a control system to represent the 2nd ode equation. Can someone help me? I'm pretty new to SimuLink and Matlab
I need help with SimuLink. It is not working. I need help
, where matrix D, C, G and F can be represented by
I'm supposed to design a control system that looks like this:
I am given that the dynamic model = fcn(D,C,G,dq) where the dq is the same as 𝑞̇ and d2q in the diagram is the same 𝑞̈. The default initial value of [𝑞(0), 𝑞̇(0)] is [0, 0].
My code is here:
function torque = fcn(D,C,G,theta,omega)
% length of the 2 robotic arms
l1 = 1;
l2=1;
r1=l1/2;
r2=l2/2;
% mass of the 2 robotic arms
m1= 5;
m2=5;
% moment of inertia of the 2 robotic arms
I1= (m1*l1^2)/3;
I2 = (m2*l2^2)/3;
p1= m1*r1^2+m2*l1^2+I1;
p2= m2*r2^2+ I2;
p3= m2*l1*r2;
p4= m1*r1+m2*l1;
p5= m2*r2;
% gravitational field strength
g = 9.81
D(theta) = [p1+p2+2*p3*cos(theta(2)) p2+p3*cos(theta(2)); p2+p3*cos(theta(2)) p2];
C(theta, omega) = [-p3*omega(2)*sin(theta(2)) -p3*(omega(1)+omega(2))*sin(theta(2)); p3*omega(1)*sin(theta(2)) 0];
G(theta) = [p4*g*theta((1))+ p5*g*cos(theta(1)+theta(2)); p5*g*cos(theta(1)+theta(2))];
F(omega) = 0
dthetadt = omega;
domegadt = D(theta)\(tau-F(omega)-G(theta)-C(theta,omega)*omega);
% Define Conditions
theta(1) = linspace(0, pi/2,10);
theta(2) = linspace(0,pi/2,10);
Is my code correct? And how to create a control system to represent the 2nd ode equation. Can someone help me? I'm pretty new to SimuLink and Matlab
I need help with SimuLink. It is not working. I need help