05-26-2011 09:54 AM
Thanks for offering the sample with the In Range and Coerce functions to create the Boolean array. But, why is the third case "4" and not "3".
I am reading the Labview help about "Boolean Array to Number Function" and it says....,
"For example, if you wire an array of two Boolean values to this function and neither value is TRUE, the function returns a value of 0. If the first Boolean value is TRUE, the function returns 1. If the second Boolean value is TRUE, the function returns 2. If both Boolean values are TRUE, the function returns 3."
So, how does the third case in your illustration become 4? If case array values 1 and 2 are both FALSE and the third one is TRUE, I would have guessed the output value to be 3, not 4. For example, if you entered a value of 25, that should make 1 and 2 both FALSE and 3 TRUE. For my own learning tool, I added string indicator to follow the functional output of the 4 cases including default.
05-26-2011 10:03 AM
I would not recommend this approach. The formula node should be reversed for just that, formulas. It is not intended to be used a C emulator by allowing you to write significant parts of your code in a text format. By doing so you will lose many of the optimization sand benefits of the native LabVIEW language.
05-26-2011 10:09 AM
Hi Mark,
I am sorry, but, I am not clear about which part of the approach you would not recommend? What "formula node" are you talking about? What do you think would be a better architecture that provides better optimization? I am very much interested in speed, so, I am interested in making sure that my code is efficient.
05-26-2011 10:43 AM
@JFT' wrote:
Hi Bernie,
You can do that and many others things, using only one structure. I'm talking above "Formula node". See the help of this structure directly in LV, and you will find a very useful aid.
JFT
Sorry, I was referring to what this person had recommended. He was suggesting using the formula node to implment you decision processing.
However on second thouht if all that you used the formula node to do was output a value based on testing the ranges of the input this would be fine. If however you tried to implement complex code (other than actual calculations) I would not recommend that.
05-26-2011 12:18 PM
Thanks, Mark, but, what does "formula node" mean? I am very new to Labview and learning a lot of things, but, I can't say that I could define "formula node" if asked. Would you kindly offer a definition of description of what that phrase means?
Thanks,
Dave
05-26-2011 01:34 PM - edited 05-26-2011 01:35 PM
A formula node is a structure within LabVIEW that allows you to enter formulas and some basic programming constructs in txt form with a syntax that is similar to C. The formula node has inputs and outputs so that data can be passed in and out of it similar to the way a subVI works. LabVIEW is a great language but it is not very easy to implement complex mathematical equations in the native language. This is one area where the tradition text representation of an algorithm is easier to understand. Formula nodes are very good in those instances. However if someone is making the transition from text based programming to LabVIEW they may be tempted to overuse the formula node where native LabVIEW constructs would probably be better suited.
Here is a basic example of a formula node.
05-26-2011 02:02 PM
Thank you very much. I understand it now. I believe that formula nodes are possible only with the Math Scripts add-on. Is that your understanding too? I recall reading about formula nodes, but, I couldn't practice any exercises with them because I don't have the Math Scripts add-on.
05-26-2011 02:46 PM
The formula node is included in all releases. You can find it under the Structures palate. I don't have any of the Mathscript addons either.
05-26-2011 03:22 PM
@dav2010 wrote:
Thanks for offering the sample with the In Range and Coerce functions to create the Boolean array. But, why is the third case "4" and not "3".
I am reading the Labview help about "Boolean Array to Number Function" and it says....,
"For example, if you wire an array of two Boolean values to this function and neither value is TRUE, the function returns a value of 0. If the first Boolean value is TRUE, the function returns 1. If the second Boolean value is TRUE, the function returns 2. If both Boolean values are TRUE, the function returns 3."
So, how does the third case in your illustration become 4? If case array values 1 and 2 are both FALSE and the third one is TRUE, I would have guessed the output value to be 3, not 4. For example, if you entered a value of 25, that should make 1 and 2 both FALSE and 3 TRUE. For my own learning tool, I added string indicator to follow the functional output of the 4 cases including default.
The output to boolean array to number is three if the first AND second case are both true. Binary 00000011 is 3 decimal.
Each digit is the result of a true/false comparison (the in range/coerce function). So if your 3rd condition is true, then the 3rd digit is a 1 (the 1st and 2nd are zero or should be because your comparisons should never overlap.) So you have 00000100 in binary which is 4 in decimal. This is all binary logic/conversion.
Another alternative is to searcha 1D array on the boolean array looking for a True. Then you will get a 0 for the initial condtion, 1 for the second condtion, 2 for the 3rd, and so on. If nothing is true, then you should get a -1. This method should work just fine for you also since your conditions should only have 1 true. If you had multiple Trues, it will only give you the element # of the first True.
05-26-2011 05:34 PM
ALL RIGHT!! Thanks, that is a wonderful explanation. I really appreciate that. I would not have gleaned that from the Labview Help alone.
Dave