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