TConnolly
Lifetime Supporting Member
I have a DINT tag named ToolSelect (ControlLogix) in which only one bit will ever be set at a time. Each bit corresponds to a location in a tool holder. The set bit is the tool that is currently selected.
To determine the number of the bit which is set (for display on HMI as the tool number) I am using the following equation.
ToolNumber = LN(ToolSelect)/LN(2)
or
CPT ToolNumber LN(ToolSelect)/.69314718
Quick and simple. It also flies right over the head of Bubba on the maintenance staff.
I've tried to come up with an easier to understand method that can be programmed in one or two rungs.
I know I could do a repetitive divide by 2 and count the number of iterations, but Bubba doesn't get loops either.
Short of just commenting the rung and telling Bubba that is just how it is, does anyone have any ideas.
To determine the number of the bit which is set (for display on HMI as the tool number) I am using the following equation.
ToolNumber = LN(ToolSelect)/LN(2)
or
CPT ToolNumber LN(ToolSelect)/.69314718
Quick and simple. It also flies right over the head of Bubba on the maintenance staff.
I've tried to come up with an easier to understand method that can be programmed in one or two rungs.
I know I could do a repetitive divide by 2 and count the number of iterations, but Bubba doesn't get loops either.
Short of just commenting the rung and telling Bubba that is just how it is, does anyone have any ideas.