Second Order System DemoThis built-in demo runs a simulation of a simple 2nd order system. It includes an interface file and a DSim setup file. The purpose of this demo is to provide a basic example of how DSim can be used to simulate dynamic systems, and how to interact with simulations in VisualCommander.
The model is a standard single-input, single-output (SISO) 2nd order response. The transfer function from control input U(s) to output Y(s) has the form:
We can also express the time response y(t) by writing the second derivative as follows:
The system has a unit steady-state response. In other words, when the time response stops changing, the time derivatives are zero, and the output y(t) is equal to the input.
The interface file is named "second_order.vci". It has a single page with command plugins to control the input, natural frequency, and damping ratio. It prints out the value of these commands, as well as the output and output rate, and shows a 2D plot that includes both the input and output signals. A sample screenshot is shown below.
The box in the upper left corner is a "Session Manager" plugin. Use it to start, stop, pause, and reset the simulation. You can also configure its properties, specifying the session name, and whether the simulation should start upon initialization.
The box in the uppper right hand corner is a "Simulation Status" plugin. It shows the current simulation time and indicates the percentage complete with a horizontal bar plot.
To use the interface, first enter a value for "u" in the red command plugin and hit "Send". You will see the value in the red data display box change to your commanded value, and the red line in the plot will jump to the same value. The blue line ("y") will follow the red line according to the second order dynamics, while the changing value of "y" is displayed in the blue data display box.
Try changing the natural frequency and damping ratio and then command new values for "u" to see how the nature of the time response changes.
The setup file for the second order demo is very simple. The entire file is shown below:
# DSim Setup File (v1), generated # Base Simulation Parameters TimeStep 0.010000; TimeScale 1.000000; EndSimulationSecs 60.000000; # Constraints # Object Hierarchy Object second_order dsim_second_order builtin SetIntegrator dsim_rk4 builtin EndObject # End simulation file
The first section defines the base simulation parameters. Here, we use a time step of 0.01 seconds, a time scale of 1.0 (synced with real-time) and run for 60 seconds. The starting time is ignored in this simulation, as are constraints.
In this simulation, we have only one object. We name it "second_order". It derives from the "dsim_second_order" class. It is not included in any separate bundle, but is one of the "builtin" classes that is provided with DSim.
For more information about the building and customizing a simulation from Dsim components, see the SimBuilder help documentation.
To learn more about setup file usage and syntax, see: