Tutorial - Creating An Alpha Type Stirling Engine
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
The most complex part is the piston, you need to make some extruded cuts, to create space for the connecting rod.
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.
After the cilinders, you need to create a connecting rod, a crankshaft and a flywheel.
You need to create a block for the engine and a support where you can place the engine itself.
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.
Click on Save As
STL
VRML(At the options menu, select VRML97, and uncheck theSave all components of the assembly in a single file)
Create screenshots from the assembly, and the main parts. Save the assembly as stirlingengine.jpg
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
It will result a simulink model like this. You need to organize the blocks to get a better view on the model
After ordering, select all components, and create Subsystem, or press Ctrl+G
image(imread(stirlingengine.jpg));
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
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.
Start the simulation, and move the slider, check if everthing works fine.
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);
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
After opening the file, click on New world, and click on Insert Background
Click on the TEST button to visualize the engine With the help of the mooving tools, get a good viewpoint.
Insert a Directional Light, if it is badly enlightened, modify the direction of the Directional Light
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
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
At the model, this sample connection will be added. Copy(Ctrl+C) the body sensor, and the GOTO blocks.
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)
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
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.
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 Browse select the stirlingengine.wrl Thick the rotation and translation icon at all moving parts
After you exit the Block Parameters window, your VR sink will look like this.
Connect them; rotations to rotations, and translations to translations, rotations need an aditional block.
Make the link between the vr sink and the simulink model Click Update Tags select the Tag you need Do this to all elements
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.
Go back to your subsystem, delete the Slider Gain, and connect the Constant with the subsystem.
Save As GUI Duble click the background, change width to 180, height to 45
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
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
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');
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)
Good Luck!