﻿<?xml version="1.0" encoding="utf-8"?>
<IngeniaMacros MotionLabVersion="v2.10.1">
  <Macro Number="1" Description="">
    <Functions>
      <Function Type="If" Comment="10: Check if the drive is in error" Active="True" Label="">
        <Condition>Register</Condition>
        <AnalogInput>AN1</AnalogInput>
        <DigitalInput>GPI1</DigitalInput>
        <RegisterIfIndex>0x2c00</RegisterIfIndex>
        <RegisterIfSubIndex>3</RegisterIfSubIndex>
        <ConditionValue>Equal</ConditionValue>
        <ConditionDigitalInput>On</ConditionDigitalInput>
        <ConditionMotor>Off</ConditionMotor>
        <Threshold>Constant</Threshold>
        <ConstantCondition>10</ConstantCondition>
        <RegisterConditionIndex>0x6040</RegisterConditionIndex>
        <RegisterConditionSubIndex>0x00</RegisterConditionSubIndex>
        <ActionThen>MacroContinue</ActionThen>
        <ActionMotorThen>MotorOn</ActionMotorThen>
        <MacroNumberThen>0</MacroNumberThen>
        <ActionElse>Jump</ActionElse>
        <MacroNumberElse>0</MacroNumberElse>
        <ThenJumpType>Instruction</ThenJumpType>
        <ThenInstructionNumber>0</ThenInstructionNumber>
        <ThenLabelName />
        <ElseJumpType>Label</ElseJumpType>
        <ElseInstructionNumber>0</ElseInstructionNumber>
        <ElseLabelName>EndIf10</ElseLabelName>
      </Function>
      <Function Type="SetVariable" Comment="0x4 = ErrorCheck" Active="True" Label="">
        <Index>0x2c00</Index>
        <SubIndex>0x4</SubIndex>
        <Operation>AND</Operation>
        <AddOperands>ConstantVariable</AddOperands>
        <MultiplyOperands>ConstantVariable</MultiplyOperands>
        <AndOperands>ConstantVariable</AndOperands>
        <OrOperands>ConstantVariable</OrOperands>
        <XorOperands>ConstantVariable</XorOperands>
        <SubtractOperands>ConstantVariable</SubtractOperands>
        <DivideOperands>ConstantVariable</DivideOperands>
        <ShiftLeftOperands>ConstantVariable</ShiftLeftOperands>
        <ShiftRightOperands>ConstantVariable</ShiftRightOperands>
        <ComplementOperands>Constant</ComplementOperands>
        <ConstantValue>8</ConstantValue>
        <Variable1Index>0x6041</Variable1Index>
        <Variable1SubIndex>0x00</Variable1SubIndex>
        <Variable2Index>0x2c00</Variable2Index>
        <Variable2SubIndex>0x04</Variable2SubIndex>
      </Function>
      <Function Type="If" Comment="Check if in error" Active="True" Label="">
        <Condition>Register</Condition>
        <AnalogInput>AN1</AnalogInput>
        <DigitalInput>GPI1</DigitalInput>
        <RegisterIfIndex>0x2c00</RegisterIfIndex>
        <RegisterIfSubIndex>0x4</RegisterIfSubIndex>
        <ConditionValue>Equal</ConditionValue>
        <ConditionDigitalInput>On</ConditionDigitalInput>
        <ConditionMotor>Off</ConditionMotor>
        <Threshold>Constant</Threshold>
        <ConstantCondition>8</ConstantCondition>
        <RegisterConditionIndex>0x6040</RegisterConditionIndex>
        <RegisterConditionSubIndex>0x00</RegisterConditionSubIndex>
        <ActionThen>MacroContinue</ActionThen>
        <ActionMotorThen>MotorOn</ActionMotorThen>
        <MacroNumberThen>0</MacroNumberThen>
        <ActionElse>Jump</ActionElse>
        <MacroNumberElse>0</MacroNumberElse>
        <ThenJumpType>Instruction</ThenJumpType>
        <ThenInstructionNumber>0</ThenInstructionNumber>
        <ThenLabelName />
        <ElseJumpType>Label</ElseJumpType>
        <ElseInstructionNumber>0</ElseInstructionNumber>
        <ElseLabelName>EndIf10</ElseLabelName>
      </Function>
      <Function Type="If" Comment="Check Error = Undervoltage. If not, go to end. " Active="True" Label="">
        <Condition>Register</Condition>
        <AnalogInput>AN1</AnalogInput>
        <DigitalInput>GPI1</DigitalInput>
        <RegisterIfIndex>0x603F</RegisterIfIndex>
        <RegisterIfSubIndex>0</RegisterIfSubIndex>
        <ConditionValue>Equal</ConditionValue>
        <ConditionDigitalInput>On</ConditionDigitalInput>
        <ConditionMotor>Off</ConditionMotor>
        <Threshold>Constant</Threshold>
        <ConstantCondition>0x3221</ConstantCondition>
        <RegisterConditionIndex>0x6040</RegisterConditionIndex>
        <RegisterConditionSubIndex>0x00</RegisterConditionSubIndex>
        <ActionThen>MacroContinue</ActionThen>
        <ActionMotorThen>MotorOn</ActionMotorThen>
        <MacroNumberThen>0</MacroNumberThen>
        <ActionElse>Jump</ActionElse>
        <MacroNumberElse>0</MacroNumberElse>
        <ThenJumpType>Instruction</ThenJumpType>
        <ThenInstructionNumber>0</ThenInstructionNumber>
        <ThenLabelName />
        <ElseJumpType>Label</ElseJumpType>
        <ElseInstructionNumber>0</ElseInstructionNumber>
        <ElseLabelName>End</ElseLabelName>
      </Function>
      <Function Type="SetVariable" Comment="Undervoltage detected, set state = 20" Active="True" Label="">
        <Index>0x2c00</Index>
        <SubIndex>3</SubIndex>
        <Operation>Constant</Operation>
        <AddOperands>ConstantVariable</AddOperands>
        <MultiplyOperands>ConstantVariable</MultiplyOperands>
        <AndOperands>ConstantVariable</AndOperands>
        <OrOperands>ConstantVariable</OrOperands>
        <XorOperands>ConstantVariable</XorOperands>
        <SubtractOperands>ConstantVariable</SubtractOperands>
        <DivideOperands>ConstantVariable</DivideOperands>
        <ShiftLeftOperands>ConstantVariable</ShiftLeftOperands>
        <ShiftRightOperands>ConstantVariable</ShiftRightOperands>
        <ComplementOperands>Constant</ComplementOperands>
        <ConstantValue>20</ConstantValue>
        <Variable1Index>0x2c00</Variable1Index>
        <Variable1SubIndex>0x03</Variable1SubIndex>
        <Variable2Index>0x2c00</Variable2Index>
        <Variable2SubIndex>0x04</Variable2SubIndex>
      </Function>
      <Function Type="If" Comment="20: Error detected, check voltage" Active="True" Label="EndIf10">
        <Condition>Register</Condition>
        <AnalogInput>AN1</AnalogInput>
        <DigitalInput>GPI1</DigitalInput>
        <RegisterIfIndex>0x2c00</RegisterIfIndex>
        <RegisterIfSubIndex>0x03</RegisterIfSubIndex>
        <ConditionValue>Equal</ConditionValue>
        <ConditionDigitalInput>On</ConditionDigitalInput>
        <ConditionMotor>Off</ConditionMotor>
        <Threshold>Constant</Threshold>
        <ConstantCondition>20</ConstantCondition>
        <RegisterConditionIndex>0x6040</RegisterConditionIndex>
        <RegisterConditionSubIndex>0x00</RegisterConditionSubIndex>
        <ActionThen>MacroContinue</ActionThen>
        <ActionMotorThen>MotorOn</ActionMotorThen>
        <MacroNumberThen>0</MacroNumberThen>
        <ActionElse>Jump</ActionElse>
        <MacroNumberElse>0</MacroNumberElse>
        <ThenJumpType>Instruction</ThenJumpType>
        <ThenInstructionNumber>0</ThenInstructionNumber>
        <ThenLabelName />
        <ElseJumpType>Label</ElseJumpType>
        <ElseInstructionNumber>0</ElseInstructionNumber>
        <ElseLabelName>End</ElseLabelName>
      </Function>
      <Function Type="SetVariable" Comment="0x5 = Min V + Threshold" Active="True" Label="">
        <Index>0x2c00</Index>
        <SubIndex>5</SubIndex>
        <Operation>Add</Operation>
        <AddOperands>ConstantVariable</AddOperands>
        <MultiplyOperands>ConstantVariable</MultiplyOperands>
        <AndOperands>ConstantVariable</AndOperands>
        <OrOperands>ConstantVariable</OrOperands>
        <XorOperands>ConstantVariable</XorOperands>
        <SubtractOperands>ConstantVariable</SubtractOperands>
        <DivideOperands>ConstantVariable</DivideOperands>
        <ShiftLeftOperands>ConstantVariable</ShiftLeftOperands>
        <ShiftRightOperands>ConstantVariable</ShiftRightOperands>
        <ComplementOperands>Constant</ComplementOperands>
        <ConstantValue>2500</ConstantValue>
        <Variable1Index>0x2101</Variable1Index>
        <Variable1SubIndex>0x03</Variable1SubIndex>
        <Variable2Index>0x2c00</Variable2Index>
        <Variable2SubIndex>0x04</Variable2SubIndex>
      </Function>
      <Function Type="If" Comment="If motor voltage resetted, enable motor" Active="True" Label="">
        <Condition>Register</Condition>
        <AnalogInput>AN1</AnalogInput>
        <DigitalInput>GPI1</DigitalInput>
        <RegisterIfIndex>0x2101</RegisterIfIndex>
        <RegisterIfSubIndex>0x1</RegisterIfSubIndex>
        <ConditionValue>Higher</ConditionValue>
        <ConditionDigitalInput>On</ConditionDigitalInput>
        <ConditionMotor>Off</ConditionMotor>
        <Threshold>Register</Threshold>
        <ConstantCondition>0</ConstantCondition>
        <RegisterConditionIndex>0x2c00</RegisterConditionIndex>
        <RegisterConditionSubIndex>0x05</RegisterConditionSubIndex>
        <ActionThen>MacroContinue</ActionThen>
        <ActionMotorThen>MotorOn</ActionMotorThen>
        <MacroNumberThen>0</MacroNumberThen>
        <ActionElse>Jump</ActionElse>
        <MacroNumberElse>0</MacroNumberElse>
        <ThenJumpType>Instruction</ThenJumpType>
        <ThenInstructionNumber>0</ThenInstructionNumber>
        <ThenLabelName />
        <ElseJumpType>Label</ElseJumpType>
        <ElseInstructionNumber>0</ElseInstructionNumber>
        <ElseLabelName>End</ElseLabelName>
      </Function>
      <Function Type="SetVariable" Comment="Fault reset" Active="True" Label="">
        <Index>0x6040</Index>
        <SubIndex>0x00</SubIndex>
        <Operation>Constant</Operation>
        <AddOperands>ConstantVariable</AddOperands>
        <MultiplyOperands>ConstantVariable</MultiplyOperands>
        <AndOperands>ConstantVariable</AndOperands>
        <OrOperands>ConstantVariable</OrOperands>
        <XorOperands>ConstantVariable</XorOperands>
        <SubtractOperands>ConstantVariable</SubtractOperands>
        <DivideOperands>ConstantVariable</DivideOperands>
        <ShiftLeftOperands>ConstantVariable</ShiftLeftOperands>
        <ShiftRightOperands>ConstantVariable</ShiftRightOperands>
        <ComplementOperands>Constant</ComplementOperands>
        <ConstantValue>128</ConstantValue>
        <Variable1Index>0x2c00</Variable1Index>
        <Variable1SubIndex>0x03</Variable1SubIndex>
        <Variable2Index>0x2c00</Variable2Index>
        <Variable2SubIndex>0x04</Variable2SubIndex>
      </Function>
      <Function Type="SetVariable" Comment="Drive shutdown status" Active="True" Label="">
        <Index>0x6040</Index>
        <SubIndex>0x00</SubIndex>
        <Operation>Constant</Operation>
        <AddOperands>ConstantVariable</AddOperands>
        <MultiplyOperands>ConstantVariable</MultiplyOperands>
        <AndOperands>ConstantVariable</AndOperands>
        <OrOperands>ConstantVariable</OrOperands>
        <XorOperands>ConstantVariable</XorOperands>
        <SubtractOperands>ConstantVariable</SubtractOperands>
        <DivideOperands>ConstantVariable</DivideOperands>
        <ShiftLeftOperands>ConstantVariable</ShiftLeftOperands>
        <ShiftRightOperands>ConstantVariable</ShiftRightOperands>
        <ComplementOperands>Constant</ComplementOperands>
        <ConstantValue>6</ConstantValue>
        <Variable1Index>0x2c00</Variable1Index>
        <Variable1SubIndex>0x03</Variable1SubIndex>
        <Variable2Index>0x2c00</Variable2Index>
        <Variable2SubIndex>0x04</Variable2SubIndex>
      </Function>
      <Function Type="SetVariable" Comment="Drive Switch on status" Active="True" Label="">
        <Index>0x6040</Index>
        <SubIndex>0x00</SubIndex>
        <Operation>Constant</Operation>
        <AddOperands>ConstantVariable</AddOperands>
        <MultiplyOperands>ConstantVariable</MultiplyOperands>
        <AndOperands>ConstantVariable</AndOperands>
        <OrOperands>ConstantVariable</OrOperands>
        <XorOperands>ConstantVariable</XorOperands>
        <SubtractOperands>ConstantVariable</SubtractOperands>
        <DivideOperands>ConstantVariable</DivideOperands>
        <ShiftLeftOperands>ConstantVariable</ShiftLeftOperands>
        <ShiftRightOperands>ConstantVariable</ShiftRightOperands>
        <ComplementOperands>Constant</ComplementOperands>
        <ConstantValue>7</ConstantValue>
        <Variable1Index>0x2c00</Variable1Index>
        <Variable1SubIndex>0x03</Variable1SubIndex>
        <Variable2Index>0x2c00</Variable2Index>
        <Variable2SubIndex>0x04</Variable2SubIndex>
      </Function>
      <Function Type="SetVariable" Comment="Drive motor enable" Active="True" Label="">
        <Index>0x6040</Index>
        <SubIndex>0x00</SubIndex>
        <Operation>Constant</Operation>
        <AddOperands>ConstantVariable</AddOperands>
        <MultiplyOperands>ConstantVariable</MultiplyOperands>
        <AndOperands>ConstantVariable</AndOperands>
        <OrOperands>ConstantVariable</OrOperands>
        <XorOperands>ConstantVariable</XorOperands>
        <SubtractOperands>ConstantVariable</SubtractOperands>
        <DivideOperands>ConstantVariable</DivideOperands>
        <ShiftLeftOperands>ConstantVariable</ShiftLeftOperands>
        <ShiftRightOperands>ConstantVariable</ShiftRightOperands>
        <ComplementOperands>Constant</ComplementOperands>
        <ConstantValue>15</ConstantValue>
        <Variable1Index>0x2c00</Variable1Index>
        <Variable1SubIndex>0x03</Variable1SubIndex>
        <Variable2Index>0x2c00</Variable2Index>
        <Variable2SubIndex>0x04</Variable2SubIndex>
      </Function>
      <Function Type="SetVariable" Comment="Back to state 10" Active="True" Label="">
        <Index>0x2c00</Index>
        <SubIndex>0x03</SubIndex>
        <Operation>Constant</Operation>
        <AddOperands>ConstantVariable</AddOperands>
        <MultiplyOperands>ConstantVariable</MultiplyOperands>
        <AndOperands>ConstantVariable</AndOperands>
        <OrOperands>ConstantVariable</OrOperands>
        <XorOperands>ConstantVariable</XorOperands>
        <SubtractOperands>ConstantVariable</SubtractOperands>
        <DivideOperands>ConstantVariable</DivideOperands>
        <ShiftLeftOperands>ConstantVariable</ShiftLeftOperands>
        <ShiftRightOperands>ConstantVariable</ShiftRightOperands>
        <ComplementOperands>Constant</ComplementOperands>
        <ConstantValue>10</ConstantValue>
        <Variable1Index>0x2c00</Variable1Index>
        <Variable1SubIndex>0x03</Variable1SubIndex>
        <Variable2Index>0x2c00</Variable2Index>
        <Variable2SubIndex>0x04</Variable2SubIndex>
      </Function>
      <Function Type="Jump" Comment="" Active="True" Label="End">
        <JumpType>Instruction</JumpType>
        <InstructionNumber>0</InstructionNumber>
        <LabelName />
      </Function>
    </Functions>
  </Macro>
</IngeniaMacros>