Move Operations for IEC
See also: IEC 61131 Language Editor Programming
See also: Project Toolbox for IEC
Topic Menu
Home > View > Project Toolbox > Move Operations
Move Single 
Operator - variable assignment.
Inputs
IN : ANY Any variable or complex expression
Outputs
Q : ANY Forced variable
Remarks - The output variable and the input expression must have the same type. The forced variable cannot have the "read only" attribute. In LD and FBD languages, the "1" block is available to perform a "1 gain" data copy. In LD language, the EN enables the assignment, and the ENO keeps the state of the EN. In IL language, the LD instruction loads the first operand, and the ST instruction stores the current result into a variable. The current result and the operand of ST must have the same type. Both LD and ST instructions can be modified by "N" in case of a Boolean Boolean- [Data Type BOOL] - A single bit, binary value, or register/variable. Boolean points have only two possible values, 'TRUE' or 'FALSE'. operand for performing a Boolean negation.
ST Language
Q := IN; (*copy IN into variable Q*)
Q := (IN1 + (IN2 / IN 3 )) * IN4; (* assign the result of a complex expression *)
result := SIN (angle); (* assign a variable with the result of a function *)
time := MyTon.ET; (* assign a variable with an output parameter of a function block *)
FBD Language
LD Language
(* The copy is executed only if EN is TRUE *)
(* ENO has the same value as EN *)
IL Language
Return to the Top: Move Operations for IEC
Move Block 
Operator – This element moves a block of register values from source to destination location.
Inputs
SRC[ ] – (TYPE : ANY[]) - Source value must be an array, the move will start at the first value of the array, no offset can be specified.
For example - Sr[0] to Sr[4] is containing 28.
DST[ ] – (TYPE : ANY[]) - This is output register and it must be an array, the move will start with the first value, no offset can be specified.
For example - Dest[0] to Dest[4] and count is 5 then it moves from Sr0 – Sr4 value to Dest0 – Dest4.
# COUNT – (TYPE : INT) - It should be a constant value and enter in INT#5 format. For example - Count value is 5.
ST Language
(* MVB1 is a declared instance of MVB function block *)
FBD Language
(* MVBFBD is a declared instance of MVB function block *)
LD Language
(* MoveBlock is a declared instance of MVB function block *)
IL Language
(* Move is a declared instance of MVB function block *)
Return to the Top: Move Operations for IEC
Fill Block 
Operator – This element fills a source register values from src location to destination location. NOTE: The Fill element operates on 16-bit data only.
WARNING: If the IN value is a signed numeric constant, it is treated as an unsigned number when the element is configured. For example, if IN is configured as '-1', the value '65535' is used.
Inputs
SRC – (TYPE : INT) - Source value can be either an integer constant or the value contained in another register. For e.g. R1 is containing 123.
DST[ ] - (TYPE : Any[]) - This is output starting register. For e.g. R10 and count is 5 then start to fill the value as follow:
R10 – 123
R11 -- 123
R12 -- 123
R13 -- 123
R14 -- 123
#COUNT – (TYPE : INT) - It should be a constant value and enter in INT#5 format. For e.g. Count value is 5.
ST Language
(* FILL1 is a declared instance of FILL function block *)
FILL1 (SRC, DST[], #COUNT);
FBD Language
LD Language
IL Language
(* FILL1 is a declared instance of FILL function block *)
Return to the Top: Move Operations for IEC
Shift Elements 
Operator – This function allows an array of BITS, BYTES, WORDS, and DWORDS to be shifted left or right a variable numbers of elements.
Inputs
Power Flow – (TYPE : BOOL) - When the input to this function block is high it completes a shift as specified by the parameters every scan. This function is not edge sensitive. This function always passes power flow.
N - (TYPE : INT) - This is the number of elements to shift. This can be a constant or a WORD variable. The N (number) range is less than or equal to the LEN value.
SRC[ ] – (TYPE : ANY[]) - This is the starting BIT, BYTE, WORD or DWORD for the array to be shifted. After the data is shifted it is stored in the array of data starting at this location. BIT arrays can start at any location (%I1, %I6, %R1.1, and % R4.7...). BYTE, WORD, and DWORD arrays must start on a WORD boundary (%I1, %I17, %I33, %R1, and % R2...).
#LEN – (TYPE : DINT) - This is the number of BITS, BYTES, WORDS, or DWORDS in the array.
This must be a constant number as follows:
BIT: 1 to 32767
BYTE: 1 to 4096
WORD: 1 to 2048
DWORD: 1 to 1024
Left - (TYPE : BOOL) - This is the direction to shift. If this input is high the data is shifted to the left. If this input is low the data is shifted to the right.
IN - (TYPE : ANY) - This is the BIT, BYTE, WORD, or DWORD to shift into the array.
@OUT - (TYPE : ANY) - This is the last BIT, BYTE, WORD or DWORD shifted out of the array.
ST Language
(* MS is a declared instance of MultiShift function block *)
MS(N, SRC[], #LEN, LEFT, @OUT, IN);
FBD Language
LD Language
En is the Enable input & Eno is the enable output. En & Eno will be the same state. The other functionality is similar to that of a FBD.
IL Language
(* MS is a declared instance of MultiShift function block *)
Return to the Top: Move Operations for IEC
Rotate Elements 
Operator – This function allows an array of BITS, BYTES Byte - [Data Type BYTE] - A string of 8 consecutive bits. A single BYTE is also the size of a single ASCII character., WORDS
Word - [Data Type WORD] - A string of 16 consecutive bits. WORD values are used where the value of the data is not as important as the bit patterns (shifts and rotates)., and DWORDS
DWORD - [Data Type DWORD] - A string of 32 consecutive bits. DWORD values are used where the value of the data is not as important as the bit patterns (shifts and rotates). to be rotated left or right a variable numbers of elements.
Inputs
Power Flow – (TYPE : BOOL Boolean- [Data Type BOOL] - A single bit, binary value, or register/variable. Boolean points have only two possible values, 'TRUE' or 'FALSE'.) - When the input to this function block is high it completes a rotate as specified by the parameters every scan. This function is not edge sensitive. This function always passes power flow.
N – (TYPE : INT Integer - [Data Type INT] - A 16-bit signed value. Integers are used where the value of the data is expected to be in the range of -32,768 to +32,767.) - This is the number of elements to rotate. This can be a constant or a WORD
Word - [Data Type WORD] - A string of 16 consecutive bits. WORD values are used where the value of the data is not as important as the bit patterns (shifts and rotates). variable. The N (number) range is less than or equal to the LEN value.
SRC[ ] – (TYPE : ANY[]) - This is the starting BIT, BYTE, WORD or DWORD for the array to be rotated. After the data is rotated it is stored in the array of data starting at this location. BIT arrays can start at any location (%I1, %I6, %R1.1, and % R4.7...). BYTE, WORD, and DWORD arrays must start on a WORD boundary (%I1, %I17, %I33, %R1, and % R2...).
#LEN – (TYPE : DINT Double Integer - [Data Type DINT] - A 32-bit signed value. Double Integers are used where the value of the data is expected to be in the range of -2,147,483,648 to +2,147,483,647.) - This is the number of BITS, BYTES, WORDS, or DWORDS in the array. This must be a constant number from 1 to 32767.
BIT: 1 to 32767
BYTE: 1 to 4096
WORD: 1 to 2048
DWORD: 1 to 1024
Left - This is the direction to rotate. If this input is high the data is rotated to the left. If this input is low the data is rotated to the right.
ST Language
(* MR is a declared instance of MultiRot function block *)
MR(N, SRC[], #LEN, LEFT);
FBD Language
LD Language
En is the Enable input & Eno is the enable output. En & Eno will be the same state. The other functionality is similar to that of a FBD.
IL Language
(* MR is a declared instance of MultiRot function block *)
Return to the Top: Move Operations for IEC
Binary Selector
Function - Select one of the inputs - 2 inputs.
Inputs
SELECT : BOOL Selection command
IN1 : DINT First input
IN2 : DINT Second input
Outputs
Q : DINT IN1 if SELECT is FALSE; IN2 if SELECT is TRUE
Truth Table
Select | Q |
---|---|
0 |
IN1 |
1 |
IN2 |
Remarks - In LD language, the selector command is the input rung. The output rung keeps the same state as the input rung. In IL language, the first parameter (selector) must be loaded in the current result before calling the function. Other inputs are operands of the function, separated by commas.
ST Language
Q:= SEL (SELECT, IN1, IN2);
SerializeIn
(Supported only in Enhanced IEC language)
Function - Extract the value of a variable from a binary frame.
Inputs
FRAME: USINT : Source buffer - must be an array.
DATA: ANY (*) : Destination variable to be copied.
POS: DINT : Position in the source buffer.
BIGENDIAN: BOOL : TRUE if the frame is encoded with Big Endian format.
(*) DATA cannot be a STRING.
Outputs
NEXTPOS: DINT : Position in the source buffer after the extracted data.
0 in case or error (invalid position / buffer size).
Remarks
This function is commonly used for extracting data from a communication frame in binary format.
-
In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung.
-
The FRAME input must fit the input position and data size. If the value cannot be safely extracted, the function returns 0.
-
The DATA input must be directly connected to a variable, and cannot be a constant or complex expression. This variable will be forced with the extracted value.
-
The function extracts the following number of bytes from the source frame:
-
1 byte for BOOL, SINT, USINT and BYTE variables
-
2 bytes for INT, UINT and WORD variables
-
4 bytes for DINT, UDINT, DWORD and REAL variables
-
8 bytes for LINT and LREAL variables
-
-
The function cannot be used to serialize STRING variables.
-
The function returns the position in the source frame, after the extracted data. Thus, the return value can be used as a position for the next serialization.
ST Language
nextpos5: = Serializein (frame5, data5, pos5, Bigendian);
FBD Language
LD Language
The function is executed only if EN is TRUE.
ENO keeps the same value as EN.
Return to the Top: Move Operations for IEC
SerializeOut
(Supported only in Enhanced IEC language)
Function - Copy the value of a variable to a binary frame.
Inputs
FRAME: USINT : Destination buffer - must be an array.
DATA: ANY (*) : Source variable to be copied.
POS: DINT : Position in the destination buffer.
BIGENDIAN: BOOL : TRUE if the frame is encoded with Big Endian format.
(*) DATA cannot be a STRING.
Outputs
NEXTPOS: DINT : Position in the destination buffer after the copied data.
0 in case or error (invalid position / buffer size).
Remarks
This function is commonly used for building a communication frame in binary format.
-
In LD language, the operation is executed only if the input rung (EN) is TRUE. The output rung (ENO) keeps the same value as the input rung.
-
The FRAME input must be an array large enough to receive the data. If the data cannot be safely copied to the destination buffer, the function returns 0.
-
The DATA input must be directly connected to a variable, and cannot be a constant or complex expression. This variable will be forced with the extracted value.
-
The function copies the following number of bytes to the destination frame:
-
1 byte for BOOL, SINT, USINT and BYTE variables
-
2 bytes for INT, UINT and WORD variables
-
4 bytes for DINT, UDINT, DWORD and REAL variables
-
8 bytes for LINT and LREAL variables
-
-
The function cannot be used to serialize STRING variables.
-
The function returns the position in the destination frame, after the copied data. Thus, the return value can be used as a position for the next serialization.
ST Language
Nextpos4 := SERIALIZEOUT ( frame4, data4, pos4, BigEndian );
FBD Language
LD Language
The function is executed only if EN is TRUE.
ENO keeps the same value as EN.
Return to the Top: Move Operations for IEC
Stepper Move 
Operator -The Stepper Move element provides the necessary interface between Cscape and the Horner remote I/O with a stepper.
Inputs
STEPPER STARTING % AQ (@Stepper): (TYPE: INT) - This contains the address of the first % AQ register assigned to the Stepper SmartStack module. This information can be taken from the Stepper Module SmartStack Configuration.
DESTINATION POSITION ( DP): (TYPE: DINT) - This is a 32-bit register, contains the position where the move is to end. Value range is -8,388,608 to +8,388,607
VELOCITY RESOLUTION ( VR): (TYPE: INT) - This is a 16-bit register. Values range from 20 to 65535.
BASE VELOCITY ( BV): (TYPE: INT) - This is a 16-bit register. Values range from 1 to 8190.
RUNNING VELOCITY ( RV): (TYPE: INT) - This is a 16-bit register. Values range from 2 to 8191.
ACCELERATION TIME (AC): (TYPE: INT) - This is a 16-bit register. Times are listed in milliseconds ( mS). Values range from 1 to 27300.
DECELERATION TIME (DC): (TYPE: INT) - This is a 16-bit register. Times are listed in milliseconds ( mS). Values range from 0 to 27300.
ST Language
(* STEPM is a declared instance of StepperMove function block *)
STEPM(@Stepper, DP, VD, BV, RV, AC, DC);
FBD Language
LD Language
IL Language
Return to the Top: Move Operations for IEC
Indexed Stepper Move
StepperMoveInd
Operator - Stepper Move element provides the necessary interface between Cscape and Horner remote I/O with Index defined.
Inputs
STEPPER STARTING % AQ (@Stepper): (TYPE: INT) - This contains the address of the first % AQ register.
DESTINATION POSITION ( DP): (TYPE: DINT) - This is a 32-bit register, contains the position where the move is to end. Value range is -8,388,608 to +8,388,607
VELOCITY RESOLUTION ( VR): (TYPE: INT) - This is a 16-bit register. Values range from 20 to 65535.
BASE VELOCITY ( BV): (TYPE: INT) - This is a 16-bit register. Values range from 1 to 8190.
RUNNING VELOCITY ( RV): (TYPE: INT) - This is a 16-bit register. Values range from 2 to 8191.
ACCELERATION TIME (AC): (TYPE: INT) - This is a 16-bit register. Times are listed in milliseconds ( mS). Values range from 1 to 27300.
DECELERATION TIME (DC): (TYPE: INT) - This is a 16-bit register. Times are listed in milliseconds ( mS). Values range from 0 to 27300.
The following registers are used only for Index Move operations:
INDEX DESTINATION POSITION ( IDP): (TYPE: DINT) - This is a 32-bit register. Values range from 0 to 16,777,215.
INDEX DECELERATION ( IDC): (TYPE: INT) - This is a 16-bit register. Values range from 1 to 27,300.
INDEX WINDOW OPEN (IWO): (TYPE: DINT) - This is a 32-bit register. Values range from 0 to 16,777,215.
INDEX WINDOW CLOSED ( IWC): (TYPE: DINT) - This is a 32-bit register. Values range from 0 to 16,777,215.
ST Language
(* STEPM1 is a declared instance of StepperMoveInd function block *)
STEPM1(@Stepper, DP, VD, BV, RV, AC, DC, IDP, IDC, IWO, IWC);
FBD Language
LD Language
IL Language
Return to the Top: Move Operations for IEC
Copy to 3D Array
This block is used to copy the input value to a particular three dimensional array.
IN - This is the input value that needs to be copied to a particular array.
Arr[] - Three dimensional array
I, J, K - Array to which the input value needs to be copied.
FBD Language
Eg: Here the input value 100 will be copied to the array [9,9,9].
LD Language
ST Language
Three_Arr [Three_I 2, Three_J 1, Three_K 2] := Three_in 123;
IL Language
Return to the Top: Move Operations for IEC
Copy to 2D Array
This block is used to copy the input value to a particular two dimensional array.
IN - This is the input value that needs to be copied to a particular array.
Arr[] - Two dimensional array
I, J - Array to which the input value needs to be copied.
FBD Language
Eg: Here the input value 50 will be copied to the array [0,9].
LD Language
ST Language
Two_Arr[Two_I 8, Two_J 9] := Two_In 456;
IL Language
Return to the Top: Move Operations for IEC
Copy to 1D Array
This block is used to copy the input value to a particular Single dimensional array.
IN - This is the input value that needs to be copied to a particular array.
Arr[] - Single dimensional array
I - Array to which the input value needs to be copied.
FBD Language
Eg: Here the input value 5 will be copied to the array [5].
LD Language
ST Language
One_Arr_I 7] := One_In 789;
IL Language
Return to the Top: Move Operations for IEC
Copy from 3D Array
This block gets the value from a particular three dimensional array.
Arr[] - Three dimensional array
I, J, K - Array from which value needs to be obtained.
Out - This is the output value that is obtained from a particular array.
FBD Language
Eg: Here value 999 is obtained from the configured array [1,8,9]
LD Language
ST Language
Three_Out 999 := Three_Arr[Three_I 1, Three_J 2, Three_K 3];
IL Language
Return to the Top: Move Operations for IEC
Copy from 2D Array
This block gets the value from a particular two dimensional array.
Arr[] - Two dimensional array
I, J - Array from which value needs to be obtained.
Out - This is the output value that is obtained from a particular array.
FBD Language
Eg: Here value 555 is obtained from the configured array [9,9]
LD Language
ST Language
Two_out 888 := Two_Arr[Two_I 4, Two_J 5];
IL Language
Return to the Top: Move Operations for IEC
Copy from 1D Array
This block gets the value from a particular Single dimensional array.
Arr[] - Single dimensional array
I - Array from which value needs to be obtained.
Out - This is the output value that is obtained from a particular array.
FBD Language
Eg: Here value 55 is obtained from the configured array [6]
LD Language
ST Language
One_out 777 := One_Arr[One_I 6];
IL Language
Return to the Top: Move Operations for IEC