Digit data move
This FP instruction moves n_Digits number of digits of the source value s_Source from digit position n_SourcePos to the destination digit position n_DestPos of the 16-bit data specified by d_Dest.
Input
Data area of source
Specifies source hexadecimal digit position (0–3)
Number of hexadecimal digits (1–4)
Specifies destination hexadecimal digit position (0–3)
Output
data area of destination
If the number of digits from the starting digit position exceeds the maximum number of digits (n_SourcePos + n_Digits > 4), the remaining digits are shifted to the digit position starting from 0 of the same word.
The operands s1_Start and s2_End should be:
in the same memory area, e.g. DT, WR, FL, LD ...
s1_Start £ s2_End
Move multiple digits
Move four digits
if one of the input variables/output variable is out of range
if one of the input variables/output variable is out of range
Corresponding F instructions: F6_DGT
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*)
wInput_value: WORD:=2#1000100010001000;
iSourceBitPosition: INT:=0;
(*digit no.0 locates the position of the source bit (here: 2)*)
iNumberofDigit: INT:=1;
iDestinationBitPosition: INT:=2;
(*digit no.2 locates the position of the destination bit (here: 15)*)
wOutput_value: WORD:=2#1111111111111111;
(*result after a 0->1 leading
edge from start:
2#0111111111111111*)
END_VAR
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 := 8 ;
NETWORK_BODY
B(B_F,FP_MOVE_DIGITS!,,13,1,22,8,,?DEN?Ds_Source?Dn_SourcePos?Dn_Digits?Dn_DestPos?AENO?Cd_Dest);
B(B_VARIN,,wInput_value,11,3,13,5,);
B(B_CONTACT,,bStart,7,2,9,4,);
B(B_VARIN,,iSourceBitPosition,11,4,13,6,);
B(B_VARIN,,iNumberofDigit,11,5,13,7,);
B(B_VARIN,,iDestinationBitPosition,11,6,13,8,);
B(B_VAROUT,,wOutput_value,22,3,24,5,);
L(1,3,7,3);
L(9,3,13,3);
L(1,0,1,8);
END_NETWORK_BODY
END_NET_WORK
END_BODY
If (bStart) then
FP_MOVE_DIGITS(s_Source := wInput_value,
n_SourcePos := iSourceBitPosition,
n_Digits := iNumberofDigit,
n_DestPos := iDestinationBitPosition,
d_Dest => wOutput_value);
End_if;