Code for a variable of type ¨TIME¨

Question:
How can a code be generated for a variable of type 'TIME'?

Answer:
The instance parameter manager (DDS: Register Resources), which serves for generating new codes, supports the following data types:

· BOOL
· BYTE
· WORD
· DWORD
· SINT
· USINT
· INT
· UINT
· DINT
· UDINT

Consequently, for variables of type TIME codes cannot be generated directly with the instance parameter manager.

In order to be able to enter / display a time via a code, an auxiliary variable is created with one of the data types (e. g. UDINT) described above. By means of a conversion function (e. g. UDINT_TO_TIME) the value of the variable can be converted in data type TIME. The data type TIME has a data size of 32 Bit. During conversion value 1 corresponds to 1 millisecond.

Example:

The time for the IEC-61131-timing element TON is to be indicated via a code. The input for the time indication of all IEC-61131-timing elements is of data type TIME.

Solution:

The auxiliary variable udnTime of data type UDINT is connected to the instance parameter manager with a code. Via the converting function UDINT_TO_TIME this auxiliary variable is assigned to the time input of function block TON. Via the code a max. delay of 4294967295ms can be entered, which corresponds to a bit more than 49 days.

URL for linking this AKB article: https://www.lenze.com/en-de/go/akb/200603041/1/
Contact form