Jump to content

Convert INT8 tag value to binary


Roman85

Recommended Posts

Hello,
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.