Table of Contents

STEP5 / UNITY path general information

This chapter gives the general informations for STEP5 to UNITY conversion path.

Variable translation schemes

The comments of the variables are kept with their initial values (only for DB variables) but not the name.

There are two types of variables: The Memento variables The data block variables

Mementos variables

@S5Unity NameUnity Type@ UnityExample
Mx.yMx_yBOOL%MW(x/2).yM10.0 ⇒ %MW5.0
MBxMbxBYTE%MW(x/2)MB20 ⇒ %MW10
MWXMwxINT%MW(x/2)MW30 ⇒ %MW15

Data block variables

S5 DB NumberS5 DB WORD NumberUnity NameUnity Type@ Unity
DBxWyDbx_WyINTMemory plan DB begin at %MW6000

Input/Output

The mapping of the digital inputs/outputs of the source must be done by the user to define the new location in the new hardware configuration.

@S5Unity NameUnity Type@ Unity
Ex.yEx_yEBOOLuser define
Ax.yAx_yEBOOLuser define
EBxEBxBYTEuser define
EWxEWxINTuser define
ABxABxBYTEuser define
AWxAWxINTuser define

Codes modules translation schemes

Module name (OB, PB, SB,etc.) is converted like comment at the beginning of the section or SR.

Segment name and segment number are converted like comments at the beginning of the segment.

Language

The original Step5 code is always LIST. After translation in UNITY, by default the generated code is LADDER. But if some errors occur during the translation, the generated code is literal.

OB : Organization Block

OBs are translated in section and named Mast_Obx where x is the OB number.

<note> some OB may be translated as SR. </note>

PB : Program Block

PBs are translated in subroutine (SR)and named Mast_Pbx where x is the PB number.

SB : Sequential Block

SBs are translated in subroutine (SR)and named Mast_Sbx where x is the SB number.

FB / FX : Functions Block

FBs or FXs are translated in subroutine (SR) and named Mast_Fbx or Mast_FXx where x is the FB/FX number.

The Comments of the program

Only the comment of the last instruction is kept.

This Step5 code

0013      :U         E50.4          px tappo ext
0014      :UN        M96.2          controllo tappo fatto
0015      :S         M111.4         ev contr tappo

is translated in UNITY by

if E50_4 and not M96_2 then   
   (* ev contr tappo*)
   Set (M111_4);
end_if;

The System functions

Timers

Each Step5 timer type is translated by DBF S5_timer, whose behavior is the same as Step5 timer.

Step5 Timer TypeDFB input Timer_type
SI1
SE2
SV3
SS4
SA5
Reset7

Counters

The ZV and ZR counters are translated by an integer.

S5 CounterUNITY
ZVxZvx_Val_Int
ZRxZrx_Val_Int

Zvx_Val_Int is incremented on the rising edge of the condition.
Zrx_Val_Int is decremented on the rising edge of the condition.

The constructor FB

The constructor FB are not translated. The user has to translate them manually.

The Special functions

The special functions ( communications, regulation, axes, motion, …) are not translated. The user has to translate them manually.

intrinsic limitations of the conversion

Memory Access by absolute addresses

All memory access instructions by the absolute address are not supported.

Examples : instructions TIR, LIR, TNB, TNW,…

Indexation

In Step5, indexation instructions are identified by the character “B” followed by the address of the index (MW16 in the below example).

003A      :B         MW16

Only indexation instructions on a DB word are translated.

002B      :L         MW26           
002C      :B         MW16           
002D      :T         DW0            

is well translated by

Dbx_w0_ar[MW16] := MW26;

All other indexation instructions on Mementos, DB, FB, conditional jump… are not translated.

<note> In the example bellow, the execution of one of the jumps (SPA instr.) to label Lxxx depends on the value of the index at address MW128. The user has to translate them manually.

011C      :B         MW128          
011D      :SPA       L129           
011E      :SPA       L12B           
011F      :SPA       L130           
0120      :SPA       L135           
0121      :SPA       L13A           
0122      :SPA       L13C           
0123      :SPA       L148           
0124      :SPA       L149           
0125      :SPA       L14A           
0126      :SPA       L14B           
0127      :SPA       L14C           

</note>

Overlapping mementos address (bit, byte, word)

Step5 Memory Mapping Coding in little endian
WORDn+1
WORDn WORDn+2
BYTEn BYTEn+1 BYTEn+2 BYTEn+3
01234567012345670123456701234567
Unity Memory Mapping Coding in big endian
WORDn WORDn+1
BYTEn BYTEn+1
15141312111098765432101514131211109876543210

Bytes are addressed in word (%MW)

if in same S5 code, you have two consecutive words (for example MW0 and MW1), when you write byte MB1, you write also MW0 and MW1.

the user must identify in the code:

and adapt the code accordingly

What is the current DB

In some cases, it is difficult to determine the current DB.

For example here we first use the DB10 (“A DB10”) before calling FB10 (“SPA FB10”)

0001      :A         DB10
0002      :SPA       FB10

and at the beginning of FB10, depending on the value of M10.0 (“U M10.0”) we either jump to L000 (“SPB L000”) or continue and use the DB20 (“A DB20”) and just before the L000 label (“L000:”) we use the DB30 (“A DB30”).

0100      :U       M10.0
0101      :SPB     L000
0102      :A       DB20
......
......
......
0120      :A       DB30
0121  L000:L       MW22
0122      :T       DW11    

In this case, current DB depends on the value of M10.0. In line 0122, current DB is DB10 if M10.0 is TRUE else DB current is DB30.
But the translation is:

     DB30_w11 := MW22;

The user must identify these problems and rewrite the translated code.