Math Functions - SCL - Book - 30 S
Math Functions - SCL - Book - 30 S
1 FUNCTION_BLOCK STD_MATH
2 TITLE = 'Call examples for math functions'
3 //Chapter 30.3 "Math Functions"
4
5 NAME : STD_MATH
6 FAMILY : SCL_Book
7 AUTHOR : Berger
8 VERSION : '1.0'
9
10 VAR
11 real1 : REAL := 0;
12 real2 : REAL := 0;
13 real3 : REAL := 0;
14 real4 : REAL := 0;
15 real5 : REAL := 0;
16 real6 : REAL := 0;
17 real7 : REAL := 0;
18 real8 : REAL := 0;
19 real9 : REAL := 0;
20 real10 : REAL := 0;
21 real11 : REAL := 0;
22 real12 : REAL := 0;
23 real13 : REAL := 0;
24 real14 : REAL := 0;
25
26 Reactive_power: REAL := 0;
27 Voltage : REAL := 230;
28 Current : REAL := 1.5;
29 PHI : REAL := 0.35;
30 Volume : REAL := 0;
31 Radius : REAL := 47;
32 Level : REAL := 120;
33 PI : REAL := 3.141593;
34 a : REAL := 5;
35 b : REAL := 12;
36 c : REAL := 0;
37
38 END_VAR
39
40 BEGIN
41 //***************************************************************************
42
43 real2 := ABS(real1); //Absolute value
44 real3 := SQR(real1); //Generate square
45 real4 := SQRT(real1); //Generate square root
46
47 real5 := SIN(real1); //Sine
48 real6 := COS(real1); //Cosine
49 real7 := TAN(real1); //Tangent
50
51 real8 := ASIN(real1); //Arc sine
52 real9 := ACOS(real1); //Arc cosine
53 real10 := ATAN(real1); //Arc tangent
54
55 real11 := EXP(real1); //Exponentiation to base e
56 real12 := EXPD(real1); //Exponentiation to base 10
57 real13 := LN(real1); //Natural logarithm
58 real14 := LOG(real1); //Decimal logarithm
59
60 //***************************************************************************
61
62 Reactive_power:= Voltage * Current * sin(PHI);
63 Volume := SQR(Radius) * Level * PI;
64 c := SQRT(SQR(a) + SQR(b));
65
66 //***************************************************************************
67
68 END_FUNCTION_BLOCK
69
Page 1 of 1