flylikechris Posted October 18, 2013 Report Posted October 18, 2013 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!!
JRoss Posted October 20, 2013 Report Posted October 20, 2013 Not really, that's the way to do it. You need more than 16?
flylikechris Posted October 20, 2013 Author Report Posted October 20, 2013 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.
Gambit Posted October 21, 2013 Report Posted October 21, 2013 (edited) 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 October 21, 2013 by Gambit
jorgensen Posted October 21, 2013 Report Posted October 21, 2013 (edited) 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 October 21, 2013 by jorgensen
flylikechris Posted February 4, 2014 Author Report Posted February 4, 2014 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!!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now