Samples | Motion Parameterizing axes Axis parameters are set via the axis's XML description. The recommended procedure is to first create an axis and then export its current configuration using ProduceXml . The returned XML description serves as a template that can be customized as needed and reimported via ConsumeXml . C#: ITcSmTreeItem axis = systemManager.LookupTreeItem("TINC^NC-Task^Axes^Axis 1"); string xmlDescription = axis.ProduceXml(); After modifying the XML description, it is written back using ConsumeXml : axis.ConsumeXml(xmlDescription); PowerShell:
$axis = $systemManager.LookupTreeItem("TINC^NC-Task^Axes^Axis 1") $xmlDescription = $axis.ProduceXml() # Here configuration of the values in the xml needed $axis.ConsumeXml($xmlDescription) 6.10.2 Linking NC axes to I/O or a PLC | Linking NC axes to I/O or a PLC After being created, an NC axis must be linked to an I/O drive so that it can access process data. Two variants are available for this. Variant 1 passes the path to the I/O drive via ConsumeXml using an NcAxisDef element. TwinCAT automatically selects the appropriate PDO mappings. Variant 2 explicitly sets the links for individual process variables using ConsumeMappingInfo , which provides complete control over the mapping.
Requirements A TwinCAT solution is open, and a DTE connection is active. ITcSysManager was initialized as a COM object in an STA thread. An NC axis has been created under TINC (see MOT01 — Creating an NC axis [ } 293] ). An I/O device with the target drive is present in the configuration. Variant 1: Linking the axis to the I/O drive get_Child(1) returns the first child of the TINC node – that is, the first NC task. The axis folder is then opened via LookupChild("Axes") . NcAxisDef XML specifies the path to the I/O drive and the channel.
// Look up NC axis ITcSmTreeItem ncConfig = sysManager.LookupTreeItem("TINC"); // LookupChild("Axes") is more reliable than a path string with a potential SAF suffix ITcSmTreeItem axesFolder = ncConfig.get_Child(1).LookupChild("Axes"); ITcSmTreeItem ncAxis = axesFolder.LookupChild("Axis 1"); // Variant 1: link axis with I/O drive (source-verified) string linkXml = @" 1 CANopen-DS402 TIID^Device 1 (EtherCAT)^Term 1 (EK1100)^Drive 2 (AX8206-0000-0105) 0 "; ncAxis.ConsumeXml(linkXml); Variant 2: Explicitly linking individual variables ConsumeMappingInfo is available starting with ITcSysManager3 . The interface is cast to the existing sysManager object.
The XML format requires the full tree path to the axis and drive, as well as the variable names for both sides. TE1000 294 Version: 1.7.0