StarWing

Fx3U range compare

6 posts in this topic

I have a range of markers, for example M500-520 which I use for fault diagnosis. Is there an instruction which I can use to set a device (Y, M, S, ...) if one of the markers in this range activates ?

I looked at the programming manual and tried a couple of things with compare and word devices, but I cant' figure it out. Alternatively I can put them all parallel and set a device, but there must be an easiers way I think.

Share this post


Link to post
Share on other sites

Why don’t you just check the value of k5m500 of if it other than 0. Set a bit.

 

Share this post


Link to post
Share on other sites

Or, if you have a large range (or a range that does not fit into 16 bits), just do a FOR-NEXT loop over the range...

Share this post


Link to post
Share on other sites
48 minutes ago, kaare_t said:

Or, if you have a large range (or a range that does not fit into 16 bits), just do a FOR-NEXT loop over the range...

As @kaare_t said you can use for loop to check which M between M500 to M520 are on.As in example below if there are some bits on will set M522 to On you can modify number of M to check by adjust D0 value

FX_Loop_Check.jpg

Edited by Wasan

Share this post


Link to post
Share on other sites

Thanks for the replies guys,

I managed to acomplish this by the FNC224 LD Data comparison function.

In short words, compare K5M500 greater or equal with K1 and write to Mxxx

Share this post


Link to post
Share on other sites

I usually use not equal to 0. You might be all right because you're using 5 nibbles, but if you use 4 (INT) or 8 (DINT), then the most significant bit acts like a sign bit, which means if it's on the value of the grouped bits will be negative.

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