Jump to content

Convert INT8 tag value to binary


Recommended Posts

I'm using Combo Box in my HMI. My Combo Box has 16 options and the user choice is stored in a tag name "Select_Valve"  (of type INT8).

I want to convert the value of "Select_Valve" to binary type. In the end, I want to open one of the values according to the user selection using "UID_0016 -> Outputs_0:Outputs3"

Thank You!

Untitled picture.png

Link to comment
Share on other sites

There is a Ladder Element called Num to Bits, which should take a number and convert it to bits.

For example, I took an Int8 and used the Num to Bits elements with a bits array of size of 4 (0 to 3), and it behaves as you've would expect (value 0 gets 0 on all bits, and value 15 gets 1 in all bits).

One note though, when I've outputed the result to the UID-0016 outputs, all the bits were reset (oven ones that are not from 0 to 3).

If you don't want that behavior, when you can use a bits array with size 4, and then copy the array (with Copy array part to array) to the outputs

Link to comment
Share on other sites

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 link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

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

  • Create New...