Old PLC5 Indirect Address

asterof

Member
Join Date
May 2007
Location
Califonia
Posts
554
In an old PLC5 I see an output like this
B37
-()-
[N19:21]

If I remember correctly that says to set the bit of word
37 thats equal to the value of N19:21
So if N19:21 = 26 then bit 26 of the word 37 would go true

So how would I convert that to a CLX instruction
Thanks
 
In the PLC5, the "B37" file is similar to an array of bits for the controllogix plc.

The difference is the way the "B37" file can be addressed. You can reference the word/bit or simply the bit element in the PLC5.

So, B37:3/0 is the same as B37/48.

The reason I say that is you would need to see how many "elements" or total bits are in the B37 file of the PLC5. Then create a bit array in controllogix of the same size. You could even name the array B37 to make it easy for conversion.

Then you need to create an integer file for the indirect address "pointer" value. The integer "pointer" cannot be an array.

To address similar in the controllogix it would be B37[pointer].
 
The PLC5 does not have Arrays
So what it has is B37:79 which creates 80 words
and I need to keep B37 as an array in CLX
B37[80]

So I need to figure out how to set x bit in B37 word
based on the value in N19[21]


In the PLC5, the "B37" file is similar to an array of bits for the controllogix plc.

The difference is the way the "B37" file can be addressed. You can reference the word/bit or simply the bit element in the PLC5.

So, B37:3/0 is the same as B37/48.

The reason I say that is you would need to see how many "elements" or total bits are in the B37 file of the PLC5. Then create a bit array in controllogix of the same size. You could even name the array B37 to make it easy for conversion.

Then you need to create an integer file for the indirect address "pointer" value. The integer "pointer" cannot be an array.

To address similar in the controllogix it would be B37[pointer].
 
In the PLC5, the "B37" file is similar to an array of bits for the controllogix plc.

The difference is the way the "B37" file can be addressed. You can reference the word/bit or simply the bit element in the PLC5.

So, B37:3/0 is the same as B37/48.

The reason I say that is you would need to see how many "elements" or total bits are in the B37 file of the PLC5. Then create a bit array in controllogix of the same size. You could even name the array B37 to make it easy for conversion.

Then you need to create an integer file for the indirect address "pointer" value. The integer "pointer" cannot be an array.

To address similar in the controllogix it would be B37[pointer].

actually two pointers are required. One for the word element and one for the bit element. MOD math is required for this

bit 15 is Word 0 bit 15
bit 16 is Word 1 bit 0

ScreenHunter_01 Nov. 20 13.11.jpg
 
actually two pointers are required. One for the word element and one for the bit element. MOD math is required for this

bit 15 is Word 0 bit 15
bit 16 is Word 1 bit 0

I dont follow you here
if I have 213 in N19[21] MOD 16 I get word 5
but how do I determine the bit

So B37[213] would be word 13 bit five ?
 
Originally posted by curlyandshemp:

word = 213 MOD 16 = 13

That would be incorrect. The MOD operator returns the remainder of the division. So 213 MOD 16 is 5 as asterofstated. What you want to do is:

Bit = 213 MOD 16
Word = (213-Bit) / 16

However, this assumes you created an array of INTs and want to reference to the bit level.

But you really don't need to do this either. If memory isn't an issue just create an array of BOOLS and make the reference directly. Each BOOL will be a DINT so it will take up memory. But the access is direct and the BOOL location will work correctly in logical instructions. And it will be faster.

Keith
 
It is a direct PLC5 to CLX conversion
the B37's are used as ints in other places
here is what I did
Maybe I will make an AOI for this

the My_Bits is to check to see if the correct bit was set
just for test

pointer.jpg
 
That would be incorrect. The MOD operator returns the remainder of the division. So 213 MOD 16 is 5 as asterofstated. What you want to do is:

Bit = 213 MOD 16
Word = (213-Bit) / 16

However, this assumes you created an array of INTs and want to reference to the bit level.

But you really don't need to do this either. If memory isn't an issue just create an array of BOOLS and make the reference directly. Each BOOL will be a DINT so it will take up memory. But the access is direct and the BOOL location will work correctly in logical instructions. And it will be faster.

Keith

My Bad

ScreenHunter_09 Nov. 20 14.53.jpg
 
So I tried the 203 in the PLC5 code
Oddly enought it set two bits
B37:12.11 and B37:13.5
So I am really confused
I am wrong I did not turn off the previous bit

The original PLC5 code would do the same thing. I bet there was a copy of a blank array into B37:XX before the indexed bit was set.
 
We're looking at two different issues.

You are correct that you didn't turn off the previous bit before you changed the indirect reference. If you are going to do something like this you need to make sure you babysit the reference so the state is what you expect before the reference is changed.

What I was refering to was the rung snippet you posted with the indirect address word and bit calculator. The way you are determining the values you are at the mercy of the PLC rounding rules. I suspect if you had used 203 as the pointer in the CLX the word value would have come out as 13, even though you wanted it to come out as 12. That is why I did it the way I did in my previous post. I figured out the bit reference first and then subtracted the bit value from the total pointer before dividing to get the word value. It ensures that the value you divide by 16 is an even multiple of 16.

Keith
 

Similar Topics

I'm bidding on a project to upgrade a machine that is using a PLC5/30 and a PC based user interface that is running on Windows 3.1. The...
Replies
35
Views
9,747
Hello ppl! First sorry about my english and thank you for your attention. I'm kinda lost. A friend lent me a couple of racks with plc5/15 and...
Replies
11
Views
2,465
I have a vibration transmitters, its scale is 0-1 inches/second for 4-20mA, it's Hi Hi SD is 0.6"/s. In the plc5 1771-IFE, it use BTR to read all...
Replies
7
Views
2,752
Hey guys, I've got an easy one for ya, but you might have to wipe the dust off to answer it. I've got an old PLC5 that is running right now...
Replies
3
Views
3,189
S
I have a plc5/40 processor that when cold booted will not scan its remote I/O. If I take the processor from REMRUN to Program and back to Run...
Replies
1
Views
3,185
Back
Top Bottom