Or logic For integer Value equal a number

cstep7263

Member
Join Date
Dec 2019
Location
Katy, TX
Posts
35
Hello,
I need a little help. I’m looking for a way to program integer values to activate a bit for an alarm. for example... If any Integer[0] thru Interger[20] equal 1001, activate a bit.
I’m trying to find a cleaner way to do it without 21 branches around an equal instruction.
 
Last edited:
Mask and Check

It looks like you're working with 32-bit data. Take the register and AND it with hexadecimal 0x1FFFFF into another register. This turns off all except the 21 bits that you are interested in. Then compare that register to a constant 0.

The plc class outline download at corsairhmi.com has some related information.

I reread your request. It appears you want to do some sort of matrix (array) search. The method to do this varies with PLC - unless you do it in structured text.
 
Last edited:
You could always indirect address Integer[x] and use a counter that increments x by one each scan (self resetting after counting to 20), and then compare the values for each of them one at a time. Of course it will take 20 scans to check all 20 values. It works but depending on how important speed is in the application it might not be the best approach.
 
See attached file

1) What about using FOR instruction a repeat a comparison 20 times as is in this case.

2) Use FSC see attached figure. Your comparison has 20 values , mine has 400. .FD bit indicates that the comparison is true.

Capture FSC.JPG
 
Last edited:
I'd be inclined to break it up into two or three rungs each with multiple parallel branches and keep it simple with brute force, although the FSC with a robust rung comment is equally appealing.
 

Similar Topics

Good morning fellow sea captains and wizards, I am being asked to do the above and obtain 4 values from each slave, I know about the MRX and MWX...
Replies
20
Views
188
I have a machine which is undergoing upgradation. As part of the process two SEW drives are being replaced., existing Gen B with new Gen C. The...
Replies
3
Views
176
Hello Dear users, I am writing about a problem that has been bothering me for a few days, i.e. I am trying to establish remote access to the Allen...
Replies
0
Views
83
My PLC is currently running the program and the process is still live. One of my 1769-if16C cards values are all frozen but the card is not...
Replies
1
Views
118
need to find C bits in the logic. They are hidden someplace! Thank you! Bob
Replies
5
Views
188
Back
Top Bottom