Counts the number of rising edges for each bit
This FP instruction counts the number of rising edges of each bit in the data area specified by the starting address s1_Start and the number of bits n_Bits. The counting results are stored in n_Bits elements of data type DINT or UDINT starting with d_Start.
Input
Starting address of the data area for the bits to be evaluated.
Use the following formula to determine the minimum size of this data area:
All decimal places in the result of this integer division must be removed.
n_Bits from 1–16 => size is 1 word.
n_Bits from 17–32 => size is 2 words...
Starting address of the working area. Its size must be identical to the size of s1_Start.
Number of bits (permissible range: 1–65535)
Output
Starting address of the data area storing the counting results consisting of minimum n_Bits elements of data type DINT or UDINT. Please use the instructions Adr_Of_Var_I (LD/FBD) or Adr_Of_Var (ST) to apply this data area.
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;
iTestIndex: INT:=0;
iWorkAreaCount: INT:=0;
arrCountEvents: ARRAY [0..5] of dint:=[6(0)];
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 := 6 ;
NETWORK_BODY
B(B_F,FP_EVENTS_COUNT!,,12,0,22,6,,?DEN?Ds1_Start?Ds2_WorkArea?Dn_Bits?AENO?Cd_Start);
B(B_VARIN,,iTestIndex,10,2,12,4,);
B(B_VARIN,,iWorkAreaCount,10,3,12,5,);
B(B_VARIN,,6,10,4,12,6,);
B(B_VAROUT,,arrCountEvents[0],33,2,35,4,);
B(B_CONTACT,,bStart,3,1,5,3,);
B(B_F,Adr_Of_Var_O!,,25,2,33,4,,?D?C);
L(1,2,3,2);
L(5,2,12,2);
L(22,3,25,3);
L(1,0,1,6);
END_NETWORK_BODY
END_NET_WORK
END_BODY
IF (bStart) then
FP_EVENTS_COUNT(s1_Start := iTestIndex,
s2_WorkArea := iWorkAreaCount,
n_Bits := 6,
d_Start => Adr_Of_Var(arrCountEvents[0]));
END_IF;