Вы находитесь на странице: 1из 53

Creating an alpha type Stirling engine in virtual reality.

ing. Mtys Attila Masterand ISM 2012-2013

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

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.

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.

Creating the 3D model

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

Creating the 3D model

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

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.

Creating the 3D model

When we finished the regenerator, save it.

Exporting from 3D model

Click on Save As

Exporting from 3D model

STL

Exporting from 3D model

VRML(At the options menu, select VRML97, and uncheck theSave all components of the assembly in a single file)

Exporting from 3D model

SimMechanics Link Export SimMechanics First Generation Save it as *.XML

Exporting from 3D model

Create screenshots from the assembly, and the main parts. Save the assembly as stirlingengine.jpg

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

Creating Simulink model

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

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

Creating Simulink model

Right click on subsystem

image(imread(stirlingengine.jpg));

Creating Simulink model

Duble click on the Revolute joint on axa_principala, change nr. of ports to 2

Creating Simulink model

Create this model from simulink library browser.

Change the second option at the Joint Actuator to Motion.

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

Creating Simulink model

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

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

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);

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.

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

Creating the Virtual World

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

Creating the Virtual World

Click on the TEST button to visualize the engine With the help of the mooving tools, get a good viewpoint.

Creating the Virtual World

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

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

Creating the Virtual World

Insert Navigation info, and World info Save the file, and exit the virtual realm builder

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

Creating the Virtual World

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

Creating the Virtual World

Rename the GOTO blocks to : - rod1_rot - rod1_trans

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)

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

Creating the Virtual World

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

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

Go back to the VR sink model

Duble click the VR Sink Simulation Block parameters

Creating the Virtual World Browse select the stirlingengine.wrl Thick the rotation and translation icon at all moving parts

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.

Creating the Virtual World

Connect them; rotations to rotations, and translations to translations, rotations need an aditional block.

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

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.

Creating the Virtual World

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

Creating the Graphical User Interface

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

Creating the Graphical User Interface

Save As GUI Duble click the background, change width to 180, height to 45

Creating the Graphical User Interface

Right click on background View CallbacksCreateFcn GUI.m will be opened

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

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

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');

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)

Creating the Graphical User Interface

Your GUI is ready to run!

Good Luck!

Вам также может понравиться