PTcl as simulation control language

Create PTcl scripts

You can use MLDesigner to create an appropriate PTcl script that describes a system model using PTcl commands.

To create a PTcl file that constructs the system model you can use the Generate Extern toolbar button which is available in Simulation Mode. To illustrate this use the sinMod system. It is located at MLD LibrariesSDFDemo. Proceed as follows.

Now, a PTcl file (.ptcl) as well as a parameter file (.params) with the parameters of the system are created by MLDesigner.

Execute the simulation

You can use the PTcl Shell located in the Console View to execute the PTcl script using the command

execute <directory>/sinMod.ptcl

where directory specifies the directory where you stored the sinMod PTcl file. If this is a subdirectory, enter the full path to your file.

An MLDesigner PTcl shell makes it possible to execute PTcl simulations independent of the MLDesigner GUI. To execute the simulation type

$MLD/ptclsh -x Systemname.ptcl

into your command shell.

On Windows® you may use the MSYS command shell which is shipped with MLDesigner.

You can use the systemlist and cursystem command to get the list of known system models as well as the current system model.

To run a simulation of the sinMod with different waveform frequencies use a text editor to open the file


Change the file so it looks as follows:

    Frequency  : PI/100
    GlobalSeed : 1234567890
    Phase      : for -1.0 to 1.0 step 0.1
    RunLength  : 400

You can now execute the simulation by entering the following command in the PTcl Shell.

execute <directory>/sinMod.ptcl

The result will be 21 frequency modulation output graphs.

Every PTcl simulation produces a .params.simulationNumber file with the simulation parameters for the specific simulation. This file is for record purposes and is not parsed when the simulation is rerun.

The combination of PTcl and the GUI of MLDesigner is very powerful. The examples shown above are just some hints on how they can be used together.