Jump to content
Sign in to follow this  
Roman85

Convert INT8 tag value to binary

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Thank you,

1. Num to Bits works

2. How to work with 'Copy array Part to array'?  I made a bits array size 4 (Valve_Selction), but I can't copy directly to the output of UID-0016.

 

Untitled picture.png

Share this post


Link to post
Share on other sites

A = source array

b = 0 (offset)

c = 4 (length)

d = outputs

 This worked for me. (i might be mixing the order of b and c. I don't have unilogic in the computer i'm replying from)

 

Share this post


Link to post
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.

Guest
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.

Sign in to follow this  

×
×
  • Create New...