ControlLogix Expression

Snoppy

Member
Join Date
May 2019
Location
Anderson SC
Posts
2
Hello, I am a new member to this site but have been able to find the answer to many questions here in the past.
I was hoping someone could help me understand how the expression "B9[(N12_0 AND -16)/16].[N12_0 AND 15]” works (this is a tag for a BOOL XIC). I know what it does but don't understand how it does it.Basically the XIC is true when "N12_0" is equal to the position of a bit that is also true in the array "B9". B9 is configured as 9 DINTs and somehow bits 16-31 are excluded from each DINT. For example; If N12_0 = 68 then the XIC is true only when the 68th bit in the array ("B9[4].4") is true.
Thanks.
 
That is a double index into what was originally an array of INTs. This looks like code converted from a PLC5 or something like that.

N12_0 contains a specific bit number from a continuous range of bits, lets say 128 of them. You need to reference the correct bit in the array of DINTs that is equivalent to bit 68.

(N12_0 AND -16)/16 defines which word of the DINT array the bit is in. The "AND -16" part mask off the lower four bits of the value in N12_0. The bit pattern for 68 is:
0000 0000 0000 0000 0000 0000 0100 0100.
The bit pattern for -16 is:
1111 1111 1111 1111 1111 1111 1111 0000.
A word level bitwise AND of those two values results in a bit pattern of:
0000 0000 0000 0000 0000 0000 0100 0000, or 64.
Divide that by 16 and you get 4.

The N12_0 AND 15 determines the bit location in the selected word. We know the bit pattern for 68. The bit pattern for 15 is:
0000 0000 0000 0000 0000 0000 0000 1111.
AND that to get 0000 0000 0000 0000 0000 0000 0000 0100, or 4.

So, B[(N12_0 AND -16)/16].[N12_0 AND 15] simplifies to B[4].[4].

Keith
 
Hello, I am a new member to this site but have been able to find the answer to many questions here in the past.
I was hoping someone could help me understand how the expression "B9[(N12_0 AND -16)/16].[N12_0 AND 15]” works (this is a tag for a BOOL XIC). I know what it does but don't understand how it does it.Basically the XIC is true when "N12_0" is equal to the position of a bit that is also true in the array "B9". B9 is configured as 9 DINTs and somehow bits 16-31 are excluded from each DINT. For example; If N12_0 = 68 then the XIC is true only when the 68th bit in the array ("B9[4].4") is true.
Thanks.

To help figure this out, use the windows calculator in programmer mode with Dword selected.

First solve the N12_0 AND -16. Assume N12_0 = 68
68 dec = 0000 0000 0000 0000 0000 0000 0100 0100
-16dec = 1111 1111 1111 1111 1111 1111 1111 0000
ANDing them together you see that only the 6th place is equal. So the
AND = 0100 0000 or 64 decimal.
So now 64/16 = 4

Now the second part is N12_0 AND 15.
68 decimal = 0100 0100 binary (no need to show the other leading zeros)
15 decimal = 0000 1111 binary
AND = 0000 0100 binary = 4 decimal

So the end result is indirect addressing of address:
B9[4].[4]

As to why someone wrote it that way? You'd have to know more about the N12_0 and more about what they are attemting to accomplish.
 
kamenges and g.mccormick,

Thank you very much. I corresponded with Rockwell for more than a week and they were no help. You guys cleared it up for me in less than an hour. Thanks Again.
 
Kamenges just beat me to it. I believe that I stated incorrectly calling it indirect addressing.
 
Thats some arcane stuff alright.
Looks like someone has a byte.bit address encoded as the nibbles in a byte :)

edit: In SLC it would have been a linear bit address in the bit file with indexing across words.

b9/[n12:0]
 
Last edited:

Similar Topics

Why does the controllogix redundancy modules use a single mode fiber vs multimode fiber?
Replies
1
Views
61
Hello, I have two 16 point input cards and 1 16 point output card showing module faulted on my IO tree in Logix Designer. The fault code is...
Replies
7
Views
207
Hello, My associate and I are trying to sync up two ControlLogix racks (7-slot chassis) with identical modules. We are able to see the secondary...
Replies
4
Views
185
Trying to setup a message read via Ethernet. I have the path setup as 1, 1, 2, 192.168.66.10 I get an error code 1, ext err 315. I am beating...
Replies
9
Views
226
I have a redundant ControlLogix being set up. This program reads a value from a remote site which happens to be SLC PLC. Rockwell mentions SLC...
Replies
2
Views
91
Back
Top Bottom