The Web-based Transfer Function Simulator is a simplistic (yet quite powerful) imitation of commercial products such as Simulink(r) by MathWorks(c) or PLECS(r) by PLEXIM(c). The purpose behind providing the simulator is simple: not everyone has access to Simulink. Alternatively, there might not a free license at the time or simply one would like to explore the design of control systems online on a machine without installed MatLab.
Simulator Options
At the moment, these options are available:
Zoom-in
Maximum zoom-in factor : 13 (number of pixels per unit distance, e.g., the scope block is 4x4).
Zoom-out
Maximum zoom-out factor : 8 (number of pixels per unit distance, e.g., the scope block is 4x4).
Settings
End time. Fixed at the moment.
Simulation steptime. Fixed at the moment.
Run
Commences a time domain simulation. Progress in shown in a progress bar located in the upper right corner.
Info
Shows relevant schematic/simulation info, such as number of blocks, code version, simulation settings, etc.
Debug
Shows debug info, such as connection source, port net connection, etc.
Download
Downloads the simulation to your computer as a JSON textfile, including the simulation settings.
Upload
Upload a saved simulation from your computer.
Block Description
At the moment, these blocks are available:
Summing junction
The summing junction block can have up to three input connections with "+", "-", and "|" notations. Connection ports start from top and continue to the left and the bottom.
Gain
Proportional gain. The output signal is equal to the inputs signal times the gain block parameter.
Integrator
A continuous-time integrator. The output signal is calculated as the integral of the input signal over time. Backward Euler approximation is used.
Each integrator might have an initial condition which is loaded during the first simulation step.
Transfer Function
A continuous-time transfer function. Backward Euler approximation is used.
Order of the denominator must be higher or equal to the numerator order. Second-order is the maximum order of the transfer function block.
Constant
The output of the block is equal to the block parameter at all times.
Scope
The scope block monitors any waveform in the schematics.
The maximum number of scopes is 4.
Step function
The step function block outputs the "Initial value" until the simulation time hits the "Time" parameter, after which the block outputs the "Final value".
Ramp function
The output of the block is a ramp with these parameters:
Initial Value
Ramp Slope
Start Time
Saturation
The Saturation Block clamps the incoming signal between the "Lower Limit" and "Upper Limit" values.
Sine function
The output of the block is a sine wave with these parameters:
Amplitude
Frequency (+/-100 Hz max)
Phase offset [rad]
Perturbation Source
Perturbation is used to determine the transfer function of an element or a group of elements, either open-loop or closed-loop.
Careful! Saturation blocks tend to invalidate results.
The main purpose of this window is to let user delete highlighted connections.
Simulation Settings
Two simulation settings are available: end-time and simulation time step. The time step is currently fixed at 10 us (this limits the maximum reasonable pole frequency to ~ 5 kHz). The end time could be as short as 100 ms and as long as 10 s.
Simulation Info
The Simulation Info pop-up displays the number of blocks in the simulation as well as the number of connections and all simulation settings. It truly is an FYI feature.
Behind the Scene
Schematic Block Connections
Each connection is a "tree" - that is, each connection is an object. The master connection starts at an absolute position and an "xy" vector with differential values determines shape of the connection.
Connection starts with the sink port. That is, each connection can have only one driver.
Each fork in a connection is the place where the parent connection has at least (but three at most) children connections. Children connections do not have the absolute position available.
The picture below shows the actual connection object for the longer connection in the accompanying schematic.
The following describes the behavior when extending a connection.
When extending a connection:
End connection extension
a. If the previous connection is vertical, start vertical
b. If the previous connection is horizontal, start horizontal
Start of existing connection
a. The same as 1a)
b. The same as 1b)
Middle of an existing connection
a. Always perpendicular
Block port
a. Have a unity length stub in the direction of the port (could be any of the four)
When dropping a connection:
In open space - follow the rules above
On a block port - have a unity length stub
On a net (must be a master connection sink) - both rotations are ok
Cannot drop the connection on:
Source net
a. Existing connection except starts of other nets
b. Occupied sink ports (covered by condition a)
c. Source ports
Sink net
a. Ends of the same net
b. Sink ports
c. Master nets start
To Do:
Save/Load function
Allow the user to save and load schematics. This will likely be done using JSON, but of course the existing data structures used for connections and blocks are not supported.
Move connection
Existing connections could be dragged around. This is difficult, however, since many times parent canopy would be affected as well.
Detect algebraic loops
Currently the simulator does not detect algebraic loops and therefore does not produce correct results if there are some.
Convergence
The simulator steps through all existing nets and calculates the next step individually - using backward Euler approximation. This leads to errors over time. But this is not a Simulink replacement...
If a pole is at a very high frequency (say more than 1/100th of the step frequency), the step should be adjusted.
Add additional blocks
Sine wave
Saturation
Change log
8/3/2017
Started work on Web-based Simulator.
9/20/2017
Enabled Save/Load functionality
Added the info/error bar
Fixed bug when a connection was drawn across terminals of a block and the block spliced the connection
9/21/2017
Save/Load now captures all connections, blocks, and simulation settings data
Restored the "Delete Selection" button
mouseCarry.existing is now initialized correctly (-1)
Simulation Settings object now supports the "fixed" property such that deletion or location modification is not allowed
Fixed the issue with transfer function output - the internal memory vector did not restart properly, which caused the very first output to track the last simulation result.
9/22/2017
Library can now be disabled; this will be useful for built-in fixed examples
9/24/2017
Disabled the Delete key press action (to prevent diagram block deletion when modifying block parameters)
Info bar now shows error and info symbols
Error is correctly shown when placing more scope than allowed (4 max).
The library browser now supports multiple pages.
Added ramp source block functionality.
When transfer function numerator order is higher than the denominator order, the simulation throws an error and does not run.
9/26/2017
Added saturation block functionality.
All menus are now a pop-up. The scope feature was moved to the right of the block diagram.
9/27/2017
Simplified pop-up menus.
Simulation info is now a pop-up menu.
Simulation end-time is now applied correctly.
10/1/2017
Added sine wave block functionality.
The simulator now checks for "demo" flag in the url. If a certain flag is met, an appropriate demo is loaded.