Connecting Blocks

When you initially create a simulation and define blocks, they are not connected together but independent elements in the simulation space. In order to connect the blocks and form your virtual block diagram, you need to define how the blocks are interconnected. There are several approaches that can be taken to wiring the blocks together.

Series

When blocks are placed into a series element, they are connected together in the order in which they are added to the block. For example, the following diagram shows how the elements in the following example would be connected:

series-blocks.jpg
<series>
    <transferFunction name="system1" num="1" den="1"/>
    <transferFunction name="system2" num="1" den="1"/>
    <transferFunction name="system3" num="1" den="1"/>
</series>

Parallel

The parallel elements behave in much the same way as the series elements, splitting a value between different paths, before combining them using a summation. The systems that are applied to the paths are connected in the order in which the elements appear in the parent. For example, to connect the same transferFunction elements in the earlier example you would change the series tags to parallel tags.

<parallel
    <transferFunction name="system1" num="1" den="1"/>
    <transferFunction name="system2" num="1" den="1"/>
    <transferFunction name="system3" num="1" den="1"/>
</parallel>
parallel-blocks.jpg

By default elements in parallel are added together. Elements can be subtracted or added by adjusting the polarity property, which indicates the polarity of each element being summed. The "+" symbol denotes positive polarity while the "-" symbol denotes negative polarity.

<parallel polarity="+--">
    <transferFunction name="system1" num="1" den="1"/>
    <transferFunction name="system2" num="1" den="1"/>
    <transferFunction name="system3" num="1" den="1"/>
</parallel>

Stack

The stack parental element can be used in a similar way to the parallel structure, but to separate values in parallel without the final summation block. For example, when combined with the demux and mux operators covered later in this guide, you can create systems that apply separate gains to separate elements in a vector like this:

<demux outputs="3"/>
<stack>
   <gain value="1"/>
   <gain value="2"/>
   <gain value="3"/>
</stack>
<mux inputs="3"/>

which translates into the following diagram

stack-blocks.jpg

Feedback

The feedback parent element is the final automated wiring option. The two elements that are placed into feedback blocks are treated as the open (or forward) loop element, and the feedback element in a closed-loop system. If only one element is provided, then it is treated as a closed-loop system with unity feedback. Feedback is negative by default. Take a look at the following code.

<feedback positive="true">
  <!-- Forward path -->
  <series>
      <!-- Controller -->
      <parallel>
          <gain name="Kp" value="20" />
          <series>
              <gain name="Kd" value="0.5" />
              <transferFunction name="derivative" num="1 0" den="1 100" />
          </series>
      </parallel>
      <!-- Plant -->
      <transferFunction name="plant" num="1" den="1 3 1" />
  </series>
</feedback>

Which creates the system below.

positive-feedback.jpg

Wire

The wire tool is a simple additional connection tool. When you create a wire element, you provide the signal that you want to form the connection from, and the connection that you want to to go to. The ports are formatted as follows:

<wire from="mySolver.mySystem.myPort.mySignal" ... />

If the signal is omitted, then the whole port is connected. If the port is left out, then the first port is connected. The system must be defined, but the solver also be left out as long as the connection is not made between multiple solvers. To connect ports to multiple destinations, a list of ports can be provided.