====== 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 ====
^**@S5**^**Unity Name**^**Unity Type**^**@ Unity**^**Example**^
|Mx.y|Mx_y|BOOL|%MW(x/2).y|M10.0 => %MW5.0|
|MBx|Mbx|BYTE|%MW(x/2)|MB20 => %MW10|
|MWX|Mwx|INT|%MW(x/2)|MW30 => %MW15|
==== Data block variables ====
^**S5 DB Number**^**S5 DB WORD Number**^**Unity Name**^**Unity Type**^**@ Unity**^
|DBx|Wy|Dbx_Wy|INT|Memory 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.
^**@S5**^**Unity Name**^**Unity Type**^**@ Unity**^
|Ex.y|Ex_y|EBOOL|user define|
|Ax.y|Ax_y|EBOOL|user define|
|EBx|EBx|BYTE|user define|
|EWx|EWx|INT|user define|
|ABx|ABx|BYTE|user define|
|AWx|AWx|INT|user 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.
some OB may be translated as SR.
==== 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 Type**^**DFB input Timer_type**^
|SI|1|
|SE|2|
|SV|3|
|SS|4|
|SA|5|
|Reset|7|
=== Counters ===
The ZV and ZR counters are translated by an integer.
^**S5 Counter**^**UNITY**^
|ZVx|Zvx_Val_Int|
|ZRx|Zrx_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.**
* example of unsupported indexation when calling a DB: 002C :B MW16
002D :A DB10
it affects all following usages of DWx that refer to that selected DB which is unknown because indexed by the value of MW16.
* example of unsupported indexation for affectation of analog outputs: 0015 :L DW0
0016 :B MW196
0017 :T AW0
here the problem is that indexation on outputs are not supported by Unity-Pro.
* example of unsupported indexation for conditional jump:
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
==== 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 ||||||||
|0|1|2|3|4|5|6|7|0|1|2|3|4|5|6|7||0|1|2|3|4|5|6|7|0|1|2|3|4|5|6|7|
==Unity Memory Mapping Coding in big endian==
| WORDn ||||||||||||||||| WORDn+1 ||||||||||||||||
| |||||||| BYTEn ||||||||| |||||||| BYTEn+1 ||||||||
|15|14|13|12|11|10|9|8|7|6|5|4|3|2|1|0||15|14|13|12|11|10|9|8|7|6|5|4|3|2|1|0|
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:
* overlapping of bits, bytes and words
* Consecutive words eg (MW10, MW11, MW12 ...)
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.