﻿<?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://www.plcopen.org/xml/tc6_0200">
  <fileHeader companyName="Rexroth" productName="ctrlX PLC Engineering" productVersion="ctrlX PLC 3.6.1" creationDateTime="2025-07-01T20:13:32.8325797" />
  <contentHeader name="SyncMotion_Workshop_Cam_3V06b.project" modificationDateTime="2025-07-01T20:11:39.967272">
    <coordinateInfo>
      <fbd>
        <scaling x="1" y="1" />
      </fbd>
      <ld>
        <scaling x="1" y="1" />
      </ld>
      <sfc>
        <scaling x="1" y="1" />
      </sfc>
    </coordinateInfo>
    <addData>
      <data name="http://www.3s-software.com/plcopenxml/projectinformation" handleUnknown="implementation">
        <ProjectInformation />
      </data>
    </addData>
  </contentHeader>
  <types>
    <dataTypes>
      <dataType name="ProbeShotType">
        <baseType>
          <enum>
            <values>
              <value name="SINGLE_SHOT" value="0" />
              <value name="CONTINUOUS" value="1" />
            </values>
          </enum>
        </baseType>
        <addData>
          <data name="http://www.3s-software.com/plcopenxml/objectid" handleUnknown="discard">
            <ObjectId>f62b64d6-1185-4cb3-b190-76ed48c49da2</ObjectId>
          </data>
        </addData>
      </dataType>
      <dataType name="ProbeSignalSelect">
        <baseType>
          <enum>
            <values>
              <value name="UNDEFINED" value="0" />
              <value name="ENCODER_1" value="1" />
              <value name="ENCODER_2" value="2" />
              <value name="FINE_TIME" value="3" />
              <value name="IPO_POS" value="4" />
              <value name="ACT_POS" value="5" />
              <value name="MOTION_INTERNAL_DATA" value="6" />
            </values>
          </enum>
        </baseType>
        <addData>
          <data name="http://www.3s-software.com/plcopenxml/objectid" handleUnknown="discard">
            <ObjectId>2df6a6eb-7ea9-4816-92cd-91b57f670dd3</ObjectId>
          </data>
        </addData>
      </dataType>
      <dataType name="ProbeSignalSelectEx">
        <baseType>
          <enum>
            <values>
              <value name="NONE" value="0" />
              <value name="MASTER_AXIS_POSITION" value="1" />
              <value name="RESULTING_MASTER_AXIS_POSITION" value="2" />
              <value name="EFFECTIVE_MASTER_AXIS_POSITION" value="3" />
            </values>
          </enum>
        </baseType>
        <addData>
          <data name="http://www.3s-software.com/plcopenxml/enumvaluedocumentation" handleUnknown="implementation">
            <EnumValueDocumentation>
              <EnumValue>
                <Name>MASTER_AXIS_POSITION</Name>
                <Documentation>
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">equivalent to P-0-0053</xhtml>
                </Documentation>
              </EnumValue>
              <EnumValue>
                <Name>RESULTING_MASTER_AXIS_POSITION</Name>
                <Documentation>
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">equivalent to P-0-0775</xhtml>
                </Documentation>
              </EnumValue>
              <EnumValue>
                <Name>EFFECTIVE_MASTER_AXIS_POSITION</Name>
                <Documentation>
                  <xhtml xmlns="http://www.w3.org/1999/xhtml">equivalent to P-0-0776</xhtml>
                </Documentation>
              </EnumValue>
            </EnumValueDocumentation>
          </data>
          <data name="http://www.3s-software.com/plcopenxml/objectid" handleUnknown="discard">
            <ObjectId>6f4f203a-4915-4554-b76a-b6be0a87b67c</ObjectId>
          </data>
        </addData>
      </dataType>
    </dataTypes>
    <pous>
      <pou name="FB_ConfigureProbe" pouType="functionBlock">
        <interface>
          <inputVars>
            <variable name="Execute">
              <type>
                <BOOL />
              </type>
            </variable>
            <variable name="SignalSelect">
              <type>
                <derived name="ProbeSignalSelect" />
              </type>
              <initialValue>
                <simpleValue value="ACT_POS" />
              </initialValue>
              <documentation>
                <xhtml xmlns="http://www.w3.org/1999/xhtml">signal to be captured</xhtml>
              </documentation>
            </variable>
            <variable name="SignalSelectEx">
              <type>
                <derived name="ProbeSignalSelectEx" />
              </type>
              <initialValue>
                <simpleValue value="NONE" />
              </initialValue>
              <documentation>
                <xhtml xmlns="http://www.w3.org/1999/xhtml">master position from the calculcation pipeline (only relevent if SignalSelect = MOTION_INTERNAL_DATA)</xhtml>
              </documentation>
            </variable>
            <variable name="ShotType">
              <type>
                <derived name="ProbeShotType" />
              </type>
              <initialValue>
                <simpleValue value="CONTINUOUS" />
              </initialValue>
              <documentation>
                <xhtml xmlns="http://www.w3.org/1999/xhtml">continuous or single shot</xhtml>
              </documentation>
            </variable>
            <variable name="PositiveEdgeDeadtime">
              <type>
                <LREAL />
              </type>
            </variable>
            <variable name="NegativeEdgeDeadtime">
              <type>
                <LREAL />
              </type>
            </variable>
            <variable name="PositiveEdgeEnable">
              <type>
                <BOOL />
              </type>
              <initialValue>
                <simpleValue value="TRUE" />
              </initialValue>
            </variable>
            <variable name="NegativeEdgeEnable">
              <type>
                <BOOL />
              </type>
            </variable>
            <variable name="ExternalProbeIndex">
              <type>
                <derived name="ML_ProbeIndex" />
              </type>
              <documentation>
                <xhtml xmlns="http://www.w3.org/1999/xhtml">not relevent unless ExternalProbeAxis is specified</xhtml>
              </documentation>
            </variable>
            <variable name="ExternalProbeAxis">
              <type>
                <derived name="AXIS_REF" />
              </type>
              <documentation>
                <xhtml xmlns="http://www.w3.org/1999/xhtml">leave empty unless probe input comes from a different drive than specified by Axis</xhtml>
              </documentation>
            </variable>
            <variable name="ProbeIndex">
              <type>
                <derived name="ML_ProbeIndex" />
              </type>
              <initialValue>
                <simpleValue value="PROBE_1" />
              </initialValue>
            </variable>
            <variable name="Axis">
              <type>
                <derived name="AXIS_REF" />
              </type>
              <initialValue>
                <structValue>
                  <value member="AxisName">
                    <simpleValue value="'Axis_1'" />
                  </value>
                </structValue>
              </initialValue>
            </variable>
          </inputVars>
          <outputVars>
            <variable name="Done">
              <type>
                <BOOL />
              </type>
            </variable>
            <variable name="Error">
              <type>
                <BOOL />
              </type>
            </variable>
            <variable name="ErrorText">
              <type>
                <string />
              </type>
            </variable>
          </outputVars>
          <localVars>
            <variable name="stSignalSelect">
              <type>
                <string />
              </type>
            </variable>
            <variable name="stSignalSelectEx">
              <type>
                <string length="120" />
              </type>
            </variable>
            <variable name="stShotType">
              <type>
                <string />
              </type>
            </variable>
            <variable name="DL_WriteNode_SignalSelect">
              <type>
                <derived name="DL_WriteNode" />
              </type>
            </variable>
            <variable name="DL_WriteNode_SignalSelectEx">
              <type>
                <derived name="DL_WriteNode" />
              </type>
            </variable>
            <variable name="DL_WriteNode_Source">
              <type>
                <derived name="DL_WriteNode" />
              </type>
            </variable>
            <variable name="DL_WriteNode_SourceInfo">
              <type>
                <derived name="DL_WriteNode" />
              </type>
            </variable>
            <variable name="DL_WriteNode_ShotType">
              <type>
                <derived name="DL_WriteNode" />
              </type>
            </variable>
            <variable name="DL_WriteNode_PositiveEdgeDeadtime">
              <type>
                <derived name="DL_WriteNode" />
              </type>
            </variable>
            <variable name="DL_WriteNode_NegativeEdgeDeadtime">
              <type>
                <derived name="DL_WriteNode" />
              </type>
            </variable>
            <variable name="DL_WriteNode_PositiveEdgeEnable">
              <type>
                <derived name="DL_WriteNode" />
              </type>
            </variable>
            <variable name="DL_WriteNode_NegativeEdgeEnable">
              <type>
                <derived name="DL_WriteNode" />
              </type>
            </variable>
            <variable name="String1">
              <type>
                <string />
              </type>
              <initialValue>
                <simpleValue value="'motion/axs/'" />
              </initialValue>
            </variable>
            <variable name="String2">
              <type>
                <string />
              </type>
              <initialValue>
                <simpleValue value="'/cfg/functions/probe/probe1/signal/select'" />
              </initialValue>
            </variable>
            <variable name="stSignalSelectNode">
              <type>
                <string />
              </type>
            </variable>
            <variable name="stSourceNode">
              <type>
                <string />
              </type>
            </variable>
            <variable name="stSourceInfoNode">
              <type>
                <string />
              </type>
            </variable>
            <variable name="stSignalSelectExNode">
              <type>
                <string />
              </type>
            </variable>
            <variable name="stShotTypeNode">
              <type>
                <string />
              </type>
            </variable>
            <variable name="stProbeString">
              <type>
                <string />
              </type>
            </variable>
            <variable name="stExternalProbeString">
              <type>
                <string />
              </type>
            </variable>
            <variable name="stPosEdgeEnableNode">
              <type>
                <string />
              </type>
            </variable>
            <variable name="stNegEdgeEnableNode">
              <type>
                <string />
              </type>
            </variable>
            <variable name="stPosEdgeDeadtimeNode">
              <type>
                <string />
              </type>
            </variable>
            <variable name="stNegEdgeDeadtimeNode">
              <type>
                <string />
              </type>
            </variable>
            <variable name="bDLError">
              <type>
                <BOOL />
              </type>
            </variable>
            <variable name="bExternalSourceActive">
              <type>
                <BOOL />
              </type>
            </variable>
          </localVars>
        </interface>
        <body>
          <ST>
            <xhtml xmlns="http://www.w3.org/1999/xhtml">
	CASE SignalSelect OF
		0: stSignalSelect := 'UNDEFINE';
		1: stSignalSelect := 'ENCODER_1';
		2: stSignalSelect := 'ENCODER_2';
		3: stSignalSelect := 'FINE_TIME';
		4: stSignalSelect := 'IPO_POS';
		5: stSignalSelect := 'ACT_POS';
		6: stSignalSelect := 'MOTION_INTERNAL_DATA';
	END_CASE
	
	CASE SignalSelectEx OF
		0: stSignalSelectEx := '';
		1: stSignalSelectEx := CONCAT('motion/axs/',CONCAT(Axis.AxisName,'/state/functions/coupling/sync-motion/calculation-pipeline/gear_in_pos/steps/1/inputs[0]'));
		2: stSignalSelectEx := CONCAT('motion/axs/',CONCAT(Axis.AxisName,'/state/functions/coupling/sync-motion/calculation-pipeline/gear_in_pos/steps/4/inputs[0]'));
		3: stSignalSelectEx := CONCAT('motion/axs/',CONCAT(Axis.AxisName,'/state/functions/coupling/sync-motion/calculation-pipeline/gear_in_pos/steps/5/inputs[0]'));
	END_CASE
	
	CASE ShotType OF
		0: stShotType := 'SINGLE_SHOT';
		1: stShotType := 'CONTINUOUS';
	END_CASE;
	
	IF ProbeIndex = PROBE_2 THEN
		stProbeString := 'probe2';
	ELSE
		stProbeString := 'probe1';
	END_IF
	
	IF ExternalProbeAxis.AxisName = '' THEN
		bExternalSourceActive := FALSE;
	ELSE
		bExternalSourceActive := TRUE;
	END_IF
	
	
    IF ExternalProbeIndex = PROBE_1 AND bExternalSourceActive THEN 
		stExternalProbeString := 'probe1';
	ELSIF ExternalProbeIndex = PROBE_2 AND bExternalSourceActive THEN 
		stExternalProbeString := 'probe2';
	ELSE stExternalProbeString := '';
	END_IF
	
	
	//stSignalSelectNode := CONCAT('motion/axs/',CONCAT(Axis.AxisName,'/cfg/functions/probe/probe1/signal/select'));
	stSignalSelectNode := CONCAT('motion/axs/',CONCAT(Axis.AxisName,CONCAT('/cfg/functions/probe/',CONCAT(stProbeString,'/signal/select'))));
	stSignalSelectExNode := CONCAT('motion/axs/',CONCAT(Axis.AxisName,CONCAT('/cfg/functions/probe/',CONCAT(stProbeString,'/signal/select-info'))));
	stSourceNode := CONCAT('motion/axs/',CONCAT(Axis.AxisName,CONCAT('/cfg/functions/probe/',CONCAT(stProbeString,'/signal/source'))));
	stSourceInfoNode := CONCAT('motion/axs/',CONCAT(Axis.AxisName,CONCAT('/cfg/functions/probe/',CONCAT(stProbeString,'/signal/source-info'))));
	stShotTypeNode := CONCAT('motion/axs/',CONCAT(Axis.AxisName,CONCAT('/cfg/functions/probe/',CONCAT(stProbeString,'/signal/shot-type'))));
	stPosEdgeDeadtimeNode := CONCAT('motion/axs/',CONCAT(Axis.AxisName,CONCAT('/cfg/functions/probe/',CONCAT(stProbeString,'/dead-time/pos'))));
	stNegEdgeDeadtimeNode := CONCAT('motion/axs/',CONCAT(Axis.AxisName,CONCAT('/cfg/functions/probe/',CONCAT(stProbeString,'/dead-time/neg'))));
	stPosEdgeEnableNode := CONCAT('motion/axs/',CONCAT(Axis.AxisName,CONCAT('/cfg/functions/probe/',CONCAT(stProbeString,'/edge/pos-edge'))));
	stNegEdgeEnableNode := CONCAT('motion/axs/',CONCAT(Axis.AxisName,CONCAT('/cfg/functions/probe/',CONCAT(stProbeString,'/edge/neg-edge'))));
	
//	stSignalSelectExNode := CONCAT('motion/axs/',CONCAT(Axis.AxisName,'/cfg/functions/probe/probe1/signal/select'));
	
	DL_WriteNode_SignalSelect(
		Execute := Execute,
		NodeName := stSignalSelectNode,
		Value := stSignalSelect);
		
	DL_WriteNode_SignalSelectEx(
		Execute := Execute,
		NodeName := stSignalSelectExNode,
		Value := stSignalSelectEx);
		
	DL_WriteNode_Source(
		Execute := Execute,
		NodeName := stSourceNode,
		Value := ExternalProbeAxis.AxisName);
		
	DL_WriteNode_SourceInfo(
		Execute := Execute,
		NodeName := stSourceInfoNode,
		Value := stExternalProbeString);
				
	DL_WriteNode_ShotType(
		Execute := Execute,
		NodeName := stShotTypeNode,
		Value := stShotType);
		
	DL_WriteNode_PositiveEdgeDeadtime(
		Execute := Execute,
		NodeName := stPosEdgeDeadtimeNode,
		Value := PositiveEdgeDeadtime);
		
	DL_WriteNode_NegativeEdgeDeadtime(
		Execute := Execute,
		NodeName := stNegEdgeDeadtimeNode,
		Value := NegativeEdgeDeadtime);
		
	DL_WriteNode_PositiveEdgeEnable(
		Execute := Execute,
		NodeName := stPosEdgeEnableNode,
		Value := PositiveEdgeEnable);
		
	DL_WriteNode_NegativeEdgeEnable(
		Execute := Execute,
		NodeName := stNegEdgeEnableNode,
		Value := NegativeEdgeEnable);
		
	Done := DL_WriteNode_SignalSelect.Done AND DL_WriteNode_SignalSelectEx.Done AND DL_WriteNode_ShotType.Done AND DL_WriteNode_PositiveEdgeEnable.Done AND DL_WriteNode_NegativeEdgeEnable.Done;
	Error := DL_WriteNode_SignalSelect.Error OR DL_WriteNode_SignalSelectEx.Error OR DL_WriteNode_ShotType.Error OR DL_WriteNode_PositiveEdgeEnable.Error OR DL_WriteNode_NegativeEdgeEnable.Error;

	IF DL_WriteNode_SignalSelect.Error AND DL_WriteNode_SignalSelectEx.Error AND DL_WriteNode_ShotType.Error AND DL_WriteNode_PositiveEdgeEnable.Error AND DL_WriteNode_NegativeEdgeEnable.Error THEN
		ErrorText := 'Axis does not exist';
		bDLError := TRUE;
	ELSE
		bDLError := FALSE;
	END_IF
	
	IF (DL_WriteNode_SignalSelect.Error OR DL_WriteNode_SignalSelectEx.Error OR DL_WriteNode_ShotType.Error OR DL_WriteNode_PositiveEdgeEnable.Error OR DL_WriteNode_NegativeEdgeEnable.Error) AND NOT bDLError THEN
		ErrorText := 'Probe is active, abort probe then retry';
	END_IF
	
	IF NOT Error THEN
		ErrorText := 'No error';
	END_IF
	
	IF NOT Execute THEN
		ExternalProbeAxis.AxisName := '';
	END_IF</xhtml>
          </ST>
        </body>
        <addData>
          <data name="http://www.3s-software.com/plcopenxml/objectid" handleUnknown="discard">
            <ObjectId>42a8c03d-e704-4cc0-a7fa-f86f16e377cd</ObjectId>
          </data>
        </addData>
      </pou>
    </pous>
  </types>
  <instances>
    <configurations />
  </instances>
  <addData>
    <data name="http://www.3s-software.com/plcopenxml/projectstructure" handleUnknown="discard">
      <ProjectStructure>
        <Folder Name="ProbeUtilities">
          <Object Name="ProbeShotType" ObjectId="f62b64d6-1185-4cb3-b190-76ed48c49da2" />
          <Object Name="ProbeSignalSelect" ObjectId="2df6a6eb-7ea9-4816-92cd-91b57f670dd3" />
          <Object Name="ProbeSignalSelectEx" ObjectId="6f4f203a-4915-4554-b76a-b6be0a87b67c" />
          <Object Name="FB_ConfigureProbe" ObjectId="42a8c03d-e704-4cc0-a7fa-f86f16e377cd" />
        </Folder>
      </ProjectStructure>
    </data>
  </addData>
</project>