JJH
Member
Hey all,
Here's a tricky decimal to binary conversion project I could use some help with:
In my RSLogix 5000 application, I have a "checklist", that a user needs to check off all the necessary boxes on an HMI application. Depending on the app, they might only need to use four checks, or as many as sixteen. This has previously been done by Boolean tags, but it requires a fair amount of maintenance, and especially so when not all 16 checks are required for a certain application.
I'm trying to simply that process by creating a DINT value for the checklist and each "check" represents a Boolean portion of that value. So, the DINT called CheckVal will be 15 when CheckVal.0, .1, .2 and .3 are selected.
What I need to do though is to compare the CheckVal number against the number of checks expected. So, if I say there are supposed to be four checks, as in the above example, when CheckVal is 15, then the user has checked all the boxes. If the number of needed checks is say 6, however, then the checks aren't complete until CheckVal is equal to 63. In this way, a programmer just has to enter in how many checks are needed for the application and the Complete bit will be set once that's done. Also, when clearing bits, a '0' can be moved into CheckVal.
So! How can I create some basic logic to set a binary number from a decimal entry to compare against the CheckVal number? If I enter in a four for the number of checks, it should convert to 15, which I can then compare against the CheckVal number to show it is completed.
Sort of a confusing way to explain it, but I'm sure it's an easy solution. Please respond with your thoughts. I have started a simple logic application I can send to anyone interested for an easier visual review.
Thanks~
Here's a tricky decimal to binary conversion project I could use some help with:
In my RSLogix 5000 application, I have a "checklist", that a user needs to check off all the necessary boxes on an HMI application. Depending on the app, they might only need to use four checks, or as many as sixteen. This has previously been done by Boolean tags, but it requires a fair amount of maintenance, and especially so when not all 16 checks are required for a certain application.
I'm trying to simply that process by creating a DINT value for the checklist and each "check" represents a Boolean portion of that value. So, the DINT called CheckVal will be 15 when CheckVal.0, .1, .2 and .3 are selected.
What I need to do though is to compare the CheckVal number against the number of checks expected. So, if I say there are supposed to be four checks, as in the above example, when CheckVal is 15, then the user has checked all the boxes. If the number of needed checks is say 6, however, then the checks aren't complete until CheckVal is equal to 63. In this way, a programmer just has to enter in how many checks are needed for the application and the Complete bit will be set once that's done. Also, when clearing bits, a '0' can be moved into CheckVal.
So! How can I create some basic logic to set a binary number from a decimal entry to compare against the CheckVal number? If I enter in a four for the number of checks, it should convert to 15, which I can then compare against the CheckVal number to show it is completed.
Sort of a confusing way to explain it, but I'm sure it's an easy solution. Please respond with your thoughts. I have started a simple logic application I can send to anyone interested for an easier visual review.
Thanks~