Sign in to follow this  
Followers 0
flylikechris

Index Registers in Function Blocks

6 posts in this topic

Hi guys, I have run into a problem where I am trying to use a device offset in a repeat call function block. My understanding is that I only have a certain amount of these Z/V registers (16 total). Do you guys know of another way I can call a device, with a variable offset? example, load a value of "1002" into Z0, and then call D0Z0, but really be looking at D1002. I am passing a function block a configurable I/O start location (constant). I then load this start I/O location into Z0, and call D0Z0 in my function block. Any help is greatly appreciated. Thanks!!

Share this post


Link to post
Share on other sites
Not really, that's the way to do it. You need more than 16?

Share this post


Link to post
Share on other sites
Thanks for the reply. The more I think about it, the more I realize that this will work just as I need it. I guess I will just have to be careful about how I manage these registers among different block types.

Share this post


Link to post
Share on other sites
If you are using IEC Developer or GX Works (structured). You can also use an Array. For instance Arrayname[0] or ArrayName[index] where index is a word device Edited by Gambit

Share this post


Link to post
Share on other sites
When using index registers in a block it is good practice to save/restore the value to a local variable or use push/pop, and if the index value should be retained restore and save it to a global variable. You may also check the U/G addressing mode for module reference in a block. Edited by jorgensen

Share this post


Link to post
Share on other sites
I know this is an old thread, but I wanted to say thanks to jorgensen for his input. Right now I am opening a block call, and immediately writing the index register value to a temporary location. Then before exiting the block, I write the initial value back to the index register. This lets me use the index registers freely throughout the block. Thanks!!

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