This topic contains the following information:
oTouchprobe functionality / time-stamped inputs
oTouchprobe configuration and start mechanism
Touchprobe Functionality / Time-Stamped Inputs
The reference to touchprobe inputs is to the functionality of touchprobe within PacDrive. The profiles TM5SDM8DTS_TSIOO and TM5SDM8DTS_TSITSO configure the module inputs as time-stamped inputs in support of the touchprobe functionality (for more information, refer to the Modicon TM5 Digital I/O Modules Hardware Guide).
NOTE: The references in the present document to touchprobe inputs is specifically to the configuration of the physical inputs as time-stamped inputs.
If a TM5SDM8DTS_TSIOO or a TM5SDM8DTS_TSITSO object is added to the Devices tree, four sub objects are automatically added under the TM5SDM8DTS_TSIOO or the TM5SDM8DTS_TSITSO object respectively.
Each one represents one touchprobe input of the module:
oTP_0_x: physical module channel 1
oTP_1_x: physical module channel 2
oTP_2_x: physical module channel 5
oTP_3_x: physical module channel 6
NOTE: The maximum number of touchprobe inputs used on TM5SDM8DTS modules with one controller is 252.
Each module configured with a TM5SDM8DTS_TSIOO or a TM5SDM8DTS _TSITSO configuration profile supports four touchprobe inputs.
This leads to a maximum number of 63 TM5SDM8DTS modules with a TM5SDM8DTS_TSIOO or a TM5SDM8DTS_TSITSO configuration profile inside one application.
The resolution of the touchprobe values is 1 μs.
Parameters of TM5SDM8DTS_TSIOO / TM5SDM8DTS_TSITSO Touchprobe Inputs
oFor a general description of the parameters, refer to Touchprobe inputs.
oFor a detailed description of the parameters CaptureEdge, CaptureEdgeSet, and CaptureEdgeSetDelayed, refer to Configuration of the edge.
oParameter CaptureValue
The behavior of the CaptureValue is different depending on the devices used:
oImplementation for touchprobes on the LMC, drives (Lexium 52 and Lexium 62), as well as PacNet (BT-4 DIO): If more than one edge is detected during one Sercos III cycle, the first one is calculated into the CaptureValue.
oImplementation for touchprobes on TM5SDM8DTS_TSIOO or TM5SDM8DTS_TSITSO: If more than one edge is detected during one Sercos III cycle, the last one is calculated into the CaptureValue.
If more than one edge is detected, this can be evaluated using the CaptureCount parameter. This parameter displays the number of edges detected during the last Sercos III cycle. If this value is >1, this indicates CaptureCount-1 edges have been discarded.
NOTE: The behavior of the CaptureValue is different depending on the devices used (as described above). Therefore, there are some applicative differences between those devices. If you substitute one for the other, ensure that you validate your application.
Single Cycle Data Loss (During Touchprobe)
A single cycle data loss during an active touchprobe measurement leads to a deferred upload of the time-stamp that was measured by the module. This leads to a later evaluation in the controller. The measurement is delayed.
If a new edge is detected by the hardware during the single cycle data loss time, the first capture gets lost.
For more details, refer to Single Cycle Data Loss.
Touchprobe Configuration and Start Mechanism
For PacDrive 3 V4.2, a new touchprobe configuration and start mechanism is introduced.
This mechanism works generically for the touchprobe objects in the PacDrive 3 system.
The new, generic solution splits the functionality of the old FC_TPEdge() function into two parts:
NOTE: The TM5SDM8DTS_TSIOO / TM5SDM8DTS_TSITSO touchprobes are only usable with this new mechanism.
Using the old method (calling FC_TPEdge() with the logical address of a touchprobe object of the TM5SDM8DTS_TSIOO / TM5SDM8DTS_TSITSO module) returns -1 (i_stTPId invalid).
The configuration of the edge is split from the capture starting function because the time needed to change the edge depends on the underlying hardware.
It differs much between for example, touchprobe inputs directly connected to an LMCx00C controller and the TM5SDM8DTS_TSIOO / TM5SDM8DTS_TSITSO touchprobe inputs.
As of PacDrive 3 V4.2, the touchprobe objects have the following new parameters to configure the edge that will be detected after starting a capture:
Parameter |
Meaning |
Value |
---|---|---|
CaptureEdge (AD) |
Configured edge |
Falling edge / 0 Rising edge / 1 Reserved / 2 In progress (for example if service channel transfer is in progress) / 3 Set non-operational (if service channel transfer is unsuccessful) / 4 |
When the CaptureEdge parameter displays set non-operational / 4, it cannot be determined which edge is active and FC_TPEdgeStart() call returns -6 (Measurement not possible). This value is also set if the CaptureEdgeSet is used in invalid CaptureStates (if CaptureState is active / 1 or not ready / 5).
Parameter |
Meaning |
Value |
---|---|---|
CaptureEdgeSet (EFC) |
Edge of the respective touchprobe input Can be set online and offline. |
Falling edge / 0 Rising edge / 1(default) |
If the touchprobe input is on a TM5SDM8DTS_TSIOO / TM5SDM8DTS_TSITSO module, the call of CaptureEdgeSet starts an asynchronous task, which sets the edge on the module via Sercos III service channel. Verify that the result in the CaptureEdge parameter is the same as the CaptureEdgeSet. A change of the configured edge can take about 20 Sercos cycles.
If the CaptureState of the touchprobe input is active / 1 or not ready / 5 or the CaptureEdge is in progress / 3, the new value is not written to CaptureEdgeSet. This can be detected by reading CaptureEdgeSet.
Parameter |
Meaning |
Value |
---|---|---|
CaptureEdgeSetDelayed (AD) |
Delay on change of CaptureEdge TRUE if the change of the edge is not set directly in the hardware. This is the case with TM5SDM8DTS_TSIOO / TM5SDM8DTS_TSITSO module touchprobe objects. |
False / 0 True / 1 |
FC_GetIdentificationMandatoryItfByLogAddr()
The the parameters are part of a new interface IF_Touchprobe2.
To simplify the usage of interfaces for the customer, a new function FC_GetIdentificationMandatoryItfByLogAddr() is available:
FUNCTION FC_ GetIdentificationMandatoryItfByLogAddr :
GetIdentificationMandatoryItfByLogAddr
VAR_INPUT
i_stLogAdr : ST_LogicalAddress;
END_VAR
This function returns the IF_IdentificationMandatory interface of an object with the logical address i_stLogAdr.
This simplifies working with the new interface, especially in existing libraries where only logical addresses are used.
The function searches through the Devices tree until the object with the logical address i_stLogAdr is found. If the object is found, the function returns the IF_IdentificationMandatory of this object, else it returns 0.
For starting the capture, a new function FC_TPEdgeStart() is available.
The parameters of the new function are exactly the same as from FC_TPEdge() but without the i_xPosEdge, which was setting the edge that is captured. The new FC_TPEdgeStart() is callable with the touchprobe types in the system:
FUNCTION FC_TPEdgeStart : DINT
VAR_INPUT
i_stTPId : ST_LogicalAddress;
i_stDevId : ST_LogicalAddress;
i_diParType : DINT;
i_lrLowLimit : LREAL;
i_lrHighLimit : LREAL;
END_VAR
As of PacDrive 3 V4.2, the touchprobe objects implement a new interface IF_Touchprobe2 (SystemConfigurationItf).
The interface provides the parameters:
oCaptureEdge
oCaptureEdgeSet
oCaptureEdgeSetDelayed
In addition, the interface provides the following three methods:
TPEdgeStart(): This method calls the FC_TPEdgeStart() function with the ST_LogicalAddress of the object as i_stTPId.
METHOD TPEdgeStart : DINT
VAR_INPUT
i_stDevId : ST_LogicalAddress;
i_diParType : DINT;
i_lrLowLimit : LREAL;
i_lrHighLimit : LREAL;
END_VAR
TPOff (): This method calls the FC_TPOff () function with the ST_LogicalAddress of the object as i_stTPId.
METHOD TPOff : DINT
VAR_INPUT
END_VAR
TPReset (): This method calls the FC_TPReset () function with the ST_LogicalAddress of the object as i_stTPId.
METHOD TPReset : DINT
VAR_INPUT
END_VAR
PROGRAM SR_TouchprobeExample
VAR
iState : INT := STATE_INIT;
stLogicalAddr : ST_LogicalAddress; // Logical Address of TP object
ifIM : IF_IdentificationMandatory := 0;
ifTP2 : IF_Touchprobe2 := 0;
diResult : DINT := 0;
xResult : BOOL := FALSE;
END_VAR
-----------------------------------------------------------------------
CASE iState OF
STATE_INIT:
stLogicalAddr := TP_0_1.stLogicalAddress;
ifIM := FC_GetIdentificationMandatoryItfByLogAddr(stLogicalAddr);
iState := STATE_CHANGE_EDGE;
STATE_CHANGE_EDGE:
xResult := __QUERYINTERFACE(ifIM, ifTP2);
IF (xResult) THEN
ifTP2.CaptureEdgeSet := 0; // 0 = falling edge
IF (0 <> ifTP2.CaptureEdgeSet) THEN
iState := STATE_ERROR; // Set was not possible because of wrong state
END_IF
iState := STATE_WAIT_CHANGE_EDGE;
ELSE
iState := STATE_ERROR; // should never happen!
END_IF
STATE_WAIT_CHANGE_EDGE:
IF (0=ifTP2.CaptureEdge) THEN // 0 = falling edge
iState := STATE_START_CAPTURE;
END_IF
IF (4=ifTP2.CaptureEdge) THEN // 4 = set failed
iState := STATE_ERROR;
END_IF
STATE_START_CAPTURE:
// Start capture of RefPosition between 0 and 360
diResult := FC_TPEdgeStart(ifIM.stLogicalAddress, DRV_Lexium62.stLogicalAddress, 1, 0, 360);
IF (0=diResult) THEN
iState := STATE_TOUCHPROBE_ACTIVE;
ELSE
iState := STATE_ERROR;
END_IF
STATE_TOUCHPROBE_ACTIVE:
; // Touchprobe start successful
STATE_ERROR:
; // ERROR occurred during edge set
END_CASE