Код:
FUNCTION_BLOCK DEC_8
VAR_INPUT
D: BOOL;
A0: BOOL;
A1: BOOL;
A2: BOOL;
END_VAR
VAR_OUTPUT
Q0: BOOL;
Q1: BOOL;
Q2: BOOL;
Q3: BOOL;
Q4: BOOL;
Q5: BOOL;
Q6: BOOL;
Q7: BOOL;
END_VAR
VAR
X : INT;
END_VAR
(*
version 1.3 28. mar. 2009
programmer hugo
tested by oscat
a bit input will be decoded to one of the 8 outputs
dependent on the Adress on A0, A1 and A2
*)
X.0 := A0; X.1 := A1; X.2 := A2;
Q0 := FALSE;
Q1 := FALSE;
Q2 := FALSE;
Q3 := FALSE;
Q4 := FALSE;
Q5 := FALSE;
Q6 := FALSE;
Q7 := FALSE;
CASE X OF
0 : Q0 := D;
1 : Q1 := D;
2 : Q2 := D;
3 : Q3 := D;
4 : Q4 := D;
5 : Q5 := D;
6 : Q6 := D;
7 : Q7 := D;
END_CASE;