Skip to content

Creation of PlcTask from PLCOpen XML fails in TwinCAT

When importing a PLCOpen XML file in TwinCAT that is generated with the PLC code generator, TwinCAT fails.

Severity	Code	Description	Project	File	Line	Suppression State
Error		Creation of object 'PlcTask' failed.
Reason: The string 't#10ms' is not a valid TimeSpan value.			0	

All other files (GVL's, POU's, and DUT's) are imported correctly.

I also tried importing the XML file in CODESYS, but I could not get that to work for the PlcTask object.

We can obtain inspiration from what ESCET generates:

<task interval="t#10ms" name="PlcTask" priority="20">
  <pouInstance name="MAIN" typeName="MAIN"/>
</task>

versus TwinCAT:

<task name="PlcTask" interval="PT0S" priority="20">
  <pouInstance name="MAIN" typeName="">
    <documentation>
      <xhtml xmlns="http://www.w3.org/1999/xhtml" />
    </documentation>
  </pouInstance>
  <addData>
    <data name="http://www.3s-software.com/plcopenxml/tasksettings" handleUnknown="implementation">
      <TaskSettings KindOfTask="Cyclic" Interval="10000" IntervalUnit="us">
        <Watchdog Enabled="false" TimeUnit="ms" />
      </TaskSettings>
    </data>
    <data name="http://www.3s-software.com/plcopenxml/objectid" handleUnknown="discard">
      <ObjectId>a0704795-6c85-4284-a1d2-39a3c7febdd7</ObjectId>
    </data>
  </addData>
</task>

Official specification can be found here: https://plcopen.org/technical-activities/xml-exchange

Edited by Dennis Hendriks