Sign in to follow this  
Followers 0
jcole1

Allen Bradley Addressing

7 posts in this topic

I am a beginner. I am looking for some help on indirect and indexed addressing on some of the Allen Bradley SLC 500 processors. Maybe some examples? Thanks.

Share this post


Link to post
Share on other sites
You can download an example of indirect addressing here: http://forums.mrplc.com/index.php?act=Downl...&CODE=02&id=339

Share this post


Link to post
Share on other sites
Assuming you know what indexed and indirect addressing are then ... indexed addressing uses S:24 and the index. To index an address by word (not files) the use w.g #N7:3. N7:3 addresses the value at N7:3. #N7:3 addresses the value at N7: (S:24 + 3) where 3 is a constant Indexing files is not possible. Use example Mov N7:0 S:24 to set the index register. indirect addressing can index files and words and bits. Use N7:6/[N7:5] to access word 6 and the bit pointed to by N7:5 Use N7:[N7:4]/3 to access bit 3 of the word pointed to by N7:4 Use N[N7:2]:1/3 to access the bit 3 of word 1 pointed to by N7:2 Any combination of the above is possible, e.g. N[N7:2]:[N7:4]/[N7:5] (usually) Using indexing is also possible e.g. #N7:6/[N7:5] gives the bit in file N7 at word (S:24+6) and the bit pointed to by N7:5 The file type pointed to (e.g. N7:2 above) must be of the same type. Thats about all there is to it except they are slow and avoid indirect addressing if possible. Edited by Spedley

Share this post


Link to post
Share on other sites
Thanks for the reply. Can you explain what you mean by "index" and how it relates to S:24. Also why do you not recommend indirect addressing? One more question. I was told everytime you see the pound sign (#) in an address it meant it was an indexed address. I also read it meant it was a file indicator for the address. Which is it? Can you clear this up for me?

Share this post


Link to post
Share on other sites
Greetings jcole1, that is also correct ... in the sense that a “file” is a “list” of addresses which starts at a certain location (the “base” address) and then continues on for some distance (as specified by the “Length” entry) ... hopefully that will answer all of the questions you asked ... if not, please post again and I’ll take another shot at it ... finally, I tell my beginner students to interpret the pound sign (#) in an Allen-Bradley address as “start here” ... obviously there is more to it than that, but this little trick is usually enough to help someone who’s just beginning to study PLCs ... applied to the example used in this post, the ideas run something like this: let’s COPy a series of memory locations ... our Source will be “start here” at S:37 ... our Destination will be “start here” at N7:0 ... and we’ll do this for six steps as specified by the “Length” entry ... I hope this helps ... and welcome to the forum ... best regards, Ron

Share this post


Link to post
Share on other sites
Ron gave an excellent explanation on the index register S:24 but keep in mind that it can also be used as a powerful replacement tool for indirect addressing. Back in the old days of SLC 5/01 and 5/02 and some of the older OS, there were no indirect addressing so instead we use the index register S:24. For example, if you want to move an integer value in file N7:0 pointed to by pointer N10:0 into a destination address N10:1, you would program something like this for indirect addressing: MOV N7:[N10:0] N10:1 if N10:0 is 0 then N7:0 is moved to N10:1 if N10:0 is 5 then N7:5 is moved to N10:1 etc.... Now if you want to do the same thing with the index address S:24, you would program: MOV N10:0 S:24 MOV #N7:0 N10:1 If N10:0 is 0 then S:24 is 0 and #N7:0 is N7:0 and moved to N10:1 If N10:0 is 5 then S:24 is 5 and #N7:0 is N7:5 and moved to N10:1 etc... The only thing to keep in mind about S:24 is that you have to keep track of it's value because it's changed/reset every time you hit an instruction with the #. For example, if you ran into the COP instruction shown in Ron's example, the S:24 would reset to 0 afterward. You won't have any problem using the index example above but if you put conditions in front of the 1st MOV instruction, S:24 will become unpredictable.

Share this post


Link to post
Share on other sites
Just an abstract point that I think should be mentioned. Indexed addressing is just a way of accessing arrays (tables, lists ... whatever you want to call them). Going back to basics, Imagine we set the data in N7 to this: N7:0=10 N7:1=11 N7:2=12 N7:3=13 N7:4=14 then we could use this as our table and access it using N7:0, N7:1 etc. The problem here is if we want to add one to all the 'elements' in the list then we would need a seperate instruction for each and if our list is 100 long then that is impractical. What we do is use S:24 as a pointer. This value of this pointer can be changed so that the same bit of code accesses different 'elements'. We do this by #N7:0 So if we MOV 2 into S:24 and use the address #N7:0 it gets the number 12 (from N7:[0+S:24] ) This also means we can change the 'base' or start of the list to anywhere in the file. E.g. #N7:6 get the value at N7:(6+S:24) so the start of our list starts at element 6 and element 0 is N7:6, element 1 is N7:7 etc.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0