4. S7 PROGRAMMING LANGUAGE & BLOCKS TYPE

publicité
Tricom Controls
Here we will illustrate the programming
languages & the block types.
4.
PROGRAMMING LANGUAGE &
BLOCKS TYPE
Tricom Controls S.A.E
‫ ا‬
‫ام‬
20 Street 295, New Maadi, Cairo - Postal Code 11435 - Tel: 002 02/25181138, Fax: 002 02/25181137
Email: [email protected]
٠٠٢ ٠٢/٢٥١٨١١٣٧ :‫ ف‬٠٠٢ ٠٢/٢٥١٨١١٣٨ :‫ ت‬- ١١٤٣٥ ‫ ر ى‬- ‫ ا دى اة‬- ٢٩٥ ‫ رع‬٢٠
42
Tricom Controls
Programming languages
Introduction:
There are several programming languages in STEP 7 that can be used depending on preference
and knowledge. By adhering to specific rules, the program can be created in Statement List and
later converted into another programming language.
LAD
Ladder Diagram is very similar to a circuit diagram. Symbols such as contacts and coils are used.
This programming language often appeals to those who have a drafting or electrical background.
STL
The Statement List consists of STEP 7 instructions. You can program fairly freely with STL.
This programming language is preferred by programmers who are already familiar with other
programming languages.
FBD
Tricom Controls S.A.E
‫ ا‬
‫ام‬
20 Street 295, New Maadi, Cairo - Postal Code 11435 - Tel: 002 02/25181138, Fax: 002 02/25181137
Email: [email protected]
٠٠٢ ٠٢/٢٥١٨١١٣٧ :‫ ف‬٠٠٢ ٠٢/٢٥١٨١١٣٨ :‫ ت‬- ١١٤٣٥ ‫ ر ى‬- ‫ ا دى اة‬- ٢٩٥ ‫ رع‬٢٠
43
Tricom Controls
The Function Block Diagram uses “boxes” for the individual functions. The character in the box
indicates the function (such as & --> AND Logic Operation).
This programming language has the advantage that even a “non-programmer” can work with it.
Function Block Diagram is available as of Version 3.0 of the STEP7 Software.
View
You choose the View menu to switch from one STEP 7 programming language to another:
• LAD (Ladder Diagram)
• FBD (Function Block Diagram)
• STL (Statement List).
Switching the Program Language
You can switch the programming language as you wish when you create as well as later on.
Tricom Controls S.A.E
‫ ا‬
‫ام‬
20 Street 295, New Maadi, Cairo - Postal Code 11435 - Tel: 002 02/25181138, Fax: 002 02/25181137
Email: [email protected]
٠٠٢ ٠٢/٢٥١٨١١٣٧ :‫ ف‬٠٠٢ ٠٢/٢٥١٨١١٣٨ :‫ ت‬- ١١٤٣٥ ‫ ر ى‬- ‫ ا دى اة‬- ٢٩٥ ‫ رع‬٢٠
44
Tricom Controls
LAD/FBD => STL
You can convert program sections that have been written in the graphical programming
languages (LAD/FBD) into STL. You should, however, be aware that the result of this
conversion is not always the most efficient solution in Statement List.
STL => LAD/FBD
It is not always possible to convert program sections written in STL into LAD or FBD. The
sections of the program that cannot be converted are left in STL.
No sections of the program are lost on conversion.
Block types
Blocks
The programmable logic controller provides various types of blocks in which the user program
and the related data can be stored. Depending on the requirements of the process, the program
can be structured in different blocks.
Organization Block OB
Organization blocks (OBs) form the interface between the operating system and the user
program. The entire program can be stored in OB1 that is cyclically called by the operating
system (linear program) or the program can be divided and stored in several blocks (structured
program).
Tricom Controls S.A.E
‫ ا‬
‫ام‬
20 Street 295, New Maadi, Cairo - Postal Code 11435 - Tel: 002 02/25181138, Fax: 002 02/25181137
Email: [email protected]
٠٠٢ ٠٢/٢٥١٨١١٣٧ :‫ ف‬٠٠٢ ٠٢/٢٥١٨١١٣٨ :‫ ت‬- ١١٤٣٥ ‫ ر ى‬- ‫ ا دى اة‬- ٢٩٥ ‫ رع‬٢٠
45
Tricom Controls
Function FC, SFC
A function (FC) contains a partial functionality of the program. It is possible to program
functions so that they can be assigned parameters. As a result, functions are also suited for
programming recurring, complex partial functionalities such as calculations.
System functions (SFC) are parameter-assignable functions integrated in the CPU‘s operating
system. Both their number and their functionality are fixed.
Function Block FB, SFB
Basically, function blocks offer the same possibilities as functions. In addition, function blocks
have their own memory area in the form of instance data blocks.
As a result, function blocks are suited for programming frequently recurring, complex
functionalities such as closed-loop control tasks.
System function blocks (SFB) are parameter-assignable functions integrated in the CPU‘s
operating system. Both their number and their functionality are fixed.
Data Blocks DB
Data blocks (DB) are data areas of the user program in which user data are managed in a
structured manner.
Permissible Operations
You can use the entire operation set in all blocks (FB, FC and OB).
Tricom Controls S.A.E
‫ ا‬
‫ام‬
20 Street 295, New Maadi, Cairo - Postal Code 11435 - Tel: 002 02/25181138, Fax: 002 02/25181137
Email: [email protected]
٠٠٢ ٠٢/٢٥١٨١١٣٧ :‫ ف‬٠٠٢ ٠٢/٢٥١٨١١٣٨ :‫ ت‬- ١١٤٣٥ ‫ ر ى‬- ‫ ا دى اة‬- ٢٩٥ ‫ رع‬٢٠
46
Tricom Controls
Linear Program
The entire program is found in one continuous program block. This model resembles a hardwired relay control that was replaced by a programmable logic controller. The CPU processes the
individual instructions one after the other.
Partitioned Program
The program is divided into blocks, whereby every block only contains the program for solving a
partial task. Further partitioning through networks is possible within a block. You can generate
network templates for networks of the same type.
The OB 1 organization block contains instructions that call the other blocks in a defined
sequence.
Tricom Controls S.A.E
‫ ا‬
‫ام‬
20 Street 295, New Maadi, Cairo - Postal Code 11435 - Tel: 002 02/25181138, Fax: 002 02/25181137
Email: [email protected]
٠٠٢ ٠٢/٢٥١٨١١٣٧ :‫ ف‬٠٠٢ ٠٢/٢٥١٨١١٣٨ :‫ ت‬- ١١٤٣٥ ‫ ر ى‬- ‫ ا دى اة‬- ٢٩٥ ‫ رع‬٢٠
47
Tricom Controls
Structured Program
A structured program is divided into blocks. The code in OB1 is kept to a minimum with calls to
other blocks containing code. The blocks are parameter assignable. These blocks can be written
to pass parameters so they can be used universally.
When a parameter assignable block is called, the programming editor lists the local variable
names of the blocks. Parameter values are assigned in the calling block and passed to the
function or function block.
Example:
• A "pump block" contains instructions for the control of a pump.
• The program blocks, which are responsible for the control of special pumps, call the "pump
block" and give it information about which pump is to be controlled with which parameters.
• When the "pump block" has completed the execution of its instructions, the program returns to
the calling block (such as OB 1), which continues processing the calling block‘s instructions.
The CPU checks the status of the inputs and outputs in every cycle. There are specific memory
areas in which the module‘s binary data are stored: PII and PIQ. The program accesses these
registers during processing.
Tricom Controls S.A.E
‫ ا‬
‫ام‬
20 Street 295, New Maadi, Cairo - Postal Code 11435 - Tel: 002 02/25181138, Fax: 002 02/25181137
Email: [email protected]
٠٠٢ ٠٢/٢٥١٨١١٣٧ :‫ ف‬٠٠٢ ٠٢/٢٥١٨١١٣٨ :‫ ت‬- ١١٤٣٥ ‫ ر ى‬- ‫ ا دى اة‬- ٢٩٥ ‫ رع‬٢٠
48
Tricom Controls
PII
The Process-Image Input table is found in the CPU‘s memory area. The signal state of all inputs
is stored there.
PIQ
The Process-Image Output (Q) table contains the output values that result from the program
execution. These output values are sent to the actual outputs (Q) at the end of the cycle.
User Program
When you check inputs in the user program with, for example, A I 2.0, the last state from the PII
is evaluated. This guarantees that the same signal state is always delivered throughout one cycle.
Note
Outputs can be assigned as well as checked in the program. Even if an output is assigned a state
in several locations in the program, only the state that was assigned last is transferred to the
appropriate output module.
Starting
The CPU carries out a complete restart (with OB100) when switching on or when switching from
STOP --> RUN. During a complete restart, the operating system:
•
•
•
Deletes the non-retentive bit memories, timers and counters.
Deletes the interrupt stack and block stack.
Resets all stored hardware interrupts and diagnostic interrupts.
Tricom Controls S.A.E
‫ ا‬
‫ام‬
20 Street 295, New Maadi, Cairo - Postal Code 11435 - Tel: 002 02/25181138, Fax: 002 02/25181137
Email: [email protected]
٠٠٢ ٠٢/٢٥١٨١١٣٧ :‫ ف‬٠٠٢ ٠٢/٢٥١٨١١٣٨ :‫ ت‬- ١١٤٣٥ ‫ ر ى‬- ‫ ا دى اة‬- ٢٩٥ ‫ رع‬٢٠
49
Tricom Controls
•
Starts the scan cycle monitoring time.
Scan Cycle
The cyclical operation of the CPU consists of three main sections, as shown in the diagram
above. The CPU:
•
•
•
Checks the status of the input signals and updates the process-image input table.
Executes the user program with the respective instructions.
Writes the values from the process-image output table into the output modules.
Inserting a Block
With the appropriate "Blocks" folder highlighted, from a specific "S7 Program", select the Insert
-> S7 Block menu option to display a list of block types:
-Organization blocks (OB) are called by the operating system.
Tricom Controls S.A.E
‫ ا‬
‫ام‬
20 Street 295, New Maadi, Cairo - Postal Code 11435 - Tel: 002 02/25181138, Fax: 002 02/25181137
Email: [email protected]
٠٠٢ ٠٢/٢٥١٨١١٣٧ :‫ ف‬٠٠٢ ٠٢/٢٥١٨١١٣٨ :‫ ت‬- ١١٤٣٥ ‫ ر ى‬- ‫ ا دى اة‬- ٢٩٥ ‫ رع‬٢٠
50
Tricom Controls
These blocks form the interface between operating system and user program.
-Functions (FC) and function blocks (FB) contain the actual user program.
They enable a complex program to be divided into small, easy-to-follow units.
-Data blocks contain user data.
After choosing the type of block you want, the "Properties" dialog box opens so that you can
enter the block number and choose a programming language (LAD, STL or FBD).
There are other settings you can make, depending on the type of block, but these will be
discussed later.
When you have made your settings and confirmed them by clicking the "OK" button, the new
block is inserted in the current program.
Starting the Editor
The easiest way to start the LAD/STL/FBD Editor is by double-clicking on an S7 block in the
SIMATIC® Manager.
Tricom Controls S.A.E
‫ ا‬
‫ام‬
20 Street 295, New Maadi, Cairo - Postal Code 11435 - Tel: 002 02/25181138, Fax: 002 02/25181137
Email: [email protected]
٠٠٢ ٠٢/٢٥١٨١١٣٧ :‫ ف‬٠٠٢ ٠٢/٢٥١٨١١٣٨ :‫ ت‬- ١١٤٣٥ ‫ ر ى‬- ‫ ا دى اة‬- ٢٩٥ ‫ رع‬٢٠
51
Tricom Controls
The Editor has the following components:
Declaration Table
The declaration table belongs to the block. This table is used for declaring variables and
parameters for the block.
The declaration table is discussed in detail in the "Functions and Function Blocks" chapter.
Code Section
The code section contains the program itself, divided into separate networks if required.
A syntax check is made during instruction input (in STL) and in labeling program elements or
operation symbols.
Detail Window
The detail window provides the following functions and information:
1: Error:
Lists the syntax errors found in the course of a context check or a compilation procedure
2: Info:
Gives additional information such as "expected data type of an address"
3: Cross references
A list of addresses used in the network and where they are used in the entire program
4: Address info
Enables you to monitor the addresses used in the network
5: Modify
Enables you to modify the addresses used in the network
6: Diagnostics
Display of existing data for process diagnostics (only if configured)
7: Comparison
Navigation with the function "Compare blocks"
Tricom Controls S.A.E
‫ ا‬
‫ام‬
20 Street 295, New Maadi, Cairo - Postal Code 11435 - Tel: 002 02/25181138, Fax: 002 02/25181137
Email: [email protected]
٠٠٢ ٠٢/٢٥١٨١١٣٧ :‫ ف‬٠٠٢ ٠٢/٢٥١٨١١٣٨ :‫ ت‬- ١١٤٣٥ ‫ ر ى‬- ‫ ا دى اة‬- ٢٩٥ ‫ رع‬٢٠
52
Tricom Controls
Comments:
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tricom Controls S.A.E
‫ ا‬
‫ام‬
20 Street 295, New Maadi, Cairo - Postal Code 11435 - Tel: 002 02/25181138, Fax: 002 02/25181137
Email: [email protected]
٠٠٢ ٠٢/٢٥١٨١١٣٧ :‫ ف‬٠٠٢ ٠٢/٢٥١٨١١٣٨ :‫ ت‬- ١١٤٣٥ ‫ ر ى‬- ‫ ا دى اة‬- ٢٩٥ ‫ رع‬٢٠
53
Téléchargement