LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Periodic Table of Elements

Solved!
Go to solution

I have created a periodic table of elements, using a bunch of boolean switches, color-coded and labeled as shown.  Anyone have any suggestions as to the easiest way to create a list of all the elements selected? 

The PC-based application will use a touch screen monitor.  The general idea is below.

1.   Analyst clicks on all of the elements in the sample.  (I want to ensure that the array only lists an element once, regardless of whether they click a button multiple times - I may make it so the button is disabled after they press it once

2.   On a second tab, there will be a list of all those elements selected on the 1st tab.  There will be a keypad here, so that the analyst can enter the percent weight for each element in the sample.

 

I've attached screen captures of what I have so far (not much).  Just looking for some general ideas -  not looking for anyone to do my job...

Message 1 of 43
(5,568 Views)

First of all, nicely done.

 

Use switch when pressed for the boolean control.

In that case the selection stays until reset, resetting can be done by pressing it agian or programmatically restting the value to false.

 

To get the values of all true elements if there on a tab and the onlyu one on a tab.

Use VI server:

Create a reference to the tabcontrol.

Get the array of page references.

Index the page that contains the elements.

Get all control references for that page reference.

Iterate the control references and where value is TRUE get the boolean text and build it into an array.

 

Regards,
André (CLA, CLED)
Message 2 of 43
(5,535 Views)

My solution would be to wrap up your controls in a cluster (you can make the cluster box invisible so it doesnt take away from your front panel apperance.)  Then I would use an event structure to handle "Value Change" for "All Elements" in that Cluster.  Then I would convert this cluster to array of booleans and send this to OpenG's "Search Array" which will return an array of indices of all those elements which matched the search value (TRUE in your case.)  Once you have this array of indices, and since you know the predefined order of the elements, you can create your list.   I think this is probably the cleanest approach but you'll have to use (free) 3rd party VI's for it.

 

 

Message Edited by SiegeX on 11-20-2008 03:05 PM

Message 3 of 43
(5,522 Views)

The (free) 3rd party VI is not necessary.

 

Its not hard to create the functionality yourself. Probably faster than finding out how to get the free VI. From openG?

Regards,
André (CLA, CLED)
0 Kudos
Message 4 of 43
(5,512 Views)
Ya, its not that difficult.  Below is a link to the source (since its free.)  Getting the whole OpenG suite is fairly easy (and auotmated) with VI Package Manager though, and I use their VI's quite a bit.

0 Kudos
Message 5 of 43
(5,505 Views)

Here's another idea.

 

 

 

Involving several semi-advanced LabVIEW topics: VI server, Event driven programming, Dynamic events.

What it does, is filter all the boolean controls, register for a value change on any of the booleans, upon a value change the list of elements is determined by the booleans which are true.

 

Ton

Message Edited by TonP on 11-20-2008 10:58 PM
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 6 of 43
(5,492 Views)
SiegeX, THANKS for the help. OUTSTANDING results.  Now I just have to figure out how to convert the Indices to the Element names.  THey are not in any particular order (I just copied and pasted until I had an 18 x 9 array of buttons.  Then I deleted buttons to create the right numbers in each row and column.  Then I changed their labels and boolean text and color-coded them.)  Is there something simple I'm missing to convert back from the indices to to the names, or am I going to have to pass the indices into some sort of a case structure which outputs the element names?
0 Kudos
Message 7 of 43
(5,398 Views)

You can get the actual clicked button from the left side of the Event structure, which you can convert to a boolean type, than you can read the boolean texts:

 

Ton

Message Edited by TonP on 11-24-2008 04:55 PM
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 8 of 43
(5,389 Views)

Ton, thanks for the feedback.  I've tried this:

 

I added an element (CtlRef) to the event structure

I ran that to the reference iput on a  "To More Specific Class" function and wired a boolean constant to the target class input. 

I created a Strings (4) Property for the Boolen Class and connected its output to an Index Array function whose output goes to a front panel indicator.

 

If I interpret this code correctly, it should just look for those boolean controls which are returning a true, grab their string values and build an array of those strings.  When I run this as described, I get the following error:

 

Error 1507 occured at To More Specific Class in

Periodic Table.vi

 

Possible Reason(s):

LabVIEW:  Type mismatch: Object cannot be type casted to the

specified type.

 

I don't understand why it can't be typecast to a boolean, since it is a boolean control, and I'm confused as to why I'm not using a build array insterad of an index array

 

 

 

0 Kudos
Message 9 of 43
(5,374 Views)
I understand the first part of the code; I'm just narrowing my focus from the front panel cluster to specifically the boolean controls that comprise the cluster. I just don't understand why I get the error saying that the object (cluster) cannot be type casted to a boolean if it's a cluster of boolean controls.
0 Kudos
Message 10 of 43
(5,363 Views)