Data Output


The probe is used to pass data from a particular part of the simulation to a destination outside of the simulation. This can be used to update the values displayed in labels or tables, or passed to plots. In the following example the output from the plant is sent to a table in another part of the document:

<transferFunction name="plant" num="1" den="1 3 1" />
<probe ref="myDemo.mytable.outputRow.outputColumn.outputLabel"/>

and in this example the sine waves are sent to a plot to be rendered:

<simulation name="simulation" duration="10" period="0.02">
                <sine amplitude="3" />
                <sine amplitude="2" />
                <sine amplitude="1" />
            <probe ref="myExperiment.myDrawing.theplot" />

Typically when plotting simulation data you should use a timePlot, as it automatically plots the data against the simulation sample time. You can also output points to an xyPlot, where the data passed through the probe will be treated as X-Y pairs. To do this, simply set the time attribute on the probe to false.

The probe element also has a conditional attribute which will only write data when specified. When the conditional attribute is set to true, a second input port opens. When a non-zero value is passed through this second port the probe will write data to the referenced XML element. When a zero value is passed through the second port, no data will be written from the probe. In this example data is only written to the target when the simulation time is greater than 1 second.

<simulation name="mySim" period="0.01"> 
        <output name="out" width="6" />
        <output name="enable" width="1" />
          if time < 1 then
            enable = vector({1})
            enable = vector({0})
          return DataSend, enable
      <!--Only writing DataSend to target when enable is greater than zero-->
      <probe ref="mySection.CommStream" conditional="true" />


The signal element is similar to the probe, but acts in the opposite direction. Creating a signal element allows you to access an external data source and integrate it into your simulation directly without the need for additional Lua scripting. For example, the following code would take the value from a slider and use it as an input to a feedback loop.

<slider name="myslider"/>
<simulation duration="10" name="sim" period="0.1">
            <signal ref="mysection.myslider"/>

This same method can be used to connect a button, text input, etc.