# Number conversion

## Recommended Posts

Hey All,

I have a project I did a while back with a V570, revamping an older relay logic machine with PLC/HMI controls, and as I've done with some other retrofits I am saving runtime data in a data table which then gets retrieved using DataXport, then some Quality Control type person uses that data to document performance.

On this machine, I have been asked to implement "downtime" reporting.
If the machine has been off for "X" amount of time, the operator must enter the reason for the machine being down before he can start it back up.

The logic of this was not too difficult, after "X" amount of time the "Start" button becomes a "Go to downtime screen" button", where the operator selects one of sixteen predefined downtime codes, then it returns to the main screen where the Start button is now the Start button.

So far, so good.....

Now in my logic for selecting the downtime code, I have a screen with sixteen buttons that will be labeled with their predefined codes, these buttons are assigned to a block of sixteen MB's, and I am using a Bit-to-Number function to decode which button was pressed, then storing that number fur use in my report.

But, the Bit-to-Number gives me the decimal value of the binary sequence of the block of MB's;
1
2
4
8
16
32
64
128
256 and so on up to 32768

Which I can deal with, but I'd rather just give them the numbers 1-16 on their report....

Now I know I can whip up 16 lines of equal-to/store to accomplish this, but I was hoping to find cleaner/neater way of doing this.

Anybody got a better way of doing this?

JohnR

##### Share on other sites

• MVP 2023

How about putting the button MBs into MB 1-16 then use Vector Find?

A: Use SB 1 for the compare.

B: MB 1

C: #16

D: MI x will have the number 1-16.

##### Share on other sites

Hey, Thanks Flex.......

I knew there had to be a more elegant way, I actually looked at the vector find earlier, but wasn't sure what to do with the trigger (A), I always forget about using things like SB1......

nets may be free,  but it's always nice to do things in a cleaner, less cluttered way.....

Regards,

JohnR

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×