-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCLICK_CNT.EXP
More file actions
executable file
·58 lines (46 loc) · 1.04 KB
/
CLICK_CNT.EXP
File metadata and controls
executable file
·58 lines (46 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
(* @NESTEDCOMMENTS := 'Yes' *)
(* @PATH := '\/Logic\/generators' *)
(* @OBJECTFLAGS := '0, 8' *)
(* @SYMFILEFLAGS := '2048' *)
FUNCTION_BLOCK CLICK_CNT
VAR_INPUT
IN : BOOL;
N : INT;
TC : TIME;
END_VAR
VAR_OUTPUT
Q : BOOL;
END_VAR
VAR
tx : TP;
edge: BOOL;
cnt: INT := -1;
END_VAR
(*
version 1.0 16. jul. 2008
programmer hugo
tested by oscat
this Module decodes a specified number of clicks.
the output trig is high for one cycle if N clicks are present within a specified time TC.
*)
(* @END_DECLARATION := '0' *)
(* Q shall only be active for one cycle only *)
Q := FALSE;
IF in AND NOT edge AND NOT tx.q THEN
(* a rising edge on in sets the counter to 0 *)
cnt := 0;
ELSIF tx.Q AND NOT IN AND edge THEN
(* count falling edges when tp.q is true *)
cnt := cnt + 1;
ELSIF NOT tx.Q THEN
Q := cnt = N;
cnt := -1;
END_IF;
(* remember the status of IN *)
edge := IN;
tx(in := IN, pt := TC);
(* revision history
hm 16. jul. 2008 rev 1.0
original version released
*)
END_FUNCTION_BLOCK