Registro di spostamento a SINISTRA/DESTRA
Sposta 1 bit dell'intervallo dati a 16 bit a sinistra o a destra.
Ingresso
Trigger sinistra/destra; specifica la direzione della rimozione a seguito dello spostamento.
Specifica i nuovi dati spostati all'interno.
Nuovi dati spostati all'interno = TRUE = 1: quando l'ingresso dati è TRUE.
Attiva lo spostamento
Sposta 1 bit a sinistra o destra quando viene rilevato il fronte di salita del trigger (FALSE®TRUE).
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
Area a 16 bit finale
Area a 16 bit iniziale
Uscita
Bit rimosso
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).
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
Quando la variabile enable_leftShift è impostata su TRUE, la funzione esegue lo spostamento a sinistra, diversamente esegue lo spostamento a destra.
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
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]);