How do I find the most significant bit of a dint?
Backstory following.
I found out years ago that a small machine with 30 steps or less was easier to find the step if it was a bit of a word. We had guys moving steps by 5 into the step position. The maintenance guys had a hard time finding which MOV instruction was actually in command. So I started using a DINT and bits. Each bit is the step its in and you seal in the step so they are all on and you can see what its waiting on.
To trouble shoot 0000 0000 0000 0000 0000 0000 0001 1111
Bit 1 is step 1
Bit 2 is step 2
Bit 3 is step 3 and so on.
We just need to look at bit 6 of the word to see why its not stepping to the next step. I break the machine down into smaller steps if the process needs more than 30 steps. 0 is not running and 31 is complete.
I want to know the most significant bit so I can show it on an HMI. I don't care what the lesser bits are doing they have to be made for the most significant to make.
Backstory following.
I found out years ago that a small machine with 30 steps or less was easier to find the step if it was a bit of a word. We had guys moving steps by 5 into the step position. The maintenance guys had a hard time finding which MOV instruction was actually in command. So I started using a DINT and bits. Each bit is the step its in and you seal in the step so they are all on and you can see what its waiting on.
To trouble shoot 0000 0000 0000 0000 0000 0000 0001 1111
Bit 1 is step 1
Bit 2 is step 2
Bit 3 is step 3 and so on.
We just need to look at bit 6 of the word to see why its not stepping to the next step. I break the machine down into smaller steps if the process needs more than 30 steps. 0 is not running and 31 is complete.
I want to know the most significant bit so I can show it on an HMI. I don't care what the lesser bits are doing they have to be made for the most significant to make.