From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

controling 20 bits

Solved!
Go to solution

I have 20 test I  want to run .. Each test is represented by a bit

If all the test are running all the bits are set to one ( 0xFFFFF - which is default setting). 

If a test is not supposed to run we will minus that hex number from defualt number.

 

If test 19 is not supposed to run I will subtract default setting 0xFFFFF by 0x40000 (bit for test 19). 

 

Is there better way to do bit manipulation without remember each bit hex number?

I basically just want to put the test number in without having to worry about the hex decimal number.

 

 

 

*also want to add test too. 

 

Download All
0 Kudos
Message 1 of 12
(3,696 Views)

Why don't you make the boolean array a control, initialize it to all true, and then let the user turn LEDs off as needed. (show the exact number of elements and hide the index display to prevent the user from adding elements). Now convert the final boolean array to a number to be used. 

0 Kudos
Message 2 of 12
(3,689 Views)

Without looking at your code (I have LV 2009 on the PC) I guess you could convert the number to an array of booleans, flip the appropriate bit and then change it back into a number.  I know there are better ways, but I like this way because you it's like you are physically manipulating the bits and not doing a bitwise operation - which I'm terrible at doing.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 12
(3,685 Views)

I changed the code to LV 8. it not best looking (or design) code  i just wanted to work on concept. 

 

 

thanks for concept. i did not think of that. I am not great with bit manipulation too. that why i figure the forum could help me with that. 

0 Kudos
Message 4 of 12
(3,672 Views)

I think it will be neater if i do not use whole array on the front panel. I rather the user put in the test number or maybe use a enum.  both method will take up less space. 

 

 but then i will have to worrry about overflow if the user add test when all the bits are set to one. 

0 Kudos
Message 5 of 12
(3,669 Views)

It doesn't have to be plain-jane boolean LEDs.  You can use switches or toggles.  Just right-click on the LED and choose replace... and then replace them with various boolean controls until you find one you like.  Also, since elements of an array have to have the same property values, you'll have to use free labels or text boxes next to each boolean control to "label" the tests.  But if you arrange the boolean in a vertical fashion, you can get a decent UI going...

 

Oh and you can use the Number of Rows property to display the proper amount of booleans.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 12
(3,655 Views)
Solution
Accepted by topic author sticyfinger

Are you aware that most boolean functions work on integers? 

 

Although your description of what you want is not entirely clear, I think that Scale by power of 2 and Boolean Invert and AND may do what you want.

 

Lynn

0 Kudos
Message 7 of 12
(3,643 Views)

@billko wrote:

It doesn't have to be plain-jane boolean LEDs.  You can use switches or toggles.  Just right-click on the LED and choose replace... and then replace them with various boolean controls until you find one you like.  Also, since elements of an array have to have the same property values, you'll have to use free labels or text boxes next to each boolean control to "label" the tests.  But if you arrange the boolean in a vertical fashion, you can get a decent UI going...

 

Oh and you can use the Number of Rows property to display the proper amount of booleans.


I would suggest the Check Boxes.  They are very intuitive and simple to use.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 8 of 12
(3,640 Views)

Thanks alot for all the suggestions.

 

@johnsold

In the first version of the program (which need to be done in couple weeks) I can use an array on front panel. In the second version of the program a plc will send me hex value of the test to disable or enable.

 

And thanks for answering my question.

 

@Billko thanks for the suggestion on how to update plain jain Boolean LEDS. I will use that on first version of the program.

 

 

@anyone

I will have to worry about bit manipulation in the second version of the program. To disable a bit I just add number and to enable a bit a subtract number. But what happen if all the bits are set to true and the plc still send me bit to turn on test 1.

 

Example ( situation 1 )  – if current value is default ( 0xFFFFF) and I add 1 the result of the number will be 0x100000.  Basically turning off all the number

 

Situation 2.  If all the test are disable (0x0) and the plc send command to disable test 1 all the bits will be set to one.  

 

And idea on how I can do this? This being dealing with input command from plc ? 

0 Kudos
Message 9 of 12
(3,594 Views)

@sticyfinger wrote:

Thanks alot for all the suggestions.

 

@johnsold

In the first version of the program (which need to be done in couple weeks) I can use an array on front panel. In the second version of the program a plc will send me hex value of the test to disable or enable.

 

And thanks for answering my question.

 

@billko thanks for the suggestion on how to update plain jain Boolean LEDS. I will use that on first version of the program.

 

 

@anyone

I will have to worry about bit manipulation in the second version of the program. To disable a bit I just add number and to enable a bit a subtract number. But what happen if all the bits are set to true and the plc still send me bit to turn on test 1.

 

Example – if current value is default ( 0xFFFFF) and I add 1 the result of the number will be 0x100000.  Basically turning off all the number

 


Numbers are numbers are numbers.  If you just change the control radix to hex, you can view/enter the number in hex.  🙂

 

How does the data arrive?  As a string?  As an array of bits?  As a binary string - i.e., "0001 0000"?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 10 of 12
(3,585 Views)