53
Creating an alpha type Stirling engine in virtual reality. ing. Mátyás Attila Masterand – ISM 2012-2013

Tutorial - Creating an Alpha Type Stirling Engine

Embed Size (px)

DESCRIPTION

Exporting to Matlab's virtual reality from a SolidWorks model.

Citation preview

Page 1: Tutorial - Creating an Alpha Type Stirling Engine

Creating an alpha type Stirling

engine in virtual reality.

ing. Mátyás Attila Masterand – ISM

2012-2013

Page 2: Tutorial - Creating an Alpha Type Stirling Engine

Creating the 3D model in virtual reality consists of the following

steps:

• Constructing and assembling the elements in SolidWorks to

obtain the 3D model

• Exporting the 3D CAD model to a SimMechanics model

• Exporting the SimMechanics model to the Virtual World

• Creating a Graphical User Interface(GUI), to view. And control

the mechanism

Page 3: Tutorial - Creating an Alpha Type Stirling Engine

Creating the 3D model

The most complex part is the piston, you need to make some extruded cuts, to

create space for the connecting rod.

Page 4: Tutorial - Creating an Alpha Type Stirling Engine

Creating the 3D model

The next step is to create the two cilinders with the same inner diameter as the pistons,

you need a cold cilinder, and a hot cilinder.

You can place some ribs on the cold cilinder, for a better look.

Page 5: Tutorial - Creating an Alpha Type Stirling Engine

Creating the 3D model

After the cilinders, you need to create a connecting rod, a crankshaft and a flywheel.

Page 6: Tutorial - Creating an Alpha Type Stirling Engine

Creating the 3D model

You need to create a block for the engine and a support where you can place the engine

itself.

Page 7: Tutorial - Creating an Alpha Type Stirling Engine

Creating the 3D model

After you got the components you need to create an assembly file. When you place the

constraints with the “Mate” command, you have to work with the next hierarchy:

Block-CrankShaft-Connecting rods(2)-Pistons(2)-Cilinders(2). When the assembly is

ready you need to create the regenerator, with a 3D sketch.

Page 8: Tutorial - Creating an Alpha Type Stirling Engine

Creating the 3D model

When we finished the regenerator, save it.

Page 9: Tutorial - Creating an Alpha Type Stirling Engine

Exporting from 3D model

• Click on “Save As”

Page 10: Tutorial - Creating an Alpha Type Stirling Engine

Exporting from 3D model

• STL

Page 11: Tutorial - Creating an Alpha Type Stirling Engine

Exporting from 3D model

• VRML(At the options menu, select VRML97, and uncheck the‟Save all

components of the assembly in a single file‟)

Page 12: Tutorial - Creating an Alpha Type Stirling Engine

Exporting from 3D model

• SimMechanics Link Export SimMechanics First Generation

• Save it as *.XML

Page 13: Tutorial - Creating an Alpha Type Stirling Engine

Exporting from 3D model

• Create screenshots from the assembly, and the main parts. Save the

assembly as „stirlingengine.jpg‟

Page 14: Tutorial - Creating an Alpha Type Stirling Engine

Creating Simulink model

To open the SolidWorks model in SimMechanics, you have to do

th next:

• Open MATLAB, and set current folder the folder where you

have saved all the files previously.

• Click on the command line, and type

“mech_import(„stirlingengine.xml‟)”, or simply

“mech_import”, and browse for the *.xml file

Page 15: Tutorial - Creating an Alpha Type Stirling Engine

• It will result a simulink model like this.

• You need to organize the blocks to get a better view on the model

Creating Simulink model

Page 16: Tutorial - Creating an Alpha Type Stirling Engine

• After ordering, select all components, and create Subsystem, or press Ctrl+G

Creating Simulink model

Page 17: Tutorial - Creating an Alpha Type Stirling Engine

• Right click on subsystem

image(imread(„stirlingengine.jpg‟));

Creating Simulink model

Page 18: Tutorial - Creating an Alpha Type Stirling Engine

• Duble click on the Revolute joint on „axa_principala‟, change nr. of ports

to 2

Creating Simulink model

Page 19: Tutorial - Creating an Alpha Type Stirling Engine

• Create this model from

simulink library browser.

• Change the second option at

the Joint Actuator to Motion.

Creating Simulink model

Page 20: Tutorial - Creating an Alpha Type Stirling Engine

Creating Simulink model

• Go back to the main subsystem, open Simulink Library Browser, get the 3

blocks from there (Constant, Slider Gain, Display)

• Connect them in this order

Page 21: Tutorial - Creating an Alpha Type Stirling Engine

• Change the simulation time from 10, to inf.

• Change the Slider Gain max value to 360, so that our engine can make a full rotation.

Creating Simulink model

Page 22: Tutorial - Creating an Alpha Type Stirling Engine

Creating Simulink model

• Start the simulation, and move the slider, check if everthing works fine.

Page 23: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Virtual World

• Stop the simulation, and go back to the main Matlab window.

• Check if you are working in the correct current folder, if not change it.

• Type: „vrcadcleanup(„name of the assembly.wrl‟);

Page 24: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Virtual World

This command will clean up our wrl file in a fes seconds. cleaning the spaces and

making ready the file to be opened in the virtual reality toolbox.

Page 25: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Virtual World

• Open the virtual reality toolbox. You can find it in you Matlab folder or on

the following path:

C:\Program Files\MATLAB\R2012b\toolbox\sl3d\vrealm\program\vrbuilder2

• Open – stirlingengine.wrl

Page 26: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Virtual World

• After opening the file, click on New world, and click on Insert Background

Page 27: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Virtual World

• Click on the TEST button to visualize the engine

• With the help of the mooving tools, get a good viewpoint.

Page 28: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Virtual World

• Insert a Directional Light, if it is badly enlightened, modify the direction of the

Directional Light

Page 29: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Virtual World

• After getting the right position, create a viewpoint, and in the desciption, give it a

name, like View1

• Move the position of the engine, and create 2 other views: View2, and View3

Page 30: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Virtual World

• Insert Navigation info, and World info

• Save the file, and exit the virtual realm builder

Page 31: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Virtual World

• Go back to the main Matlab window, and enter the next command:

vrphysmod(„stirlingengine.wrl‟, stirlingengine);

• This command will add a Vrsink, and a sample connection to our simmechanics

model

Page 32: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Virtual World

• At the model, this sample connection will be added. Copy(Ctrl+C) the body sensor,

and the GOTO blocks.

Page 33: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Virtual World

• Rename the GOTO blocks to : - rod1_rot

- rod1_trans

Page 34: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Virtual World

• Duble click on the piston Add CS

• Make this step with the displacer, connecting_rod_2, axa_pricipala, volanta (You need

to do this with all moving parts; there are 6 moving parts)

Page 35: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Virtual World

• Paste(Ctrl+V) the blocks, and connect them with the CS4.

• Rename the GOTO blocks piston1_trans; piston1_rot;

• Do these steps with all the other moving parts

Page 36: Tutorial - Creating an Alpha Type Stirling Engine

• Select the 4 blocks create a subsystem Mask it wit the

image(imread(„rod.jpg‟)); command.

• Repeat these steps with the other moving parts too.

Creating the Virtual World

Page 37: Tutorial - Creating an Alpha Type Stirling Engine

• At last you create a subsystem from the root part, and you will get a similar model

like on the picture.

Creating the Virtual World

Page 38: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Virtual World

• Go back to the VR sink model

• Duble click the VR Sink

• Simulation

• Block parameters

Page 39: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Virtual World

• Browse select the

stirlingengine.wrl

• Thick the rotation and

translation icon at all

moving parts

Page 40: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Virtual World

• After you exit the Block Parameters window,

your VR sink will look like this.

• Copy the 3 blocks, and make an overall of 6

pairs of them.

Page 41: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Virtual World

• Connect them; rotations to rotations, and translations to translations, rotations need an

aditional block.

Page 42: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Virtual World

• Make the link between the vr sink and the simulink model

• Click Update Tags select the Tag you need

• Do this to all elements

Page 43: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Virtual World

• Open the VR Sink, Click reload, to refresh, check if you can switch between the view

points, and run a TEST, check if everything works fine, if you move the slider.

Page 44: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Virtual World

• Go back to your subsystem, delete the Slider Gain, and connect the Constant with

the subsystem.

Page 45: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Graphical User Interface

• Go back to main window, NEW Graphical User Iterface Blank GUI OK

Page 46: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Graphical User Interface

• Save As GUI

• Duble click the background, change width to 180, height to 45

Page 47: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Graphical User Interface

• Right click on background View CallbacksCreateFcn

• GUI.m will be opened

Page 48: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Graphical User Interface

This is the part where the virtual reality engine will be aded to the GUI

• Copy this code under “function varargout”

• c1=vr.canvas(w,gcf, [“coordinates of the window”, “Dimension of the window”]);

• c1.Viewpoint=„Name of the view‟

• Create 3 views in total

Page 49: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Graphical User Interface

• Create 3 buttons: “Start Simulation”, “Stop Siulation”, “Exit”

• Create a slider, an edit text, and statical text

• Change the Max value of the slider to 360

Page 50: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Graphical User Interface

• Right click on the slider View callbacks Callback

set_param('stirlingengine/Constant','Value',num2str(get(hObject,'Value'))); a=get_param('stirlingengine/angle','RuntimeObject'); val_a=a.InputPort(1).Data; set(handles.angle,'String',round(val_a));

• Right click on the Start Button View callbacks Callback

set_param('stirlingengine','SimulationCommand','start'); • Right click on the Stop Button View callbacks Callback

set_param('stirlingengine','SimulationCommand','stop');

Page 51: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Graphical User Interface

Right click on the Stop Button View callbacks Callback

save_system('stirlingengine'); close_system('stirlingengine'); close; • Save the GUI again • Run the GUI (F5 or Ctrl-T)

Page 52: Tutorial - Creating an Alpha Type Stirling Engine

Creating the Graphical User Interface

• Your GUI is ready to run!

Page 53: Tutorial - Creating an Alpha Type Stirling Engine

Good Luck!