Technical FAQs

Ask a Question

How to get same DDT variables alignment between Simulator and M340/M580 PLC

M580 , M340 data are aligned on 32 bits, while Premium, Quantum and Unity Pro PLC Simulator are aligned on 16 bits
So on M580 and M340 , 32 bits data (DINT, REAL, UDINT) must only be aligned on even addresses (eg : %MW10), while on PLC simulator they can be aligned on even or odd (eg : %MW10 or %MW11).
Address of DINT, REAL or UDINT elements mapped in a DDT structure may change when the target is switched from real M580/M340 PLC  to Simulator.
 
It is possible to arrange DDT in order to have same DDT variable alignment between Simulator and M340/M580 PLC
 
For that you have to enable the Project setting General/Management of build messages “DDT mapping compatibility generates”,  doing this when an analyze is done potential difference between M580 and simulator are reported by a warning.
With these information for the DDT identified : you have to follow the rules written inside UP documentation: "DDT: Mapping Rules" and rearrange the elements 
until not warning is reported.
 
For example:
my_DDT      %MW10
- W1 INT    %MW10
- DW1 DINT  %MW12
 
Message at the Built:
            :              Memory mapping of my_DDT elements might be different between PLC families. Refer to mapping rules in the online help
 
Effectively with the simulator it becomes:
my_DDT      %MW10
- W1 INT    %MW10
- DW1 DINT  %MW11
 
 
if you re-arrange the DDT
my_DDT      %MW10
- DW1 DINT  %MW10
- W1 INT    %MW12
 
With the simulator it stays the same:
my_DDT      %MW10
- DW1 DINT  %MW10
- W1 INT    %MW12
 
Nevertheless the message will appears again because the DDT does not contain an even number of element.
The final DDT to be sure to have no difference is the following:
 
my_DDT      %MW10
- DW1 DINT  %MW10
- W1 INT    %MW12
- free INT  %MW13
 
Doing an Analyze no more message appears and you will be sure to have the same behaviour between simulator and PLC.
 
Note: in case you want to keep the initial order of the element  you can also define the DDT like this:
my_DDT      %MW10
- W1 INT    %MW10
- free INT  %MW11
- DW1 DINT  %MW12
 
Was this helpful?
What can we do to improve the information ?