F5_BTM

Bit data move

1 bit of the 16-bit data or constant value specified by s is copied to a bit of the 16-bit area specified by d according to the content specified by n if the trigger EN is in the ON-state. When the 16-bit equivalent constant is specified by s, the bit data move operation is performed internally converting it to 16-bit binary expression.

Parameters

Input

s (WORD, INT, UINT)

Source 16-bit area

n (WORD, INT, UINT)

Specifies source and destination bit positions

Output

d (WORD, INT, UINT)

Destination 16-bit area

Example

Explanation with example value 16#8888 and bit at position 2 moves to destination value at bit position 15

  1.  (1) Source: bit position
  2.  (2) Target: bit position
  3.  (3) Result: bit position

Bit at position 15 is exchanged, destination value in this example: 16#7FFF

Remarks

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

  • The variables s and d have to be of the same data type.

  • The operand n specifies the bit number as follows:

    1.  (1) Bit position of source
    2.  (2) Bit position of destination

      Bit No. 0 bis 3

      source bit No. (16#0 to 16#F)

      Bit No. 4 bis 7

      FP2/2SH and 10SH: number of bits to be transferred (16#0 to 16#F)

      FP3: invalid

      Bit No. 8 bis 11

      destination bit No. (16#0 to 16#F)

      Bit No. 12 bis 15

      invalid

    For example, reading from the right, n = 16#C01 would move from bit position one, one bit to bit position 12 (16#C).

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;
			(*activates the function*)
		input_value: WORD:=2#1000100010001000;
		copy_operand: WORD:=16#0F02;
			(*digit no.1 and no.3 are invalid, digit no.0 locates
the position of the source bit (here: 2),
digit no.2 locates the position of the destination bit
(here: 15)*)
		output_value: WORD:=2#1111111111111111;
			(*result after a 0->1 leading
edge from start:
2#0111111111111111*)
	END_VAR

POU body

When the variable start 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 := 6 ;
        NETWORK_BODY
B(B_F,F5_BTM,,12,0,19,5,,?DEN?D@'s'?Dn?AENO?Cd);
B(B_CONTACT,,start,8,1,10,3,);
B(B_VARIN,,input_value,10,2,12,4,);
B(B_VARIN,,copy_operand,10,3,12,5,);
B(B_VAROUT,,output_value,19,2,21,4,);
L(1,2,8,2);
L(10,2,12,2);
L(1,0,1,6);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

IF start then
    F5_BTM( s:= input_value,
         n:= copy_operand,
         d=> output_value);
END_IF;

IL body

LD

start

(* EN = start; Starting signal for the F5_BTM function. *)

F5_BTM

input_value, copy_operand, output_value

(* s = input_value (source) *)

(* n = copy_operand; e.g. Var_1 = 16#0A0B *)

(* 11 source bit (B) Þ 10 destination bit (A) *)

(* d = output_value (destination) *)

ST

out

(* option *)

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