%% Cartesian 3D Printer
% This example models a Cartesian 3D printer. The model allows you to specify the rotational motion of the motor on each
% axis to define a printing path. In this example, the printing head moves along the edges of two
% letters, S and M, using the predefined rotational motions.
%  
% The printer has three linear actuators that drive the motion of the printing head along _x_-, _y_-, and _z_-directions. These
% actuators are modeled by the Lead Screw Joint blocks. The lead screw
% joints convert the rotational inputs to translational motions.
% 
% Copyright 2020 The MathWorks, Inc.

%% Model
open_system('sm_3d_printer');
set_param('sm_3d_printer','SimMechanicsOpenEditorOnUpdate','off');
%% Subsystems
% The 3D printer has three degrees of freedom and consists of five subsystems: the printing bed, printer base assembly, gantry
% assembly, sliding block assembly, and printing head assembly. The prismatic and lead screw joints constrain the
% subsystems and permit movements along _x_-, _y_-, and _z_- axes.

open_system('sm_3d_printer/3D Printer','force');

%% Mechanics Explorer Animation
% <<../Printer.gif>>

%% Simulation Results
% This plot shows the _x_-, _y_-, and _z_-positions of the printing head during the printing.
sm_3d_printer_plotdata
set_param('sm_3d_printer','SimMechanicsOpenEditorOnUpdate','on');
 
%%
close all
bdclose all
clear all
