LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Re:To turn on 8 LEDS into a binary(base2) representation for the 8 bit unsigned integer.Please help on this!Thnx!

Solved!
Go to solution

Hi,

I'm a newbie to LabVIEW.Currently I'm doing few design peoblems for my assignment.

One of question I'm having right now is to create a front panel that has 8 LED indicators and vertical slider control that is an 8 bit unsigned integer.The problem is to turn the 8 LEDs into a binary(base2) representation for the number in the slider.

 

I'm thinking if the slide is set to number 10(which in base 2 is 00001010=1*(2^3)+1*2,the LEDs,1 and 3 should be on.
However I have no idea how to convert the interger to binary and make the LEDs to light up.
Please help me to look at this problem and guide me to the final requirement.
Attached with what I have done.
Thank you.
Best Regards,
Vicky
0 Kudos
Message 1 of 8
(8,996 Views)
Solution
Accepted by topic author SG_SP_OLED
Easiest would be to make your Booleans an array, make the control a U8, and use the Number to Boolean Array.
0 Kudos
Message 2 of 8
(8,990 Views)

Hi,

 

I have attached the new code.  Notice that I have only made minimal changes.  Two main things I have changed:

 

1. Your slider was in double.  I changed it to U8 like you said.  You need to watch out for formatting.

2. Since the number is a U8 now, I can use number to boolean array to convert the number to binary. 

 

Yik

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
Message 3 of 8
(8,988 Views)

Just a couple of points to add to the earlier posts.  As they imply, using an array of booleans simplifies the display and the code.  The slider has a datatype, you should set it, and it has a digital display so no need to wire to a separate indicator.

 

I show two ways to convert to the boolean array, the usual is using 'Number to Boolean Array' which gives you computer ordered results (LSB first).  If it is just for show (and it usually is) I use type cast with Convert 4.x selected to give a human ordered array (MSB first).  You can also reverse the Number to Boolean Array result if you wish.

 

NumberToBooleanArray.png

Message 4 of 8
(8,978 Views)

Hi,

Thanks for the help.the solution is what I want only if able to change the indicator reading from LSB(right) to MSB(left).currently is LSB(left) to MSB(right).

 

Rgds,

Vic

0 Kudos
Message 5 of 8
(8,933 Views)

Hi,

Thank you for the help.My LabView is version 8.6 occured the problem to open version9.possible to send me again because I need to change MSB(Left first) then LSB(Right).

 

Download All
0 Kudos
Message 6 of 8
(8,924 Views)
If you want to make the LSB come first just use Reverse 1D Array in the arrays pallet.
=====================
LabVIEW 2012


Message 7 of 8
(8,921 Views)

Hi,

Thanks, you are right.Question sloved!:)

 

Best Rgds,

Vic

Message 8 of 8
(8,904 Views)