-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathinitiateSimulation.m
More file actions
29 lines (24 loc) · 859 Bytes
/
initiateSimulation.m
File metadata and controls
29 lines (24 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
% clear all;
close all;
clc;
%%
fs=5000; % sampling frequency
Ts=1/fs; % sampling period
%%
fn = 700; % resonant frequency
wn = fn * 2 * pi;
zn = 0.03; % damping ratio
m = [5,20];
Gp = createPlantModel(m,fn,zn,2); % non-colocated double-mass-block model
s = tf('s');
tau = 1.5*Ts;
delayModel = exp(-tau*s); % time delay model, the 0.5 sampling time delay is used to approxiamte zero order hold effect
% delayModel = pade(delayModel,2);
Gp = Gp * delayModel; % plant model with time delay considered
% w = linspace(100 * 2 * pi,1500 * 2 * pi,2048);
% figure;bodeplot(Gp,w); % plot Bode diagram of plant model
load('180HzPIDWith700HzNotchForTimeDelay.mat'); % load feedback controller, the control bandwidth is 180Hz
% ideal feedforward coefficients
idealAccCoef = sum(m);
idealJerkCoef = sum(m) * tau;
idealSnapCoef = sum(m) * ( 1/wn.^2 + 0.5 * tau.^2);