DINT to INT

RRoc

Member
Join Date
Jan 2017
Location
California
Posts
45
RSLogix 5000 any way to get a DINT to INT.
I'm trying to send two registers. Lower Byte will be example R1 with a data type INT and Upper Byte will R2 with a data type INT.

I can't figure out how to shift the Upper Byte to the Lower Byte with BSR Function Block.
 
If your INT were an array of 2, you can simply use a COP instruction to store the DINT into your INT array (maybe with a byte-swap if they are in the wrong order). In your case where your INT's are individual tags, you will need to use the BTD instruction.
 
As dmroeder suggests, using the COP instruction is a good solution.

Even if you already have the tags defined as two separate INTs. Create an INT array with 2 elements and call it Scratchpad. Enter the following code: MOV R1 Scratchpad[0], MOV R2 Scratchpad[1], COP Scratchpad DestinationDINT 1.

It's still cleaner and easier to follow than the BTD solution.
 
It's through the COP instruction with a length of 16 and it will parse out the upper and lower byte.
I see the light.

Thank you @mellis and @dmroeder.
 
The "length" in the COP instruction is determined by the destination data type. If you are copying to one DINT, then the length is "1" (that will copy all 32 bits from the two INTs into one DINT).
 

Similar Topics

Hi I am being given several fault words (as a DINT) from a Drive that I am receiving into a Compactlogix L33ER controller. I have a small...
Replies
12
Views
1,100
I am working on a project with a Controllogix 5582 processor using v32 firmware where I will be communicating with a Genset using Modbus TCP. It...
Replies
14
Views
893
Hi! It is always said, that DINT is the most performant datatype in AB plcs. I while ago i made a performance test. Several instructions like ADD...
Replies
4
Views
617
Im trying to use a MSG instruction to get the serial numbers of all addon cards and display the serials on a HMI interface. I have the logic done...
Replies
2
Views
518
Just something I think about when choosing data types in Studio 5000. It seems logical, but I've never looked deeply into the question. When...
Replies
12
Views
1,305
Back
Top Bottom