Welcome to the new Schneider Electric Community

It's your place to connect with experts and peers, get continuous support, and share knowledge.

  • Explore the new navigation for even easier access to your community.
  • Bookmark and use our new, easy-to-remember address (community.se.com).
  • Get ready for more content and an improved experience.

Contact SchneiderCommunity.Support@se.com if you have any questions.

Close
Invite a Co-worker
Send a co-worker an invite to the Exchange portal.Just enter their email address and we’ll connect them to register. After joining, they will belong to the same company.
Send Invite Cancel
84579members
353849posts

Copy data between different data types in Unity

Industry Automation and Control Forum

This forum is addressing industrial automation design & engineering, operations, asset performance, cyber security and digital transformation for Plants & Machines.

Solved
EMurphy
Crewman
Crewman
0 Likes
3
1082

Copy data between different data types in Unity

I am using READ_VAR to read data from a slave device.  It returns data as an Array of INTs.  Using Function Block or Structured Text is there a way to copy this data to a DDT so that I don't have to extract the data register by register.  I am currently assigning the Array and the DDT to the same address, but I have to turn off the Overlapping Address warnings.  Wondering if there is a programmatic method?

 

Thanks

Tags (1)

Accepted Solutions
Juan
Commander
Commander
0 Likes
0
1041

Re: Copy data between different data types in Unity

Hi,

 

Use the extract function to copy memory zones.

 

EXTRACT (SRC := (*ANY*),
                  SRC_NELEM := (*UDINT*),
                  SRC_POS := (*UDINT*),
                  DST_POS := (*UDINT*),
                  CPY_NELEM := (*UDINT*),
                  DST => (*ANY*),
                  ERR => (*INT*));

 

Regards,

Juan

See Answer In Context

Tags (1)
3 Replies 3
S_Stolyarov
Lieutenant JG
Lieutenant JG
0 Likes
0
1074

Re: Copy data between different data types in Unity

Dear colleagues, I'm also interested in this topic, are there SMART solution for that?

Tags (1)
JerryBartlemay
Ensign Ensign
Ensign
0 Likes
0
1051

Re: Copy data between different data types in Unity

There really isn't a "smart" way to do this.  I would suggest using a DFB with structured text or FBD using moves to take the data from the INT array and move into the appropriate elements of the DDT you create.  This would eliminate the issues you have with memory word alignment on REALs and DINTs.  

 

Even if you were using a Modbus TCP DTM on a NOC module, it is not always possible to create a DDT items within the DTM instance because of this alignment constraint.  In that case, a DFB to do the moves is still the best answer.

 

Of course, you could do those moves in a section of logic, but even for a one-off usage, creating a DFB encapsulates the code and simplifies your base logic.

Tags (1)
Juan
Commander
Commander
0 Likes
0
1042

Re: Copy data between different data types in Unity

Hi,

 

Use the extract function to copy memory zones.

 

EXTRACT (SRC := (*ANY*),
                  SRC_NELEM := (*UDINT*),
                  SRC_POS := (*UDINT*),
                  DST_POS := (*UDINT*),
                  CPY_NELEM := (*UDINT*),
                  DST => (*ANY*),
                  ERR => (*INT*));

 

Regards,

Juan

Tags (1)