F6_DGT

Digit data move

The hexadecimal digits in the 16-bit data or in the 16-bit equivalent constant specified by s are copied to the 16-bit area specified by d as specified by n.

Parameters

Input

s (WORD, INT, UINT)

Source 16-bit area

n (WORD, INT, UINT)

Specifies source and destination hexadecimal digit position and number of hexadecimal digits

Output

d (WORD, INT, UINT)

Destination 16-bit area

Remarks

  • Instead of using this F instruction, we recommend using the corresponding FP7 instruction: FP_MOVE_DIGITS

  • Digits are units of 4 bits used when handling data. With this instruction, 16-bit data is separated into four digits. The digits are called in order hexadecimal digit 0, digit 1, digit 2 and digit 3, beginning from the least significant four bits:

    1. 16-bit data

    2. bit

    3. hexadec. digit

  • n specifies the (3) source hexadecimal digit position, the (2) number of digits and the (1) destination hexadecimal digit position to be copied using hexadecimal data as follows:

    1.  (1) Destination: Starting hexadecimal digit position

      0 Hexadecimal digit 0

      1 Hexadecimal digit 1

      2 Hexadecimal digit 2

      3 Hexadecimal digit 3

    2.  (2) Number of hexadecimal digits to be copied

      0 Copies 1 hexadecimal digit (4 bits)

      1 Copies 2 hexadecimal digits (8 bits)

      2 Copies 3 hexadecimal digits (12 bits)

      3 Copies 4 hexadecimal digits (16 bits)

    3.  (3) Source: Starting hexadecimal digit position

      0 Hexadecimal digit 0

      1 Hexadecimal digit 1

      2 Hexadecimal digit 2

      3 Hexadecimal digit 3

    Following are some patterns of digit transfer based on the specification of n.

    • Specify n: 16#101 when hexadecimal digit 1 of the source is copied to hexadecimal digit 1 of the destination.

    • Specify n: 16#003 (short form: 16#3) when hexadecimal digit 3 of the source is copied to hexadecimal digit 0 of the destination.

    • Specify n: 16#212 when multiple hexadecimal digits (hexadecimal digits 2 and 3) of the source are copied to multiple hexadecimal digits (hexadecimal digits 2 and 3) of the destination.

    • Specify n: 16#210 when multiple hexadecimal digits (hexadecimal digits 0 and 1) of the source are copied to multiple hexadecimal digits (hexadecimal digits 2 and 3) of the destination.

    • Specify n: 16#130 when 4 hexadecimal digits (hexadecimal digits 0 to 3) of the source are copied to 4 hexadecimal digits (hexadecimal digits 0 to 3) of the destination.

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
		start: BOOL:=FALSE;
		source: INT:=329;
			(*decimal 329 = 16#149*)
		specify_n: WORD:=16#111;
			(*Beginning from the end:
1: first hex. digit is digit 1, i.e. 4
1: copies 2 hex. digits, i.e. 14
1: destination is hex. digit 1*)
		output: INT:=0;
			(*16#140 = decimal 320*)
	END_VAR

POU body

When the variable start is set to TRUE, the function is carried out. The values for source and output in the “Monitor header” of the ladder diagram body have been set to display the hexadecimal value by activating the “Hex” button in the toolbar.

LD body

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 5 ;
        NETWORK_BODY
B(B_F,F6_DGT!,Instance,12,0,18,5,,?DEN?D@'s'?Dn?AENO?Cd);
B(B_VARIN,,source,8,2,10,4,);
B(B_VARIN,,specify_n,8,3,10,5,);
B(B_VAROUT,,output,18,2,20,4,);
B(B_CONTACT,,start,6,1,8,3,);
L(10,3,12,3);
L(10,4,12,4);
L(8,2,12,2);
L(1,2,6,2);
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

IF start then
    F6_DGT( s:= source,
         n:= specify_n,
         d=> output);
END_IF;

IL body

Modified on: 2019-01-24Feedback on this pagePanasonic hotline