vasekd

Indirect addressing in FB CJ2

9 posts in this topic

Hi all,

how can I use indirect addressing in FB for CPU CJ2. For instance in this simple example (without using D500)

 

addressing.jpg

Share this post


Link to post
Share on other sites

Since it is tag based, you'll have to use an Array instead. Edit the variable then click on Advanced.

Share this post


Link to post
Share on other sites

My understanding is that if the address is prefixed with @, the actual address referenced is based on the value in that register.

So your second move command isn't writing to D500, it's looking at D500 and writing to the address indicated inside.

So based on your example code, The value 123 is written to D1500.

Share this post


Link to post
Share on other sites

Yes, I know it. But I need make it in FB ( It is onpy example. It will be more comlex function with start address as parameter - I will set start address on input FB and fuction use address space from it.)

Share this post


Link to post
Share on other sites
On 11/13/2017 at 8:26 AM, IO_Rack said:

Since it is tag based, you'll have to use an Array instead. Edit the variable then click on Advanced.

I second this comment.  Use an array inside the FB with a variable as the index.  

5a0c762113093_FBArray2.jpg.500f6cee55f77

5a0c75e05f6c4_FBArray.thumb.jpg.89c76cde

Share this post


Link to post
Share on other sites

Thank you very much.

Now it's quite understandable for me .  I'll try it tomorrow.

Share this post


Link to post
Share on other sites

For FB typically we use the IR and DR register for indirect addressing. Although compared to the Decimal-based reference above (The @ tag) it's more complicated to use. But pretty reliable I'd say

Share this post


Link to post
Share on other sites
20 hours ago, innoaloe said:

For FB typically we use the IR and DR register for indirect addressing. Although compared to the Decimal-based reference above (The @ tag) it's more complicated to use. But pretty reliable I'd say

Yes, I tried to provide the simplest (although perhaps less capable) solution.  If he does not need to access memory by address specifically (as many Omron FBs require to access memory for specific modules or functions), then this is much simpler.  

Share this post


Link to post
Share on other sites

Thank you for the explanation. It made me learn to use IR, DR. I think it will be a good solution for my program.

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