Jim82

GX Works2, Registry compare function

16 posts in this topic

Hi!

I wanna make a EQ compare with a range of dataregistry and depending on the value in all of them it will affect an output.
Instead of making an compare block for every specific data i wonder if there is a function that can do it?

For example:

D20, D21, D22 -> D30, if any of those in range has an 1 in it, output Y0 is ON

Hope you guys understand my bad english and poor explanation!

Br,

Jim

Share this post


Link to post
Share on other sites

Welcome,

You can use the ZCP instruction, this is a zone compare that compares a range with a value and sets bits for >, < or equal to.

The instruction manual explains it a bit further.

Steve

 

Share this post


Link to post
Share on other sites

Zone compare is only looking at once set of source data, sounds like he wants multiple compares.  

You didn't say which PLC, so not easy to make recommendations.  I know Q Series and L Series have block compare commands.

Share this post


Link to post
Share on other sites

Thanks for you replies guys!

I have a Mitsubishi FX3GE plc.
Zone compare might work, never used it but i will look that up.
I cant look at the manual for the block cause my HELP command (F1) wont work, when i press F1 i get the following error:


 

Skärmklipp.JPG

Edited by Jim82

Share this post


Link to post
Share on other sites

An example would be   [ZCP D10  D20  K1  M10]  This would compare D10 through to D20  to the value 1 (K1) and would turn on M10 if the result is less than, M11 if its equal to, or M12 if its greater than.

(The ZCP is a pulsed instruction so the rung needs to go false then true again to activate it again.)

Steve

Edited by nehpets

Share this post


Link to post
Share on other sites

I tried your ZCP like this, and it triggerd the M12 when the 1 value was in D5, but as soon as it moved to D6 (its a shiftregistry) M12 turned off...

Edit: Seems like it just compares s1 and s2 with s3... not the whole range from D5 -D19

Skärmklipp.JPG

Edited by Jim82

Share this post


Link to post
Share on other sites

Sorry that doesn't seem to work, you could try something like this attached.

The FX3GE has a cut down instruction set.

The k10 in the FOR instruction is the number of data stores you are comparing and the D6300 is the start of your data stores (ignore the comments they are a reminant of an old program).

Steve

 

12-01-2016 18-57-22.bmp

Edited by nehpets

Share this post


Link to post
Share on other sites

Go back to your GX Works2 install media and install the FX help file to fix your problems with the help.

Share this post


Link to post
Share on other sites

Maybe not quite as elegant as it might be, but why not just add up the values in the range D20 to D30, put the answer into (say) D31 and do a single compare
of the answer.

IF D31 equals 0 THEN ......

If true, then there are no 1s in any of the words from D20 to D30.

Share this post


Link to post
Share on other sites
On 2016-01-13 at 6:20 AM, Crossbow said:

Go back to your GX Works2 install media and install the FX help file to fix your problems with the help.

I downloaded the GX Works2 from Beijer website... so i dont have tha media unfortunatly. Cant seem to find the help installation file anywhere..

Share this post


Link to post
Share on other sites
19 hours ago, Colin Carpenter said:

Maybe not quite as elegant as it might be, but why not just add up the values in the range D20 to D30, put the answer into (say) D31 and do a single compare
of the answer.

IF D31 equals 0 THEN ......

If true, then there are no 1s in any of the words from D20 to D30.

That was my first plan to do.. but im going to use a range from D0 to D300 so its going to be quite alot of adding... ;)
Thats why i asked you guys if there is a function that dont need to specify each data...

Share this post


Link to post
Share on other sites
On 2016-01-12 at 8:20 PM, nehpets said:

Sorry that doesn't seem to work, you could try something like this attached.

The FX3GE has a cut down instruction set.

The k10 in the FOR instruction is the number of data stores you are comparing and the D6300 is the start of your data stores (ignore the comments they are a reminant of an old program).

Steve

 

12-01-2016 18-57-22.bmp

Sorry Steve, i dont get that FOR instruction, i have a FOR function but that is:

"FOR/NEXT    Loop instruction

The FOR/NEXT loop repeats single program sequences without setting an input condition. The program sequence located between the FOR and the NEXT command is repeated for n times.

After executing the FOR/NEXT loop for n times, the next program step following the NEXT command is executed.

The variable n can be specified from 1 to 32767. If n is less than or equal to 0, it is processed as 1. Thus, the FOR/NEXT loop will be executed at least once.

If a program sequence between the FOR/NEXT loop is not intended to be executed, it can be skipped by a jump instruction (CJ or SCJ).

In total, up to 16 levels (A series = 5 levels) of FOR/NEXT loops can be nested up."

Skärmklipp.JPG

Share this post


Link to post
Share on other sites

To condition the FOR-NEXT loop enclose in a MC-MCR block.

It's not easy trying to second guess what you are actually trying to achieve.

The V0 is an index register that indexes your data registers with the for next loop iterations compareing each data register + index with 1, turning the output on if a 1 is found in any of the data registers.

 

Steve

 

14-01-2016 20-53-43.bmp

Share this post


Link to post
Share on other sites
15 hours ago, Jim82 said:

That was my first plan to do.. but im going to use a range from D0 to D300 so its going to be quite alot of adding... ;)
Thats why i asked you guys if there is a function that dont need to specify each data...

It's not as bad as you think.

If you drag in one of the "ADD "function blocks onto the page then click on it, you should find that your cursor turns into a double headed arrow that enables you to drag the bottom of the block  downwards and add extra inputs. This enables single function blocks that would add up (say) 10  D registers to give the result.

If I was doing it, I'd make one of these that added 10 variables together (say D00 to D09 and enter them as D00, D01 etc) then copy that block and use "find and replace" to change "D0" to "D1" which would then give you a block that added D10 to D19. Do this eight more times and you should have the sum of D00 to D99. Then copy all ten blocks you have created and use "find and replace to change "D" to "D1" and you should then have the next one hundred blocks. Repeat ( find and replace "D1" with "D2") to get the next one hundred etc.

Would imagine it might take about half an hour to programme ... it's only 30 function blocks and you could put them all in the same "rung" and have all 30 results feeding into an ADD block with 30 inputs which would then give the single answer.

Would look quite elegant .... a bit like the wiring diagram of a CPU :)

1 person likes this

Share this post


Link to post
Share on other sites
10 hours ago, Colin Carpenter said:

It's not as bad as you think.

If you drag in one of the "ADD "function blocks onto the page then click on it, you should find that your cursor turns into a double headed arrow that enables you to drag the bottom of the block  downwards and add extra inputs. This enables single function blocks that would add up (say) 10  D registers to give the result.

If I was doing it, I'd make one of these that added 10 variables together (say D00 to D09 and enter them as D00, D01 etc) then copy that block and use "find and replace" to change "D0" to "D1" which would then give you a block that added D10 to D19. Do this eight more times and you should have the sum of D00 to D99. Then copy all ten blocks you have created and use "find and replace to change "D" to "D1" and you should then have the next one hundred blocks. Repeat ( find and replace "D1" with "D2") to get the next one hundred etc.

Would imagine it might take about half an hour to programme ... it's only 30 function blocks and you could put them all in the same "rung" and have all 30 results feeding into an ADD block with 30 inputs which would then give the single answer.

Would look quite elegant .... a bit like the wiring diagram of a CPU :)

Ahh! Thanks, "Find and Replace" worked like a charm! :)
But i used the MAXIMUM block and a GT instead of ADD.

Perfect!

Br,
Jim

Skärmklipp.JPG

Edited by Jim82

Share this post


Link to post
Share on other sites

Glad it was of use.

Have never come across the MAXIMUM comand before, but would assume that it takes the maximum value that it finds in all those registers shown and puts that value into the GT block. If that maximum value is greater than zero, then you know that at least one of the registers is non zero.

Sweet way to do it. Well done.

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