Copy data from SINT array to UDT

RAndersson

Member
Join Date
Jan 2022
Location
Sweden
Posts
3
Hello!

I am completely new to PLCs, so I apologize in advance if this is a dumb question.

I have a device that sends out its data as a number of configurable data types, for example 4 SINTs, 1 DINTs and 6 SINTs. This arrives in the PLC as a SINT array of matching size. So, for example if the device is configured to send out 4 SINTs, 1 DINTs and 6 SINTs the data arrives in the PLC as a SINT array of length 4 + 1*4 + 6 = 14.

In addition, I have a User data type that my device can export that matches the data types, so for the example above: 4 SINTs, 1 DINTs and 6 SINTs.

What I want to do is to copy the content of the SINT array to a tag of type myUDT. To do so, I am trying to use (Which I am not sure is the correct way):

COP(myDevice:I.Data[0], testTag, 1)

or

COP(myDevice:I.Data[0], testTag.firstElement, 14)

This works for the first 4 SINTs, but the DINT data is not correct. In addition, the data in the 6 SINTs following the DINT is offset 3 positions backwards (So data data in the SINT array position 13 (The last one) is copied to the fourth last SINT in testTag instead of the last)

As a test, I tried to copy 4 bytes in the SINT array to the DINT alone, and this works:

COP(myDevice:I.Data[4], myDINT, 1)

Is there a way to copy the content of the SINT array to the UDT in this way?
 
I might have figured something out: If the DINTs are placed on positions evenly divided by 4, then it works, else it does not. For example, a structure like:

3 SINTs, 1 DINT, 4 SINT

Does not work, while

4 SINTs, 1 DINT, 4 SINT

Works (Using COP()).
 
Hello!

So, for example if the device is configured to send out 4 SINTs, 1 DINTs and 6 SINTs the data arrives in the PLC as a SINT array of length 4 + 1*4 + 6 = 14.

A DINT is 2 INTs (or 4 bytes/32 bits) so you would have an array length of 12
 

Similar Topics

This feels like a simple, elementary question, but I am a Siemens novice and know there are experts here. My S7-1500 project (TIA Portal v17) has...
Replies
10
Views
2,711
Hi everyone! I am working on a Siemens plc (1200/1500), and I have two instruction that i have to perform. A) data structure (40 bools, 40...
Replies
3
Views
2,464
Hello, I am new to Siemens' Simotion Scout software. I looked for a thread that might include this but...I have a CU320 and an existing project...
Replies
9
Views
2,639
In a few months I'll be decommissioning a PLC-3. We have a DOS VM with the AB6200 software that can apparently go online with this beast. I say...
Replies
1
Views
1,459
Hi, I'm still at the beginning of my journey with TIA, and am doing something for which I'm sure there must be a better way than writing each bit...
Replies
7
Views
2,741
Back
Top Bottom