Twido Functions

 

Twido Functions

Overview

The following list provides an overview of the Twido functions:

oFC_AsciiCharToInt

oFC_AsciiToInt

oFC_AsciiToReal

oFC_ConcatOfInt

oFC_CopyArrDint

oFC_CopyArrInt

oFC_CopyArrReal

oFC_CopyBitString

oFC_CopyPackedBitString

oFC_DegToRad

oFC_EqualArrDint

oFC_EqualArrReal

oFC_FindEqDint

oFC_FindEqReal

oFC_FindGtDint

oFC_FindGtReal

oFC_FindLtDint

oFC_FindLtReal

oFC_HiOfDint

oFC_IntToAscii

oFC_Lkup

oFC_LoOfDint

oFC_MaxArrDint

oFC_MaxArrReal

oFC_MeanArrReal

oFC_MinArrDint

oFC_MinArrReal

oFC_MoveArrDint

oFC_MoveArrInt

oFC_MoveArrReal

oFC_OccurArrDint

oFC_OccurArrReal

oFC_RadToDeg

oFC_RealToAscii

oFC_RolArrDint

oFC_RolArrReal

oFC_RorArrDint

oFC_RorArrReal

oFC_Round

oFC_SortArrDint

oFC_SortArrReal

oFC_SumArrDint

oFC_SumArrReal

FC_AsciiCharToInt

This function returns the 2 characters as an integer value.

Input values

i_sChar: STRING with 2 characters.

Return values

Returns characters as integer value.

If the string is invalid, the global variable G_xSystemBitS18 is set to TRUE.

FC_AsciiToInt

The ASCII to integer conversion function executes the conversion of an ASCII string value to its equivalent integer value.

Name in EcoStruxure Machine Expert - Basic / Twido

ASCII_TO_INT

Input values

i_psStartAddr: POINTER TO STRING;

Return values

ASCII_TO_INT: INT

The ASCII to integer instruction rules are as follows:

oThe ASCII value must be included between -32768 to 32767.

oThe function always reads the most significant byte first.

oAny ASCII character that is not in the interval [0...9] ([30 hex - 39 hex]) is considered to be an end character, except for a minus sign '-' (2D hex) when it is placed as the first character.

oIn case of an overflow (>32767 or <-32768), the global variable G_xSystemBitS18 (arithmetic overflow or detected error) is set to 1 and the value 32767 or -32768 is returned.

oIf the first character of the operand is an "end" character, the value 0 is returned and the global variable G_xSystemBitS18 is set to TRUE.

FC_AsciiToReal

The ASCII to REAL function executes the conversion of the ASCII string value to its equivalent REAL value.

Name in EcoStruxure Machine Expert - Basic / Twido

ASCII_TO_FLOAT

Input values

i_psStartAddr: POINTER TO STRING

Return values

FC_AsciiToReal : REAL

ASCII to REAL conversion rules are as follows:

oThe function reads the most significant byte first.

oAny ASCII character that is not in the interval [0...9] ([30 hex - 39 hex]) is considered to be "end" character, except for:

odecimal point '.' (2E hex)

ominus '-' (2D hex)

oplus '+' (2B hex)

oexponent 'e' or 'E' (65 hex or 45 hex)

oThe ASCII string format can be in exponential notation (that is "-2.34567e+13") or in decimal notation (that is 9826.3457).

oIn case of an overflow (calculation result is > 3.402824E+38 or < -3.402824E+38):

oThe global variable G_xSystemBitS18 (arithmetic overflow or detected error) is set to TRUE.

oThe value +/- 1.#INF (+ or - infinite value) is returned.

oIf the calculation result is between -1.175494E-38 and 1.175494E-38, then the result is rounded to 0.0.

oIf the operand is not a number, the value 1.#QNAN is returned and the global variable G_xSystemBitS18 is set to TRUE.

FC_ConcatOfInt

This function concatenates two integers into a double integer.

Name in EcoStruxure Machine Expert - Basic / Twido

CONCATW

Input values

i_iLowVal: INT

i_iHighVal: INT

Return values

FC_ConcatOfInt : DINT

FC_CopyArrDint

The function copies an array of DINT values to another given memory address.

Name in EcoStruxure Machine Expert - Basic / Twido

COPY_ARR_DINT

Input values

i_pdiSource : POINTER TO DINT

i_pdiDestination : POINTER TO DINT

i_bySize : BYTE

Return values

FC_CopyArrDint : BOOL

FC_CopyArrInt

The function copies an array of INT values to another given memory address.

Name in EcoStruxure Machine Expert - Basic / Twido

COPY_ARR_INT

Input values

i_piSource : POINTER TO INT

i_piDestination: POINTER TO INT

i_bySize : BYTE

Return values

FC_CopyArrInt : BOOL

FC_CopyArrReal

The function copies an array of REAL values to another given memory address.

Name in EcoStruxure Machine Expert - Basic / Twido

COPY_ARR_REAL

Input values

i_prSource : POINTER TO REAL

i_prDestination : POINTER TO REAL

i_bySize : BYTE

Return values

FC_CopyArrReal : BOOL

FC_CopyBitString

The function copies an array of BOOL values to another given memory address.

Name in EcoStruxure Machine Expert - Basic / Twido

COPY_ARR_BOOL

Input values

i_pxSource : POINTER TO BOOL

i_pxDestination : POINTER TO BOOL

i_bySize : BYTE

Return values

FC_CopyBitString : BOOL

FC_CopyPackedBitString

The function copies a packed BitString of the length of i_bySize bits to another memory location.

Name in EcoStruxure Machine Expert - Basic / Twido

FC_CopyPackedBitString

Input values

i_pbySource : POINTER TO BYTE

i_pbyDestination: POINTER TO BYTE

i_bySize : BYTE - limited to SIZE OF (DINT)

Return values

FC_CopyPackedBitString : DINT

FC_DegToRad

The function FC_DegToRad executes the conversion of an angle expressed in degree to radian.

Name in EcoStruxure Machine Expert - Basic / Twido

DEG_TO_RAD

Input values

i_rDeg : REAL;

Return values

FC_DegToRad: REAL

Formula

Radian = Degrees * (Pi / 180)

Where,

Pi = 3.1415926535

Rules of use:

The angle to be converted must be between -737280.0 and +737280.0.

For values outside these ranges, the displayed result is + 1.#QNAN and the global variable G_xSystemBitS18 is set to TRUE.

FC_EqualArrDint

The function FC_EqualArrDint compares 2 defined size tables, element by element. If there is a difference, the rank of the first dissimilar element is returned in the form of an integer. If there is no difference, the value"-1" is returned.

Name in EcoStruxure Machine Expert - Basic / Twido

EQUAL_ARR

Input values

i_pdiFirstArrStartValue: POINTER TO DINT

i_pdiSecondArrStartValue: POINTER TO DINT

i_bySize: BYTE

Return values

FC_EqualArrDint: INT

The start addresses of the 2 arrays to be compared are provided at the 2 pointer inputs.

The number of elements to be compared must be defined at the input i_bySize.

FC_EqualArrReal

The function FC_EqualArrReal compares 2 defined size tables, element by element. If there is a difference shown, the rank of the first dissimilar element is returned in the form of an integer. If there is no difference, then the value -1 is returned.

Name in EcoStruxure Machine Expert - Basic / Twido

EQUAL_ARR

Input values

i_pdiFirstArrStartValue: POINTER TO REAL

i_pdiSecondArrStartValue: POINTER TO REAL

i_bySize: BYTE

Return values

FC_EqualArrReal : INT

The start addresses of the 2 arrays to be compared are provided at the 2 pointer inputs.

The number of elements to be compared must be defined at the input i_bySize.

FC_FindEqDint

The function FC_FindEqDint searches in a set of given DINT values for the position of the first array element, which is equal to a given value.

Name in EcoStruxure Machine Expert - Basic / Twido

FIND_EQR

Input values

i_diValue: DINT

i_pdiStartAddr: POINTER TO DINT

i_bySize : BYTE

Return values

FC_FindEqDint : INT

If the given value is not contained in the array, -1 is returned.

FC_FindEqReal

The function FC_FindEqReal searches in a set of given REAL values for the position of the first array element which is equal to a given value defined by the user.

Name in EcoStruxure Machine Expert - Basic / Twido

FIND_EQR

Input values

i_rValue: REAL

i_prStartAddr: POINTER TO REAL

i_bySize : BYTE

Return values

FC_FindEqReal : INT

If the given value is not contained in the array, -1 is returned.

FC_FindGtDint

The function FC_FindGtDint search in a set of given DINT values for the position of the first array element which is greater than a given value defined by the user.

Name in EcoStruxure Machine Expert - Basic / Twido

FIND_GTR

Input values

i_diValue: DINT

i_pdiStartAddr: POINTER TO DINT

i_bySize : BYTE

Return values

FC_FindGtDint : INT

If no element in the array is greater than the given value, -1 is returned.

FC_FindGtReal

The function FC_FindGtReal searches in a set of given REAL values for the position of the first array element which is greater than a given value defined by the user.

Name in EcoStruxure Machine Expert - Basic / Twido

FIND_GTR

Input values

i_rValue: REAL

i_prStartAddr: POINTER TO REAL

i_bySize : BYTE

Return values

FC_FindGtReal : INT

If no element in the array is greater than the given value, -1 is returned.

FC_FindLtDint

The function FC_FindLtDint searches in a set of given DINT values for the position of the first array element which is smaller than a given value defined by the user.

Name in EcoStruxure Machine Expert - Basic / Twido

FIND_LTR

Input values

i_diValue: DINT

i_pdiStartAddr: POINTER TO DINT

i_bySize : BYTE

Return values

FC_FindLtDint : INT

If no element in the array is greater than the given value, -1 is returned.

FC_FindLtReal

The function FC_FindLtReal searches in a set of given REAL values for the position of the first array element which is smaller than a given value defined by the user.

Name in EcoStruxure Machine Expert - Basic / Twido

FIND_LTR

Input values

i_rValue: REAL

i_prStartAddr: POINTER TO REAL

i_bySize : BYTE

Return values

FC_FindLtReal : INT

If no element in the array is greater than the given value, -1 is returned.

FC_HiOfDint

This function extracts most significant bits (MSB) of a double integer to an integer.

Name in EcoStruxure Machine Expert - Basic / Twido

HW

Input values

i_diVal: DINT

Return values

FC_LoOfDint : INT

FC_IntToAscii

The integer to ASCII function executes the conversion of an integer value to its equivalent ASCII string value.

Name in EcoStruxure Machine Expert - Basic / Twido

INT_TO_ASCII

Input values

i_iVal: INT

Return values

INT_TO_ASCII : ARRAY [1..4] OF INT

The integer to ASCII conversion rules are as follows:

oThe integer value must be included between -32768 to 32767.

oThe function always writes the most significant byte first.

oThe end character is "Carriage return" (ASCII 13).

oThe function automatically determines how many %MWs should be filled with ASCII values (from 1 to 4)

FC_Lkup

The function FC_Lkup is used to interpolate a set of X versus Y floating point data for a given X value.

Name in EcoStruxure Machine Expert - Basic / Twido

LKUP

Input values

i_prStartAddr : POINTER TO REAL

i_bySize : BYTE

Return values

FC_Lkup : INT

The following conditions apply for the input value i_prSartAddr:

oeven number of values

ominimum of 6 values

ofirst element is x value to be found

osecond element is set by the function: interpolation result

oall following elements are interpolation supporting points by pairs of X and Y

Interpolation rules:

The LKUP function uses the linear interpolation rule, as defined in the following equation:

G-SE-0033193.1.gif-high.gif

 

 

For Xi  ≤ X  ≤  Xi + 1, where i = 1 … (m-1)

Assuming Xi values are ranked in ascending order: X1 ≤ X2 ≤ ...X...≤ Xm-1 ≤ Xm

If any of 2 consecutive Xi values are equal (Xi=Xi+1=X), the equation 1 results in an invalid exception. To handle this exception, the following algorithm is used in place of equation 1:

G-SE-0033211.1.gif-high.gif

 

 

For Xi = Xi+1 = X, where i = 1…(m-1).

Result value:

The result value shows if the interpolation was successful or not.

0: Successful interpolation

1: Interpolation error: incorrect array, Xm < Xm-1

2: Interpolation error: i_rXValue out of range, X < X1

4: Interpolation error: i_rXValue out of range, X > Xm

8: Invalid size of data array: i_prYValue is set as an odd number, or i_prYValue < 6

The result value does not contain the computed interpolation value (Y). For a given (X) value, the result of the interpolation (Y) is contained in i_prYValue.

i_rXValue is the floating point variable that contains the user-defined (X) value for which to compute the interpolated (Y) value.

The valid range for i_rXValue is:

X1 ≤  i_rXValue  ≤ Xm

FC_LoOfDint

This function extracts least significant bits (LSB) of a double integer to an integer.

Name in EcoStruxure Machine Expert - Basic / Twido

LW

Input values

i_diVal: DINT

Return values

FC_LoOfDint : INT

FC_MaxArrDint

In a set of given DINT values, this function searches the maximum value. The search is carried out only on the defined length of the table.

Name in EcoStruxure Machine Expert - Basic / Twido

MAX_ARR

Input values

i_pdiStartAddr: POINTER TO DINT

i_bySize : BYTE

Return values

FC_MaxArrDint : DINT

FC_MaxArrReal

In a set of given REAL values, this function searches the maximum value. The search is only carried out within the defined table length.

Name in EcoStruxure Machine Expert - Basic / Twido

MAX_ARR

Input values

i_prStartAddr: POINTER TO REAL

i_bySize : BYTE

Return values

FC_MaxArrReal : REAL

FC_MeanArrReal

In a set of given REAL values, this function is used to calculate the mean average in the required length of REAL values table.

Name in EcoStruxure Machine Expert - Basic / Twido

MEAN

Input values

i_prStartAddr: POINTER TO REAL

i_bySize : BYTE

Return values

FC_MeanArrReal : REAL

FC_MinArrDint

In a set of given DINT values, this function searches the minimum value. The search is carried out only on the defined length of the table.

Name in EcoStruxure Machine Expert - Basic / Twido

MIN_ARR

Input values

i_pdiStartAddr: POINTER TO DINT

i_bySize : BYTE

Return values

FC_MinArrDint : DINT

FC_MinArrReal

In a set of given REAL values, this function searches the minimum value. The search is carried out only on the defined length of the table.

Name in EcoStruxure Machine Expert - Basic / Twido

MAX_ARR

Input values

i_prStartAddr: POINTER TO REAL

i_bySize : BYTE

Return values

FC_MinArrReal : REAL

FC_MoveArrDint

The function moves the input value in the DINT value tables for a number of elements equal to a given value.

Name in EcoStruxure Machine Expert - Basic / Twido

MOVE_ARR_DINT

Input values

i_diValue : DINT

i_pdiStartAddr: POINTER TO DINT

i_bySize : BYTE

Return values

FC_MoveArrDint : BOOL

FC_MoveArrInt

The function moves the input value in the INT values table for a number of elements equal to a given value.

Name in EcoStruxure Machine Expert - Basic / Twido

MOVE_ARR_INT

Input values

i_iValue : INT

i_piStartAddr: POINTER TO INT

i_bySize : BYTE

Return values

FC_MoveArrInt : BOOL

FC_MoveArrReal

The function moves the input value in the REAL value tables for a number of elements equal to a given value.

Name in EcoStruxure Machine Expert - Basic / Twido

MOVE_ARR_REAL

Input values

i_rValue : REAL

i_prStartAddr: POINTER TO REAL

i_bySize : BYTE

Return values

FC_MoveArrReal : BOOL

FC_OccurArrDint

In a set of given DINT values, this function searches the number of elements equal to a given value.

Name in EcoStruxure Machine Expert - Basic / Twido

OCCUR_ARR

Input values

i_diValue: DINT

i_pdiStartAddr: POINTER TO DINT

i_bySize : BYTE

Return values

FC_OccurArrDint : INT

FC_OccurArrReal

In a set of given REAL values, this function searches the number of elements equal to a given value.

Name in EcoStruxure Machine Expert - Basic / Twido

OCCUR_ARR

Input values

i_rValue: REAL

i_prStartAddr: POINTER TO REAL

i_bySize : BYTE

Return values

FC_OccurArrReal : INT

FC_RadToDeg

This function FC_RadToDeg executes the conversion of an angle expressed in radian to degree.

Name in EcoStruxure Machine Expert - Basic / Twido

RAD_TO_DEG

Input values

i_rRad : REAL;

Return values

FC_RadToDeg: REAL

Formula

Degree = Radian * (180 / Pi)

Where,

Pi = 3.1415926535

Rules of use:

The angle to be converted must be between -4096Pi and 4096Pi.

For values outside these ranges, the displayed result is + 1.#QNAN and G_xSystemBitS18 is set to TRUE.

FC_RealToAscii

The REAL to ASCII function executes the conversion of REAL value to its equivalent ASCII string value.

Name in EcoStruxure Machine Expert - Basic / Twido

FLOAT_TO_ASCII

Input values

i_rVal: REAL

Return values

FC_RealToAscii : ARRAY [1..7] OF INT

The REAL to ASCII conversion rules are as follows:

oThe function always writes the most significant byte (MSB) first.

oThe representation is made using conventional exponential notation.

o"Infinite" or "Not a number" results return the string "NAN".

oThe end character is "Carriage return" (ASCII 13).

oThe conversion precision is 6 figures.

FC_RolArrDint

In a given DINT array this function shifts every element n position(s) towards the start address of the list. The first n elements are moved to the end of the list.

Name in EcoStruxure Machine Expert - Basic / Twido

ROL_ARR

Input values

i_iShiftPosNumber: INT

i_pdiStartAddr: POINTER TO DINT

i_bySize : BYTE

Return values

FC_RolArrDint : BOOL

If the value of i_iShiftPosNumber is negative or 0, no shift is performed.

FC_RolArrReal

In a set of given REAL values, this function performs a rotate shift of n position(s) from top to bottom of the elements.

Name in EcoStruxure Machine Expert - Basic / Twido

ROL_ARR

Input values

i_iShiftPosNumber: INT

i_prStartAddr: POINTER TO REAL

i_bySize : BYTE

Return values

FC_RolArrReal : BOOL

If the value of i_iShiftPosNumber is negative or 0, no shift is performed.

FC_RorArrDint

In a given DINT array this function shifts every element n position(s) towards the list’s end address. The last n elements are moved to the begin of the list.

Name in EcoStruxure Machine Expert - Basic / Twido

ROR_ARR

Input values

i_iShiftPosNumber: INT

i_pdiStartAddr: POINTER TO DINT

i_bySize : BYTE

Return values

FC_RorArrDint : BOOL

If the value of i_iShiftPosNumber is negative or 0, no shift is performed.

FC_RorArrReal

In a set of given REAL values, this function performs a rotate shift of n position(s) from bottom to top of the elements.

Name in EcoStruxure Machine Expert - Basic / Twido

ROL_ARR

Input values

i_iShiftPosNumber: INT

i_prStartAddr: POINTER TO REAL

i_bySize : BYTE

Return values

FC_RorArrReal : BOOL

If the value of i_iShiftPosNumber is negative or 0, no shift is performed.

FC_Round

The function FC_Round rounds a floating point representation that is stored in an ASCII string.

Name in EcoStruxure Machine Expert - Basic / Twido

ROUND

Input values

i_psStartAddr: POINTER TO STRING;

i_byRoundNumber: BYTE;

Return values

FC_Round: ARRAY[1..7] of INT

The ROUND instruction rules are as follows:

oThe operand is always rounded down.

oThe end character of the operand string is used as an end character for the result string.

oThe end character can be any ASCII character that is in the interval [0...9] ([30 hex - 39 hex]), except:

odot '.' (2E hex),

ominus '-' (2D hex),

oplus '+' (2B hex),

oExp 'e' or 'E' (65 hex or 45 hex).

oThe result and operand must not be longer than 13 bytes: Maximum size of an ASCII string is 13 bytes.

FC_SortArrDint

The function sorts the elements of a DINT values table in ascending or descending order and stores the result in the same table.

Name in EcoStruxure Machine Expert - Basic / Twido

SORT_ARR

Input values

i_iSortDirection: INT

i_pdiStartAddr: POINTER TO DINT

i_bySize: BYTE

Return values

FC_SortArrDint: BOOL

The direction parameter i_iSortDirection indicates the sort sequence:

odirection > 0, sorting in ascending order.

odirection < 0, sorting in descending order.

odirection = 0, no sorting is performed.

FC_SortArrReal

The function sorts the elements of a DINT values table in ascending or descending order and stores the result in the same table.

Name in EcoStruxure Machine Expert - Basic / Twido

SORT_ARR

Input values

i_iSortDirection: INT

i_prStartAddr: POINTER TO REAL

i_bySize : BYTE

Return values

FC_SortArrReal : BOOL

The direction parameter i_iSortDirection gives the order of the sort:

odirection > 0, sorting in ascending order.

odirection < 0, sorting in descending order.

odirection = 0, no sorting is performed.

FC_SumArrDint

The function FC_SumArrDint is used to perform the addition of a defined number of array elements whose address is defined at the input i_pdiStartAddr. This means that the function sums up all the elements of an object table.

Name in EcoStruxure Machine Expert - Basic / Twido

SUM_ARR

Input values

i_pdiStartAddr: POINTER TO DINT

i_bySize: BYTE

Return values

FC_SumArrDint : DINT

When the result is not within the valid double word format range according to the table operand, the global variable G_xSystemBitS18 is set to TRUE.

FC_SumArrReal

The function FC_SumArrReal is used to perform the addition of a defined number of array elements whose address is defined at the input i_pdiStartAddr. This means that the function sums up all the elements of an object table.

Name in EcoStruxure Machine Expert - Basic / Twido

SUM_ARR

Input values

i_pdiStartAddr: POINTER TO DINT

i_bySize: BYTE

Return values

FC_SumArrReal : REAL

When the result is not within the valid double word format range according to the table operand, the global variable G_xSystemBitS18 is set to TRUE.