BOOL to DINT in ControlLogix

KerryP

Member
Join Date
Dec 2010
Location
Urbana, IL
Posts
40
In ControlLogix I have an array of 384 bits (BOOL[384]) that I need to move to an array of integers (DINT[12])so that I can refer to them in a FactoryTalk View alarm trigger setup. I can't seem to find an instruction to do this, even if I have to do it 12 times.
 
I'm pretty sure you're going to have to do this 384 times.
XIC BOOL[0] OTE DINT[0].0
XIC BOOL[1] OTE DINT[0].1
ETC....

As far as I know there's no other way to do this.
 
Just bite the bullet and replace your BOOL[n] with DINT[n].x

or copy this into a subroutine. This is the logic from above post.

just select all and make a new rung select the rung and hit enter.

This will open the ASCII TEXT BAR and paste it there then hit enter. it will do all 384 rungs.
 
I'm pretty sure you're going to have to do this 384 times.
XIC BOOL[0] OTE DINT[0].0
XIC BOOL[1] OTE DINT[0].1
ETC....

As far as I know there's no other way to do this.

Create a loop and index through:
XIC BOOL[Pointer] OTE "DINT[(Pointer AND(NOT 31))/32].[Pointer AND 31]"

or, instead of loop, just index once per scan (will take longer to get bits set within the DINT). Make sure you have limits set on array sizes, or will fault the processor. I assume you understand indirect addressing?

James
 
cwal61 - but I don't WANT 384 new rungs. I WANT one rung.

Phrog30 - exactly, thanks. I do understand indirect addressing and I do understand not pointing to non-existent elements in arrays, thanks again.

This very same program used to crash the processor all of the time until I went through and found all of the places where operator input was used as indirect address values. An array is 600 elements long and if a fat finger on the keyboard entered a number above 599, the whole line stopped because we just red-lighted the PLC. I think I'm up to around 11 or 12 rungs where I installed LIM instructions.
 
Piggybacking on your LIM case, the CLX processors support an instruction called SIZE, which returns the size of a specific dimension of an array. This doesn't affect too many people but if you either have a case where you think you may need to adjust the size of your array one way or another in the future OR you are using the same logic on different array sizes you may be better off using the SIZE instruction to determine the array size and limit the index to SIZE-1.

Keith
 
cwal61 - but I don't WANT 384 new rungs. I WANT one rung.

Just something for you to think about: 384 new brute force rungs will execute faster than looping through 384 addresses. You'll execute more instructions on the processor by looping plus deal with all the overhead of the loop. By using MS Excel to create the rungs you can create all 384 rungs in less than ten minutes. Throw them all in a mapping subroutine and then forget about them, the subroutine call will be one rung in your main program. You would already be done. I program a lot of loops, but the choice of method boils down to what you need: speed, or ease.

There are a few threads on here that deal with how to program super fast using MS Excel to generate rungs - a search on Excel should turn them up.

Even looping usually requires more than one rung. Its unfortunate the FAL instruction won't let you assign a BOOL to a DINT as that would give you a one rung solution. You could always create your own AOI (advanced programmers).
 
Last edited:
Keith, thanks for the heads up. I learned something today.
TConnolly, I'm with you now. I never actually programmed with MS Excel, until today. Thanks.
 
Originally posted by TConnolly:

You could always create your own AOI (advanced programmers).

That's a solid idea. It makes it look in a single line instruction in the main body of the software and effectively hides the functional existence of the code from the casual observer so it doesn't "confuse the issue". Granted, you will lose efficiency relative to a subroutine call but that probably won't kill you.

Keith
 
If you can make your BOOL array an element of a UDT, then you can use COP to copy the array into a DINT array.

The length is expressed as the number of elements of the COP destination, so in this case, 12

EDIT : I've just tried this, and it doesn't work - but I definitely KNOW I have done this before. Gonna try it in a much earlier revision to see if the idea has been "stamped on"...


2nd EDIT : Got it.... see the revised picture, the source for the COP must be the whole "structure" tagname...

2014-06-26_222335.jpg 2014-06-26_222646.jpg
 
Last edited:
Booleans are not the same thing as bits, but Logix5 and 500 programers often confuse them with B addresses. Booleans have some significant limitations when it comes to file instructions. There are several technotes in the AB knowledge base that cover the topic. One of the easiest is to put the bool array in a UDT as DABA showed. You can also convert all of your Bools to Alias tags with the base address being a bit in your DINT array. This method saves you the hassle of copying the state of each Bool to the DINTs but you will no longer be able to have the Bools in an array, it will be 384 discrete aliases (so give them a meaningful name while you are at it).

I don't know where you are programming level wise, but another option is to use a bit overlay. A bit overlay is a technique for attaching a tag name to an individual bit in a DINT, much the same way a timer's DN, TT, and EN bits are named bits in an integer. This is advanced programming but I've covered it briefly in a few threads. If you want more info do a search. Bit overlays are created in XML and imported. They cannot be created or modified in Logix5000, online or offline. To change one it has to be deleted and re-imported, so if its something you might be changing online then its not for you, but they do have their places.
 
Thanks guys, this is all very helpful and educational. I'm really looking for a relatively efficient and easy-to-troubleshoot way of moving these BOOLs into DINTs solely for the purpose of triggering alarms in a PanelView. I'm going to use the Excel thing to create a bunch of rungs quickly, but I'm also going to study these other suggested methods and techniques. The UDT sounds like a really solid answer but I'm in a plant where my opportunities for going into Program Mode are about twice a year. The same constraint would keep me from considering the XML bit overlay. But thanks for sharing the knowledge.
 
When it comes to easy to troubleshoot, there simply is no beating

XIC MyBools[0] OTE MyDints[0].0

Bubba on the midnight maintenance shift can follow and troubleshoot it.
 
TConnolly - I used to live in Northern California and work for Rust Instrumentation of SLC. One of my favorite places in the world, seriously beautiful, nice people everywhere. I live in flat, corn-covered central Illinois now and I'm jealous. I hope you are happy there.
 

Similar Topics

I work at a cheese factory and we recently ran into a problem where in an older controller they where able to use a REAL Data type in OTU and XIC...
Replies
13
Views
2,590
Hello I have two Bool data type tags located in the "Program Tags" under the Main Program routine. These tags are internal memory tags. How would...
Replies
4
Views
1,087
Hello guys hope y’all healthy during this time, Im looking for help in a project im trying to finish. I need to get a bool (ote) when a dint...
Replies
6
Views
1,787
I need to iterate though the bits in a DINT, but it seems you can't indirectly address a DINT at the bit level..... So my next thought was...
Replies
9
Views
3,431
I'm not a ladder or AB guy and the people asking me are using both, so this has me stumped. Long story short, they have several arrays of...
Replies
11
Views
5,335
Back
Top Bottom