Skip to content

Commit

Permalink
Merge pull request hasemar#1 from hasemar/stateSpace_ryanEdits
Browse files Browse the repository at this point in the history
MotorConstants and Commenting
  • Loading branch information
hasemar authored Feb 23, 2017
2 parents 370d2d4 + 97182b1 commit 7b25433
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 11 deletions.
63 changes: 63 additions & 0 deletions stateSpaceModel.asv
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
%% State-Space catcher thing
clear; close all

%% define vars
% motor parameters
Kt = 1; % torque constant = 2NBlr
Kv = 1; % back-emf constant (incase have this instead)
L = 1; % H motor inductance
r = 1000; % ohms motor resistance
% physical parameters
m1 = 10; % kg mass of platform
m2 = 3; % kg mass of puck
k = 1000; % N/m mechanical spring element
b1 = 1000; % Ns/m
J = 1; % kgm^2 moment of inertial
b2 = 1000; % Ns/m bearing friction
pRatio
% transformer
TFbelt = 1; % transformer translation to rotation
TFmotor = Kt; % transformer rotation to electrical

% stuff
Vs = 12; % volts voltage supply
TFelement = (b1*TFbelt^2*TFmotor)/(J*TFmotor*m2*TFbelt^2*TFmotor); % calculating elements in A
t = 0:.001:1; % time array

%% define matricies
x0 = [...
0;...
0;...
0;...
0;];
A = [...
-b1/m1, b1/m1, -1/m1,0;...
TFelement, -TFelement, TFelement, TFelement/(TFbelt*TFmotor);...
k, -k,0,0;...
0,0,0,-r/L;];

B = [...
0;...
0;...
0;...
1/L];
C = [1,0,0,0];
D = 0;

%% create state-space
sys = ss(A,B,C,D);
%sys.InputName = 'Vs';
%sys.OutputName = {'Vm1';'Vm2'};
F1 = impulse(sys,t);

%% plot things
figure
plot(t,F1);
title('Impulse Response');
xlabel('time (s)')
ylabel('velocity of m1 (m/s)')

figure(2)
rlocus(sys);


34 changes: 23 additions & 11 deletions stateSpaceModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,30 @@
clear; close all

%% define vars
m1 = 10; % kg mass of platform
m2 = 3; % kg mass of puck
k = 1000; % N/m mechanical spring element
b1 = 1000; % Ns/m
TFbelt = 1; % transformer translation to rotation
TFmotor = 1; % transformer rotation to electrical
J = 1; % kgm^2 moment of inertial
b2 = 1000; % Ns/m bearing friction
L = 1; % H motor inductance
r = 1000; % ohms motor resistance
% motor parameters
Kt = 1; % torque constant = 2NBlr
Kv = 1; % back-emf constant (incase have this instead)
L = 1; % H motor inductance
r = 1000; % ohms motor resistance
% physical parameters
m1 = 10; % kg mass of platform
m2 = 3; % kg mass of puck
k = 1000; % N/m mechanical spring element
b1 = 1000; % Ns/m
J = 1; % kgm^2 moment of inertial
b2 = 1000; % Ns/m bearing friction
p1 = 5; % cm pulley 1
p2 = 5; % cm pulley 2
pRatio = p2/p1;
% transformer
TFbelt = pRatio; % transformer translation to rotation
TFmotor = Kt; % transformer rotation to electrical

% stuff
Vs = 12; % volts voltage supply
TFelement = (b1*TFbelt^2*TFmotor)/(J*TFmotor*m2*TFbelt^2*TFmotor); % calculating elements in A
t = 0:.001:1; % time array

%% define matricies
x0 = [...
0;...
Expand All @@ -35,12 +45,14 @@
1/L];
C = [1,0,0,0];
D = 0;

%% create state-space
sys = ss(A,B,C,D);
%sys.InputName = 'Vs';
%sys.OutputName = {'Vm1';'Vm2'};
F1 = impulse(sys,t);
F1 = impulse(sys,t);

%% plot things
figure
plot(t,F1);
title('Impulse Response');
Expand Down

0 comments on commit 7b25433

Please sign in to comment.