10-12-2018 02:11 PM
Hello people,
I'm working on a code which calculates some mechanical loads. It has a number of variables so I tought I'd rather use Formula Node than wire all the things together. However, when I try to nest two for loops in each other, or an "if" in a for loop, I can't have the code start. I excluded all the other possible errors and I had a really strange conclusion... that one cannot nest structures in each other the range of which is determined by {} characters. Can someone please comfirm it, or tell me what's the way to make these nested structures run? I attach the code, don't bother about the other variables, the point is the loops and the if structures.
Greetings,
Andris
10-12-2018 10:20 PM
First, if you want some help, please post some data in your controls, make those value default, and then save and post the VI. That way we don't have to guess what the data should be to make it run.
Second, index array is expandable. Drag the bottom border downwards. Then you'll get indices 0 through 3 with a single function node, and BONUS!, you don't have to create all those index constants. It gives the indices in order.
Third, why are you using a formula structure? If you are just using some loops and if then else statements, that can all be done in LabVIEW G code.
10-13-2018 09:37 AM
Thank you RavensFan, expanding Index Array was whole new for me.
I wanted to use Formula Node because on some further parts I will need to nest two For loops in each other and then two If in each other within the inner loop. After some search for G code in Labview I only found what I suspected - machine tools' programming. I don't see how would that help me in writing loops and conditions, can you please recommend me a thread at the forum or any article on that?
Andris
10-13-2018 10:23 AM
No. G was not meant as in the CNC program code. G as in "graphical" programming, which LabVIEW is a part of.
Actually use LabVIEW. There are Case Structures, For Loops, and While Loops. Shift Registers maintain a "variable" from one loop iteration to the next.
I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours
10-13-2018 10:34 AM
@Andris26 wrote:
After some search for G code in Labview I only found what I suspected - machine tools' programming.
Andris,
I decided to try to write your Formula in LabVIEW (it should, in principle, be very simple to do). However, I was struck by the comment you made in your last post, so wanted to start by clarifying something. When talking about a Programming Language, many of them are given names, sometimes consisting of a single letter (C and R come to mind). I don't know when (or how formal it is) that LabVIEW Developers began "informally" (though there may be a formal definition, I'm just too "green" to know) calling the Graphical representation of LabVIEW code "G" (as in "Graphic" or "Graphical", get it?). So by "G", we mean "The structures, wires, and functions you get when you open LabVIEW and create a new VI or sub-VI".
So I thought it would be easy to go from your Formula Node to the Inputs, Outputs, and the "stuff in the middle", but several things seem "wrong" --
Here is a suggestion, which will certainly help us to help you: instead of writing down the computations you want to do using a script language (which appears, to me, to have several mistakes in it), why don't you show us the formula you are trying to compute (if it is available on the Web, you can point us to it, or you can write it down in "math" notation, using Capital Letters for 1D Arrays (Vectors) and lower case letters for scalar variables. As has also been suggested, if you provide what might be typical (or otherwise known, reasonable) values for these quantities and the output that you would expect, we would be able to test any code we suggested to ensure that it works.
One of the beauties of LabVIEW (or "G") is that you can often glance at some code and see what is going on. For loops with arrays going into them are much easier (for someone who knows LabVIEW) to recognize as "process each element of this array" than a C-style For statement (see my last point, above, where you appear to have left two indices out in your computation).
Bob Schor
10-15-2018 03:09 PM
@Bob_Schor wrote:
@Andris26 wrote:
After some search for G code in Labview I only found what I suspected - machine tools' programming.
Andris,
I decided to try to write your Formula in LabVIEW (it should, in principle, be very simple to do). However, I was struck by the comment you made in your last post, so wanted to start by clarifying something. When talking about a Programming Language, many of them are given names, sometimes consisting of a single letter (C and R come to mind). I don't know when (or how formal it is) that LabVIEW Developers began "informally" (though there may be a formal definition, I'm just too "green" to know) calling the Graphical representation of LabVIEW code "G" (as in "Graphic" or "Graphical", get it?). So by "G", we mean "The structures, wires, and functions you get when you open LabVIEW and create a new VI or sub-VI".
Bob Schor
The official name for the language is G, where LabVIEW is the actual name of the IDE. Since you have to use the IDE in order to program, most people simply started calling it LabVIEW.
10-16-2018 05:21 PM
@Mark_Yedinak wrote:
@Bob_Schor wrote:
@Andris26 wrote:
After some search for G code in Labview I only found what I suspected - machine tools' programming.
Andris,
I decided to try to write your Formula in LabVIEW (it should, in principle, be very simple to do). However, I was struck by the comment you made in your last post, so wanted to start by clarifying something. When talking about a Programming Language, many of them are given names, sometimes consisting of a single letter (C and R come to mind). I don't know when (or how formal it is) that LabVIEW Developers began "informally" (though there may be a formal definition, I'm just too "green" to know) calling the Graphical representation of LabVIEW code "G" (as in "Graphic" or "Graphical", get it?). So by "G", we mean "The structures, wires, and functions you get when you open LabVIEW and create a new VI or sub-VI".
Bob Schor
The official name for the language is G, where LabVIEW is the actual name of the IDE. Since you have to use the IDE in order to program, most people simply started calling it LabVIEW.
G-Wiz. That's my new name for you.