Sign in to follow this  
Followers 0
Chris Elston

Where's the INT to BINARY function?

4 posts in this topic

Hmm...I just noticed that there doesn't seem to be a nice way to take an Integer Value in a WORD and convert that to a Binary Ouput or MASK move out. In other words, not a built in FUNCTION. Looks like I got take my %R value and move it into a %M which is byte aligned. Then it will directly drive some binary handshaking I need. Is this the best way to convert an %R to some outputs? Assume %R = 5 Next I need to Map over my %R word to a byte aligned %M like %M17 then %M17 turn on %Q1 directly. %M18 turn on %Q2 directly. %M19 turn on %Q3 directly. %M20 turn on %Q4 directly. Then make sure I don't use %M21 through %M32 when %M17 is binary 1 = %Q1 = output on when %M18 is binary 2 = %Q2 = output off when %M19 is binary 4 = %Q3 = output on when %M20 is binary 8 = %Q4 = output off Final Handshake in binary... Is that the best way in GE to do what I need?

Share this post


Link to post
Share on other sites
That's how I would do it. I would use T's as they are intended for "Temporary" use but it doesn't really matter. If you are worried about using up values, reuse the bits as long as you're careful of the scan order: Move %r into %m's(or %t's) Link %m's into %q's Move New %r into same %m's link %m's to new %q's Etc. As long as the %r is reloaded into the %m's before each output this is no problem.

Share this post


Link to post
Share on other sites
You could use the MOVE_BIT instruction. In your example, use a LEN of 4, put the %R address at the IN node and %Q001 at the Q node. The MOVE_BIT with a length parameter set at 4 will copy the first four bits from the %R register to the four consecutive %Qs starting at the address you specify.

Share this post


Link to post
Share on other sites
Nice suggestion.... How come you always come up with the good ideas? I guess we can keep you around for awhile. BTY...I LOVE PROFIBUS...far easier than Device Net...

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