I'm .NET Framework senior programmer but I really failed to understand the whole story of programming in STL. I want to understand the technology very fast. I purchased Automation with Step7 in STL and SCL. I know that the code is event-oriented but how OB, FB and FC communicate with each other.
Let me tell you what I understand and correct me if I'm wrong.
The PLC's operating system keeps looping through OB1. OB1 contains all events that should be maintained and how PLC would handle these events. In order to make our program well organized we divide it into Function Blocks. Also, we have DB or Data Blocks which represent Functions parameters. Global Verialbles are defined in VAT which can be used by the whole program.
I'd better post an example so that you guys can tell me if I'm doing fine or not.
Let's assume that we have two inputs (e.g. level sensors) and two outputs (e.g. green light and engine). The system can be in automatic mode or manual mode. engine will be switched on if both level sensors are on and only if the automatic mode is on.
So in VAT we would write the following:
//OB1
I 0.1 "Sensor1" BOOL
I 0.2 "Sensor2" BOOL
Q 4.0 "Green_Light" BOOL
//OB1
I 0.3 "Automatic_On" BOOL
I 0.4 "Manual_On" BOOL
//FB1
I 1.0 "Switch_Engine_On" BOOL
I 1.1 "Switch_Engine_Off" BOOL
Q 5.0 "Engine_On"
in DB1 ("EngData") which is going to be used by FB1, we would write the following:
0.0 in Switch_Engine_On BOOL
0.1 in Switch_Engine_Off BOOL
5.0 out Engine_On
in FB1 ("Engine") , we would write the following:
A "Switch_Engine_On"
A "Automatic_On"
S "Engine_On"
O "Switch_Engine_Off"
O "Manual_On"
R "Engine_On"
in OB1, we would write
A "Sensor1"
A "Sensor2"
= "Green_Light"
Call "Engine", "EngData"
Switch_Engine_On := "Switch_Engine_On"
Switch_Engine_Off := "Switch_Engine_Off"
Engine_On := "Engine_On"
--------------------------
Please also let me know how operating system would communication with OB2, 3, etc.
Thanks for your help
Let me tell you what I understand and correct me if I'm wrong.
The PLC's operating system keeps looping through OB1. OB1 contains all events that should be maintained and how PLC would handle these events. In order to make our program well organized we divide it into Function Blocks. Also, we have DB or Data Blocks which represent Functions parameters. Global Verialbles are defined in VAT which can be used by the whole program.
I'd better post an example so that you guys can tell me if I'm doing fine or not.
Let's assume that we have two inputs (e.g. level sensors) and two outputs (e.g. green light and engine). The system can be in automatic mode or manual mode. engine will be switched on if both level sensors are on and only if the automatic mode is on.
So in VAT we would write the following:
//OB1
I 0.1 "Sensor1" BOOL
I 0.2 "Sensor2" BOOL
Q 4.0 "Green_Light" BOOL
//OB1
I 0.3 "Automatic_On" BOOL
I 0.4 "Manual_On" BOOL
//FB1
I 1.0 "Switch_Engine_On" BOOL
I 1.1 "Switch_Engine_Off" BOOL
Q 5.0 "Engine_On"
in DB1 ("EngData") which is going to be used by FB1, we would write the following:
0.0 in Switch_Engine_On BOOL
0.1 in Switch_Engine_Off BOOL
5.0 out Engine_On
in FB1 ("Engine") , we would write the following:
A "Switch_Engine_On"
A "Automatic_On"
S "Engine_On"
O "Switch_Engine_Off"
O "Manual_On"
R "Engine_On"
in OB1, we would write
A "Sensor1"
A "Sensor2"
= "Green_Light"
Call "Engine", "EngData"
Switch_Engine_On := "Switch_Engine_On"
Switch_Engine_Off := "Switch_Engine_Off"
Engine_On := "Engine_On"
--------------------------
Please also let me know how operating system would communication with OB2, 3, etc.
Thanks for your help