0
1
00:00:20,930 --> 00:00:22,350
Hello.
1

2
00:00:22,450 --> 00:00:23,440
In this video.
2

3
00:00:23,470 --> 00:00:32,520
We are going to learn how to create a function blocks in delta plcs and how to use it I will create
3

4
00:00:32,520 --> 00:00:40,140
a new project and controller type will be AS model and the plc type will be a 332T.
4

5
00:00:40,740 --> 00:00:46,370
I will say okay and the new project is created in the left side.
5

6
00:00:46,410 --> 00:00:50,150
You will see function block section in the project tree.
6

7
00:00:50,370 --> 00:00:51,300
Come here.
7

8
00:00:51,300 --> 00:00:59,410
Select function blocks and right click and say new and give a name to your function block.
8

9
00:00:59,420 --> 00:01:01,880
This is a it can be like this.
9

10
00:01:01,880 --> 00:01:06,410
Function block Zero and then I will use ladder diagram in function block.
10

11
00:01:06,470 --> 00:01:13,070
You can select which programming language in your function block for example you are writing your programs
11

12
00:01:13,430 --> 00:01:20,540
and we are using a ladder diagram in your program section complete plc project but you can use in your
12

13
00:01:20,540 --> 00:01:28,100
function block a ST language or CFC language or C language but I will use ladder language.
13

14
00:01:28,160 --> 00:01:34,040
I will say okay and the function block is open.
14

15
00:01:34,090 --> 00:01:40,970
And now we are inside all function block and it is similar like a program section it is similar page
15

16
00:01:40,970 --> 00:01:42,860
and similar area.
16

17
00:01:42,860 --> 00:01:52,010
And I will create my variables so left click to here come here to left click twice an identifier and
17

18
00:01:52,010 --> 00:01:53,030
class.
18

19
00:01:53,030 --> 00:01:56,450
First thing the variable means var means variable.
19

20
00:01:56,450 --> 00:02:02,000
And the variable means you can use the variables in your function block then these variables cannot
20

21
00:02:02,000 --> 00:02:06,950
be used in your plc project just inside of function block.
21

22
00:02:07,250 --> 00:02:14,810
So for example if you say start variable in your function block this start cannot be reachable in your
22

23
00:02:15,170 --> 00:02:22,310
project in your program section I will create a variable input on this variable input is inputs of function
23

24
00:02:22,310 --> 00:02:29,960
block and this can be seems or you can see it in your program section and you can put the input to this
24

25
00:02:30,200 --> 00:02:35,160
input to this pin for output variable output also similar.
25

26
00:02:35,290 --> 00:02:35,660
Than.
26

27
00:02:35,930 --> 00:02:37,290
Let's continue.
27

28
00:02:37,570 --> 00:02:39,570
You're going to see a little bit later.
28

29
00:02:39,660 --> 00:02:49,950
Variable input will be startmotor and the type will be bool and the variable input selected and I will
29

30
00:02:49,950 --> 00:02:50,880
say okay.
30

31
00:02:50,940 --> 00:03:00,510
And the variable output I will create motor turn forward and type will be bool and I will say okay.
31

32
00:03:00,570 --> 00:03:02,200
And in here ld 
32

33
00:03:02,620 --> 00:03:15,920
Now I can use identifier and start motor and as output out motorforward.
33

34
00:03:17,040 --> 00:03:22,940
I will compile it and this cyclic task needs to assign at this one.
34

35
00:03:23,250 --> 00:03:30,030
So we need to create a program now in program section I will select the ladder diagram.
35

36
00:03:30,030 --> 00:03:31,260
This is similar.
36

37
00:03:31,260 --> 00:03:36,920
And this error is given because of we did not use this function block in any word.
37

38
00:03:37,170 --> 00:03:39,870
I will click this function block select this one.
38

39
00:03:39,870 --> 00:03:46,530
And with the drag and drop method just keep it like this and put it here.
39

40
00:03:46,530 --> 00:03:57,490
So this function block identifier or name will be test function block say ok and test.
40

41
00:03:57,500 --> 00:03:59,450
Function block is created.
41

42
00:03:59,660 --> 00:04:12,420
So in here if you left click twice you will be inside your function block and I will add here one normally
42

43
00:04:12,540 --> 00:04:25,340
open contact to see inputs , M1000 is always on contact and start motor so we need to adopt here our
43

44
00:04:26,210 --> 00:04:27,130
inputs.
44

45
00:04:27,420 --> 00:04:33,560
They will give this input and this input will trigger motor turning.
45

46
00:04:33,560 --> 00:04:37,740
Forward output what can we put here.
46

47
00:04:37,980 --> 00:04:40,540
For example we can put here.
47

48
00:04:40,680 --> 00:04:47,420
Let's create the two and other one variable for example.
48

49
00:04:47,460 --> 00:04:49,410
Now watch all this.
49

50
00:04:49,530 --> 00:04:51,330
We are in program 0.
50

51
00:04:51,360 --> 00:04:57,410
So program section left click to here, than.
51

52
00:04:57,440 --> 00:04:58,230
variable
52

53
00:04:58,250 --> 00:05:09,510
They will create an variable retain remained or retained values for these and variable will start motor
53

54
00:05:10,630 --> 00:05:16,920
others will be assigned automatically and I will say okay.
54

55
00:05:17,270 --> 00:05:20,940
And turnmotor
55

56
00:05:24,120 --> 00:05:27,930
forward and this is the bool
56

57
00:05:30,110 --> 00:05:33,410
now motor
57

58
00:05:34,490 --> 00:05:35,430
Turning.
58

59
00:05:35,580 --> 00:05:43,940
Forward and will be bool and now I will assign these ones to here.
59

60
00:05:44,100 --> 00:05:47,840
But I will create one more network LD.
60

61
00:05:47,940 --> 00:05:53,540
Start motor and the output as output
61

62
00:05:56,080 --> 00:05:57,280
turnmotor
62

63
00:05:58,750 --> 00:05:59,380
Forward.
63

64
00:05:59,830 --> 00:06:01,670
And this one will be here.
64

65
00:06:03,890 --> 00:06:11,520
Third motor forward will be input of our function block and output will be motor turning.
65

66
00:06:11,540 --> 00:06:13,950
Forward you can select it like this.
66

67
00:06:14,000 --> 00:06:18,170
Compile this project and send it to our simulator.
67

68
00:06:22,700 --> 00:06:26,990
Now it's transferring it's transferred now.
68

69
00:06:27,620 --> 00:06:34,540
I will say Run plc , now we are at the run situation.
69

70
00:06:34,630 --> 00:06:35,470
That's okay.
70

71
00:06:35,590 --> 00:06:41,100
And I will say start motor so turn the motor forward is activated.
71

72
00:06:41,140 --> 00:06:42,760
So this is activated.
72

73
00:06:43,030 --> 00:06:45,680
So this needs to be activated.
73

74
00:06:45,680 --> 00:06:50,140
Also so let's take a look what is happening.
74

75
00:06:50,140 --> 00:06:57,400
Device monitor table I will create a new device monitor table in here and the monitor table is created
75

76
00:06:57,430 --> 00:07:02,480
and left click here an identifier and program 0.
76

77
00:07:02,620 --> 00:07:06,280
I will select these ones turn motor forward
77

78
00:07:09,810 --> 00:07:18,560
program 0 I will delete this one and stop motor and then it is one motor turning.
78

79
00:07:18,620 --> 00:07:24,090
Forward so motor turning forward is not activated.
79

80
00:07:25,270 --> 00:07:30,130
Let's go back to our program section and let's take a look.
80

81
00:07:30,130 --> 00:07:31,380
What is the problem.
81

82
00:07:31,390 --> 00:07:35,170
Now we're at the run situation and motor turning for.
82

83
00:07:35,200 --> 00:07:36,460
That's OK.
83

84
00:07:36,470 --> 00:07:42,610
And go back our function block in here what is going on.
84

85
00:07:42,620 --> 00:07:43,390
Let's take a look.
85

86
00:07:44,360 --> 00:07:53,960
Motor turn forward is our variable and start motor is activated by input variable input and then variable
86

87
00:07:53,960 --> 00:07:54,880
output.
87

88
00:07:54,920 --> 00:07:57,890
This must give an output.
88

89
00:07:57,890 --> 00:08:03,750
Let's take a look.
89

90
00:08:03,770 --> 00:08:16,240
This is not this should be always on M1000 I will delete this one enable always
90

91
00:08:18,890 --> 00:08:23,890
update the program line update is completed.
91

92
00:08:24,460 --> 00:08:32,570
So now you see motor turning forward is activated according to our function block.
92

93
00:08:33,040 --> 00:08:39,910
Now this is because of M1000 is did not became on always on.
93

94
00:08:39,940 --> 00:08:46,090
So because of this we did not get this output but now it is always enabled.
94

95
00:08:46,090 --> 00:08:48,430
So a motor is turning forward.
95

96
00:08:48,730 --> 00:08:54,080
So let's continue to put another one inputs than outputs.
96

97
00:08:54,370 --> 00:08:58,510
What will happen now inside of the function block.
97

98
00:08:58,660 --> 00:09:04,360
I will create one more input.
98

99
00:09:04,580 --> 00:09:05,980
Let's give an example.
99

100
00:09:05,990 --> 00:09:07,610
For example we will say
100

101
00:09:10,420 --> 00:09:13,370
system ready
101

102
00:09:16,070 --> 00:09:31,700
and move and system error will be variable output that that type will be moved and this should be variable
102

103
00:09:32,240 --> 00:09:38,320
input inside of our ladder logic in function block.
103

104
00:09:38,500 --> 00:09:43,440
I will say LDI system
104

105
00:09:46,470 --> 00:09:50,790
ready then that means system is not ready.
105

106
00:09:50,790 --> 00:10:03,370
If the system is not ready and let's give a timer T0 zero and for example 50 and if LD T0 is goes
106

107
00:10:03,390 --> 00:10:15,400
high given system error message , out system in error compile it and that moment we change the structure
107

108
00:10:15,400 --> 00:10:23,950
of function block in our program section you're going to see this is assigned after the compile But sometimes
108

109
00:10:23,950 --> 00:10:30,940
it can give an error but that moment you need to delete this function below and you need to drag and
109

110
00:10:30,940 --> 00:10:32,890
drop again like this
110

111
00:10:37,000 --> 00:10:45,940
if you put it like this it will ask again to identify a name and add symbol but you can say test function
111

112
00:10:46,050 --> 00:10:49,050
block so what will happen now let's take a look.
112

113
00:10:49,180 --> 00:10:58,400
Multiply multiple declaration it was assigned before so I will give a name test function block 1.
113

114
00:10:58,450 --> 00:11:02,770
So in here you can delete it for a moment.
114

115
00:11:02,770 --> 00:11:10,120
What we did in here start motor should be turn motor forward and output should be motor turning forward
115

116
00:11:10,510 --> 00:11:18,160
and we will say for example slaves are ready it's coming.
116

117
00:11:18,170 --> 00:11:25,770
Imagine from our communication modbus communication and slaves are ready input will be here.
117

118
00:11:25,870 --> 00:11:29,260
And if slaves are ready what will happen.
118

119
00:11:29,320 --> 00:11:41,150
We won't get an error message and I will say in here as I identify it system has system detected.
119

120
00:11:41,170 --> 00:11:46,530
Let's say like this error and address will be bool and I will say okay.
120

121
00:11:46,870 --> 00:11:55,390
So this will be slaves are ready and this will be system detected error.
121

122
00:11:55,390 --> 00:12:04,980
And in here let's continued to write a plc project again anymore and imagine a lot of information
122

123
00:12:04,980 --> 00:12:08,000
is coming and LD M1
123

124
00:12:08,040 --> 00:12:12,210
This is the system inside of the system.
124

125
00:12:12,210 --> 00:12:13,810
This is the slave M1.
125

126
00:12:13,830 --> 00:12:19,430
Imagine like this and we will check is this slave is okay or not.
126

127
00:12:19,430 --> 00:12:20,640
And if this is coming.
127

128
00:12:20,640 --> 00:12:24,090
Slaves will be ready out slaves
128

129
00:12:28,950 --> 00:12:30,750
ready like this.
129

130
00:12:30,860 --> 00:12:34,650
So I will send it to plc again.
130

131
00:12:34,930 --> 00:12:36,950
It's compiling our project
131

132
00:12:39,670 --> 00:12:46,170
I will say yes and transfer to our simulator yes.
132

133
00:12:46,340 --> 00:12:50,110
And now we have run situation.
133

134
00:12:50,120 --> 00:12:53,390
If we say start motor motorist turning.
134

135
00:12:53,390 --> 00:13:00,200
Forward start motor is of motor turning forward goes off.
135

136
00:13:00,410 --> 00:13:03,550
So no system detected error is high.
136

137
00:13:03,560 --> 00:13:13,540
So imagine we have an input from slave , system detected error is gone I will say okay you disconnected
137

138
00:13:13,540 --> 00:13:20,390
your slave from your system imagine like this set off, 1 and 2 and 3 and 4 and 5.
138

139
00:13:20,470 --> 00:13:29,080
So we will get system detected error after 5 seconds according to our function block because we have
139

140
00:13:29,080 --> 00:13:32,830
a timer and this timer's value 50 second.
140

141
00:13:32,860 --> 00:13:38,710
So you can create your function block like this and you can with the drag and drop method.
141

142
00:13:38,740 --> 00:13:45,040
You can put your function block to here and you can do a lot of things in this function block.
142

143
00:13:45,070 --> 00:13:50,080
This is really basic example of this function block you need to give a name to your function block
143

144
00:13:50,110 --> 00:13:56,950
unit to enable your function block inputs and outputs and you need to adopt your variable inputs and outputs
144

145
00:13:57,170 --> 00:14:04,600
thats all for the function block and the inside of the function block these identifiers are getting
145

146
00:14:04,630 --> 00:14:10,560
addresses automatically and you can assign your addresses in here.
146

147
00:14:10,690 --> 00:14:13,130
I will show it to for example.
147

148
00:14:13,300 --> 00:14:16,510
This can be bool or word or lower.
148

149
00:14:16,540 --> 00:14:22,930
Instead your real string timer everything that function block type and the data unit type and you can
149

150
00:14:22,930 --> 00:14:25,100
select anyone else from here.
150

151
00:14:25,120 --> 00:14:27,830
For example if your communication.
151

152
00:14:28,450 --> 00:14:34,750
If you are working with the communication systems or applications if you have a lot of slaves or if
152

153
00:14:34,750 --> 00:14:41,290
you are doing the breeding analog inputs and outputs and a lot of things you can adopt your function
153

154
00:14:41,290 --> 00:14:41,580
block.
154

155
00:14:41,590 --> 00:14:48,760
Just once done you can use this function block easily in your projects and also in function block sections.
155

156
00:14:48,790 --> 00:14:56,090
If you say again for example new function block you can put your function block paste it then after
156

157
00:14:56,090 --> 00:15:01,700
you created your function block you can protect it with the password you can use a still language and
157

158
00:15:01,850 --> 00:15:10,640
other languages in your function block also and you can add a lot of function block to here I will say
158

159
00:15:10,640 --> 00:15:11,230
OK.
159

160
00:15:11,290 --> 00:15:15,150
And now you see two function block that we have in here.
160

161
00:15:15,170 --> 00:15:23,100
So this is the usage of the function block first thing do small applications with the function block
161

162
00:15:23,430 --> 00:15:30,570
and create just and variable input and output and executor and then we will also do a lot of applications
162

163
00:15:30,660 --> 00:15:38,040
about the function block in the feature in the next videos and we will learn deeply how to use function
163

164
00:15:38,040 --> 00:15:42,880
block effectively but for the moment I'm finished for this video.
164

165
00:15:42,930 --> 00:15:44,450
See you in the next video.
