Sign in to follow this  
Followers 0
wendaiyu

RSlogix 5000, odd or even?

3 posts in this topic

Hi, guys, how’s going?

 

In RSlogix 5000, if the integer in tag “number” (DINT) is odd, then the output “ODD.1” is ON. How can we program it?

 

Thanks a lot.

Share this post


Link to post
Share on other sites

any way you like... but you did not explain what you want to program...

do you want to CHECK if some integer variable is odd?

or do you want to MAKE some variable odd?

also bit ".1" is not the LSB, that is the second bit and it's weight is 2...

you want to check LSB which is first bit (Variable.0 instead of Variable.1)

so normally check would be

XIC VARIABLE.0 OTE IT_IS_ODD

or

XIO VARIABLE.0 OTE IT_IS_EVEN

or you can use mask etc.

to make it even you could reset the LSB somehow... either by using OTU Variable.0 or by masking:

AND Variable -2 Variable

to make some variable odd, you would set LSB somehow... either by using OTL Variable.0 or by masking:

OR Variable 1 Variable

check binary representation of values 1 and -2

 

 

Share this post


Link to post
Share on other sites
18 hours ago, panic mode said:

any way you like... but you did not explain what you want to program...

do you want to CHECK if some integer variable is odd?

or do you want to MAKE some variable odd?

also bit ".1" is not the LSB, that is the second bit and it's weight is 2...

you want to check LSB which is first bit (Variable.0 instead of Variable.1)

so normally check would be

XIC VARIABLE.0 OTE IT_IS_ODD

or

XIO VARIABLE.0 OTE IT_IS_EVEN

or you can use mask etc.

to make it even you could reset the LSB somehow... either by using OTU Variable.0 or by masking:

AND Variable -2 Variable

to make some variable odd, you would set LSB somehow... either by using OTL Variable.0 or by masking:

OR Variable 1 Variable

check binary representation of values 1 and -2

 

 

Amazing! Thanks a lot.

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
Sign in to follow this  
Followers 0