RAndersson
Member
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 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?