chrisb4748

Indirect Indexing

8 posts in this topic

Hi,

I am trying to indirectly index 1 D register, into 999 ZR registers.

i.e.

I have 999 dollies that are going through the factory. Each with an individual carrier ID.

I want to use 1 D register to pick up that carrier ID and enter it into the corresponding ZR Register.

If Carrier ID is 123 I want D990 to enter that into ZR60123 Or Carrier ID is 598 I want D990 and enter that into ZR60598.

How should I go about this?

Many Thanks

Share this post


Link to post
Share on other sites

Depends on your programming software.

In direct mitsubishi code this would be. 

MOV K123 Z0

MOV D.... ZR6000Z0  (ZR6000 + 123).
 

However it is also possible to write an address into a Registers and then use @ to indicate it is an indirect address.

If you use structured programming you should make an array for ZR6000 ......
 

Then it would be something like:

Mov K123 Mypointer

Mov MyValue MyArray[MyPointer]

 

 

 

Share this post


Link to post
Share on other sites

I am using GX Works2.

Is there another way of doing this? The way you have described "K...." will be changing so I couldn't use a constant.

My client has a new RFID system installed and is wanting to be able to select the different dollies through out the factory.

And in reference to the "Mypointer" could you explain further into that as I'm not 100% sure. 

 

Share this post


Link to post
Share on other sites

I personally find structured text is much easier (and clearer) to use when dealing with arrays/indexes

With “Dollies” declared as a zero based array of 1000 int’s starting at ZR60000  [0..999]

and “CarrierID” declared as an Int

and D990 has a value 888

 

When “CarrierID” has a value of 0 then the statement...

Dollies[CarrierID] := D990

would put the value of 888 into ZR60000

 

When “CarrierID” has a value of 123 then the statement...

Dollies[CarrierID] := D990

would put the value of 888 into ZR60123

 

When “CarrierID” has a value of  990 then the statement...

Dollies[CarrierID] := D990

would put the value of 888 into ZR60990

Share this post


Link to post
Share on other sites
19 minutes ago, chrisb4748 said:

I am using GX Works2.

Is there another way of doing this? The way you have described "K...." will be changing so I couldn't use a constant.

My client has a new RFID system installed and is wanting to be able to select the different dollies through out the factory.

And in reference to the "Mypointer" could you explain further into that as I'm not 100% sure. 

 

K was just an example to make it clear this could alos be a word

The My pointer is the same as the 123 in the previous example. It's just the word containing the needed offset

Share this post


Link to post
Share on other sites
3 minutes ago, Nightfly said:

I personally find structured text is much easier (and clearer) to use when dealing with arrays/indexes

 

With “Dollies” declared as a zero based array of 1000 int’s starting at ZR60000  [0..999]

 

and “CarrierID” declared as an Int

 

and D990 has a value 888

 

 

 

When “CarrierID” has a value of 0 then the statement...

 

Dollies[CarrierID] := D990

 

would put the value of 888 into ZR60000

 

 

 

When “CarrierID” has a value of 123 then the statement...

 

Dollies[CarrierID] := D990

 

would put the value of 888 into ZR60123

 

 

 

When “CarrierID” has a value of  990 then the statement...

 

Dollies[CarrierID] := D990

 

would put the value of 888 into ZR60990

 

I have never written in structured text, but appears to be the easiest way to go about this.

Could you give me some advice on doing this?

Thanks  

Share this post


Link to post
Share on other sites

Structured is indeed very flexible but maybe my explanation was not so good so here is an actual example.

index.JPG

MyDataword is the value you want to move
Carrier ID is only the offset (123) 
MyArray starts at ZR60000

 

But like @chrisb4748 already mentioned Structured text is also a good way of doing this.

Edited by Gambit

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