saruans

integer number convert to bit

7 posts in this topic

Hello,

I am confused  because need convert 8 bit integer number to bit e.g. If have number in the memory M12, 125 for me need active Output Y0=1, Y1=1, Y2=1, Y3=1, Y4=1, Y5=0, Y6=1, Y7=0. Somebody could give to me advice how need to do it? I am using GX Works2 and fx3g PLC

Share this post


Link to post
Share on other sites

M12 is a Bit Device SO I think you mean D12.

MOV D12 K2Y0 will do this

K1 is 4 bits
K2 is 8 bits
K3 is 12 bits
etc.

But you have the bits vice versa 
125 = 0111  1101 = Y7.Y6.Y5.Y4   Y3.Y2.Y1.Y0


 

 

 

 

Edited by Gambit
1 person likes this

Share this post


Link to post
Share on other sites
2 hours ago, Gambit said:

M12 is a Bit Device SO I think you mean D12.

MOV D12 K2Y0 will do this

K1 is 4 bits
K2 is 8 bits
K3 is 12 bits
etc.

But you have the bits vice versa 
125 = 0111  1101 = Y7.Y6.Y5.Y4   Y3.Y2.Y1.Y0


thank for help, I will try your advice

 

 

 

 

1 person likes this

Share this post


Link to post
Share on other sites

 

Hello Gentlemen.

 

I just read this and it seems a nice way to do it Gambit, however, I've used GX developer for years and often find using an open contact (F5) and something like  D12.0   D12.1    D12.2    d12.3  etc is an easy way to get the binary information out of a data register, but........ I just tried it to confirm the smallest and largest bits in Works2 and it didn't work!  Seems fine in Works3 and GX developer though.  Hopefully I've attached a working picture with a value of 207 in D1 chopped up as binary in the next rung.

Hope that helps

Neil

207 iin D1 shown in Binary.odt

207 iin D1 shown in Binary.odt

207 iin D1 shown in Binary.doc

Share this post


Link to post
Share on other sites

 

Hello Kaare

I've just typed it in to see what the error message was and it worked first time!   I suspect that hands were faster than brain again, it won't be the first time.

Thanks for checking though.

 

 

Share this post


Link to post
Share on other sites
Just now, Workshop Warrior said:

I suspect that hands were faster than brain again, it won't be the first time.

I know the feeling... :-)

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