<?xml version="1.0" encoding="UTF-8"?>

<ExportedUserProgram
    Version="1.0.0">
   <VariableTable>
   <Variable
       Offset="0"
       TagName="CyclesSP0"
       Format="REAL"
       Retain="True"
       DefaultValue="0"
       Description="Station 1 Cycles Setpoint (Auto Mode)"/>
   <Variable
       Offset="1"
       TagName="PrsUpSp0"
       Format="REAL"
       Retain="True"
       DefaultValue="0"
       Description="Station 1 Pressure Ramp Up Setpoint (Auto Mode)"/>
   <Variable
       Offset="4"
       TagName="CycleComp0"
       Format="REAL"
       Retain="True"
       DefaultValue="0"
       Description="Station 1 Cycles Completed (Auto Mode)"/>
   <Variable
       Offset="5"
       TagName="CycleRem0"
       Format="REAL"
       Retain="True"
       DefaultValue="0"
       Description="Station 1 Cycles Remaining (Auto Mode)"/>
   <Variable
       Offset="15"
       TagName="rampTime0"
       Format="REAL"
       Retain="True"
       DefaultValue="0.2"
       Description="Station 1 Ramp Up/Down Time (Auto Mode)"/>
   <Variable
       Offset="51"
       TagName="Sta1CyclesCompleted"
       Format="REAL"
       Retain="True"
       DefaultValue="0"
       Description="Station 1 Cycles Completed (Test is done)"/>
   <Variable
       Offset="256"
       TagName="HoldUpTimeSP0"
       Format="DINT"
       Retain="True"
       DefaultValue="0"
       Description="Station 1 Hold Pressure Up time"/>
   <Variable
       Offset="257"
       TagName="HoldDwnTimeSP0"
       Format="DINT"
       Retain="True"
       DefaultValue="0"
       Description="Station 1 Hold Pressure Down time"/>
   <Variable
       Offset="768"
       TagName="Timer0"
       Format="DINT"
       Retain="True"
       DefaultValue="0"
       Description="0"/>
</VariableTable>
   <DiscreteIO/>
   <UserProgram
    Name="Sta1CycleBothPortsAuto"
    Type="STEP"
    Number="1"
    Desc=""
    SingleInstance="True"
    TaskMask="32767">
   <ProgramBlock
       Type="STEP">
      <Comment
          Comment="Initialize cycles completed to 0 if needed"/>
      <Step>
         <Expression
             Src="IF CycleComp0 = CyclesSP0 THEN &#13;&#10;CycleComp0 := 0.0;&#13;&#10;END_IF"/>
      </Step>
      <Transition>
         <Jump
             Type="JUMP"
             Next="Next"/>
      </Transition>
   </ProgramBlock>
   <ProgramBlock
       Type="STEP"
       Label="InitializeAxis0_BothPorts">
      <Comment
          Comment="Set the PF orientation so that the controller knows which pressure transducer is its feedback (2 pressure transducers are used)."/>
      <Step>
         <Command
             Command="10"
             CmdAxes="1"
             CmdPrm1="0.0"
             CmdPrm2="1000.0"/>
         <Command
             Command="0"
             CmdAxesExpr="_Axis[0].PriControlBits.PFOrientation:=0;"/>
      </Step>
      <Transition>
         <Jump
             Type="JUMP"
             Next="Next"/>
      </Transition>
   </ProgramBlock>
   <ProgramBlock
       Type="STEP">
      <Comment
          Comment="Set control direction to POS (0-10V)."/>
      <Step>
         <Command
             Command="96"
             CmdAxes="1"
             CmdPrm1="Pos (+1)"/>
      </Step>
      <Transition>
         <Jump
             Type="JUMP"
             Next="Next"/>
      </Transition>
   </ProgramBlock>
   <ProgramBlock
       Type="STEP"
       Label="RampUpAPortAxis0_BothPorts">
      <Comment
          Comment="Ramp hydraulic pressure to the A-port of the servo valve (0 to +10V)"/>
      <Step>
         <Command
             Command="45"
             CmdAxes="1"
             CmdPrm1="PrsUpSp0"
             CmdPrm2="S-curve (1)"
             CmdPrm3="rampTime0"
             CmdPrm4="0.0"/>
      </Step>
      <Transition>
         <CheckCondition
             Type="IF-THEN"
             Condition="_Axis[0].ActPrs &gt;= PrsUpSp0;"
             True="Next"/>
      </Transition>
   </ProgramBlock>
   <ProgramBlock
       Type="STEP"
       Label="HoldOnTime_BothPorts">
      <Comment
          Comment="Hold the pressure of X-amount of time"/>
      <Step>
         <Expression
             Src="Timer0 := _SysMS;"/>
      </Step>
      <Transition>
         <CheckCondition
             Type="CASE-ELSE"
             Condition="_SysMS - Timer0 &gt;= (HoldUpTimeSP0 - 1);"
             True="Next"
             False="Wait"/>
      </Transition>
   </ProgramBlock>
   <ProgramBlock
       Type="STEP"
       Label="ReverseControlDirectionAxis0_BothPorts">
      <Comment
          Comment="Set PF Orientation = 1. &#32;This tells the controller to use the other pressure transducer as its feedback."/>
      <Step>
         <Command
             Command="10"
             CmdAxes="1"
             CmdPrm1="0.0"
             CmdPrm2="1000.0"/>
         <Command
             Command="0"
             CmdAxesExpr="_Axis[0].PriControlBits.PFOrientation:=1;"/>
      </Step>
      <Transition>
         <Jump
             Type="JUMP"
             Next="Next"/>
      </Transition>
   </ProgramBlock>
   <ProgramBlock
       Type="STEP">
      <Comment
          Comment="Set the control direction to NEG (0 to -10V)"/>
      <Step>
         <Command
             Command="96"
             CmdAxes="1"
             CmdPrm1="Neg (-1)"/>
      </Step>
      <Transition>
         <Jump
             Type="JUMP"
             Next="Next"/>
      </Transition>
   </ProgramBlock>
   <ProgramBlock
       Type="STEP">
      <Comment
          Comment="Ramp pressure to the B-port of the servo valve (0 to -10V)."/>
      <Step>
         <Command
             Command="45"
             CmdAxes="1"
             CmdPrm1="PrsUpSp0"
             CmdPrm2="Linear (0)"
             CmdPrm3="rampTime0"
             CmdPrm4="0.0"/>
      </Step>
      <Transition>
         <CheckCondition
             Type="IF-THEN"
             Condition="_Axis[0].ActPrs &gt;= PrsUpSp0;"
             True="Next"/>
      </Transition>
   </ProgramBlock>
   <ProgramBlock
       Type="STEP">
      <Comment
          Comment="Hold pressure for X-amount of time"/>
      <Step>
         <Expression
             Src="Timer0 := _SysMS;"/>
      </Step>
      <Transition>
         <CheckCondition
             Type="CASE-ELSE"
             Condition="_SysMS - Timer0 &gt;= (HoldDwnTimeSP0 - 1);"
             True="Next"
             False="Wait"/>
      </Transition>
   </ProgramBlock>
   <ProgramBlock
       Type="STEP">
      <Comment
          Comment="Bring servo valve spool back to neutral position"/>
      <Step>
         <Command
             Command="10"
             CmdAxes="1"
             CmdPrm1="0.0"
             CmdPrm2="2000.0"/>
      </Step>
      <Transition>
         <Jump
             Type="JUMP"
             Next="Next"/>
      </Transition>
   </ProgramBlock>
   <ProgramBlock
       Type="STEP"
       Label="IncrementCycleCountAxis0_BothPorts">
      <Step>
         <Expression
             Src="CycleComp0 := CycleComp0 + 1.0;&#13;&#10;CycleRem0 := CyclesSP0 - CycleComp0;&#13;&#10;&#13;&#10;IF CycleComp0 = CyclesSP0 THEN&#13;&#10;Sta1CyclesCompleted := 1.0;&#13;&#10; ELSE&#13;&#10;Sta1CyclesCompleted := 0.0;&#13;&#10;END_IF"/>
      </Step>
      <Transition>
         <Jump
             Type="JUMP"
             Next="Next"/>
      </Transition>
   </ProgramBlock>
   <ProgramBlock
       Type="STEP">
      <Step/>
      <Transition>
         <CheckCondition
             Type="CASE-ELSE"
             Condition="CycleComp0 = CyclesSP0"
             True="Next"
             False="InitializeAxis0_BothPorts"/>
      </Transition>
   </ProgramBlock>
   <ProgramBlock
       Type="STEP">
      <Step>
         <Command
             Command="22"
             CmdAxes="1"
             CmdPrm1="2000.0"/>
      </Step>
      <Transition>
         <End/>
      </Transition>
   </ProgramBlock>
</UserProgram>
</ExportedUserProgram>
