DINT to Array of INT

Rony16

Member
Join Date
Nov 2018
Location
Germany
Posts
8
Hello,

Iam new here and use Rslogix for first Time.


How can I move DINT_Value to an Array Of INT.


For example:


Move DINT_Value1 to Array_INT[3] and [4].


And also I need the opposit Solution too:


Move Array_INT[1] and [2] to DINT_Value2
 
Hello,

Iam new here and use Rslogix for first Time.


How can I move DINT_Value to an Array Of INT.


For example:


Move DINT_Value1 to Array_INT[3] and [4].


And also I need the opposit Solution too:


Move Array_INT[1] and [2] to DINT_Value2
Copy function might do it for you, just be careful how you use it.
 
thank you BruceJW for your answer,


can the following work:


Cop:
Source:- INT_Value1
Dest:- Array_INT[3]
Length:- 2 // i need the value to be moved in Array_INT[3]and [4]


Other direction:
Cop:-
Source:- Array_INT[1] // i need the value that should be moved to DInt from Array_INT[1]and [2]
Dest:- INT_Value2
Length:2
 
thank you BruceJW for your answer,


can the following work:


Cop:
Source:- INT_Value1
Dest:- Array_INT[3]
Length:- 2 // i need the value to be moved in Array_INT[3]and [4]


Other direction:
Cop:-
Source:- Array_INT[1] // i need the value that should be moved to DInt from Array_INT[1]and [2]
Dest:- INT_Value2
Length:2
if I recall correctly, length is the source length.

so a dint can got to int[3] andint [4] if specify length of 1.

edit, my bad, I just checked, it's the destination length, so you would need to use a length of 2
 
Last edited:
if I recall correctly, length is the source length.

so a dint can to got to int[3] andint [4] if specify length of 1.
what i need is not to get the same DINT_Value in INT[3] and in int[4]
what i need is to slice DINT_Value, that first part of DINT_Value go to int[3] and second part to int[4]
 
Last edited:
what i need is not get the same DINT_Value in INT[3] and in int[4]
what i need is to slice DINT_Value, that first part of DINT_Value go to int[3] and second part to int[4]
sorry I edited my post about length, make it 2, then it should do it.
 
Two BTDs (Bit Field Distribute) might be what you seek. This is a bit level copy without concern for a positive or negative value. Depending how you want to slice (what you call the first part), you might swap [3] and [4] and/or going reverse, swap Dest bits 0 and 16.

BTD
Source - DINT_Value1
Source bit - 0
Dest - INT[3]
Dest bit - 0
Length - 16

BTD
Source - DINT_Value1
Source bit - 16
Dest - INT[4]
Dest bit - 0
Length - 16

Reverse:
BTD
Source - INT[1]
Source bit - 0
Dest - DINT_Value2
Dest bit - 0
Length - 16

BTD
Source - INT[2]
Source bit - 0
Dest - DINT_Value2
Dest bit - 16
Length - 16
 
Last edited:
sorry I edited my post about length, make it 2, then it should do it.
Thanks, it is working. To be sure better one moniter it using hex, or moving DINT_Value1 to Array_INT then move this Array_INT to DINT_Value2 to see if DINT_Value2 is same like DINT_Value1


@5618 i will try it later, thank you
 
if I recall correctly, length is the source length.

No, it is the other way, the length is the number of elements of the destination.

The instruction calculates the number of bytes to copy by multiplying the number of bytes of the destination's data-type by the length specified, then it copies that number of bytes from the source to the destination.

COP, CPS, and FLL can be very destructive if you get your length specification wrong.

If the destination is a single tag, then you are protected against having the length too long, because the instruction will terminate when the destination tag has no more space for data.

But if the destination is an element of a structure (UDT) tag, then those instructions will trample over the following elements within that structure.
 
No, it is the other way, the length is the number of elements of the destination.

The instruction calculates the number of bytes to copy by multiplying the number of bytes of the destination's data-type by the length specified, then it copies that number of bytes from the source to the destination.

COP, CPS, and FLL can be very destructive if you get your length specification wrong.

If the destination is a single tag, then you are protected against having the length too long, because the instruction will terminate when the destination tag has no more space for data.

But if the destination is an element of a structure (UDT) tag, then those instructions will trample over the following elements within that structure.
yes, it is actually quite fascinating what it does when messed up.
 

Similar Topics

I have a Structure in my project which has a few nested UDTs. They are ultimately of type DINT. What I would like to do is copy the values out of...
Replies
5
Views
2,245
Studio 5000 Ladder logic, i have a dint. We will call it Station. I want to see if there is a cleaner way of saying if bit .1 is true, then a dint...
Replies
11
Views
2,229
Thank you so much for your help! I am trying to use an INT or DINT as a setpoint for my remote device using Modbus TCP/IP. My code is...
Replies
2
Views
2,371
Hi All, I cannot seem to find a way to move a Boolean from an Arrays UDT into a DINT. I have an Array of 32 elements with a UDT data type of 4...
Replies
3
Views
1,733
Hi I am using GSV to get localTime when a specific event happen, which is stored in DINT array (DINT[0] to DINT[7]). Now I want to log this date...
Replies
3
Views
2,696
Back
Top Bottom