<?xml version="1.0" encoding="UTF-8"?>
<PoBlocks>
    <Project>
        <Reset_core_on_startup>true</Reset_core_on_startup>
        <Auto_reload_project>false</Auto_reload_project>
        <Target_device>0</Target_device>
        <Author></Author>
        <Auto_start>false</Auto_start>
        <Cycle_time>10</Cycle_time>
        <Project_name></Project_name>
        <Date></Date>
        <Disable_division_by_zero_exception>false</Disable_division_by_zero_exception>
        <BlocksCount>13</BlocksCount>
        <LinksCount>8</LinksCount>
    </Project>
    <Blocks>
        <block ID="0" type="1100" position="230/100">
            <Name>Switch to MPG mode</Name>
            <hideInputs>1</hideInputs>
            <hideOutputs>0</hideOutputs>
            <hideMemory_bits>1</hideMemory_bits>
            <hideMemory_int8>0</hideMemory_int8>
            <hideMemory_int16>0</hideMemory_int16>
            <hideMemory_int32>0</hideMemory_int32>
            <hideVariables>start : INPUT(1, bit)

tmpStart : bit</hideVariables>
            <hideCode># Check clock
LOAD start
STORE S

AND !tmpStart
POP tmpStart

CMPEQ DL[1]
JMPF cancelStart

# Switch to mode 10
LOAD DL[10]
STORE Bh0980

# Setup encoder 1 for x and encoder 2 for y axis
LOAD DL[1]
STORE Bh09A8
LOAD DL[2]
STORE Bh09A9

cancelStart:
</hideCode>
        </block>
        <block ID="1" type="1100" position="230/250">
            <Name>Multiplier 1</Name>
            <hideInputs>2</hideInputs>
            <hideOutputs>0</hideOutputs>
            <hideMemory_bits>1</hideMemory_bits>
            <hideMemory_int8>0</hideMemory_int8>
            <hideMemory_int16>0</hideMemory_int16>
            <hideMemory_int32>0</hideMemory_int32>
            <hideVariables>update : INPUT(1, bit)

mult : INPUT(2, int16)

tmpStart : bit</hideVariables>
            <hideCode># Check clock
LOAD update
STORE S

AND !tmpStart
POP tmpStart

CMPEQ DL[1]
JMPF cancelSwitch2

# Set the encoder multiplier
LOAD mult
STORE Wh09B0
STORE Wh09B2

cancelSwitch2:
</hideCode>
        </block>
        <block ID="2" type="0" position="40/100">
            <Name>MPG mode</Name>
            <Pin_ID>1</Pin_ID>
            <Init_function>true</Init_function>
            <Inverted>false</Inverted>
        </block>
        <block ID="3" type="0" position="40/240">
            <Name>Select multiplier 1</Name>
            <Pin_ID>2</Pin_ID>
            <Init_function>true</Init_function>
            <Inverted>false</Inverted>
        </block>
        <block ID="4" type="0" position="40/310">
            <Name>Select multiplier 2</Name>
            <Pin_ID>3</Pin_ID>
            <Init_function>true</Init_function>
            <Inverted>false</Inverted>
        </block>
        <block ID="5" type="1100" position="230/320">
            <Name>Multiplier 2</Name>
            <hideInputs>2</hideInputs>
            <hideOutputs>0</hideOutputs>
            <hideMemory_bits>1</hideMemory_bits>
            <hideMemory_int8>0</hideMemory_int8>
            <hideMemory_int16>0</hideMemory_int16>
            <hideMemory_int32>0</hideMemory_int32>
            <hideVariables>update : INPUT(1, bit)

mult : INPUT(2, int16)

tmpStart : bit</hideVariables>
            <hideCode># Check clock
LOAD update
STORE S

AND !tmpStart
POP tmpStart

CMPEQ DL[1]
JMPF cancelSwitch3

# Set the encoder multiplier
LOAD mult
STORE Wh09B0
STORE Wh09B2

cancelSwitch3:
</hideCode>
        </block>
        <block ID="6" type="1100" position="230/460">
            <Name>Multiplier 4</Name>
            <hideInputs>2</hideInputs>
            <hideOutputs>0</hideOutputs>
            <hideMemory_bits>1</hideMemory_bits>
            <hideMemory_int8>0</hideMemory_int8>
            <hideMemory_int16>0</hideMemory_int16>
            <hideMemory_int32>0</hideMemory_int32>
            <hideVariables>update : INPUT(1, bit)

mult : INPUT(2, int16)

tmpStart : bit</hideVariables>
            <hideCode># Check clock
LOAD update
STORE S

AND !tmpStart
POP tmpStart

CMPEQ DL[1]
JMPF cancelSwitch5

# Set the encoder multiplier
LOAD mult
STORE Wh09B0
STORE Wh09B2

cancelSwitch5:
</hideCode>
        </block>
        <block ID="7" type="0" position="40/450">
            <Name>Select multiplier 4</Name>
            <Pin_ID>5</Pin_ID>
            <Init_function>true</Init_function>
            <Inverted>false</Inverted>
        </block>
        <block ID="8" type="0" position="40/380">
            <Name>Select multiplier 3</Name>
            <Pin_ID>4</Pin_ID>
            <Init_function>true</Init_function>
            <Inverted>false</Inverted>
        </block>
        <block ID="9" type="1100" position="230/390">
            <Name>Multiplier 3</Name>
            <hideInputs>2</hideInputs>
            <hideOutputs>0</hideOutputs>
            <hideMemory_bits>1</hideMemory_bits>
            <hideMemory_int8>0</hideMemory_int8>
            <hideMemory_int16>0</hideMemory_int16>
            <hideMemory_int32>0</hideMemory_int32>
            <hideVariables>update : INPUT(1, bit)

mult : INPUT(2, int16)

tmpStart : bit</hideVariables>
            <hideCode># Check clock
LOAD update
STORE S

AND !tmpStart
POP tmpStart

CMPEQ DL[1]
JMPF cancelSwitch4

# Set the encoder multiplier
LOAD mult
STORE Wh09B0
STORE Wh09B2

cancelSwitch4:
</hideCode>
        </block>
        <block ID="10" type="500" position="140/100">
            <Name>Rising edge</Name>
        </block>
        <block ID="11" type="501" position="140/170">
            <Name>Falling edge</Name>
        </block>
        <block ID="12" type="1100" position="230/170">
            <Name>Switch off MPG mode</Name>
            <hideInputs>1</hideInputs>
            <hideOutputs>0</hideOutputs>
            <hideMemory_bits>1</hideMemory_bits>
            <hideMemory_int8>0</hideMemory_int8>
            <hideMemory_int16>0</hideMemory_int16>
            <hideMemory_int32>0</hideMemory_int32>
            <hideVariables>start : INPUT(1, bit)

tmpStart : bit</hideVariables>
            <hideCode># Check clock
LOAD start
STORE S

AND !tmpStart
POP tmpStart

CMPEQ DL[1]
JMPF cancelStart2

# Switch to mode 0
LOAD DL[0]
STORE Bh0980


cancelStart2:
</hideCode>
        </block>
    </Blocks>
    <Links>
        <link ID="0">
            <source type="port" blockID="3" portID="0"/>
            <destination blockID="1" portID="0"/>
            <anchors/>
        </link>
        <link ID="1">
            <source type="port" blockID="4" portID="0"/>
            <destination blockID="5" portID="0"/>
            <anchors/>
        </link>
        <link ID="2">
            <source type="port" blockID="8" portID="0"/>
            <destination blockID="9" portID="0"/>
            <anchors/>
        </link>
        <link ID="3">
            <source type="port" blockID="7" portID="0"/>
            <destination blockID="6" portID="0"/>
            <anchors/>
        </link>
        <link ID="4">
            <source type="port" blockID="2" portID="0"/>
            <destination blockID="10" portID="0"/>
            <anchors>
                <anchor ID="0" position="80/100"/>
            </anchors>
        </link>
        <link ID="5">
            <source type="port" blockID="10" portID="0"/>
            <destination blockID="0" portID="0"/>
            <anchors/>
        </link>
        <link ID="6">
            <source type="link" linkID="4" anchorID="0"/>
            <destination blockID="11" portID="0"/>
            <anchors/>
        </link>
        <link ID="7">
            <source type="port" blockID="11" portID="0"/>
            <destination blockID="12" portID="0"/>
            <anchors/>
        </link>
    </Links>
    <Constants>
        <constant blockID="1" portID="1" value="1"/>
        <constant blockID="5" portID="1" value="10"/>
        <constant blockID="6" portID="1" value="50"/>
        <constant blockID="9" portID="1" value="30"/>
    </Constants>
    <Shared/>
</PoBlocks>
