5 TRANSLATOR
At this moment, there is only one translator ready,
that is the one that translates the Grafcet graphical
representation into an RS program. The Grafcet el-
ements implemented on the graphical interface were
discussed on previous sections, while the RS lan-
guage and automaton can be seen on(Toscani, 1993)
The variables are defined previously by the user,
but the input, output and internal signals are detected
automatically. The RS internal signals correspond to
the steps, the RS input signals are detected during the
parsing of the conditions (from actions and from tran-
sitions), and the RS output signals are detected during
the parsing of the actions that must be executed.
Some auxiliary RS internal signals are also gener-
ated, if there are more then one action associated to
one condition or step. They are generate to grant the
sequential execution of each of these actions.
All the conditions are written using the infix nota-
tion. So, a boolean expressions analyzer was created.
It is also possible to call the RS compiler, to trans-
late this RS program into an automaton.
To illustrate the idea, figure 8 shows the generated
RS program for the sample Grafcet specification pre-
sented in figure 4. The up(signal) is responsible for
activating an internal signal, and the emit(command)
is responsible for sending an specific command to the
environment.
5.1 Steps
Each step of Grafcet is treated as an internal signal of
the RS language. So, for each step an internal signal
is created, if it still does not exist, and included at the
module header of the RS program. If the step is a ini-
tial one, it is added a command up(this step)
at the initially sentence of the module header.
This means that the respective internal signal will be
activated at the beginning, starting the automaton ex-
ecution at this step. The rules are executed if the sig-
nals (internal or input) on the left side of the rule are
on. The internal signals can be signalized internally,
while the input ones are set by the external environ-
ment.
If the step contains some action, it will be parsed
to detect the actions and their respective conditions,
if they exist. For each action, an output signal is cre-
ated and inserted at the module and program headers,
and an emit(this action) command is added
at the point where this action should be executed. The
output signals are responsible for sending commands
to the external environment (as a consequence of the
emit command).
rs_prog testando_programaRS:
input : D1,P2,P3,GC,AP1,GO,D2,P1,
AP2,D3,AP3;
output: Close G, TL, Open G, TR;
module testando_modulo:
input : D1,P2,P3,GC,AP1,GO,D2,
P1,AP2,D3,AP3;
output : Close G, TL, Open G, TR;
t_signal:E1,E2,E5,E9,E3,E6,E7,E4,E8;
initially: up(E1);
D1,P2,E1 ==> emit(Close G), up(E2);
D1,P3,E1 ==> emit(Close G), up(E2);
GC, E2 ==> emit(TL), up(E5);
AP1, E5 ==> emit(Open G), up(E9);
GO, E9 ==> up(E1);
D2,P1,E1 ==> emit(Close G), up(E3);
D2,P3,E1 ==> emit(Close G), up(E3);
P3, GC, E3 ==> emit(TL), up(E6);
AP2, E6 ==> emit(Open G), up(E9);
P1, GC, E3 ==> emit(TR), up(E7);
AP2, E7 ==> emit(Open G), up(E9);
D3,P1,E1 ==> emit(Close G), up(E4);
D3,P2,E1 ==> emit(Close G), up(E4);
GC, E4 ==> emit(TR), up(E8);
AP3, E8 ==> emit(Open G), up(E9);
end module;
end rs_prog.
Figure 8: Example of a generated RS program.
5.2 Transitions
Each Grafcet transition is parsed to detect the condi-
tions, the kind of each element (input variables, auxil-
iary variables, steps), and to analyze the boolean con-
ditions that may exist. Each input variable is added as
an input signal (if it does not exist) at module and pro-
gram headers; each step is added as an internal signal
at module heading (if it does not exist). The auxil-
iary variables were added directly by the user, when
using the graphical interface, but they are included on
the respective rule, to perform the correct behavior.
All of these elements will be included on the left side
of the respective rule, with the internal signals corre-
sponding to the steps that precede this transition.
5.3 Alternatives and Simultaneous
Sequences
The alternative sequences are detected and included
at the end of each rule, by the use of the up(next
step) command. This command is responsible for
activating the internal signal associated to the next
step that must be evaluated. There is no problem in
closing this kind of sequence, because there is no syn-
chronization between the steps of this sequence.
The simultaneous sequences are treated at the same
way, but because one transition will trigger more than
A GRAPHICAL INTERFACE BASED ON GRAFCET FOR PROGRAMMING INDUSTRIAL ROBOTS OFF-LINE
117