Saxony Thermal

Variable device access in gxworks 3

10 posts in this topic

Hello,

After a lot of reading I was concluding I would have to do structured text. But then learning structured text I don't see how it solves my issue too. So I am lost:

I have incoming messages of variable length. I know what the lengths are because there is a receive counter called SM8561 for the FX5CU CPU over its built-in RS485 port. I have to do a CRC check on it and then interpret the message afterwards to do things. For my CRC, I Omit the ending DLE-ETX. But the device location of DLE-ETX changes with message length. So I can't just say, (the below is not valid syntax, just an expression of what I want to do)

  • if D4500 is start of message
  • and the end of message is always DLE-ETX-CRC-CRC, where the last CRC byte is always device location D(4500+SM8561) //SM8561 is message length
  • [MOV D(4500+ SM8561 - 0) D5000] and [MOV D(4500+ SM8561 - 1) D5000] to move the CRC bytes to another location like D5000 for me to process.

I also have to move select bytes from my message to another location and in a continuous run of devices to help with CRC check. These device locations change with message length.

I was looking at structured text but its the same issue, I can't assign a variable device number. So how do I process dynamic message lengths? This would be a cake-walk in C, I am just unfamiliar with PLC syntax to do this whether by iteration or logic array.

Share this post


Link to post
Share on other sites

You can access the elements of an array indirectly by using a device or label in the element number.  This can be done the same way in FBD and ST.

ArrayDemo.png

Share this post


Link to post
Share on other sites

Posted (edited)

Hello, I appreciate your reply but I do not see how that relates to my challenge. I know I can make arrays and index them to do calculations, but I cant put that into MOV function for a device location for example. Where I need to move a device location that changes with time to a constant device location or a moving one.

Like MOV D#a D#b, where MOV will put D#a into D#b where D#a is defined outside of the MOV function and can change, same with D#b.

Like a download command message can have varying message length like D#a = D4500 to D#b = D4516, or a longer one like D#a = D4500 to D#b = D4586. Between the two cases, the device location that is holding my CRC bytes is always at the end of the message which are different per message length and I can't have a MOV command to access them for every possibility.

I want to make an iterating search function that scans the message device by device, but there does not seem to be a way to process an iteration or loop that changes Device.

 

Does that make sense?

Edited by Saxony Thermal

Share this post


Link to post
Share on other sites

Change MyArray to be (0..499) and Assign it to D4500.

Then your subscripts into MyArray can programmatically access any word from D4500 to D4999.

Adjust to suit your needs.

Share this post


Link to post
Share on other sites

Hm, I still dont see how that can get into my ladder logic controls to increment my way through a range of devices.

But I found the solution. The Z device.

The below is working syntax for GXworks3:
MOV D4500Z0 D5000Z0
 

Where, Z is an index register and with the syntax above, it means D(4500 + Z0), and Z0 can be a number you modify with timer loops like ADD K1 Z0.

 

Here is where I found it. Read just the second reply from JRoss. Quote: " Pick a head address, say D100, and modify it with an index register, say Z0. Then you can call the indexed register like this: D100Z0. The index register acts as an offset, so if Z0 = 3, then you are actually pointing to D[100 + 3] or D103. "

 

Thanks,

 

Share this post


Link to post
Share on other sites

The constant used in the example can also be an variable.

Check the example of @pturmel  ...... MyArray[Index] 

This doesnt have to be structued text it can be used in all editors

 

 

1 person likes this

Share this post


Link to post
Share on other sites

This D5000Z0 style indexing syntax has worked great but now I have another hurdle:
If I wanted to index bit by bit, that syntax does not work anymore. For example I want to do the following:

D5000Z0.Z1 (invalid syntax)

or

D5000.Z1 (invalid syntax)

Notice the ( . ) which syntactically accesses that bit of the 16 bits. Below is all we can do:

D5000.0 (valid syntax)

Where .0 is the zeroth bit which can be .1 or other to index the specific bit of interest. But I can't put Z0 there for variable bit by bit access.

I need this so I can increment my way up devices as well as each of the 16 bits of the device in a loop.

 

Is there an appropriate syntax to do this? I also find it difficult to find where mitsubishi discusses this gxworks 3 specific syntax. I found it for ST but that doesnt help me in ladder specific syntax...

Share this post


Link to post
Share on other sites

I guess I can do this but it's not as explicit as I would like and I think causes me to loop more scan cycles? I will implement this and see.

Take D5000.0 as a relay. Then bit shift (SFTL). With each shift the D5000.0 is checked for 1 or 0. In PLC's the bitshift doesn't flow into the neighboring device (unfortunately I would like that to happen for technical reasons, if someone knows how to do that...) so after 8 bit shifts then the device is unchanged and each bit was checked. Then increment to the next device D5000Z0 where we add 1 to Z0 to summon D5001 = D5000Z0. If I wish to inspect 256 devices in a row, then I have to setup device swapings with indexed device numbers like SWAP D5000Z0 D5000Z1 or something logical I have to figure out right now in order to feed all those bytes down to D5000.0 for bit by bit inspection of a 256 device string.

I do know that BSFR bit shifts and replaces the vacancy with zeros instead of lopping the byte back around. That is nice. But I don't know how to just push it into the neighboring device.

 

Edited by Saxony Thermal

Share this post


Link to post
Share on other sites

the solution is to use the bit proicessing instructions  Like TEST - BSET etc

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