FP_MOVE_DIGITS

Digit data move

This FP instruction moves n_Digits number of digits of the source value s_Source from digit position n_SourcePos to the destination digit position n_DestPos of the 16-bit data specified by d_Dest.

Parameters

Input

s_Source (WORD)

Data area of source

n_SourcePos (INT, DINT, UINT, UDINT)

Specifies source hexadecimal digit position (0–3)

n_Digits (INT, DINT, UINT, UDINT)

Number of hexadecimal digits (1–4)

n_DestPos (INT, DINT, UINT, UDINT)

Specifies destination hexadecimal digit position (0–3)

Output

d_Dest (WORD)

data area of destination

Remarks

  • If the number of digits from the starting digit position exceeds the maximum number of digits (n_SourcePos + n_Digits > 4), the remaining digits are shifted to the digit position starting from 0 of the same word.

  • The operands s1_Start and s2_End should be:

    • in the same memory area, e.g. DT, WR, FL, LD ...

    • s1_Start £ s2_End

Example

  • Move multiple digits

    • s_Source...WX0
    • n_Digits...U2
    • d_Dest...WY0
    • n_SourcePos...U0
    • n_DestPos...U2
  • Move four digits

    • s_Source...WX0
    • n_Digits...U4
    • d_Dest...WY0
    • n_SourcePos...U0
    • n_DestPos...U4

Error flags

sys_bIsOperationErrorHold (turns to TRUE and remains TRUE)
  • if the area specified using the index modifier exceeds the limit.
  • if one of the input variables/output variable is out of range

sys_bIsOperationErrorNonHold (turns to TRUE for one scan)
  • if the area specified using the index modifier exceeds the limit.
  • if one of the input variables/output variable is out of range

Related topics:

Example

POU header

All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.

	VAR
		bStart: BOOL:=FALSE;
			(*activates the function*)
		wInput_value: WORD:=2#1000100010001000;
		iSourceBitPosition: INT:=0;
			(*digit no.0 locates the position of the source bit (here: 2)*)
		iNumberofDigit: INT:=1;
		iDestinationBitPosition: INT:=2;
			(*digit no.2 locates the position of the destination bit (here: 15)*)
		wOutput_value: WORD:=2#1111111111111111;
			(*result after a 0->1 leading
edge from start:
2#0111111111111111*)
	END_VAR

POU body

When the variable bStart is set to TRUE, the function is carried out.

LD body

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 8 ;
        NETWORK_BODY
B(B_F,FP_MOVE_DIGITS!,,13,1,22,8,,?DEN?Ds_Source?Dn_SourcePos?Dn_Digits?Dn_DestPos?AENO?Cd_Dest);
B(B_VARIN,,wInput_value,11,3,13,5,);
B(B_CONTACT,,bStart,7,2,9,4,);
B(B_VARIN,,iSourceBitPosition,11,4,13,6,);
B(B_VARIN,,iNumberofDigit,11,5,13,7,);
B(B_VARIN,,iDestinationBitPosition,11,6,13,8,);
B(B_VAROUT,,wOutput_value,22,3,24,5,);
L(1,3,7,3);
L(9,3,13,3);
L(1,0,1,8);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

If (bStart) then
    FP_MOVE_DIGITS(s_Source := wInput_value,
                   n_SourcePos := iSourceBitPosition,
                   n_Digits := iNumberofDigit,
                   n_DestPos := iDestinationBitPosition,
                   d_Dest => wOutput_value);
End_if;

Modified on: 2020-06-26Feedback on this pagePanasonic hotline