nass-simscape/demonstration/displacement_init.m

99 lines
4.7 KiB
Mathematica
Raw Normal View History

%%
clear; close all; clc;
%% Initialize simulation configuration
opts_sim = struct(...
'Tsim', 30 ...
);
initializeSimConf(opts_sim);
%% Initialize Inputs
load('./mat/sim_conf.mat', 'sim_conf')
time_vector = 0:sim_conf.Ts:sim_conf.Tsim;
% Translation Stage
T_ty = 4;
ty = zeros(length(time_vector), 1);
ty(1:T_ty/sim_conf.Ts) = 10e-3*sin(2*pi*(1/2)*time_vector(1:T_ty/sim_conf.Ts));
% Tilt Stage
T_ry = 4;
ry = zeros(length(time_vector), 1);
ry((T_ty)/sim_conf.Ts:(T_ty+T_ry)/sim_conf.Ts) = 2*pi*(3/360)*sin(2*pi*(1/2)*time_vector(T_ty/sim_conf.Ts:(T_ty+T_ry)/sim_conf.Ts));
% Spindle
T_rz = 4;
rz = zeros(length(time_vector), 1);
rz((T_ty+T_ry)/sim_conf.Ts:(T_ty+T_ry+T_rz)/sim_conf.Ts) = 2*pi*0.5*(time_vector((T_ty+T_ry)/sim_conf.Ts:(T_ty+T_ry+T_rz)/sim_conf.Ts)-time_vector((T_ty+T_ry)/sim_conf.Ts));
rz((T_ty+T_ry+T_rz)/sim_conf.Ts:end) = rz((T_ty+T_ry+T_rz)/sim_conf.Ts);
% Micro Hexapod
T_u_hexa = 10;
u_hexa = zeros(length(time_vector), 6);
% Tz
u_hexa((T_ty+T_ry+T_rz)/sim_conf.Ts:(T_ty+T_ry+T_rz+2)/sim_conf.Ts, 3) = 10e-3*sin(2*pi*(1/2)*(time_vector((T_ty+T_ry+T_rz)/sim_conf.Ts:(T_ty+T_ry+T_rz+2)/sim_conf.Ts)));
% Tx-Ty
u_hexa((T_ty+T_ry+T_rz+2)/sim_conf.Ts:(T_ty+T_ry+T_rz+3)/sim_conf.Ts, 1) = 10e-3*(time_vector((T_ty+T_ry+T_rz+2)/sim_conf.Ts:(T_ty+T_ry+T_rz+3)/sim_conf.Ts)-time_vector((T_ty+T_ry+T_rz+2)/sim_conf.Ts));
u_hexa((T_ty+T_ry+T_rz+3)/sim_conf.Ts:(T_ty+T_ry+T_rz+5)/sim_conf.Ts, 1) = 10e-3*cos(2*pi*(1/2)*(time_vector((T_ty+T_ry+T_rz+3)/sim_conf.Ts:(T_ty+T_ry+T_rz+5)/sim_conf.Ts)-time_vector((T_ty+T_ry+T_rz+3)/sim_conf.Ts)));
u_hexa((T_ty+T_ry+T_rz+3)/sim_conf.Ts:(T_ty+T_ry+T_rz+5)/sim_conf.Ts, 2) = 10e-3*sin(2*pi*(1/2)*(time_vector((T_ty+T_ry+T_rz+3)/sim_conf.Ts:(T_ty+T_ry+T_rz+5)/sim_conf.Ts)-time_vector((T_ty+T_ry+T_rz+3)/sim_conf.Ts)));
u_hexa((T_ty+T_ry+T_rz+5)/sim_conf.Ts:(T_ty+T_ry+T_rz+6)/sim_conf.Ts, 1) = 10e-3 - 10e-3*(time_vector((T_ty+T_ry+T_rz+5)/sim_conf.Ts:(T_ty+T_ry+T_rz+6)/sim_conf.Ts)-time_vector((T_ty+T_ry+T_rz+5)/sim_conf.Ts));
% Theta x Theta y
u_hexa((T_ty+T_ry+T_rz+6)/sim_conf.Ts:(T_ty+T_ry+T_rz+7)/sim_conf.Ts, 1) = 2*pi*(3/360)*(time_vector((T_ty+T_ry+T_rz+6)/sim_conf.Ts:(T_ty+T_ry+T_rz+7)/sim_conf.Ts)-time_vector((T_ty+T_ry+T_rz+6)/sim_conf.Ts));
u_hexa((T_ty+T_ry+T_rz+7)/sim_conf.Ts:(T_ty+T_ry+T_rz+9)/sim_conf.Ts, 1) = 2*pi*(3/360)*cos(2*pi*(1/2)*(time_vector((T_ty+T_ry+T_rz+7)/sim_conf.Ts:(T_ty+T_ry+T_rz+9)/sim_conf.Ts)-time_vector((T_ty+T_ry+T_rz+7)/sim_conf.Ts)));
u_hexa((T_ty+T_ry+T_rz+7)/sim_conf.Ts:(T_ty+T_ry+T_rz+9)/sim_conf.Ts, 2) = 2*pi*(3/360)*sin(2*pi*(1/2)*(time_vector((T_ty+T_ry+T_rz+7)/sim_conf.Ts:(T_ty+T_ry+T_rz+9)/sim_conf.Ts)-time_vector((T_ty+T_ry+T_rz+7)/sim_conf.Ts)));
u_hexa((T_ty+T_ry+T_rz+9)/sim_conf.Ts:(T_ty+T_ry+T_rz+10)/sim_conf.Ts, 1) = 2*pi*(3/360) - 2*pi*(3/360)*(time_vector((T_ty+T_ry+T_rz+9)/sim_conf.Ts:(T_ty+T_ry+T_rz+10)/sim_conf.Ts)-time_vector((T_ty+T_ry+T_rz+9)/sim_conf.Ts));
% Gravity Compensator system
T_mass_start = T_ty+T_ry+T_rz+T_u_hexa;
mass = zeros(length(time_vector), 2);
mass((T_mass_start)/sim_conf.Ts:(T_mass_start+2)/sim_conf.Ts, 1) = 2*pi*( 20/360)*(time_vector((T_mass_start)/sim_conf.Ts:(T_mass_start+2)/sim_conf.Ts)-time_vector(T_mass_start/sim_conf.Ts));
mass((T_mass_start)/sim_conf.Ts:(T_mass_start+2)/sim_conf.Ts, 2) = 2*pi*(-10/360)*(time_vector((T_mass_start)/sim_conf.Ts:(T_mass_start+2)/sim_conf.Ts)-time_vector(T_mass_start/sim_conf.Ts));
mass((T_mass_start+2)/sim_conf.Ts:(T_mass_start+3)/sim_conf.Ts, 1) = mass((T_mass_start+2)/sim_conf.Ts, 1);
mass((T_mass_start+2)/sim_conf.Ts:(T_mass_start+3)/sim_conf.Ts, 2) = mass((T_mass_start+2)/sim_conf.Ts, 2);
mass((T_mass_start+3)/sim_conf.Ts:(T_mass_start+5)/sim_conf.Ts, 1) = mass((T_mass_start+2)/sim_conf.Ts, 1)-2*pi*( 20/360)*(time_vector((T_mass_start+3)/sim_conf.Ts:(T_mass_start+5)/sim_conf.Ts)-time_vector((T_mass_start+3)/sim_conf.Ts));
mass((T_mass_start+3)/sim_conf.Ts:(T_mass_start+5)/sim_conf.Ts, 2) = mass((T_mass_start+2)/sim_conf.Ts, 2)-2*pi*(-10/360)*(time_vector((T_mass_start+3)/sim_conf.Ts:(T_mass_start+5)/sim_conf.Ts)-time_vector((T_mass_start+3)/sim_conf.Ts));
2018-10-02 21:46:34 +02:00
opts_inputs = struct(...
'Dy', ty, ...
'Ry', ry, ...
'Rz', rz, ...
'Dh', u_hexa, ...
'Rm', mass ...
2018-10-02 21:46:34 +02:00
);
initializeInputs(opts_inputs);
%% Initialize SolidWorks Data
2018-10-12 13:22:29 +02:00
initializeSolids();
%% Initialize Ground
initializeGround();
%% Initialize Granite
initializeGranite();
%% Initialize Translation stage
initializeTy();
%% Initialize Tilt Stage
initializeRy();
%% Initialize Spindle
initializeRz();
%% Initialize Hexapod Sym<EFBFBD>trie
initializeMicroHexapod();
%% Initialize Center of Gravity compensation
initializeAxisc();
%% Initialize NASS
2018-10-02 21:33:56 +02:00
initializeNanoHexapod(struct('actuator', 'lorentz'));
%% Initialize Sample
2018-10-02 21:33:56 +02:00
initializeSample(struct('mass', 20));