summaryrefslogtreecommitdiff
path: root/exp/FB_DI.EXP
blob: 5bead4256b8e453779814a095df8b18082456cf9 (plain) (blame)
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
59
60
61
62
63
64
65
66
67
68
(* @NESTEDCOMMENTS := 'Yes' *)
(* @PATH := '\/TEMP' *)
(* @OBJECTFLAGS := '0, 8' *)
(* @SYMFILEFLAGS := '2048' *)
FUNCTION_BLOCK FB_DI

VAR_INPUT
	E_INPUT	AT%I*	: BOOL;
	UEboDisable	: BOOL;
	UEboResetFlankenZaehler: BOOL;
	UEtEntprellZeit: TIME := t#50ms;
	UEboProtokolle : BOOL;
	UEsName: STRING := 'unbenannt';
END_VAR

VAR_OUTPUT
	UAboInputPosFlanke: BOOL;
	UAboInputEntprellt: BOOL;
	UAboInput: BOOL;
	UAboInputNegFlanke: BOOL;
END_VAR

VAR
	pfInput: R_TRIG;
	dwPosFlanken: DWORD;
	tonInput: TON;
	nfInput: F_TRIG;
	dwNegFlanken: DWORD;
	sTemp: STRING;
END_VAR
(* @END_DECLARATION := '0' *)
(* Digital Input FB *)

pfInput(clk:=E_INPUT AND NOT UEboDisable);
nfInput(clk:=E_INPUT AND NOT UEboDisable);

IF pfInput.Q THEN
	dwPosFlanken := dwPosFlanken + 1;
(*	IF UEboProtokolle THEN
		fProtokoll(1, CONCAT('pfInput: ', UEsName), 0);
	END_IF*)
END_IF

IF nfInput.Q THEN
	dwNegFlanken := dwNegFlanken + 1;
(*	IF UEboProtokolle THEN
		fProtokoll(1, CONCAT('nfInput: ', UEsName), 0);
	END_IF*)
END_IF

IF UEboResetFlankenZaehler THEN
	UEboResetFlankenZaehler := FALSE;
	dwPosFlanken := 0;
	dwNegFlanken := 0;
END_IF

(************************************)

tonInput(in:=E_INPUT AND NOT UEboDisable, pt:=UEtEntprellZeit);

(************************************)

UAboInput := E_INPUT AND NOT UEboDisable;
UAboInputPosFlanke := pfInput.Q;
UAboInputNegFlanke := nfInput.Q;
UAboInputEntprellt := tonInput.Q;
END_FUNCTION_BLOCK
in each repos: see "about"-tab (if existing) for more details / README.
mailto contact at omeckman dot net
all timestamps in UTC (German winter time: UTC+01:00, summer time: UTC+02:00)
dark theme is a modded version of: https://gist.github.com/Yoplitein/f4b671a2ec70c9e743fa