<?xml version="1.0" encoding="UTF-8"?>
<net name="test_qe" type="iopt-flow">
  <component id="c1" class="local/qe.xml" x="500" y="135" width="130" height="100" rot="0" implementation="iopt-flow">
    <name off_x="-65" off_y="-55" text="rot_qe"/>
    <source_model file="files/qe.xml"/>
    <input id="c1.Rst" name="Rst" type="event" off_x="-65" off_y="-30" microstep="0" nano-step="1"/>
    <input id="c1.ChA" name="ChA" off_x="-65" off_y="-10" type="boolean" microstep="0" nano-step="3"/>
    <input id="c1.ChB" name="ChB" off_x="-65" off_y="10" type="boolean" microstep="0" nano-step="3"/>
    <input id="c1.X4" name="X4" off_x="-65" off_y="30" type="boolean" microstep="0" nano-step="1"/>
    <output id="c1.Cntr" name="Cntr" off_x="65" off_y="-30" type="range" min="0" max="1023" microstep="0" nano-step="1"/>
  </component>
  <component id="c2" class="local/qe.xml" x="500" y="310" width="130" height="100" rot="0" implementation="iopt-flow">
    <name off_x="-65" off_y="-55" text="mtr_qe"/>
    <source_model file="files/qe.xml"/>
    <input id="c2.Rst" name="Rst" type="event" off_x="-65" off_y="-30" microstep="0" nano-step="1"/>
    <input id="c2.ChA" name="ChA" off_x="-65" off_y="-10" type="boolean" microstep="0" nano-step="5"/>
    <input id="c2.ChB" name="ChB" off_x="-65" off_y="10" type="boolean" microstep="0" nano-step="5"/>
    <input id="c2.X4" name="X4" off_x="-65" off_y="30" type="boolean" microstep="0" nano-step="1"/>
    <output id="c2.Cntr" name="Cntr" off_x="65" off_y="-30" type="range" min="0" max="1023" microstep="0" nano-step="1"/>
  </component>
  <component id="c3" class="local/nfilter.xml" x="285" y="110" width="100" height="40" rot="0" implementation="iopt-flow">
    <name off_x="-50" off_y="-25" text="nfilter_ra"/>
    <source_model file="files/nfilter.xml"/>
    <input id="c3.SIG" name="SIG" off_x="-50" off_y="0" type="boolean" microstep="0" nano-step="1"/>
    <output id="c3.FSIG" name="FSIG" off_x="50" off_y="0" type="boolean" microstep="0" nano-step="2"/>
  </component>
  <component id="c4" class="local/nfilter.xml" x="285" y="165" width="100" height="40" rot="0" implementation="iopt-flow">
    <name off_x="-50" off_y="-25" text="nfilter_rb"/>
    <source_model file="files/nfilter.xml"/>
    <input id="c4.SIG" name="SIG" off_x="-50" off_y="0" type="boolean" microstep="0" nano-step="1"/>
    <output id="c4.FSIG" name="FSIG" off_x="50" off_y="0" type="boolean" microstep="0" nano-step="2"/>
  </component>
  <component id="c5" class="local/nfilter.xml" x="325" y="260" width="100" height="40" rot="0" implementation="iopt-flow">
    <name off_x="-50" off_y="-25" text="nfilter_ma"/>
    <source_model file="files/nfilter.xml"/>
    <input id="c5.SIG" name="SIG" off_x="-50" off_y="0" type="boolean" microstep="0" nano-step="3"/>
    <output id="c5.FSIG" name="FSIG" off_x="50" off_y="0" type="boolean" microstep="0" nano-step="4"/>
  </component>
  <component id="c6" class="local/nfilter.xml" x="325" y="355" width="100" height="40" rot="0" implementation="iopt-flow">
    <name off_x="-50" off_y="-25" text="nfilter_mb"/>
    <source_model file="files/nfilter.xml"/>
    <input id="c6.SIG" name="SIG" off_x="-50" off_y="0" type="boolean" microstep="0" nano-step="3"/>
    <output id="c6.FSIG" name="FSIG" off_x="50" off_y="0" type="boolean" microstep="0" nano-step="4"/>
  </component>
  <component id="c7" class="local/diff_in.xml" x="175" y="270" width="110" height="60" rot="0" implementation="iopt-flow">
    <name off_x="-55" off_y="-35" text="diff_in_ma"/>
    <source_model file="files/diff_in.xml"/>
    <input id="c7.I_P" name="I_P" off_x="-55" off_y="-10" type="boolean" microstep="0" nano-step="1"/>
    <input id="c7.I_N" name="I_N" off_x="-55" off_y="10" type="boolean" microstep="0" nano-step="1"/>
    <output id="c7.O" name="O" off_x="55" off_y="-10" type="boolean" microstep="0" nano-step="2"/>
  </component>
  <component id="c8" class="local/diff_in.xml" x="175" y="365" width="110" height="60" rot="0" implementation="iopt-flow">
    <name off_x="-55" off_y="-35" text="diff_in_mb"/>
    <source_model file="files/diff_in.xml"/>
    <input id="c8.I_P" name="I_P" off_x="-55" off_y="-10" type="boolean" microstep="0" nano-step="1"/>
    <input id="c8.I_N" name="I_N" off_x="-55" off_y="10" type="boolean" microstep="0" nano-step="1"/>
    <output id="c8.O" name="O" off_x="55" off_y="-10" type="boolean" microstep="0" nano-step="2"/>
  </component>
  <arc id="a9" type="read" source="c4.FSIG" target="c1.ChB"/>
  <arc id="a10" type="read" source="c3.FSIG" target="c1.ChA"/>
  <arc id="a11" type="read" source="c7.O" target="c5.SIG"/>
  <arc id="a12" type="read" source="c8.O" target="c6.SIG"/>
  <arc id="a13" type="read" source="c6.FSIG" target="c2.ChB"/>
  <arc id="a14" type="read" source="c5.FSIG" target="c2.ChA"/>
  <event id="Rst" x="55" y="45" mode="input" microstep="0" nano-step="0"/>
  <arc id="a16" type="read" source="Rst" target="c1.Rst" view="symbolic"/>
  <arc id="a17" type="read" source="Rst" target="c2.Rst" view="symbolic"/>
  <signal id="RotA" x="50" y="110" mode="input" type="boolean" min="0" max="1" microstep="0" nano-step="0"/>
  <signal id="RotB" x="50" y="165" mode="input" type="boolean" min="0" max="1" microstep="0" nano-step="0"/>
  <signal id="MQEA_H" x="65" y="260" mode="input" type="boolean" min="0" max="1" microstep="0" nano-step="0"/>
  <arc id="a21" type="read" source="RotA" target="c3.SIG"/>
  <arc id="a22" type="read" source="RotB" target="c4.SIG"/>
  <signal id="MQEA_L" x="40" y="280" mode="input" type="boolean" min="0" max="1" microstep="0" nano-step="0"/>
  <arc id="a24" type="read" source="MQEA_H" target="c7.I_P"/>
  <arc id="a25" type="read" source="MQEA_L" target="c7.I_N"/>
  <signal id="MQEB_H" x="65" y="355" mode="input" type="boolean" min="0" max="1" microstep="0" nano-step="0"/>
  <signal id="MQEB_L" x="45" y="375" mode="input" type="boolean" min="0" max="1" microstep="0" nano-step="0"/>
  <arc id="a28" type="read" source="MQEB_L" target="c8.I_N"/>
  <arc id="a29" type="read" source="MQEB_H" target="c8.I_P"/>
  <operation id="o30" x="380" y="190" constant="1" rot="0" shape="rect" size="20" locked="true">
    <name off_x="-15" off_y="-5" text="1"/>
    <output off_x="20" off_y="0" name="K" id="o30.K" type="range" min="1" max="1" dynamic="none" microstep="0" nano-step="1">
      <expression>
        <text>1</text>
        <operand type="literal" value="1"/>
      </expression>
    </output>
  </operation>
  <arc id="a31" type="read" source="o30.K" target="c1.X4"/>
  <operation id="o32" x="355" y="400" constant="0" rot="0" shape="rect" size="20" locked="true">
    <name off_x="-15" off_y="-5" text="0"/>
    <output off_x="20" off_y="0" name="K" id="o32.K" type="range" min="0" max="0" dynamic="none" microstep="0" nano-step="1">
      <expression>
        <text>0</text>
        <operand type="literal" value="0"/>
      </expression>
    </output>
  </operation>
  <arc id="a33" type="read" source="o32.K" target="c2.X4"/>
  <operation id="o34" x="645" y="195" rot="0" shape="arrow" size="24">
    <name off_x="-10" off_y="-25" text="sub"/>
    <input off_x="-24" off_y="-8" name="Ref" id="o34.Ref" type="range" min="0" max="1023" frac="0"/>
    <input off_x="-24" off_y="8" name="Sens" id="o34.Sens" type="range" min="0" max="1023" frac="0"/>
    <output off_x="24" off_y="0" name="out" id="o34.out" type="range" min="-1023" max="1023" dynamic="none" frac="0" microstep="0" nano-step="2">
      <expression>
        <operand type="signal" idRef="Sens"/>
        <operator type="sub"/>
        <operand type="signal" idRef="Ref"/>
        <text>Sens - Ref</text>
      </expression>
    </output>
  </operation>
  <arc id="a35" type="read" source="c1.Cntr" target="o34.Ref"/>
  <arc id="a36" type="read" source="c2.Cntr" target="o34.Sens"/>
  <signal id="Error" x="895" y="195" mode="output" type="range" min="-127" max="127" dynamic="type" frac="0" microstep="0" nano-step="3" value="0" io_pin="0"/>
  <operation id="o39" x="740" y="195" rot="0" shape="arrow" size="16">
    <name off_x="-10" off_y="-15" text="diff"/>
    <input off_x="-16" off_y="0" name="S" id="o39.S" type="range" min="-1023" max="1023" dynamic="type" frac="0"/>
    <output off_x="16" off_y="0" name="out" id="o39.out" type="range" min="-511" max="511" dynamic="none" frac="0" microstep="0" nano-step="3">
      <expression>
        <operand type="signal" idRef="S"/>
        <operator type="add"/>
        <operand type="literal" value="1024"/>
        <operator type="when"/>
        <operand type="sub-expression">
          <operand type="signal" idRef="S"/>
          <operator type="less-or-equal"/>
          <operand type="literal" value="-512"/>
        </operand>
        <text>S + 1024 WHEN (S &lt;= -512)</text>
      </expression>
      <expression>
        <operand type="signal" idRef="S"/>
        <operator type="sub"/>
        <operand type="literal" value="1024"/>
        <operator type="when"/>
        <operand type="sub-expression">
          <operand type="signal" idRef="S"/>
          <operator type="more-or-equal"/>
          <operand type="literal" value="512"/>
        </operand>
        <text>S - 1024 WHEN (S &gt;= 512)</text>
      </expression>
      <expression>
        <operand type="signal" idRef="S"/>
        <text>S OTHERWISE</text>
      </expression>
    </output>
  </operation>
  <arc id="a40" type="read" source="o34.out" target="o39.S"/>
  <signal id="Enc1" x="895" y="105" mode="output" type="range" min="0" max="1023" dynamic="type"/>
  <signal id="Enc2" x="895" y="280" mode="output" type="range" min="0" max="1023" dynamic="type"/>
  <arc id="a3" type="read" source="c1.Cntr" target="Enc1"/>
  <arc id="a4" type="read" source="c2.Cntr" target="Enc2"/>
  <signal id="E512" x="790" y="135" mode="output" type="range" min="-511" max="511" dynamic="type" frac="0"/>
  <arc id="a2" type="read" source="o39.out" target="E512"/>
  <operation id="o3" x="820" y="195" rot="0" shape="arrow" size="16">
    <name off_x="-5" off_y="-15" text="reg"/>
    <input off_x="-16" off_y="0" name="diff" id="o3.diff" type="range" min="-511" max="511" dynamic="all" frac="0"/>
    <output off_x="16" off_y="0" name="out" id="o3.out" type="range" min="-127" max="127" dynamic="none" frac="0">
      <expression>
        <operand type="signal" idRef="diff" delay="1"/>
        <text>diff[-1]</text>
      </expression>
    </output>
  </operation>
  <arc id="a5" type="read" source="o39.out" target="o3.diff"/>
  <arc id="a6" type="read" source="o3.out" target="Error"/>
  <operation id="o1" x="1055" y="185" rot="0" shape="arrow" size="24">
    <name off_x="-14" off_y="-24" text="P"/>
    <input off_x="-24" off_y="-8" name="Kp" id="o1.Kp" type="range" min="0" max="127" frac="0"/>
    <input off_x="-24" off_y="8" name="Error" id="o1.Error" type="range" min="-127" max="127" dynamic="all" frac="0"/>
    <output off_x="24" off_y="0" name="out" id="o1.out" type="range" min="-16384" max="16383" dynamic="none" frac="0">
      <expression>
        <operand type="signal" idRef="Kp"/>
        <operator type="mul"/>
        <operand type="signal" idRef="Error"/>
        <text>Kp * Error</text>
      </expression>
    </output>
  </operation>
  <operation id="o2" x="950" y="165" constant="32" rot="0" shape="rect" size="20" locked="true">
    <name off_x="-15" off_y="-5" text="32"/>
    <output off_x="20" off_y="0" name="K" id="o2.K" type="range" min="32" max="32" dynamic="none">
      <expression>
        <text>32</text>
        <operand type="literal" value="32"/>
      </expression>
    </output>
  </operation>
  <arc id="a7" type="read" source="o2.K" target="o1.Kp"/>
  <arc id="a8" type="read" source="Error" target="o1.Error"/>
  <operation id="o9" x="1220" y="125" rot="0" shape="arrow" size="16">
    <name off_x="-6" off_y="-16" text="SetDir"/>
    <input off_x="-16" off_y="0" name="P" id="o9.P" type="range" min="-16384" max="16383" dynamic="type" frac="0"/>
    <output off_x="16" off_y="0" name="D" id="o9.D" type="boolean" min="0" max="1" dynamic="none" frac="0">
      <expression>
        <operand type="signal" idRef="P"/>
        <operator type="less"/>
        <operand type="literal" value="0"/>
        <text>P &lt; 0</text>
      </expression>
    </output>
  </operation>
  <arc id="a18" type="read" source="o1.out" target="o9.P"/>
  <operation id="o19" x="1220" y="245" rot="0" shape="arrow" size="16">
    <name off_x="-6" off_y="-16" text="ABS"/>
    <input off_x="-16" off_y="0" name="P" id="o19.P" type="range" min="-16384" max="16383" dynamic="type" frac="0"/>
    <output off_x="16" off_y="0" name="O" id="o19.O" type="range" min="0" max="16383" dynamic="none" frac="0">
      <expression>
        <operand type="signal" idRef="P" sign="-1"/>
        <operator type="when"/>
        <operand type="sub-expression">
          <operand type="signal" idRef="P"/>
          <operator type="less"/>
          <operand type="literal" value="0"/>
        </operand>
        <text>-P WHEN (P &lt; 0)</text>
      </expression>
      <expression>
        <operand type="signal" idRef="P"/>
        <text>P OTHERWISE</text>
      </expression>
    </output>
  </operation>
  <arc id="a20" type="read" source="o1.out" target="o19.P"/>
  <operation id="o21" x="1305" y="245" rot="0" shape="arrow" size="16">
    <name off_x="-6" off_y="-16" text="Div"/>
    <input off_x="-16" off_y="0" name="O" id="o21.O" type="range" min="0" max="16383" dynamic="type" frac="0"/>
    <output off_x="16" off_y="0" name="out" id="o21.out" type="range" min="0" max="1023" dynamic="none" frac="0">
      <expression>
        <operand type="signal" idRef="O" delay="1"/>
        <operator type="div"/>
        <operand type="literal" value="16"/>
        <text>O[-1] / 16</text>
      </expression>
    </output>
  </operation>
  <arc id="a23" type="read" source="o19.O" target="o21.O"/>
  <signal id="Dir" x="1370" y="125" mode="output" type="boolean" min="0" max="1" dynamic="type" frac="0"/>
  <arc id="a26" type="read" source="o9.D" target="Dir"/>
  <signal id="OutDC" x="1375" y="245" mode="output" type="range" min="0" max="1023" dynamic="type" frac="0"/>
  <arc id="a30" type="read" source="o21.out" target="OutDC"/>
</net>
