Copy a DINT to BOOL[32] in rslogix5000

chrisk_81

Member
Join Date
Mar 2011
Location
Adelaide
Posts
58
Hi All,

Can anyone tell me how I would go about copying or moving a DINT into an array of 32 Boolean values in rslogix5000?

I've tried using the COP and MOV instruction to no avail.
 
Consider just referencing the DINT at the bit level rather than making an array of 32 booleans. The processor will handle it much more efficiently.
 
Aye, this one begs the "Why" part. There are ways to do that, but they really don't gain you a lot. One place that I do something like that a lot, is taking a DINT status word from a device, and breaking it down to named bools, but I do that with UDT's*, and it is just a simply COP there.

*Okay, not actually "Simply", you need to externally edit the UDT to give names to the individual bits, but workable.
 
Consider just referencing the DINT at the bit level rather than making an array of 32 booleans.

yes but that won't work in this instance.

I have Alarm:DINT and Index:DINT where Index is always between 0 and 31. I want to reference Alarm.Index but rs has a dummy spit. If I had Alarm[32]:BOOL then Alarm[Index] would work fine I presume.

Any ideas?
 
yes but that won't work in this instance.

I have Alarm:DINT and Index:DINT where Index is always between 0 and 31. I want to reference Alarm.Index but rs has a dummy spit. If I had Alarm[32]:BOOL then Alarm[Index] would work fine I presume.

Any ideas?


Use this syntax.

AlarmInt as DINT array
AlarmIndexNum as DINT
AlarmBitNum as DINT

Say you want to reference a XIC in the 3rd element and the 5th bit.

Mov 2 to AlarmIndexNum
Mov 4 to AlarmBitNum

AlarmInt[AlarmIndexNum].[AlarmBitNum]

You just have to put your indirect reference inside square brackets for the bit reference. It works like a charm.
 
Its an advanced topic but search the forum for "bit overlay" for a way to use a DINT instead of a BOOL array and at the same time have a name for each bit in the DINT.
 
As an addition to use indirect adressing for storing alarm bits in some kind of integer array I suggest creating an UDT using bit overlays for making descriptive names for each alarm.
This is very usefull when debugging a program.

Here is a link to an example UDT I made.
I made some comments in the xaml file and I suggest opening it with e.g. Notepad++ to review these.
https://www.dropbox.com/s/8js8ezhsmqovvcx/BitOverlayExample.L5X?dl=0

edit:
Will just mention for anyone not knowing that now the descriptive boolean member will reflect the state of the target bit in the backing tag and the other way around.
 
Last edited:
Hi All,

Can anyone tell me how I would go about copying or moving a DINT into an array of 32 Boolean values in rslogix5000?

I've tried using the COP and MOV instruction to no avail.

Late to the party, but i've done this before with a simple FOR loop for an OPC vision system that didn't handle elements of an integer but it COULD handle arrays of booleans.

Preferably in STL:

To go from Bool Array to DINT

DintValue := 0
FOR Control := 0 TO 31 BY 1 DO
IF BooleanArray[Control] THEN
DintValue := DintValue +(2**Control );
END_IF;
END_FOR;

To go from DINT to Bool Array

FOR Control := 0 TO 31 BY 1 DO
BooleanArray[Control] := DintValue.[Control];
END_FOR;

You could apply the same in ladder with jump labels or maybe an FAL if you were trying to be fancy, but it's more resource intensive on the processor and you lose efficiency.

Hopefully this helps someone else who comes along!
 

Similar Topics

Hey everybody, I have a bunch of bits used for diagnostics all compiled into a couple of DINTS. I have an x-ref sheet in Excel that aligns...
Replies
8
Views
1,868
The PLC program I'm monitoring has a UDT of alarm booleans. 36 in total. What I'm trying to do is monitor a few rungs, and also monitor a possible...
Replies
3
Views
1,598
I have 2 7cp476 plcs. How can I copy one of them and install it somewhere else?
Replies
0
Views
70
Hello Inside a FB, I´m trying to transfer a string from a DB to a IN_OUT var that was define as a UDT. The problem is that i can´t determine the...
Replies
4
Views
127
Hi everyone I'm in a bit of a conundrum, I've been trying to get this HMI on our machine and I am unable to retrieve it. Device Delta Model...
Replies
10
Views
872
Back
Top Bottom