|On this page…|
In this example, you are going to model a simple hydraulic system and observe its behavior under various conditions. This tutorial illustrates the essential steps to building a hydraulic model, described in the previous section, and makes you familiar with using the basic SimHydraulics® blocks.
The following schematic represents the model you are about to build. It contains a single-acting hydraulic cylinder, which is controlled by an electrically operated 3-way directional valve. The cylinder drives a load consisting of a mass, viscous friction, and preloaded spring.
The power unit consists of a motor, a positive-displacement pump, and a pressure relief valve. Depending on its characteristics, such a power unit can be modeled in a variety of ways, as described in Modeling Power Units. In this example, the pump unit is assumed to be powerful enough to maintain constant pressure at the valve inlet. Therefore, we are going to represent it in the diagram by a Hydraulic Pressure Source block.
To create an equivalent SimHydraulics diagram, follow these steps:
Open the Simulink® Library Browser, as described in SimHydraulics Block Libraries.
Create a new model. To do this, from the top menu bar of the Library Browser, select File > New > Model. The software creates an empty model in memory and displays it in a new model editor window.
Note Alternately, you can type ssc_new at the MATLAB® Command prompt, to create a new model prepopulated with certain required and commonly-used blocks. For more information, see Creating a New Simscape Model.
Open the Simscape > Foundation Library > Hydraulic > Hydraulic Sources library and drag the Hydraulic Pressure Source block into the model window.
Open the Simscape > SimHydraulics > Hydraulic Cylinders library and place the Single-Acting Hydraulic Cylinder block into the model window.
To model the valve, open the Simscape > SimHydraulics > Valves library. Place the 3-Way Directional Valve block, found in the Directional Valves sublibrary, and the 2-Position Valve Actuator block, found in the Valve Actuators sublibrary, into the model window.
Connect the blocks as shown in the following illustration.
Ports T of the Hydraulic Pressure Source and 3-Way Directional Valve blocks have to be connected to the tank, at atmospheric pressure. To model this connection, open the Simscape > Foundation Library > Hydraulic > Hydraulic Elements library and add the Hydraulic Reference block to your diagram, as shown below. To do this, connect the only port of the Hydraulic Reference block to port T of the Hydraulic Pressure Source block, then right-click this connection line to create a branching point, and connect this point to port T of the 3-Way Directional Valve block.
Model the mechanical load for the cylinder. Open the Simscape > Foundation Library > Mechanical > Translational Elements library and add the Mass, Translational Spring, Translational Damper, and three Mechanical Translational Reference blocks to your diagram.
To indicate that the cylinder case is fixed, connect port C of the Single-Acting Hydraulic Cylinder block to one of the Mechanical Translational Reference blocks. To rotate the Mechanical Translational Reference block, select it and press Ctrl+R. You can also shorten the block name to MTR to make the diagram easier to read.
Connect the other blocks to port R of the Single-Acting Hydraulic Cylinder block, as shown below.
Now you need to add the sources and scopes. They are found in the regular Simulink libraries. Open the Simulink > Sources library and copy the Constant block and the Sine Wave block into the model. Then open the Simulink > Sinks library and copy two Scope blocks. Rename one of the Scope blocks to Valve. It will monitor the valve opening based on the input signal variation. The other Scope block will monitor the position of the cylinder rod; rename it to Position.
Double-click the Valve scope to open it. In the scope window, click to access the scope parameters, change Number of axes to 2, then click the Layout button, select the vertical layout (two squares on top of each other), and click OK. The scope window now displays two sets of axes, and the Valve scope in the diagram has two input ports.
Every time you connect a Simulink source or scope to a SimHydraulics diagram, you have to use an appropriate converter block, to convert Simulink signals into physical signals and vice versa. Open the Simscape > Utilities library and copy two Simulink-PS Converter blocks and two PS-Simulink Converter blocks into the model. Connect the blocks as shown below.
To specify the fluid properties, add the Hydraulic Fluid block, found in the Simscape > SimHydraulics > Hydraulic Utilities library, to your diagram. You can add this block anywhere on the hydraulic circuit by creating a branching point and connecting it to the only port of the Hydraulic Fluid block.
Each topologically distinct physical network in a diagram requires exactly one Solver Configuration block, found in the Simscape > Utilities library. Copy this block into your model and connect it to the circuit, similar to the Hydraulic Fluid block. Your diagram now should look like this.
Your block diagram is now complete. Save it as simple_hydro.
After you have put together a block diagram of your model, as described in the previous section, you need to select a solver and provide the correct values for block parameters. All the blocks have default parameter values that allow them to run "out of the box," but you may need to change some of them to suit your particular application.
To prepare for simulating the model, follow these steps:
Select a Simulink solver. On the top menu bar of the model window, select Simulation > Model Configuration Parameters. The Configuration Parameters dialog box opens, showing the Solver node.
Under Solver options, set Solver to ode23t (mod.stiff/Trapezoidal) and Max step size to 0.2.
Also note that Simulation time is specified to be between 0 and 10 seconds. You can adjust this setting later, if needed.
Click OK to close the Configuration Parameters dialog box.
Select a fluid. Double-click the Hydraulic Fluid block. In the Block Parameters dialog box, set Hydraulic Fluid to Skydrol 5 and set the other block parameters as shown below.
Click OK to close the Block Parameters dialog box.
Specify the units for the pressure input signal. Simulink signals are unitless. When you convert them to physical signals, you can supply units by using the converter blocks. Double-click the Simulink-PS Converter1 block, enter Pa in the Input signal unit combo box, and click OK. When the physical modeling software parses the model, it matches the input signal units with the block input ports and provides error messages if there is a discrepancy. For more information, see Model Validation.
Specify a realistic value for the pressure input signal. Double-click the Constant block, enter 10e5 in the Constant value text box, and click OK.
Open the 2-Position Valve Actuator block and note that its Nominal Signal Value parameter is set to 24.
Double-click the Sine Wave block and change its Amplitude to a value greater than 50% of the nominal signal value for the 2-Position Valve Actuator block, for example, to 20.
Adjust the 3-Way Directional Valve block parameters as shown below.
Adjust the Single-Acting Hydraulic Cylinder block parameters as shown below.
Double-click the Mass block and change its Mass to 4.5 kg.
Double-click the Translational Damper block, which models the viscous friction, and change its Damping coefficient to 250 N/(m/s).
Double-click the Translational Spring block. Set its Spring rate to 6e3 N/m and Initial deformation to 0.02 m.
Save the model.
After you've put together a block diagram and specified the initial settings for your model, you can run the simulation.
The input signal for the valve opening is provided by the Sine Wave block. The Valve scope reflects both the input signal and the valve opening as functions of time. The Position scope outputs the cylinder rod displacement as a function of time. Double-click both scopes to open them.
To run the simulation, click in the model window toolbar. The physical modeling solver evaluates the model, calculates the initial conditions, and runs the simulation. For a detailed description of this process, see How Simscape Simulation Works. Completion of this step may take a few seconds. The message in the bottom-left corner of the model window provides the status update.
Once the simulation starts running, the Valve and Position scope windows display the simulation results, as shown in the next illustration.
In the beginning, the valve is closed. Then, as the input signal reaches 50% of the actuator's nominal signal, the valve gradually opens to its maximum value and moves the cylinder rod in the positive direction. When the input signal goes below 50% of the nominal signal, the actuator closes the valve. The spring returns the cylinder rod to its initial position.
You can now adjust various inputs and block parameters and see their effect on the valve opening profile and the cylinder rod displacement.
After running the initial simulation, you can experiment with adjusting various inputs and block parameters.
Try the following adjustments:
This example shows how a change in the input signal affects the opening of the valve, and therefore the cylinder rod displacement.
Double-click the Sine Wave block, enter 40 in the Amplitude text box, and click OK.
Run the simulation. The simulation results are shown in the following illustration. With the increase in the input signal amplitude, it reaches 50% of the actuator's nominal signal sooner, and the valve stays open longer, which in turn affects the cylinder rod position.
In our model, the cylinder drives a load consisting of a mass, viscous friction, and preloaded spring. This example shows how a change in the spring stiffness affects the cylinder rod displacement.
Double-click the Translational Spring block. Set its Spring rate to 12e3 N/m.
Run the simulation. The valve opening profile is not affected, but increase in spring stiffness results in smaller amplitude of cylinder rod displacement, as shown in the following illustration.
In our model, we have used the PS-Simulink Converter block in its default parameter configuration, which does not specify units. Therefore, the Position scope outputs the cylinder rod displacement in the units specified for the parameters of the Single-Acting Hydraulic Cylinder block; in this case, in meters. This example shows how to change the output units for the cylinder rod displacement to millimeters.
Double-click the PS-Simulink Converter block. Type mm in the Output signal unit text box and click OK.
Run the simulation. In the Position scope window, click to autoscale the scope axes. The cylinder rod displacement is now output in millimeters, as shown in the following illustration.