LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Ploting 2 Scalar Numbers at The Time

Hi Everyone,
 
I have a main and a sub-vi to plot 2 scalar numbers at the time using the graph control (LV8.5), and is not working correctly as I will expect to work.   Basically the main vi has a graph that is updated everytime its sub-vi is called.   However it looks like the shift registers keep "its memory" alive even though the sub-vi has finished or stopped.
 
At the sub-vi level, I don't reset the shift registers because I don't want this operation to happen everytime this sub-vi is called.  I was hoping that Labview will reset the shift registers every time that the main vi has finished and re-started again.
 
Could someone suggest a different technique to make this vi work? 
 
Basically, the main vi calls its sub-vi 10 times and updates its graph properly.   However the main graph keeps plotting more than 10 numbers. . .
 
I know that I could use a chart and fix this issue but I would like to use a graph control if possible.
 
Thanks,
 
Frank
 
 
 
 
 
0 Kudos
Message 1 of 7
(3,078 Views)
Since you are using LabVIEW 8.5, you can use feedback nodes in the subVI without the need for any while loop. Now use a case structure connected to the "first call?" primitive as e.g. in the attached modification.
 
You should not place a wait in the subVI, this make no sense. There is no reason for the sequence frame. You also don't need to zero the graph in the main VI as you currently do.
Message 2 of 7
(3,068 Views)

altenbach ,
Thanks for your suggestions, the code works great!

In regard to shift registers,  do they suppose to reset everytime a vi is re-started after completing execution (main vi)?  or do they suppose keep the last number in memory even though a vi has been terminated or exited (main vi)?   I tought that labview will clear or release all memory allocated to local variables, shift registers, etc after completing execution of a vi (main or top vi).

Thanks again,

Frank

 

0 Kudos
Message 3 of 7
(3,048 Views)

Fvalenzu wrote:
I tought that labview will clear or release all memory allocated to local variables, shift registers, etc after completing execution of a vi (main or top vi).
A shift register keeps its data as long as the VI remains in memory, running or not. (You can clear it by forcing a recompile e.g. by clicking RUN while pressing the ctrl button).
 
The "first call?" is described in the help as:
"... Indicates that a subVI or section of a block diagram is running for the first time. The First Call? function returns TRUE only the first time you call it after you click the Run button. You can place the First Call? function in multiple locations within a VI. The function returns TRUE the first time the section of the block diagram in which it is placed runs...."
Message 4 of 7
(3,041 Views)

altenbach,

 

Thanks again for your input . . . and I just wonder if there is a way to call the main vi multiple times on a top vi and still get only 10 numbers to be displayed on the top vi's graph.  The reason is that I am calling the main vi multiple times in my program.

Please see attached vi.  Thanks,

Frank

 

0 Kudos
Message 5 of 7
(3,036 Views)

Yes, LabVIEW has all the tools to do whatever you want. 🙂

In this case you could e.g. add an extra boolean input to the subVI that lets you reset the feedback node any time you want. In this case you would reset whenever i=0 as shown in the following image (top is the code if the inner subVI and the botton image shows how you would call it).



Message Edited by altenbach on 02-01-2008 10:35 AM
Message 6 of 7
(3,029 Views)
Thansk altenbach,
 
As always your input is much appreciated!  Smiley Wink 
 
Frank
 
0 Kudos
Message 7 of 7
(3,016 Views)