FP_ROR_CARRY

Rotate data to the right with carry flag

This FP instruction rotates the data specified by d to the right (to the lower bit position) by the number of bits specified by n_Bits and including the data of the carry flag if the trigger EN is TRUE.

Parameters

Input

n_Bits (WORD, INT, UINT)

Number of bits

Values: 0–255

Input/output

d (WORD, DWORD)

Data to be rotated

Error flags

sys_bIsOperationErrorHold (turns to TRUE and remains TRUE)

if the area specified using the index modifier exceeds the limit.

sys_bIsOperationErrorNonHold (turns to TRUE for one scan)

if the area specified using the index modifier exceeds the limit.

sys_bIsCarry (turns to TRUE for one scan)
  • if d= 16-bit data and n_Bits is either 0 or a multiple of 17, no rotation occurs and the carry flag remains unchanged.
  • if d= 32-bit data and n_Bits is either 0 or a multiple of 33, no rotation occurs and the carry flag remains unchanged.

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*)
		wRotate_value: WORD:=16#1234;
	END_VAR

LD body

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

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,FP_ROR_CARRY!,,11,0,20,5,,?DEN?Dn_Bits?Dd?Ad?AENO);
B(B_CONTACT,,bStart,5,1,7,3,);
B(B_VARIN,,4,9,2,11,4,);
B(B_VARIN,,wRotate_value,9,3,11,5,);
L(1,2,5,2);
L(7,2,11,2);
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

IF DF(start) then
    FP_ROR_CARRY(n_Bits := 4, d := wRotate_value);
END_IF;

Modified on: 2022-05-13Feedback on this pagePanasonic hotline