10-05-2011 06:03 PM
I have a 2D numeric array as the output of 'Array subset' function. I need to convert the elements of each cell in this array into their binary equivalent and display them on the front panel. I am a beginner of Labview. Any help on this is greatly appreciated. Thanks.
Solved! Go to Solution.
10-05-2011 06:26 PM
Please explain what you mean by "binary equivalent".
What is the datatype of the array? If it is an integer (blue), all you might need is set the display format of a plain numeric array indicator to binary.
10-05-2011 06:42 PM
The array is a DBL array. I have attached a word document with my block diagram. The image below the block diagram is the output indicator on the front panel.
You can see that the output is Subnet Mask 255 255 0 0. I want to convert 255 to its binary equivalent ie. 11111111. This I need to do for the subsequent elements in the array and output the result on the front panel.
10-05-2011 06:56 PM - edited 10-05-2011 06:58 PM
Your array is blue, thus definitely not DBL, only your indicator is DBL and thus mismatched. Also you "mask bits" control should be integer, you cannot have fractional masks. (right-click...representation).
I assume that that array is actually U8. Take the four element U8 array and typecast it to U32, then display it as %032b.
It would be much easier if you could attach your VI containing typical data instead of a word document with a picture. A picture never tells the full story.
10-05-2011 07:25 PM
I've attached my actual VI. I've created a constant array with the mask bits and the corresponding subnet mask. This I am feeding into Array Subset function to display the Subnet mask. So when the user enters the no.of bits he wants masked, my Subnet Mask indicator would display the corresponding subnet mask in decimal format. I have to also display this subnet mask in binary like I explained before. This is where am stuck!
10-05-2011 08:39 PM
Appreciate your quick help in this regard. Thanks.
10-05-2011 09:46 PM
Try this:
(of course you also don't really need the loopup table, because it would be trivially simple to calculate the mask from first principles;))
10-05-2011 10:06 PM - edited 10-05-2011 10:08 PM
Here's a version showing a few more possibilities... pick whatever is most suitable. (notice: no more lookup table ;))
10-06-2011 01:35 PM
Oh that's a great solution! Your previous solution worked perfectly as well. I could complete the rest of my logic with ease! I've just started learning Labview. Your help is greatly appreciated. Thanks so much. 🙂