0% found this document useful (0 votes)
10 views50 pages

Understanding GRAFCET in Automation

GRAFCET, invented in 1977, is a graphical tool used to model the behaviors of control automation in industry. It consists of steps, transitions, and actions, and is used to describe sequential and combinatorial processes. The document also details the rules for GRAFCET evolution, its levels of specification and realization, as well as its applications in the field of automation.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views50 pages

Understanding GRAFCET in Automation

GRAFCET, invented in 1977, is a graphical tool used to model the behaviors of control automation in industry. It consists of steps, transitions, and actions, and is used to describe sequential and combinatorial processes. The document also details the rules for GRAFCET evolution, its levels of specification and realization, as well as its applications in the field of automation.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Chapter 1

The GRAFCET
Chapter 1 The GRAFCET

The GRAFCET

1.1 Introduction
The Grafcet, invented in 1977 in France by AFCET (French Association for the
Economic and Technical Cybernetics) is the abbreviation of the expression 'Functional Graph'
of Command Step/Transition". It allows to describe all the expected behaviors of a
control automation in response to events or information from a process
automated. In other words, it is a graphical model for representing the specifications of
charges of a logical automation.
GRAFCET is disseminated by ADEPA (National Agency for Development of
Applied Productive Engineering in the Industry.

1.2 Contextualization
The development of flexible workshops and robotization has imposed a simple graphical tool
which allows, based on a well-defined specifications document, to solve a problem
of automation and establish the operating cycle of the process, this tool is the Grafcet.
Grafcet particularly meets the needs of the industry in automation.
sequential tasks whose breakdown into steps is possible. It allows us not only
to analyze the problem presented but also to design a programmable solution whatever
such is the technology of the automaton. This tool is based on a very graphical representation
detailed system and this, before making its synthesis.
Our choice was made on this tool because it is a clear, strict language that allows for the description of a
unambiguous operation.
1.2.1 Normalisation
- NFC (French Standard for Electricity): This standard applies to any logical system
of industrial automation orders regardless of the complexity or the technology used
(electric, electronic wired or programmed, mechanical, pneumatic, etc.). The diagram
The functional "Grafcet" describes any system whose evolutions can be expressed.
sequentially, meaning that its breakdown into steps is possible. The Grafcet can be
also used for the description of combinatorial processes when it allows to give,
the control automation, a more easily analyzable sequential description and
understandable.
The present standard has been in effect since June 19, 1982, under the name NFC 03-190 of 1982, and
since the International Electrotechnical Commission: IEC 848 (1988), IEC: IEC 1131.3 (March
1993).
There is documentation and graphical symbols, functional diagram 'Grafcet' published
by the Technical Union of Electricity, UTE C03-190 November 1990.
1.2.2 Scope of Application
The functional diagram is independent of the 'all or nothing' sequential techniques.
pneumatic, electric or electronic, wired or programmed, which can be used for

Teacher: Ridha MAHJOUB 2


Chapter 1 The GRAFCET

implement the control automation. But the use of sequencers, on one hand, and
step instruction automata, on the other hand, allows for a direct transcription of the diagram
functional.
This concise and easy-to-read graphic representation is readily understandable by everyone.
person in connection with the automated system, from the designer to the user without forgetting
the maintenance agent.
Used industrially, Grafcet is also taught in technical options and
higher education.
Note well:
The Grafcet only focuses on the normal operation of the automation and does not take into account
count the various modes of operation and stop, as well as the failures;
The GEMMA will introduce us to these modes later.
1.3 Grafcet Levels
The Grafcet language includes two levels, here are their characteristics.

Level 1 (specification):
Only deals with the logical behavior of the application;
Ignore the specific constraints of sensors and actuators;
Actions and receptivities are described by sentences.

Level 2 (implementation):
Describes the actual functioning of the automation;
Takes into account the technology of sensors and actuators;
Actions and receptivities are given by logical equations on real signals.
Given the advantages that Level 2 Grafcet brings us, we will use it for the
modeling of our future processes.
1.4 Basic elements of a Grafcet
The Grafcet is a succession of transitions, consisting of (see Figure 1.1):
- Initial step: represents a step that is active at the beginning of operation, it
differentiate from other steps by doubling the sides of the square;
- Step:associated with actions,each step is represented by a labeled square
numerically
- Transition: associated with a Receptivity, the transition is represented by a line.
horizontal
- Receptivity: the conditions of receptivity are written to the right of the transition;
- Action: they are described literally or symbolically within one or more
rectangles connected by a line to the right side of the step;
- Directed links: connecting the steps to transitions and the transitions to the steps. These links
will be marked only when they do not respect the general direction of the route from top to
They indicate the direction of the path.

Teacher: Ridha MAHJOUB 3


Chapter 1 The GRAFCET

Figure 1.1 - Basic elements of a Grafcet

1.5 Evolution Rules of a Grafcet


Rule 1: Initial step
The initial step is represented by a double square and it is always activated.
unconditionally. In a Grafcet, there can be several initial steps.
Rule 2: Activation condition of a step
The transition from step n to step n+1 is subject to two conditions:
The step must be active AND the corresponding transition must be validated.
Rule 3: Simultaneous activations
There are three steps in simultaneous parallel and one transition (a+bc) with two other steps.
simultaneous 15 and 16 (see Figure 1.2). Steps 23, 14, and 7 must be active (the
the transition is crossable) AND that the transition (a+b.c) is true (the transition is crossed)
so that we can activate steps 15 and 16. If one of the three steps is not active, we cannot
cannot proceed to the next step. We must have the 3 steps active and the condition (a+b.c=1).
Rule 4: Convergence and divergence in OU
This rule is very important and widely used in industrial processes, particularly the
elevators.
The divergence in OU:
The transition from step 11 to step 12 is conditioned by the transition and the passage from 11 to
13 is conditioned by the transition y (see Figure 1.3). If x=1 and y=0, we move from step 11 to
step 12 and if x=0 and y=1, we move from step 11 to step 13;

Enseignant : Ridha MAHJOUB 4


Chapter 1 The GRAFCET

Figure 1.2 - Simultaneous actions

Figure 1.3 - Divergence in OU


The convergence in OU:
We have two steps that are already active and two transitions, the transition from step 17 to step
19 is conditioned by c and the transition from step 18 to step 19 is conditioned by d (see
Figure 2.4).
After a divergence in OU, we find a convergence in OU. The number of branches can
be greater than 2.

Figure 1.4 - Convergence in OU


Rule 5: Only one step should be activated

Teacher: Ridha MAHJOUB 5


Chapter 1 The GRAFCET

In an OR divergence, only one branch must be executed (see Figure 1.5):


If a is validated, we move from step 1 to step 2;
If b is validated, we will move from step 1 to step 3.

Figure 1.5 - Only one step must be activated


Rule 6: Simultaneous Actions
That is to say, several steps will be executed in parallel (for example, motors, some
cylinders, lamps, etc. work at the same time.

Figure 1.6 - Simultaneous actions


In this case, the transition is carried out by an end stroke f.c (see Figure 1.6).
The transition from step 1 to steps 2 and 3 is done by the end of travel f.c=1 And steps 2 and 3
at step 1 also by fc=1.

Rule 7: Gateway between Grafcets


If we have a complex specification, to simplify the Grafcet we can divide it into
several Grafcets where each manages a part but the condition must be communicative
In other words, we can call one Grafcet from another.
Figure 1.7 shows a bidirectional communication between the two Grafcets and the
transition X6 représente l’étape 6 du Grafcet à droite. Le passage de l’étape 1 a l’étape 2 est
Conditioned by the activation is the validation of step 6, if step 6 is validated and the transition.
X6 is validated, we can move from stage 1 to stage 2.
Similarly, the transition from step 4 to step 5 is conditioned by the validation of step X1.
the Grafcet on the left and the start of the cycle dcy.
Rule 8: Resume steps and leap forward
- Step resumption: Step resumption allows you to restart several times if necessary.
the same sequence as shown in Figure 1.8.
- Forward jump: The step jump is a sequence selection that allows skipping several
steps according to the evolving conditions as represented in Figure 1.9.

Teacher: Ridha MAHJOUB 6


Chapter 1 The GRAFCET

Figure 1.7 - Bidirectional communication.

Figure 1.8 - Recap of steps

Figure 1.9 - Forward jump

1.6 Task Grafcets and Sub-programs


A subprogram is an independent Grafcet whose execution and progression are
synchronized to a main Grafcet.
When a task needs to be performed multiple times in a cycle, the description of this task
in the form of an independent Grafcet allows for simplifying the analysis and simplifying the
programming. This independent Grafcet is a subprogram launched by the program that
corresponds to the main Grafcet.

Teacher: Ridha MAHJOUB 7


Chapter 1 The GRAFCET

In the example of Figure 1.10, the dosing task (GT1) is executed 2 times in the cycle and the
Grafcet dosing describes this task. The initiation of this dosing task is done by activation.
from step X2 or the activation of step X5.
When the task is completed, a status information (end of task) is returned to the Grafcet.
the principal that can then evolve. It is desirable to complete the Grafcet of the task with the
verification that the launch step of the main Grafcet is indeed disabled before it
to loop.

Figure 1.10 - Task Grafcet

1.7 Macro steps


A macro-step, repeated as many times as necessary, is introduced into the main graph.
instead of the repetitive sequence. This sequence is described in the immediate vicinity of the graph.
The macro-representation meets the needs for a progressive and structured approach to
complex industrial applications (see Figure 1.11).

Figure 1.11 - Macro stage

Teacher: Ridha MAHJOUB 8


Chapter 1 The GRAFCET

In relation to the scheduled achievement, step 10 corresponds to a jump to the sub-


program (call of the sub-program ME1) and its activity is represented by the pointer
main program.
However, the programming will not exactly conform to this description because, in
In general, the S3 test is incorporated into the subroutine.
1.8 Auxiliary graph
Steps 2 and 4 are steps that call the repetitive sequence graph and cause
the activation of step 10 by crossing transition (1), receptive to the activity of these
steps (X2 or X4) as shown in Figure 1.12.
Step 13 is the return to the main graph.

Figure 1.12 - Auxiliary Graph

Figure 1.13 - Auxiliary graph, source and sink transition concepts

Teacher: Ridha MAHJOUB 9


Chapter 1 The GRAFCET

There are other possible functional descriptions: example using the concepts of
transitions sources and sinks with simultaneous crossings of transitions (*) (see Figure 1.13).
In conclusion, there are multiple possible functional representations to describe
the use of the same resource in a sequence, at different times.
The problem can be much more complex in some cases (subroutine calls
parameterized or multiplexed, the management of multiple calls, etc.
1.9 Forcing
The forcing is a continuous action, noted in a double frame, that acts on the graph Gi,
hierarchically inferior or 'slave' by configuring this Grafcet, from anywhere
situation, in a given state.
The activation of step 10 of GrafcetG1 forces grafcetG2 to its step 21 (forced to 1), the
other steps of the grafcet G2 are deactivated (forced to 0) as shown in Figure 1.16.

Figure 1.16 – Forcing action


1.10 Grafcet from the perspective of the operational part (O.P)
The Grafcet from the perspective of the operative part describes in clear terms or by symbol the
actions and receptivities taking into account the chosen technology.
Technology concerns the elements of the operational part as well as the type of information.
received (orders) or sent (reports).
It is generally the description of the automation alone, that is to say the sequence of actions and
transitions that allow for process control. When discussing the analysis and
description of a system, we do not know which technology will be chosen for the actuators,
the sensors and the control. This Grafcet will describe the actions and events in terms of
general. This graph describes the overall functioning of the system. It translates the specifications.
without prejudice to the adopted technology. It allows for dialogue with people who are not
specialists (suppliers, decision-makers...) its writing, in plain language, allowing its
understanding by everyone.

Teacher: Ridha MAHJOUB 10


Chapter 1 The GRAFCET

1.11 Grafcet from the perspective of the control part (C.P.)


The Grafcet from the perspective of the control part describes the exchanges of the control part.
with the operating part and the dialogue with the operator, taking into account the choices
technological pre-actuators and sensors.
In this type of Grafcet, we specify the type of information received (orders) and sent.
(reports). The observer from this point of view being a specialist in the operational part, the
The command party is only interested in its effects.
1.12 Grafcet from a system perspective (process and procedure)
Description made by an observer from an external point of view to the SAP.
The system viewpoint describes the behavior of the system in relation to the product.
The process is the set of successive functions performed on the same product during
of its manufacture.
The process is the organization of the procedure. It is the succession of simultaneous functions.
carried out on all products present in the automated system.
The Grafcet from the system perspective facilitates the dialogue between the client and the designer for the
specification of the automated system.
1.13 Algebraic Interpretation
The rules of evolution of Grafcet are the starting point for the logical equations describing the
navigation between the operating steps.
1yearRule: a transition is either validated or not validated.
It is validated when all the immediately preceding steps are active. It cannot
to be crossed that:
When it is validated AND the receptivity associated with the transition is TRUE.
The translation of this rule gives the activation condition of the step:

CA XnXn‐[Link].
2thRule: crossing a transition triggers the activation of all stages.
immediately following and the deactivation of all the immediately preceding steps.
The translation of this rule provides the condition for deactivating the step:

[Link] 1InitXn 1Init


If the step n is false, step n remains in its state. This is called
the memory effect (of sequential logic). That is to say that the state of Xn at time t+δt depends
from the previous state to the instant of Xn.
Based on these three previous points, it is possible to write the truth table of the activity of
the step n of a Grafcet: Xn

Teacher: Ridha MAHJOUB 11


Chapter 1 The GRAFCET

Table 1.1 - Truth table of step Xn

Xn(t) CA(Xn) CD(Xn) Xn(t+δt) Remarks


0 0 0 0 The stepXnremains inactive (memory effect)
0 0 1 0 Step Xn remains inactive
0 1 0 1 Activation of step Xn
0 1 1 1 Activation ET Désactivation : Activation de Xn
1 0 0 1 The stage remains Active (memory effect)

1 0 1 0 Deactivation of step Xn
1 1 0 1 The step remains Active

1 1 1 1 Activation and Deactivation: Activation ofXn

The associated Karnaugh map is presented in Table 1.2.


Table 1.2 - Karnaugh Table of step Xn

CA(Xn).CD(Xn) 00 01 11 10
0 0 0 1 1
Xn
1 1 0 1 1

Whence the equation of Xn:

Xn CA Xn . XnWhich means that:Xn . . .

Or also, the expression of the generalized transfer equation of any given step of a
The GRAFCET is as follows:
Xn . . .

Teacher: Ridha MAHJOUB 12


Chapter 2

Methods of
programming of
programmable automations
industrial
Chapter 2 API programming methods

Methods of programming automata


industrial programmable devices

2.1 Introduction
The Programmable Logic Controller (PLC) is a programmable electronic device, suitable
to the industrial environment, which performs automation functions to ensure control
of pre-actuators and actuators based on logical, analog, or digital information.
The same type of programmable industrial controller can be used for different
applications, the difference is made with the program installed in it. To achieve these
programs use different languages depending on the system, the user, and the
designer.
Previously: using electromagnetic relays and pneumatic systems for the
implementation of the control parts Wired logic.
Disadvantages: expensive, no flexibility, no possible communication.
Solution: use of microprocessor-based systems allowing a modification
automated systems expert Programmed logic.
2.2 Main types of elementary data
In automated systems, the concepts of bit, byte, word, or double word
The word is often used. It is therefore necessary to know the meaning of these terms.
A bit corresponds to a position or a binary character. It is the smallest unit.
in terms of information and it only admits one of the two states: '0' or '1'.
Several bits can be grouped together into larger units.
Octet (or byte): a byte is a unit of 8 bits. It is used, for example, to group the
logical states of 8 inputs or 8 outputs (see Figure 2.1).

Figure 2.1 – Significance of the distribution of memory zones

Teacher: Ridha MAHJOUB 2


Chapter 2 API programming methods

A word consists of 2 bytes, that is, 16 bits. A word allows for grouping.
16 entries or 16 exits.
Double word: a double word consists of 2 words, or 4 bytes, or 32 bits.
the double word is the largest unit that an automaton is capable of processing except for
some APIs that handle the long word (64 bits).

In summary:
-1 Byte = 8 bits ;
-1 Word = 2 Bytes = 16 bits ;
-1 Double word = 2 words = 4 Bytes = 32 bits (see Table 2.1).
Table 2.1 - Table of Elementary Data Types
Type of Description Size or Etendue
Data number of bits
BOOL Boolean (bit) 1 0 or 1
BYTE 8-bit cord 8 No extent
WORD String of length 16 16 digital for
DWORD String of length 32 32 this type of
LWORD String of length 64 64 data
INT Signed integer n=16 -2 to + (2n+1– 1)
n-1

UINT Unsigned integer n=16 0 to (2n- 1)


REAL Real name 32 Floating point
STRING String of characters Framed by two apostrophes
TIME Duration Depends on the application in question

2.3 Representation of variables


A variable allows for the identification of data objects whose content can vary (data
associated with the inputs, outputs, or memory locations of the API.
Table 2.2 allows for a symbolic representation of a variable. The variable begins with the
symbol %.
Tableau 2.2 - Symbolic representations of variables

Prefix Meaning
I Placement of an automated entrance
Q Location of an automated exit
M Location of memo or internal memory
X Size of a single bit
B Size of a byte or octet
W Word size: 16-bit word
D Size of a double word: double word of 32 bits
L Length of a long word: 64-bit word

Enseignant : Ridha MAHJOUB 3


Chapitre 2 API programming methods

2.4 Address Allocation in Memory Areas


- Internal bits: M0.0 to M255.7 dependent on the following words;
Internal octets: set of 8 bits MBi;
Internal words: set of 16 bits MWi;
- Double words: set of 32 bits MDi.
According to the brand of the programmable logic controller (manufacturer reference) we can assign
the inputs/outputs and also the steps as shown in table 2.3.
Table 2.3 - Symbolic representations of variables

Siemens API Siemens API Omron API


S7-1200/1500 S7-300/400 CQM1 - CPU21

IB0 : I0.0…I0.7 EBO : E0.0…E0.7 000.0X : 000.00…000.07


Entries
IB1: I1.0...I1.7 EB1 : E1.0…E1.7 000.1X : 000.10…000.17
QB0 : Q0.0…Q0.7 AB0 : A0.0…A0.7 100.0X : 100.00…100.07
Output
QB1 : Q1.0…Q1.7 AB1 : A1.0…A1.7 100.1X : 100.10…100.17
MB0: M0.0...M0.7 MB0 : M0.0…M0.7 240.0X : 240.00…240.07
Steps
MB1 : M1.0…M1.7 MB1: M1.0...M1.7 240.1X : 240.10…240.17

Example:
%IW125: Location of the input word at address 125;
%QB17: Location of the output byte at address 17;
%MD48: Location of the double memory word at address 48.
Table 2.4 offers several modes of memory area distribution ranging from M0.0 to
This distribution is made according to the needs and we pay attention to overlaps.
Table 2.4 - Symbolic representations of variables

M6.0..M6.7 M5.0..M5.7 M4.0..M4.7 M3.0..M3.7 M2.0..M2.7 M1.0..M1.7 M0.0..M0.7


MB6 MB5 MB4 MB3 MB2 MB1 MB0
MW5 MW3 MB2 MW0
MB6 MW4 MW2 MW0
MW5 MB4 MD0

Example of identifying entries and exits:


The indexing or addressing is the marker corresponding to the location of each entry and
exit its address in memory where the image of its state 0 or 1 is stored, this allows
to use the input or output multiple times in the program.
A programmable controller with 8 inputs and 8 outputs, capable of occupying the following addresses:
-Entrées :I0.0 ; I0.1 ; I0.2 ; I0.3 ; I0.4 ; I0.5 ; I0.6 ; I0.7 ;
-Sorties :Q1.0 ; Q1.1 ; Q1.2 ; Q1.3 ; Q1.4 ; Q1.5 ; Q1.6 ; Q1.7.

Teacher: Ridha MAHJOUB 4


Chapter 2 API programming methods

2.5 Absolute and Symbolic Addressing


In a program, there is the choice of absolute addressing, symbolic addressing, or both at the same time.

3.5.1 Absolute addressing


Absolute addressing involves using the physical addresses of the device, that is to say the
real addresses (see Figure 2.2).

Figure 2.2 – Example of absolute addressing

Symbolic addressing
Pour donner de la clarté au programme, on utilise l’adressage symbolique. Cela revient à
replace each physical address with a symbolic address that best represents it
function as shown in Figure 2.3.

Figure 2.3 – Example of symbolic addressing

2.6 Wiring of the inputs / outputs of a programmable controller


2.6.1 Power Supply of the Automation
The programmable logic controller is usually powered by the single-phase network 230V/50 Hz.
but other power supplies are possible (110V for example).
The protection will be of the magnetic-thermal type (see the characteristics of the device and the
manufacturer's recommendations). It is advisable to control the power supply of the automation system by a
specific control circuit (contactor KM).
2.6.2 Feeding the inputs of the automaton
The automaton is generally equipped with a power supply for sensors/detectors (note
to the type of logic used: positive or negative logic.
The inputs are connected to 24V (common terminal of the inputs). The information from
Sensors/detectors are processed by the input interfaces as shown in Figure 2.2.

Teacher: Ridha MAHJOUB 5


Chapter 2 API programming methods

Figure 2.4 – Wiring of the controller inputs


2.6.3 Powering the outputs of the automation:
The output interfaces allow for the powering of various pre-actuators. It is desirable
to equip each pre-actuator with an isolation relay (not shown in Figure 2.3).

Figure 2.5 – Wiring of the controller outputs

2.7 API Programming Principle


Each automation is programmed via a proprietary programming console or by a
computer equipped with specific manufacturer software.
A program for an automaton consists of a sequence of instructions, each instruction being
compose the following elements:
A line number or an address that allows you to find an instruction in the
program
An operation code indicating the type of operator to execute (AND operation (code AND);
operation OR (code OR) ;
An operand indicating the object on which the operation is performed, it is composed of two
parties :
For example, type I for inputs and Q for outputs;

Teacher: Ridha MAHJOUB 6


Chapter 2 API programming methods

Its geographical address on the automaton (its position) for example 0.5: 0 being the number
of the module and 5 being the path on the module.
All programmable controllers operate according to the same operating mode as the
show Figure 2.4.
We call the scrutiny the set of the four operations carried out by the automaton and the time of
scrutinizes the time taken by the automaton to process the same part of the program. This time
is on the order of tens of milliseconds for standard applications.

Figure 2.6 – Operating procedure of a programmable controller


Internal processing: The machine performs control operations and updates certain
system parameters (detection of transitions to RUN / STOP, updates of values of
the time stamp, ...).
Reading inputs: The automaton reads the inputs (synchronously) and rewrites them in the
memory image of inputs.
Program execution: The automaton executes the program instruction by instruction.
and write the outputs in the output image memory.
Writing outputs: The automaton toggles the different outputs (synchronously) to
positions defined in the image memory of the outputs.
These four operations are continuously performed by the automaton (operation
cyclic.

2.8 Common elements across different languages


The structuring of a program can be edited using the following three types of modules:
Function: Module with several possible inputs, a single output variable and no
internal memory.
Functional block: Module with several possible input and output variables and a
internal memory.
Program: Module built using functions and functional blocks etc.
The internal organization of a program can involve a functional diagram of
SFC sequence. The main functions common to all programming languages of
The programmable automation are:

Teacher: Ridha MAHJOUB 7


Chapter 2 API Programming Methods

The type conversion function: REAL / INT, this function allows the conversion of a
input variable of real type into an output variable of integer type.
The numerical function: SQRT, this function allows you to calculate the square root of a
input variable.
Bit cord functions: SHL, this function allows the left shift of N bits of a
input variable and the filling of zeros to the right.
Logical functions: AND, this function performs the Boolean AND.
Selection and comparison functions:
MAX: this function determines the maximum value among three input variables;
- SEL: this function allows you to select one of the two input variables depending on
variable G ;
GT: this function performs a superiority comparison between two input variables.
(IN1>IN2).

2.9 Programming Languages of APIs


The IEC 61131-3 standard is intended to regulate the aspects of programming PLCs.
This standard for programming languages of programmable automata allows them to
classify according to three categories given by Table 2.5.
Table 2.5 - Truth table of the activity of step n

Literal languages Language of systems


Graphic languages
sequential
Language IL (Instruction List) LD (Ladder Diagram) Language SFC Diagram
Structured Text (ST) Language FBD Language (Function) (Sequential Function
Block Diagram Chart)

2.9.1 IL Language (Instruction List or instruction list language)


As its name suggests, this program, very little used by automation engineers, is made up of
d’une suite d’instructions (voir Tableau 2.6) respectant le format suivant :
Etiquette Operator Operand(s) Comment
(Non-mandatory) (Not mandatory)
This language is close to the programming language of a microprocessor: assembly.
Table 2.6 – Language Instruction List

Etiquette Operator Operand(s) Comment


Start: AND (
OR %I0.0 Bp march (NO)
OR %Q4.0 Solenoid valve
)
AND %I0.1 Bp stop (NF)
AND N %I0.2 High level (NO)
ST %Q4.0 Solenoid valve allocation

Teacher: Ridha MAHJOUB 8


Chapter 2 API programming methods

[Link] Programming List of an OMRON API


The console password: You must turn the key to the Program position then enter the
SHOW / CLEAR / SHOW / CLEAR.
The execution of a diagram always goes from left to right.
To control the operation of a program, simply position the key towards the
positionMonitor then type CL and press the down arrow.
Programming a timer: it involves translating the given contact networks.
by Figure 2.7, in List program intended for an OMRON type API.

il

Figure 2.7 – Delay contact networks


On propose le programme de la temporisation précédente en langage List :

LD 000.01 WR
OUT TIM 01 WR
50 WR
LD TIM 01 WR
OUT 100.05 WR
END. "FUNC 01 WR"

To change the timer value, simply turn the key to the Program position and tap
CLEAR then point the arrow↓ to change the time. Press SHIFT + CONT and
give the new value and finally type WR.
To see if the changes are validated or not, you need to turn the key to RUNet and check.
the operational result on the model of the automaton.
Programming the EXCLUSIVE OR function: it involves translating the contact network.
following, in List program intended for an OMRON type API.

Teacher: Ridha MAHJOUB 9


Chapter 2 API programming methods

The XOR function is a case of logical block instruction programming indeed.


The corresponding relay diagram can be subdivided into logical blocks. The instruction ORLD
allows you to define the condition that links the first block to the second, in this case the two blocks
are connected with an OR condition.
LD 000.01 WR
AND NOT 000.02 WR
LD NOT 000.01 WR
AND 000.02 WR
OR LD WR
OUT 100.01 WR
END.
Application 1 :
Write the equivalent List program for the following contact diagram:

Solution of application 1:
LD 000.01 WR
OR NOT 000.03 WR
LD NOT 000.02 WR
OR 000.04 WR
AND LD WR
OUT 100.01 WR
END.
Application 2 :
Write the List program for the following contact diagram:

Solution of application 2:
To facilitate the program, we can use the AND LD instruction as follows:

Teacher: Ridha MAHJOUB 10


Chapter 2 API programming methods

LD 000.01 WR
OR NOT 000.03 WR
LD NOT 000.02 WR
OR 000.04 WR
AND LD WR
LD NOT 000.05 WR
OR 000.06 WR
AND LD WR
OUT 100.01 WR
END.
Application 3 :
Write the equivalent List program for the following contact scheme:

Q1: Break down the diagram into logical blocks.


Q2: Write the equivalent mnemonic code in List language.
Solution to application 3:
Q1 :

Q2:
LD 000.01 WR
AND NOT 000.02 WR

Teacher: Ridha MAHJOUB 11


Chapter 2 API programming methods

LD NOT 000.01 WR
AND 000.03 WR
OR LD WR
LD 000.06 WR
AND 000.05 WR
OR LD WR
LD NOT 000.03 WR
OR 000.09 WR
AND LD WR
LD NOT 000.04 WR
AND LD WR
OUT 100.06 WR
END.
2.9.2 ST Language (Structured Text or structured literal language)
This language, rarely used by automation engineers, is composed of literal expressions made up of
of operators and operands and statements. This language is close to a programming language.
like PASCAL. It uses instructions like if, then, else.
Example 1: Order of a solenoid valve
Electrovalve command
IF (%I0.0 OR %Q4.0) AND %I0.1 AND NOT %I0.2 THEN SET %Q4.0
END_IF;
Example 2: From a demonstration program "Dosage and mixing machine of a
products" by the PL7 software from Schneider.
The content of this block written in ST language is as follows:
(*** Simulation routine of a first-order process for PID Output ***)
IF Trs THEN
Sortie : = Tri ;
ELSE
Te := INT_TO_REAL(%SW0) / 1000.0 ;
Output : = (Filtering / (Filtering + Te)) * Output + (Gain * Te) / (Filtering + Te) * Input ;
END_IF ;
With:
Polling period of the master task. Allows to modify the period of the task.
master defined in configuration, by the user program or by the terminal. The period is
expressed in ms (1 255ms). %SW0=0 in cyclic operation.

Example 3: The simulation of a delay written in ST language is as follows:


Nb := REAL_TO_INT(1000.0*Retard/INT_TO_REAL(%SW0));
IF (Nb>=999) THEN
Nb := 999;
END_IF;
IF Trs THEN

Teacher: Ridha MAHJOUB 12


Chapter 2 API programming methods

Memory :=Tri;
Sortie := Tri;
Pos := 0;
ELSE
Sortie := Memoire[Pos];
Memoire[Pos]:= Entree;
Pos := Pos + 1;
IF (Pos>= Nb) THEN
Pos := 0;
END_IF;
2.9.3 FBD Language (Function Block Diagram) or functional block language
It is a graphical language used by automation engineers where the blocks are programmed.
(libraries) or programmable ones are represented by rectangles with the inputs on the left
and the outputs to the right. This language consists of networks of functional blocks that are
connected to each other by lines, the flow of signals going from the output of a function to
the entry of the connected function.
Examples of standard functional blocks:
Functional block meters;
Functional block timers;
Functional block PID controller...
Application: Description of the SFB 2 counter
CU: Counting input, when the logic state of the CU input changes from state 0 to
In state 1 (front rising), the meter is incremented by 1.
CD: Counting input, when the logical state of the CD input changes from state 0
In state 1 (rising front), the counter is decremented by 1.
R: Reset input, when the logical state of the R input changes from state 0 to state 1, the
the counter value is forced to 0 regardless of the state of the CU input.
PV: Setting the meter value. (in the example above 10).
LD: Input "loaded", when the logical state of the LD input changes from state 0 to state
1, the counter value (CV) is forced to the value set at the PV input regardless of what
consider the state of the CD input.

The Q output is in logic state 1 if the current count value (CV) is


equal to or less than 0. (CV≤0).
-CV: MW101 in the example, reminder for displaying the value of the
counter or the use of the counter value elsewhere in the program.
Be careful not to reuse memory bits M101.0 to M102.7 for anything else.
choose from the program.
-QU: The output Q is in logical state 1 if the current count value (CV) is
equal to or greater than the value allocated to the input PV (CV≥PV).

Teacher: Ridha MAHJOUB 13


Chapter 2 API Programming Methods

Figure 2.8 - CTUD Counter (SFB 2)

2.9.4 Contact Languages (LD: ladder diagram)


Graphical language, the most commonly used, developed for electricians. It uses symbols such as
that: contacts, relays, and functional blocks and is organized in networks (labels). This language is a
graphical representation of Boolean equations combining contacts (input) and
relay (output). It allows for the manipulation of boolean data using symbols.
graphics organized in a diagram like the elements of an electrical schematic
contacts.
Elementary graphical components of a contact diagram are presented in the Table
3.7.
Table 2.7 - Language Instruction List

Input variable or normally closed contact


┤├ (I0.2 automated inputs, M1.2 bit
internal memory, etc.)

┤∕├ Complemented input variable or


contact at opening

-( )- Output variable (Q0.2 outputs


automate, M1.3 bit mémoire interne,
etc.)
-(S)- Output set to 1 stored (S = set)
-(R)- Output reset logged (R = reset)
P A rising front

[Link] The principles of relay schemes


A relay diagram has a line and branches. The left line is the line of
Bus and branch lines are instruction lines or secondary lines. Two

Teacher: Ridha MAHJOUB 14


Chapter 2 API programming methods

Instruction lines are connected by at least one condition. The execution of a scheme is done
always from left to right.
The conditions (contacts) are represented by two vertical lines or by two lines.
Verticals crossed by a diagonal. In the first case, the condition is initially open.
it is transcribed by a mnemonic such as (LD, AND, OR); in the second case it is a
initially closed condition (closed at rest) it is transcribed by a mnemonic of the type
(LDNOT, ORNOT, ANDNOT).
The vertical starting line placed at the left end of the network is the starting point of this
last.
The vertical lines parallel to this one represent subroutines by
relative to the main line.
The conditions are represented by two vertical lines.
Fundamental terminology: in relay diagrams, each condition is assigned a bit.
bit is at (one) when the condition is true, the condition is then in the ON position. A condition
initially closed is initially in the OFF position, it will switch to the ON position with a state
complementary to that of an initially open condition.
The execution conditions: in a relay scheme, the execution of an instruction is done at
from the moment when the combination of the conditions that precedes it is true.
Operand bits: input/output bit; flag (status bit); working bit; timer or
counter.
-Logical blocks and instruction blocks: the logical block is a group of instructions that generates a
logical result. Decomposing a program into several logical blocks simplifies the
synthesis and testing of applications. A block of instructions includes all the instructions.
linked together in the same diagram.
2.9.5 Programming using GRAFCET (SFC: Sequential Function Chart)
GRAFCET, a specification language, is used by some automation manufacturers.
(Schneider, Siemens) for programming. Sometimes associated with a programming language,
it allows for easy programming of sequential systems while facilitating debugging
programs as well as system troubleshooting (see Figure 2.9).
One can also translate a Grafcet into contact language and implement it on any type.
of the automaton.

Figure 2.9 – Slice of a generalized Grafcet

Teacher: Ridha MAHJOUB 15


Chapter 2 API programming methods

2.10 Method for translating transfer equations into LADDER language


This method of programming industrial programmable controllers relies on
essentially on the transfer equations determined from a Grafcet of
operation. To clarify the ideas, a slice of a generalized Grafcet is presented (see
Figure 2.10) from which we determine the transfer equations of the X [Link] Xi+1.

Figure 2.10 – Segment of a generalized Grafcet


The transfer equations of the operational Grafcet will be translated into step networks and
of actions.
- ∗ ∗

- ∗ ∗

The translation of its equations using the transfer equations method results in
Figure 2.11.

Figure 2.11 – Method of translating transfer equations

2.11 Electronic Sequencer Method

Teacher: Ridha MAHJOUB 16


Chapter 2 API programming methods

This method is essentially based on the exploitation of the functions set to 1 memorized and
reset stored (Set/Reset) and their holding functions which are:
Set: The logical set to 1 function;
Reset: The reset function (Reset to Zero).
For the application of this method, the steps of Figure 2.10 will be represented by the networks
from Figure 2.12.

Figure 2.12 – Electronic sequencer method

2.12 Criteria for Choosing a Controller


The choice of a programmable controller is primarily the choice of a company or a group.
and the business contacts and experiences lived are already a starting point.
Large companies will favor two manufacturers to create competition and leverage power.
to turn back in case of loss of speed of one of them.
However, the maintenance staff must be trained on this equipment and an excessive
diversity of equipment can have serious consequences. A programmable logic controller using
programming languages of the Grafcet type are also preferable to ensure updates
on point and repairs in the best conditions.
The possession of programming software is also a source of savings. Tools
allowing a simulation of the programs is also desirable.
It is then necessary to quantify the needs:
Number of inputs/outputs: the number of modules can have an impact on the number of
racks as soon as the number of necessary inputs/outputs becomes high.
Processor type: memory size, processing speed, and special functions
offers by the processor will allow for choice within the often very extensive range.
Special functions or modules: certain boards (axis control, weighing, etc.) will allow
to relieve the processor and should provide the desired features (resolution, etc.).
Communication functions: the programmable controller must be able to communicate with the
other control systems (API, OP, PC, etc.) and provide communication capabilities
with standardized standards (Profibus, Profinet, Modbus, etc.).

2.13 Signaling in a programmable controller


We consider the CPU of a Simatic S7-1200 programmable logic controller as an example.
concret d’un API récent. La CPU de cet API fournit les indicateurs d'état suivants:

Teacher: Ridha MAHJOUB 17


Chapter 2 API programming methods

STOP/RUN
Yellow continuous indicates the STOP state;
A continuous green light indicates the ON state;
Green and yellow flashing alternately indicate that the CPU is in the ON state.
ROUTE.
ERROR
The flashing red light indicates an error, such as an internal error in the CPU.
error with the memory card or a configuration error (modules not
concordants) ;
Continuous red signals defective equipment;
All the LEDs blink if a failure is detected in the Firmware.
The LED MAINT (Maintenance) flashes as soon as you insert a memory card.
The CPU then goes to the STOP state. Once the CPU has entered the STOP state,
execute one of the following actions to trigger the memory card evaluation:
Turn the CPU to the ON state;
Perform a general erasure (MRES);
Power off the CPU and then power it back on.
The CPU also provides two LEDs that indicate the communication status. Open the cache.
the lower terminal to see them:
The green link light illuminates to indicate that a connection has been successfully established.

Rx/Tx (yellow) lights up to indicate that a transmission activity is in progress.


The CPU and each I/O module provide an I/O Channel LED for
each of the inputs and outputs. The LED I/O Channel (green) lights up or turns off to indicate
the state of the corresponding input or output (See Table 2.8).
Table 2.8 – CPU status indicators of a Simatic S7-1200 API

STOP/RUN ERROR MAINT


Description Yellow/Green Red Yellow
Off tension Off Off Off
Startup, self-test or Indicator Off
firmware update Yellow green alternately -
State STOP On (yellow) - -
State MARCH On (green) - -
Remove the memory card On (yellow) - Turn signal
Error Lighted Turn signal -
Either yellow or green
Maintenance required
Forced E/S On
Replace the battery (if the Either yellow or green - Turned on
Battery Board is installed
Defective equipment On (yellow) On Off
LEDs test or firmware Turn signal
Defective CPU alternating yellow and green Turn signal Turn signal

Teacher: Ridha MAHJOUB 18


Chapter 2 API programming methods

Configuration version of
the unknown CPU or On (yellow) Turn signal Turn signal
incompatible

2.14 Security of automated systems


Automated systems are, by nature, a source of many dangers (used voltages,
mechanical displacements, pressure jets of matter, etc.
The failure of a programmable automaton can have serious repercussions.
For safety, the standards prohibit managing emergency stops by the programmable logic controller.
This must be done in wired technology.
Located at the heart of the automated system, the automaton must be a reliable element because:
A malfunction of this could have serious consequences for safety.
people.
The repair costs of the production tool are generally very high.
A halt in production can have serious financial consequences.
Also, the programmable controller is subject to numerous provisions to ensure safety:
External constraints: the programmable logic controller is designed to withstand the various
constraints of the industrial world and has been the subject of numerous standardized tests (resistance to
vibrations, CEM, etc.).
Power outages: the programmable controller is designed to withstand outages
of power supply and ensures, by program, correct operation during the
re-feeding (cold or hot recovery).
RUN/STOP mode: only a technician can start or stop an automated system.
programmable and the restart is done through a (programmed) initialization procedure.
Cyclic controls:
Self-monitoring procedures for memory, clock, battery, voltage
of power supply and inputs/outputs.
Verification of the polling time at each cycle called Watch-Dog.
and the triggering of an alarm procedure in case of exceeding it (regulated by
the user).
Visualization: the machines offer a visualization screen where one can see the evolution
inputs/outputs.

Teacher: Ridha MAHJOUB 19


Chapter 3

Management of modes of
operation of an S.A.P
Chapter 3 Management of the operating modes of an S.A.P

Management of the operating modes of an S.A.P

3.1 Function of a control unit


In general, it is possible to partition the Command Part into three.
main functions (regularly present in PCs) and complementary functions
related to the complexity of the system.
Command function: it is the essential function, the one for which it is built.
Order Part. It involves drafting the purchase orders for the pre-actuators for
obtain the desired behavior of the Operational Part, based on the information obtained from this
PO and operator instructions. This Command function integrates the modes of
normal production, but also the operating modes, failure, etc.
Driving function: under this function we group three levels of needs for the
operation of the automated system.
A need for flexibility;
A need for complexity;
A need for coordination or synchronization of the SPO.
Monitoring function: this function is related to the possible occurrence of defects or
failure both in the Operating Part and in the Control Part, as well as in their power supplies
And interfaces. It corresponds to alarm and security functions.
The alarm function involves monitoring the significant variables of the system, then a
treatment to achieve visualization methods to facilitate communication
with the operator.
The security function involves issuing instructions or commands to
specific actuators, or to other levels of control.
Optimization function: this function allows the introduction of data and constraints
economic in the order. It is about production objectives and data.
techniques for developing the operating model best suited to the current state of the system.
Fonction de gestion : il s'agit, à partir des résultats du modèle optimisé, des informations
issues of the system, to develop all technical, administrative, and accounting documents
and financial, etc. necessary for the proper integration of the system into the overall functioning
of the company.
Communication function: this function allows for the consideration of intervention
the person in the management of the automated system but also in all functions of
command, monitoring, management and optimization.
3.2 Structure of a command part
The Grafcet allows modeling commands where all inputs are state variables.
of binary type (0 or 1). If the entire command part of an application is not modelable
through a Grafcet, it is important to formalize the boundaries and communication with other models
of the order.

Teacher: Ridha MAHJOUB 2


Chapter 3 Management of the operating modes of an S.A.P

3.2.1 The PC calls for Grafcet functions


The structure and the different modules are described in one or more languages, others
modules are in Grafcet. The module level Grafcet is called by the control structure
through exchanges of boolean Inputs/Outputs (see Figure 3.1).

Figure 3.1 - Structure of a PC


3.2.2 A Grafcet structure the control part
The structure is described in Grafcet and the different modules are described either in Grafcet or in
another language. In this case, the main part of the command is modeled by a Grafcet.
global structure that communicates by exchanging inputs/outputs with other sub-parts
commands modeled with other formalisms (see Figure 3.2).

Figure 3.2 – Modeling of a PC


3.2.3 The Grafcet is suitable for modeling the entire control part
The structure and the different modules are described in Grafcet. In this case, the whole of the
the command is modeled by a global Grafcet structured into partial Grafcets:
Hierarchically, through orders of forcing and step variables;
Let it be without formal hierarchy, only through the exchange of step variables.
The direct command of the operating part is ensured by a number of automations.
local, thus forming a partition of the system into a number of subsystems, made up of
each of an operative sub-part and a local control part. This partition into sub-
system results from constraints:
Physical location of operational sub-parts;
On the fragmentation of investments;
Technological, etc.

Teacher: Ridha MAHJOUB 3


Chapter 3 Management of the operational modes of an S.A.P

To carry out a functional partition of the control part, it is necessary to respect the architecture.
from the operational part, functional architecture in relation to the development of added value.
3.3 Hierarchization of functions
The functions of a Control Unit can be classified by levels of intervention of the
PC on the PO.
The three main functions, command, control, safety, can be organized, at
level of the internal structure of the PC, in hierarchical levels. This type of structure leads to
generally to a three-level Global Grafcet, and therefore composed of at least three grafcets
partials (see Figure 3.3).
Security level: gathers the safety stop conditions as well as monitoring of
sensitive point of the process.
Driving level: manages the modes of starting and stopping, excluding safety.
Order level: manages the production cycle of the system under the conditions of
normal marches.

System in Safe Mode


GFS

Secure/OK Secure_OK Secure/OK

System operation
GFC

sel_manu auto select

Production in Mode
Manual Mode Production
Automatic
...
GFP_Manu GFP_Auto

Figure 3.3 – Structural organization of an automation program


3.4 Representation of the level of surveillance
The surveillance function must ensure the safety of people and property and ensure
maximum availability of the installation. The events associated with this level are of the type
random (default, power outage, AU, etc.) and can occur in any mode of
functioning.

Teacher: Ridha MAHJOUB 4


Chapter 3 Management of operating modes of an S.A.P

The surveillance level is hierarchically superior to the other two, it will therefore issue
forcing orders to lower levels but also direct orders to the PO:
The first emergency securities will be ensured by a wired logic;
The lower emergency safeties will be handled by the programmed logic (API).
In most cases of security incidents, the main difficulty is the handling of recovery.
after stopping, this may lead the designer to implement special recovery grafcet
after a stop. The EN 1131-1 standard defines three types of resumption.
3.4.1 Cold Restart
Restoration of the API configuration and its application program after all the
dynamic data (variables such as I/O image, internal memories, timers,
counters, etc. and contexts of the program) have been brought back to a predetermined state. A
Cold restart can be automatic (for example, after a power outage, a loss
information in the dynamic parts of the memory, etc.) or manual (by
example reset button, etc.).
3.4.2 Immediate resumption
Resumption after a power outage occurring during the maximum time interval
function of the process allocated to the configuration of an API to restore its operation
as if there had been no power cut. All the I/O information and all
the other dynamic data as well as the context of the application program are restored
you remain unchanged. The ability for immediate recovery requires a real-time clock or
a separately powered timer to determine the elapsed time since detection.
the power cut is an accessible way for the user to program the duration
maximum allowed based on the process.
3.4.3 Hot Reprise
Resumption after a power outage, with a set of dynamic data
predetermined and programmed by the user and an application program context
predetermined by the system. A hot restart is characterized by a status indication or
any other related means made available to the application program indicating that
The power interruption of the API configuration has been detected in RUN mode.
Security is a component of the safety of an automated system The achievement of a level of
high availability may be incompatible with security, which is why safety must be
an overall analysis to reach the best compromise. Security must be considered under
the dual aspect of risk analysis (severity and probability of occurrence) and the
applicable regulations.
3.4.4 Security actions
After detecting a failure, the PC may be tasked with different security actions.
types :
Alarm and signaling: control of lights, flashing beacons, siren, message editing
or/history of defeats;
Direct command of actuators: generally absolute and direct prohibitions of
movements (output equation);

Teacher: Ridha MAHJOUB 5


Chapter 3 Management of the operating modes of an S.A.P.

Evolution of the system: the PC causes changes in the system states towards a shutdown.
a degraded step or a safety step.
The representation of the monitoring level will include at least a safety Grafcet.
(GFS) but more often associated with one or more monitoring Grafcets (GFSUR).
3.5 Emergency Stop Handling
Two solutions can be proposed:
Without an emergency sequence: the system stops its evolution;
With emergency sequence: the appearance of an emergency stop triggers a procedure
particular.
3.5.1 Stop without emergency sequence
Fixing the automation: it is assumed in this case that the term "AU" is an implicit factor.
in all receptivities. From the occurrence of the emergency stop, no receptivity can
take the logical value 1: the situation cannot evolve. The disappearance of the emergency stop.
re-authorize the evolution of the cycle (see Figure 3.4).

Figure 3.4 - Treatment of a freeze-up


3.5.2 Stop with emergency sequence
It is known that one of the benefits of Grafcet is to indicate in each situation that the only
circumstances that cause it to evolve. The emergency stop always has to evolve the situation of
The control part should, in all rigor, be made to appear at each step of the Grafcet.
As soon as the case being handled becomes somewhat important, the Grafcet becomes completely unreadable. It is...
it follows that it is difficult to consider the emergency stop as an entry information
like the others. Moreover, it goes against the very spirit of the urgency granted to this halt
a kind of 'super priority'. However, it is interesting (but not always possible) to
to be able to formalize the expected behavior of a system when information appears
"AU" (see Figure 3.5).

Teacher: Ridha MAHJOUB 6


Chapter 3 Management of the operating modes of an S.A.P

Figure 3.5 - Sequential emergency stop processing

3.6 Normal production Grafcet


Grafcet describing the normal production operation of the system. It may refer to some
Grafcets of tasks or procedures. The dialogue between the Grafcets is carried out by the variables.
Xi (see Figure 3.6).

He will describe the cycle of the Operative Part (one or several Grafcets) to produce value.
added. In the case where a state rectangle calls for a complex procedure, it will be executed.
by a procedure Grafcet.

Figure 3.6 - Example of production Grafcets

3.7 Control Grafcet


It is the Grafcet that manages all normal operating and stopping modes. It can call upon some
Specific Grafcets (initialization, preparation, closure...). The dialogue between the Grafcets is
generally performed by the internal variables of steps Xi (see Figure 3.7).
A state (not to be confused with a step) is a mode of operation (operating mode
or stop) that a machine can take.

Teacher: Ridha MAHJOUB 7


Chapter 3 Management of the operating modes of an S.A.P

Figure 3.7 - Control Grafcet

3.8 Safety grafcet


It is the Grafcet that manages failure procedures. It is hierarchically superior to all.
the other grafcets. This hierarchy is established by orders of Forcing (see Figure 3.8).
A state (not to be confused with a step) is a mode of operation (operating mode
or stops) that a machine can take. In order to design robust and reliable machines,
It is necessary to catalog the operating states of this machine.

Figure 3.8 - Safety Grafcet

Teacher: Ridha MAHJOUB 8


Chapter 4

Processing of quantities
analogous by an API
Chapter 4 Traitement des grandeurs analogiques par un API

Processing of analog quantities by an API

4.1 Introduction
All physical quantities (voltage, temperature, pressure, positioning, speed,
etc.) are analog quantities. In order to be able to process these quantities in an API, it
it is necessary to:
Convert the physical quantity into an electrical analog quantity;
Convert the analog electrical quantity into a digital quantity.

The objective of processing analog quantities through an API is, based on the basic principles
from analog technique, characteristics of analog input and output modules.
4.2 Analog and binary signals
Binary signals can only take two logical states: logical state 1 (voltage
logical state 1 (presence of voltage) and logical state 0 (no voltage is present). In automation technology,
signals that are not only binary but also analog often need to be read, processed and
transmission. Unlike binary signals, analog signals can take any
the values contained within a defined range.
4.3 The analog inputs
In contrast to digital or logical inputs, an analog input allows for the collection of a
variable electric signal that can take an infinite number of values over a range
defined. The value of an analog input changes continuously over time depending
of the physical quantity measured by the sensor.
- Voltage type signals: Voltage type signals are generated by certain types of
analog sensors. The most common operating ranges are from 0 to 5 V/DC and from 0 to 10
V/DC.
- Current type signals: The 4 signal 20 mA has become the standard current signal
In the industry, sometimes we can also encounter type 0 sensors. 20 mA.
Resistance type signals: Resistance type signals are most of the time
used with temperature sensors like thermocouples.
To convert the physical quantity into an electrical signal, it is sufficient to carry out
a rule of three:

signalmax electric grandeurphysical


Signalelectric
grandeurmaximum physique

Teacher: Ridha MAHJOUB 2


Chapter 4 Processing of analog quantities by an API

Example No. 1: Temperature sensor capable of measuring temperatures between 0 and 500°C.

Equivalent electrical analog signal


Temperature 0..10 VDC 0..20 mA 4..20 mA
0°C 0 VDC 0 mA 4 mA
250°C 5 VDC 10 mA 12 mA
500°C 10 VDC 20 mA 20 mA
300°C 6 VDC 12 mA 13.6 mA

Example No. 2: Three-phase motor with a speed ranging from 0 to 4000 rpm.

Equivalent electric analog signal


Speed 0..10 VDC 0..20 mA 4..20 mA
0 rpm. 0 VDC 0 mA 4 mA
2000 rpm 5 VDC 10 mA 12 mA
4000 rpm 10 VDC 20 mA 20 mA
2500 rpm 6.25 VDC 12.5 mA 14 mA

4.4 The analog outputs


Unlike analog inputs, analog outputs are variable signals.
These signals are generated by the controller (analog output module) act on pre-
analog actuators. For example, an analog output can allow for controlling a
speed variator or a proportional solenoid. As for the inputs
Analog signals, the most common types of signals are voltage and current type signals.
and resistance.
4.5 Addressing of analog variables
Analog values are read or written by the API as word information. Access to
these words are executed for example with the operands:
‐ %IW 64: analog input word 64;
-%QW 64: analog output word 64.
The addressing of input values and output values depends on the addressing in the view of
devices. Figure 4.1 shows the hardware configuration of a programmable logic controller
Simatic S7-1500 with analog input/output modules.

Teacher: Ridha MAHJOUB 3


Chapter 4 Processing of analog quantities by an API

PS CPU DI16 DO16 AI8 AO4

Figure 4.1 - Example of addressing

This programmable controller has eight (8) analog inputs, the address of the first input
The analog would be in this case %IW64 and that of the eighth analog input is %IW78.
Since it has four (4) analog outputs, the address of the first analog output
in this case is %QW64 and that of the fourth analog output is %QW70.
4.6 Normalization of analog values
If an analog input value is present as a digitized value within a range
bipolar 27648 (see Table 4.1 and Figure 4.2), it usually needs to be normalized for
that the numerical values correspond to physical values of the process. The output
analog is also achieved by the transmission of a standardized value that must then be
scaled to the value of the bipolar output 27648 as shown in Table 4.1.
Tableau 4.1 – Processing of analog quantities by an API
The entries
Input voltage 27648

10
Current entry 27648

20
The outings
Output voltage 10

27648
Current output 20

27648

To adapt the analog signal, normalization and scaling conversion are used.
two predefined functions by the Step7 software.

Figure 4.2 – Nominal range of analog values/digitized values

Enseignant : Ridha MAHJOUB 4


Chapter 4 Processing of analog quantities by an API

The functional block "NORM_X" normalizes the value of the variable at the input
VALUE by reproducing it on a linear scale. We define it with the parameters MIN and
MAX, the limits of a range of values that is reflected on the scale. The result is calculated in
function of the position of the value to be normalized in this range and it is stored in the form of
real floating-point number at the OUT output (see Figure 4.3).
When the value to be normalized is equal to the input MIN value, the output OUT provides the
value 0.0.
When the value to be normalized is equal to the input value MAX, the output OUT provides the
value 1.0.

Figure 4.3 – Functional block NORM_X

The normalization instruction uses the following equation:


(VALUE - MIN)
OUT
(MAX – MIN)
The validation output ENO provides a logical state 0 when one of the following conditions is
true
The validation input EN provides the logical state 0;
The value at the MIN input is greater than or equal to the value at the MAX input;
The value of the indicated floating-point number is outside the range of numbers.
normalized according to IEEE-754;
The value at input VALUE is the result of an invalid calculation operation (NaN: not a
number).
4.7 Scaling the result of a conversion
The scaling instruction allows to scale the resulting value of an operation
of conversion by reproducing it over a specified range of values. During execution of
the predefined instruction "SCALE_X" by the Step7 software, the floating-point number to
The VALUE entry is scaled to the range of values defined by the parameters.
MIN and MAX. The result of the scaling is an integer that is stored at the output.
OUT as shown in Figure 4.4.

Teacher: Ridha MAHJOUB 5


Chapter 4 Processing of analog quantities by an API

Figure 4.4 – Functional block SCALE_X

The functional block 'SCALE_X' uses the following equation:

OUT [ VALUE*(MAX - MIN)] + MIN


The ENO validation output provides a logical state of 0 when one of the following conditions is
true
The validation input EN provides the logical state 0;
The value at the MIN input is greater than or equal to the value at the MAX input;
The value of the indicated floating-point number is out of the range of numbers.
normalized according to IEEE-754;
An overflow occurs;
The value at the input VALUE is the result of an invalid calculation operation (NaN: not a
number).
Application 1: Speed measurement
The speed of a rotating machine must be recorded within a range using a
measurement transducer allowing the passage of the interval [500 1500 rpm over a range of
tension of [0 10] V.
For a measured speed of 865 rpm, what is the value of the transmitted voltage?
measurement transducer. Deduce the digital content in the register Reg10.
Solution of application 1:
The characteristic of the transducer's response is presented in the following figure:

Enseignant : Ridha MAHJOUB 6


Chapter 4 Processing of analog quantities by an API

This feature is described by the following equation:

U K.(N - N0)

At: U = 0V when N = 500 rpm and U = 10V when N = 1500 rpm, from which:
10
10
1500 500

For: N = 500 rpm 10*5005000


-For: N = 1500 RPM 10*1500/50010.

From where then: N = 865 rpm 10*8655003.65.

This analog quantity will be processed by the analog input of the API so that it can be read.
then converted into a digital information (Analog to digital conversion) this means
that the voltage value of 3.65V will be stored as digital information in the
entry register Reg10.
27648 27648
*U *3.65 10091
10 10
Application 2: tank level control
The level of a liquid in a tank is converted into a voltage ranging from [0 +10V] by a
sensor associated with a measurement transducer.
The transducer is connected to the first analog input of the Simatic S7-1200 at the level of
what the analog signal must be converted, normalized, and scaled.
Propose a Step7 program that meets the following conditions:
-0V corresponds to a level of 100 liters and +10V corresponds to a level of 1000 liters;
The maximum permissible level is 990 liters and the minimum permissible level is 110.
litres.
Solution of application 2:
The local variables required for this application are:

Addresses Variables Types Comments


%IW64 niveau_citerne_EA Whole Tank level
%Q0.0 max_tank Boolean Signaling
level > 990 liters
%Q0.1 tank_min Boolean Signaling
level <110 liters

It is especially important that the correct data types are used, since in
the rest of the program, they must be compatible with the conversion functions used.
After declaring the local variables, the program is written in symbolic addressing of the
variables.

Teacher: Ridha MAHJOUB 7


Chapter 4 Processing of analog magnitudes by an API

Teacher: Ridha MAHJOUB 8

You might also like