Compare Bool Array to Bool - Studio 5000

KP_Verdo

Member
Join Date
Jan 2017
Location
Aarhus
Posts
3
Hi out there
is it possible to Compare a bool array to a bool, in studio 5000.
I'm think that if One of the bool's in my array is true, then i want a OTE to be true. i'm looking for the most simple way to do this.

I'm using Studio 5000 v.24.00
My PLC is 1796-L16ER

thanks in advance
 
BOOL arrays are very unfriendly, there is not a lot you can do with them.

Whenever I want to use one, I embed it as a BOOL array within a UDT.

Now it is a "structure", and can be COPied into a DINT array, where you can use a variety of methods, FSC, DDT, FBC etc., to find bits that are ON.

2017-01-23_121927.jpg 2017-01-23_122847.jpg
 
Can you be a little more clear about what you are want to do?

If you want to know if a only one Boolean in the array is true, put the bits into a DINT like Daba has suggested. One bit is set if the DINT is not zero and the DINT is a power of 2.
ONE_BIT = X && !(X & (X-1))
Be sure to comment why you are using this calculation. It probably isn't obvious to a lot of people why you are using it.
 
I have my alarm's in a Bool array, and i want to know if one or more alarms is true, so i can show it with a light.
I will try what Daba has suggested.
 
I have my alarm's in a Bool array, and i want to know if one or more alarms is true, so i can show it with a light.
I will try what Daba has suggested.

One way to test the DINT array is to SUM it, and if the result is non-zero there must be a bit or bits set.

Unfortunately there isn't a SUM instruction, but there is AVE, and since...
Average = SUM / Length,
it follows that ...
SUM = Average x Length

EDIT - Ive just tested this, and you don't need to multiply the Average (if you make it a REAL) by the Length - the result of the average will non-zero, even if just one bit is set. I believe the AVE will be quicker that the FSC, because there's no comparisons being performed for each DINT.
 
Last edited:
You can also use a FSC(File Search/Compare) on the DINT array and use an expression like
0<>DintArray[FSCControl.POS]
 
I believe the AVE will be quicker that the FSC, because there's no comparisons being performed for each DINT.

On second thoughts, the FSC will be fastest in the majority of cases, simply because it will stop (freeze) when it finds a non-zero DINT.

If that's all you need to know, you can use the FD bit to say there is at least one alarm, and reset the FSC ready for the next scan.
 
Too complicated.

How many alarms are we talking here?

First, use DINT array instead of bool arrays. Only use Bool arrays if there is an advantage to that structure. I see no advantage here.

If you want to turn on an output based on any bit in the DINT array = "ON"; the logic is simple.

BST NEQ Alarm[0] 0 NXB NEQ Alarm[1] 0 NXB NEQ Alarm[2] 0 NXB NEQ Alarm[3] 0 BND OTE Light

That rung handles 128 alarms, it's simple.
 
Too complicated.

How many alarms are we talking here?

First, use DINT array instead of bool arrays. Only use Bool arrays if there is an advantage to that structure. I see no advantage here.

If you want to turn on an output based on any bit in the DINT array = "ON"; the logic is simple.

BST NEQ Alarm[0] 0 NXB NEQ Alarm[1] 0 NXB NEQ Alarm[2] 0 NXB NEQ Alarm[3] 0 BND OTE Light

That rung handles 128 alarms, it's simple.

Simple if the numbers are small.....

One brewhouse project I worked on had 5 Logix5000 controllers, each had an alarm file of 2000 (2048) alarms. Every processor had to monitor all alarms across the system, so in total there was a global alarm strategy that extended up to 5x2048 alarms = 10,240 alarms monitored by all the controllers.

The "simple" solution would not have been manageable...

And it is convenient to use a unique numeric identifier for each alarm, rather than word.bit, so a BOOL array was easier to use.

We used that BOOL array inside a UDT that allowed us to copy it to a DINT array for processing.
 
Last edited:

Similar Topics

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,774
Help please. Im new to Omron and have a machine down. I have a compare = for barcode label scan. I've attached two pics. On the Mnemonics you can...
Replies
4
Views
622
Hi everyone! Accidentally closed it and it wont appear again. Checked and unchecked the option and seem to make no difference. Running v7.10.00...
Replies
16
Views
1,899
I'm working on an array that contains a UDT of 5 Items Array[4] DataType[0] - Part 1 - Part 2 - Part 3 - Part 4...
Replies
1
Views
839
Hi. I have 2 files where I would like to see the ladder logic differences (similar to the Rockwell compare function). I am using TISoft Siemens...
Replies
1
Views
1,263
Back
Top Bottom