LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Truth Table Node

I am not sure what I think about this idea on the exchange:

 

http://forums.ni.com/t5/LabVIEW-Idea-Exchange/General-Comparison-Operator-as-an-Express-VI/idi-p/128...

 

but, I was intrigued by the picture of the Node with with the generic truth table and thought I would mock it up and now I am parking the code here.  It is an XNode, so you just need to unzip the file to a directory and drag Truth Table.xnode to your Block Diagram.  I tend to add my experimental xnodes to a scratch palette, just be sure to change the file pattern from VIs to All files when browsing for the XNode.

 

You can wire booleans and 1D boolean arrays to either terminal and just click on the truth table to change the values.

 

TruthTable.png

 

Still not sure if I like the idea, but it was a fun exercise.

Message 1 of 24
(6,543 Views)

Darin, very nice... but you could have improved on my icon design (PowerPoint and ScreenHunter generated)!!! Smiley Wink

This essentially replaces the whole boolean operator palette and provides much more legibility.

For multiple inputs (I mean more than 2), I suggested an approach in the thread you refer to in your post, but I must admit I did not put too much thought into it. However, it would work to my liking if it behaved like I described.

Again, my point is that we rarely use the boolean operators to perform logic calculations (although I must admit that if I had had LabVIEW when I was in high school... well long time ago...this boolean palette would have come very handy to compute the stupid logic problems we had to solve at that time. Such as NAND(XOR(AND(etc...))) nested ad nauseum).

X.

 

Message 2 of 24
(6,502 Views)

Nice Truth Table Darin!

 

Aside from the old State Diagram Editor I never got into the XNodes very deep. For an encore I like to see your version of a "Bucket of Truth".

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 3 of 24
(6,473 Views)

Not exactly the Bucket of Truth (glad I was at home when I clicked that link...), here is another version, this time you can map up to six boolean inputs to different values of a wired enum.  Certainly seems like it could be useful, although I am still not completely happy with the UI for setting up the table, this attempt harkens back to Karnaugh map days in undergrad.  

 

EnumTruthTable.png

 

EditTruthTable.png

 

Can't help but feel like I am getting very close to writing an Express VI.  If nothing else I am getting my XNode manager whipped into shape.

Message 4 of 24
(6,348 Views)

Looks nice, but isn't there a GetValueFromTable.vi missing in the Zip file, or is it some part of another release?

Message 5 of 24
(6,312 Views)

Consarnit.  Here is the fixed zip file.

Message 6 of 24
(6,301 Views)

All Right! Now it works.

I am a bit confused by the interface though...

First of all, when I click on the top row (headers?), they switch to blank. I know I am not supposed to. It seems that it is due to the default font size needed to fit in the control. If I click the up arrow, I get the header name back. Minor... Maybe you want to prevent the user from being able to click in those headers. Or set the font size dynamically depending on the LV installation?

Second, I must admit that I am too old for the mental gymnastic required to read and fill the table. And I'd rather not imagine what it would be with more inputs...

Compare your approach for 6 inputs (out of which only 4 sets are in fact encountered, all the other ones being set to the default result):

 

 Darin K (6).jpg

 

 

and  what I would suggest (disclaimer: there is NO BLOCK DIAGRAM associated with this panel!!!):

 

X (6).jpg

 

What I would envision is that when the user rescales the window, the two arrays (I mean the 2D Boolean array and the Listbox) rescale to show more cases. I am not sure how to scale the Boolean array horizontally, but I guess the best would be to let the user choose whether or not to see it in a compact form - with a horizontal scrollbar - or not). The tricky part is to have the input names (number ID) rescale as well (on this dummy FP, they are just decorations I have aligned manually), and have the listbox aligned with the different cases...

 

On the plus side, I like the "Enum" input A LOT and the way you can fill the table with a "Default" value taken from the enum.

Great job and please consider my comments above as constructive!

It would be nice to have feedback from other LVers...

Best,

X.

0 Kudos
Message 7 of 24
(6,280 Views)

Now that I look at my "panel", I realize that what woluld be needed is not "input ID numbers" (1,2, ... 6) but instead the names of the wires (or controls) connected to the function. So probably we want to transpose that 2D array of Booleans, so that the "cases" are listed as columns rather than rows.

My 2 cts,

X.

0 Kudos
Message 8 of 24
(6,269 Views)

Too late to edit... Of course if you transpose the input table, then the result listbox doesn't map nicely to the different cases.

Hmmm. The ideal UI might be a bit more difficult to design than I thought.

X. 

0 Kudos
Message 9 of 24
(6,250 Views)

Maybe something like that would do the trick:

 

X (6) modified.jpg

 

 

The new listbox shows the names of the inputs. The "New" button next to it is used to add a new set (or "case") to the table, with a selected input being "True" while a unselected one is "False". Pressing "New" adds an entry (a row) to the Boolean "Truth Table" and a corresponding entry in the "Results" Enum Array (default value, which the user can obviously change).

For the full table, just press "Fill", and the complete truth table (2^N elements) is generated to the left, while a corresponding 2^N array of Enum is generated to the right (defaulting to...the default value).

There is still a need for a graceful way to increase the size of both arrays according to the panel size increase...

Feedback?

X.

0 Kudos
Message 10 of 24
(6,238 Views)