Boolean arrays

I think so, but can't test it right now.

Thinking FBC or DDT, or even plain old FSC might do it. If not then it should be relatively straightforward to code an iterative loop to do the job.

Questions :-

1. How big are the files ?

2. How fast do you want the comparison ?

3. How frequently do you want the comparison ?

4. What results do you need ? (i.e. do you just need to know they are the same/different?, where the differences are ?)

One technique I've used before, when I need to find a bit set in a BOOL array, is to COP the BOOL arrays into DINT arrays, use FSC on the DINT arrays, looking for the DINT <> 0, and then drop into another routine to find the bit set in the DINT.

The .POS of the FSC, multiplied by 32, plus the bit number tells me the position of the bit set in the BOOL array.
 
Maybe I'm not asking the question correctly. I have two tags each are date type BOOL[256]. I just want to compare the two while a process is running and set an ote high for as long as the two aren't equal.
 
Did you try daba's idea yet?

I use File Bit Compare instructions in SLCs and PLC5s that do exactly what you want.

I can't test it on a Logix CPU from my truck without logging into a running machine through a cell signal...and I got get a pressure washer after 'ole blue while the sun's out.

Check the manual for your data type or try it out.

In a SLC it takes two control words and sometimes an array of ints to store the results of the mismatches (you control the length of that array).

So it's great for Alarm Tickers or Active Fault Lists.

If you just need the FD bit, so be it. The FounD bit will be set whenever there is a mismatch, and you can ignore the other results.

DSC00324.jpg
 
Welcome to the forum myokers.

I think DABA answered the question.

Attached is a loop like he and spaderkung suggested, where index is a DINT, MisMatch is a bool and Array1 and Array2 are Bool[256]

A022811-1.JPG
 
Paul, I poked in an FBC as an option using boolean arrays and got an error. Whereas the OP says he is using BOOL arrays, and the FBC is looking for a DINT array that didn't surprise me. I didn't take time to play with it any past that to try and discover a work around. The FBC works on the PLC/5 and SLC500 B files, but a B file is really an integer file, while the ControlLogix boolean is a different animal.

FWIW, I usually avoid boolean arrays if its anything that I might want to handle as a file.

Myokers, if you can use a DINT array instead you'll make life quite a bit easier on yourself. If not then you'll probably end up having to use a loop or brute force, ie. 256 rungs. Even that isn't really that bad, 256 rungs will execute faster than that loop I posted earlier. Its just tedious to program, unless you know how to use MS Excel to write your PLC program, then it goes really fast.
 
Last edited:
Welcome to the forum myokers.

I think DABA answered the question.

Attached is a loop like he and spaderkung suggested, where index is a DINT, MisMatch is a bool and Array1 and Array2 are Bool[256]
That would work but looping 256 times is not good. Are BOOLS 32 bit or 1 bit values on a Control Logix. If the bits are packed into 4 32 bit words then why not do four 32bit compares?
 
Peter,

The CLX does word optimize Boolean arrays, unfortunately it doesn't give the programmer an easy handle to access them as 32 bit words. I have no idea why Rockwell would do it that way, perhaps Ken can shed some light or give us a new trick.
 
I'm not really conversant with the CLX platform but, couldn't one use an FAL instruction to XOR the two source files against each other and add that result to an accumulator (previously cleared)? Then just check the accumulator for a zero/nonzero value.

Something like: ACC = ACC + (arg1 xor arg2)
 
Alaric, a switch to DINTs was gonna be my next suggestion too, but the FAL did cross my mind.

With 8 dints you could put 8 NEQs in parallel and avoid the loop construct...seems this has been done before...didn't bother searching though...o_O

What about aliasing to them another data type?
 
myokers said:
Maybe I'm not asking the question correctly. I have two tags each are date type BOOL[256]. I just want to compare the two while a process is running and set an ote high for as long as the two aren't equal.

Seems like my earlier post fits the bill here - use COP to copy the BOOL arrays to DINT arays, then use FSC DINT1[x] <> DINT2[x], if .FD comes true, they aren't equal

Tomorrow I'll post the code if I get the time....
 
That would work but looping 256 times is not good. Are BOOLS 32 bit or 1 bit values on a Control Logix. If the bits are packed into 4 32 bit words then why not do four 32bit compares?

Peter, definately packed, (BOOL Arrays, that is), thats why COP overlays the 256 bits into the 8 x 32-bit DINTs nicely. (BTW, 256 bits is 8 x 32, not 4 x 32, I bet you knew that anyway....)

COP makes no attempt to do any data-conversion - it's just a bit copier.

And it is easy to use, because the COP length is always the length of the destination tag, even if you get it wrong (i.e. too large), COP will "give up" when it reaches the end of the destination tag (like BTD does). (Caveat, not so when the destination tag is embedded inside a data structure, the COP gives up when it reaches the end of the current destination tag).
 
Last edited:

Similar Topics

Im pretty new to software and could use some advice please, I am trying to fire an output if any alarms on my software are on. I have a boolean...
Replies
16
Views
4,634
Hi there!! Is there a function to shift bits when using boolean arrays?? Im using Rslogix 5000. I decided to use boolean arrays coz with DINT...
Replies
10
Views
4,883
Hi. I haven't touched an Allen Bradley PLC for more than 10 years and I'm kind of rusty. I want to do something really simple in a FBD section...
Replies
5
Views
854
All, i nto fully get it. I read trough some froums but not finaly make it running. so I try to ask. Hopefully anybody has the kindness to answers...
Replies
7
Views
1,196
Example: Take this boolean algebraic expression: note: I'm using a single quote to denote negation as I can't place a bar over the letter. (CA +...
Replies
9
Views
2,835
Back
Top Bottom