F119_LRSR

Registro di spostamento a SINISTRA/DESTRA

Sposta 1 bit dell'intervallo dati a 16 bit a sinistra o a destra.

Parametri

Ingresso

LeftDirection (BOOL)

Trigger sinistra/destra; specifica la direzione della rimozione a seguito dello spostamento.

  • TRUE: rimozione verso sinistra.
  • FALSE: rimozione verso destra.
DataInput (BOOL)

Specifica i nuovi dati spostati all'interno.

  • Nuovi dati spostati all'interno = TRUE = 1: quando l'ingresso dati è TRUE.

  • Nuovi dati spostati all'interno = FALSE = 0: quando l'ingresso dati è FALSE.
ShiftTrigger (BOOL)

Attiva lo spostamento

Sposta 1 bit a sinistra o destra quando viene rilevato il fronte di salita del trigger (FALSE®TRUE).

Reset (BOOL)

Imposta tutti i bit dell'intervallo dati specificato da d1_Start e d2_End su 0 se questo trigger è in stato TRUE.

Resetta i dati nell'area specificata da d1_Start e d2_End a 0

d2_End (WORD, INT, UINT)

Area a 16 bit finale

d1_Start (WORD, INT, UINT)

Area a 16 bit iniziale

Uscita

Carry (BOOL)

Bit rimosso

Esempio

  1.  (1) Operazione di spostamento a sinistra
  2.  (2) Il bit rimosso viene trasferito in R9009 (flag di carry)
  3.  (3) LeftDirection: TRUE, ShiftTrigger: FALSE, TRUE
  4.  (4) Quando DataInput passa a TRUE, "1" viene spostato nella posizione bit 0.
  5.  (5) Quando DataInput passa a FALSE, "0" viene spostato nella posizione bit 0.
  6.  (6) Operazione di spostamento a destra
  7.  (7) LeftDirection:TRUE; ShiftTrigger: FALSE, TRUE
  8.  (8) Il bit rimosso viene trasferito in R9009 (flag di carry).
  9.  (9) Quando DataInput passa a TRUE, "1" viene spostato nella posizione bit 15.
  10. (10) Quando DataInput passa a FALSE, "0" viene spostato nella posizione bit 15.

Note

  • Le variabili d1_Start e d2_End devono presentare lo stesso tipo di dato.

  • Questa funzione non richiede una variabile all'uscita Carry.

  • Lo spostamento a sinistra/destra è un registro di spostamento che sposta 1 bit dell'area dati specificata a sinistra (verso la posizione bit più significativa) o a destra (verso la posizione bit meno significativa).

Esempio

Intestazione del POU

Tutte le variabili di ingresso e uscita utilizzate per programmare questa funzione sono state dichiarate nell'intestazione del POU. La stessa intestazione del POU è utilizzata per tutti i linguaggi di programmazione.

	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

Corpo del POU

Quando la variabile enable_leftShift è impostata su TRUE, la funzione esegue lo spostamento a sinistra, diversamente esegue lo spostamento a destra.

Corpo LD

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

Corpo ST

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]);

L'ultima revisione: 2021-07-14Feedback su questa paginaPanasonic hotline