LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Formula node problem

Basically I initialize an array and then run a formula node  which fills  up an array based on the cells that are written in the first frame of the sequance to that  array. My problem is that it appears that the formula node does not actually write anything to my array table. I ran multiple simulations but was not able to explain this problem. Please see the sequance structure at the bottom of my code.
0 Kudos
Message 1 of 19
(4,786 Views)
Your fundamental problem is not understanding data dependency. Your "RowHdrs", "ColHdrs", and "Value" property nodes will not be executed until the sequence frame has finished. Also, in frame 2 the tunnel is feeding you the initial value of the table, which is empty.

Also, what you do in the formula node can be easily done in LabVIEW. Try it. It won't hurt. I promise. Smiley Wink
0 Kudos
Message 2 of 19
(4,779 Views)
How come I will gate empty values in the 2nd frame? In my first frame I fill out the table so by the time the second frame arrives the table can't be emty. Am I right?

0 Kudos
Message 3 of 19
(4,772 Views)
Nope. As I pointed out, the "Value" property node will not be executed until after the entire sequence structure has completed. Also, as I said, the tunnel is providing you the initial value of the table because that's how the tunnel works. That's the data that the sequence frame saw when it executed, and that's the data that you get. You're thinking in linear "C" code. Run the code with execution highlight on (the light bulb in the toolbar) and you'll see what I mean.
0 Kudos
Message 4 of 19
(4,768 Views)
A few additional comments, seeing as this seems to be the start of some program:
  • Because of your data dependency issue you are writing the table twice when the sequence structure completes. There's no way of knowing which "Value" property node will be executed first, and if it's the one on the right, the table will have no values (because of the tunnel issue I indicated before).
  • You seem to have hard-coded values for the table data as well as the row headers. I'm guessing you probably want to get the table data from a file, or something, and the row headers would be generated based on the number of rows, rather than the fixed value of 16.
  • It would be a good idea to enforce data dependency by making sure the while loop doesn't start until after your initialization is done.
  • Unless you are explicitly doing something in the "Timeout" case of the Event Structure, leave the "Event Timout" unwired. There's little point in triggering the event structure with nothing to do.
  • Is the "Save data to a file" supposed to act like a toggle or a pushbutton? If it's the latter, leave the mechanical action to the default of "Latch When Released", and handle the control's "Value Change" event rather than the "Mouse Down" event. Then, place the terminal inside the event case so the control gets read (and thereby reset).
0 Kudos
Message 5 of 19
(4,760 Views)
but my time out event is emty no?
So is there an example which shows how to manipulate the array based on some prewritten cells from that table via labview. I feel like I am completelly confused with the formula node. I thought  the formula  node will simplify my code.

0 Kudos
Message 6 of 19
(4,754 Views)
also if I use  the flat sequence instead of the stacked one will that write the Value after each frame instead of writing only after the end of the whole sequence structure?


0 Kudos
Message 7 of 19
(4,748 Views)
Your Timeout case may be empty, but since you're wiring a constant of 10 to the Event Structure's "Event Timeout" the Event Structure will trigger every 10 msec even if there's nothing to do. If you left the "Event Timout" unwired the event structure will trigger only when there's an actual event.

There are numerous examples that ship with LabVIEW. Open the Example Finder (Help -> Find Examples), and then in the tree menu select "Fundamentals -> Arrays and Clusters". You should start with the example "Building Tables", as this is what you really want to do. Basically, all you're doing is adding some columns to a pre-existing array. Your implementation of the formula is not correct to begin with since you only get one value out, and I'm guessing you want to generate those additional "Harmonic" columns. The best/easiest way to do this is with an autoindexed loop. Here is one way to do this:



Also, in regards to your statement
also if I use  the flat sequence instead of the stacked one will that write the Value after each frame instead of writing only after the end of the whole sequence structure?
The answer is no, if you keep the tunnel and property nodes in the same way. The type of sequence frame doesn't matter. It's when the data is available.


Message Edited by smercurio_fc on 05-27-2008 03:29 PM
0 Kudos
Message 8 of 19
(4,744 Views)
wow, Thanks for your thorough explanation. It started to make sense to me. The reason i added timeout 10ms to my event structure is because without it my controls used to freeze. On this forum I I was recomended to include  timeout becaused without it the event structure will intercept control from the application while waiting for the event.With time out the event structure will wait only 10ms and then another part of code will execute. That  is how I understood it from my other thread http://forums.ni.com/ni/board/message?board.id=170&message.id=326077#M326077
0 Kudos
Message 9 of 19
(4,737 Views)
It really depends on what you're doing. If you need to have something happen every x msec even if there are no other events, then wire a value to that timeout input. As mentioned in that thread, this is basically having a "clock" event. If you just want it to respond when events are fired (buttons pressed, etc), leave it unwired. See the online help as well as the shipping examples for more information.
0 Kudos
Message 10 of 19
(4,732 Views)