Sign in to follow this  
Followers 0
hipoint2

Control Logix Coversion

7 posts in this topic

Anyone know how to take a DINT and convert it to a binary value? I am trying to take a Dint and convert it to binary and then put it into excel so I can see each bit that is on.

Share this post


Link to post
Share on other sites
You don't really convert it to binary, you just change the way you view the data. There are two easy ways to do it. 1. Do the binary conversion in Excel 2. If your tags is MyDint then pull each bit into Excel. MyDint.0 through MyDint.31

Share this post


Link to post
Share on other sites
For number 2 I thought I could do that, but when I goto RSLinx and find the address to copy and paste the link it does not go down to bit level. I only get the whole word. Whats up with that?

Share this post


Link to post
Share on other sites
Your right. You can't do number 2. I was thinking about something else. I have an Excel sheet doing this. Give me a few hours to find it. Very busy right now. If you I don't get back to you in time here is the basic idea going completely off of memory. (MyDint &1)/1 = Bit 0 (MyDint &2)/2 = Bit 1 (MyDint &4)/4 = Bit 2 (MyDint &8)/8 = Bit 3 (MyDint &16)/16 = Bit 4 (MyDint &32)/32 = Bit 5 ......... (MyDint &2147483648)/2147483648 = Bit 31

Share this post


Link to post
Share on other sites
Ok in Excel you have to put the above code in a macro. I knew there was a catch but couldn't remember where. Excel does not have a bitwise AND but VB does. The other option is to take the 32 bits of your DINT to 32 BOOLs in RsLogix 5000

Share this post


Link to post
Share on other sites
Try this for a binary display in Excel... In cell A1, put the DINT from ControlLogix. In cell A3, put =DEC2HEX(A1,8). In cell A5, put =HEX2BIN(MID($A$3,1,2),8). In cell A6, put =HEX2BIN(MID($A$3,3,2),8). In cell A7, put =HEX2BIN(MID($A$3,5,2),8). In cell A8, put =HEX2BIN(MID($A$3,7,2),8). This will give you 4 groups of 8 bits each. You can't just DEC2BIN the DINT because Excel gives up after 10 digits of binary. Good luck, Mike Ellis

Share this post


Link to post
Share on other sites
You can also use the VB Editor from with in Excel and DIM tagname as Boolean There are several examples in the downloads section on who to use VB

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