F119_LRSR

LEFT/RIGHT shift register

Shifts 1 bit of the 16-bit data range to the left or to the right.

Parameters

Input

LeftDirection (BOOL)

Left/right trigger; specifies the direction of the shift-out:

  • TRUE: shifting out to the left
  • FALSE: shifting out to the right
DataInput (BOOL)

Specifies the new shift-in data.

  • new shift-in data = TRUE = 1: when the data input is in the TRUE-state.

  • new shift-in data = FALSE = 0: when the data input is in the FALSE-state.
ShiftTrigger (BOOL)

Activates shift

Shifts 1 bit to the left or right when the rising edge of the trigger is detected (FALSE®TRUE).

Reset (BOOL)

Turns all the bits of the data range specified by d1_Start and d2_End to 0 if this trigger is in the TRUE-state.

Resets data in area specified by d1_Start and d2_End to 0

d2_End (WORD, INT, UINT)

Ending 16-bit area

d1_Start (WORD, INT, UINT)

Starting 16-bit area

Output

Carry (BOOL)

Bit shifted out

Example

  1.  (1) Left shift operation
  2.  (2) Shifted-out bit is transferred to R9009 (carry flag)
  3.  (3) LeftDirection: ON; Shift Trigger: OFF, ON
  4.  (4) When DataInput turns on, “1” is shifted into bit position 0.
  5.  (5) When DataInput turns off, “0” is shifted into bit position 0.
  6.  (6) Right shift operation
  7.  (7) LeftDirection:OFF; ShiftTrigger: OFF, ON
  8.  (8) Shifted-out bit is transferred to R9009 (carry flag).
  9.  (9) When DataInput turns on, “1” is shifted´ into bit position 15.
  10. (10) When DataInput turns off, “0” is shifted´ into bit position 15.

Remarks

  • The variables d1_Start and d2_End have to be of the same data type.

  • This function does not require a variable at the output Carry.

  • Left/right shift is a shift register which shifts 1 bit of the specified data area to the left (to the higher bit position) or to the right (to the lower bit position).

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
		data_array: ARRAY [0..2] OF INT:=[2#0000000000000001,2#0011111111111111,2#0011111111111110];
		enable_leftShift: BOOL:=FALSE;
			(*function shifts left if TRUE,
else it shifts right*)
		reset: BOOL:=FALSE;
			(*if TRUE, the whole array
will be set to zero*)
		input: BOOL:=TRUE;
			(*specifies the new shift-in data*)
		shift_trigger: BOOL:=FALSE;
			(*activates the function at a 0->1
leading edge*)
		carry_out_value: BOOL:=FALSE;
			(*result after a 0->1 leading edge
from shift_trigger: 1.
After the next cycle the value will be
set back to zero.*)
	END_VAR

POU body

When the variable enable_leftShift is set to TRUE, the function shifts left, else it shifts right.

LD body

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 9 ;
        NETWORK_BODY
B(B_F,F119_LRSR!,Instanz,12,1,22,9,,?DLeftDirection?DDataInput?DShiftTrigger?DReset?Dd1_Start?Dd2_End?ACarry);
B(B_CONTACT,,enable_leftShift,7,2,9,4,);
B(B_VARIN,,input,9,3,11,5,);
B(B_VARIN,,shift_trigger,9,4,11,6,);
B(B_VARIN,,reset,9,5,11,7,);
B(B_VARIN,,data_array[0],9,6,11,8,);
B(B_VARIN,,data_array[2],9,7,11,9,);
B(B_VAROUT,,carry_out_value,22,2,24,4,);
L(1,3,7,3);
L(9,3,12,3);
L(11,4,12,4);
L(11,5,12,5);
L(11,6,12,6);
L(11,7,12,7);
L(11,8,12,8);
L(1,0,1,9);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

carry_out_value:=F119_LRSR( LeftDirection:= enable_leftShift,
         DataInput:= input,
         ShiftTrigger:= shift_trigger,
         Reset:= reset,
         d1_Start:= data_array[0],
         d1_End:= data_array[2]);

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