From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I initialize a graphy?

Solved!
Go to solution

I have a program for the HP4192A.

 

The program can plot x-y, but the next plot will build on the previous ones. So I have to close the program to clear the graph.

 

How can I add a button or switch to initialize the graph, so I don't have to close the program.

 

Thank you so much.

0 Kudos
Message 1 of 8
(3,315 Views)

There are several ways to initialize the graph.

 

1. Set the default value of the graph to empty (from the front panel, right click on graph and select Data Operation > Clear Graph then right click on the graph and select Data Operations > Make Current Value Default to set the empty graph as the default value). With the graph default value empty, you can use the invoke node to reinitialize the graph to its default value (from the block diagram or front panel, right click on the graph and select Create > Invoke Node > Reinitialize To Default). Wire the invoke at the entry point of your program.

 

2. Create a local variable from the graph indicator and write an empty array to it at the beginning of your program

 

3. Use a Value property node to set the value to an empty array at the beginning of your program

0 Kudos
Message 2 of 8
(3,306 Views)

How are you running this VI?  It only takes one data point each time it runs.  The feedback node retains the previous data for the next run.

 

Are you using the Continuous run button or is this a subVI to a main program?  Continuous run is not intended for this kind of usage.  It is better to put the code inside a while loop and stop the loop with a Stop button on the panel or when some logical condition (such as a fatal error) occurs.  Wire the error in and error out terminals to eliminate the use of the sequence structure.

 

Lynn

0 Kudos
Message 3 of 8
(3,297 Views)

Can you look at this program? This is what I use to run the instrument.

 

Thank you so much.

0 Kudos
Message 4 of 8
(3,294 Views)
Solution
Accepted by topic author Michael.Xie

I cleaned up the diagram on the EIS test VI.  It is much easier to see what is happening this way.

 

Comments about the program:

1. Do not both wire to the N terminal of a for loop and connect an array via an autoindexing terminal.  The one with the smaller value will determine the number of times the loop iterates.

2. It is generally not a good practice to use Build Array inside a loop because it can cause frequent memory reallocations.  Better practice is to initialize the array to the maximum size it will reach outside the loop and use Replace Array Subset inside the loop.

3. There is nothing wrong with mixing feedback nodes and shift registers in one loop, but it may confuse someone who looks at the program later as to why. I prefer the shift register but that is at least in part because I was using LV long before the feedback node was introduced.

4. The top shift register ends up with the same data as the array fed into the loop from the sequence builder VIs.  Is there a reason why you take it apart and put it back together again?  Similarly it is not necessary use Index array with the Index input connected to i, especially since you are already autoindexing the same array.

5. I would consider modifying the HP4192 Measure VI further: Eliminate the feedback nodes and graphs since you are performing those functions in the main VI.

6.  Use the Negate function rather than multiplying by -1.

 

I cannot save back to version 7.1 so I have attached an image of the block diagram with many of these changes.

 

Lynn

0 Kudos
Message 5 of 8
(3,272 Views)

I really appreciate the help and kindness from all of you.

 

I will read these threads through:)

0 Kudos
Message 6 of 8
(3,254 Views)

Lynn, can you kindly post the program you created? Here I have a Labview updated, so I can use the program directly.

 

Thank you again.

 


@johnsold wrote:

I cleaned up the diagram on the EIS test VI.  It is much easier to see what is happening this way.

 

Comments about the program:

1. Do not both wire to the N terminal of a for loop and connect an array via an autoindexing terminal.  The one with the smaller value will determine the number of times the loop iterates.

2. It is generally not a good practice to use Build Array inside a loop because it can cause frequent memory reallocations.  Better practice is to initialize the array to the maximum size it will reach outside the loop and use Replace Array Subset inside the loop.

3. There is nothing wrong with mixing feedback nodes and shift registers in one loop, but it may confuse someone who looks at the program later as to why. I prefer the shift register but that is at least in part because I was using LV long before the feedback node was introduced.

4. The top shift register ends up with the same data as the array fed into the loop from the sequence builder VIs.  Is there a reason why you take it apart and put it back together again?  Similarly it is not necessary use Index array with the Index input connected to i, especially since you are already autoindexing the same array.

5. I would consider modifying the HP4192 Measure VI further: Eliminate the feedback nodes and graphs since you are performing those functions in the main VI.

6.  Use the Negate function rather than multiplying by -1.

 

I cannot save back to version 7.1 so I have attached an image of the block diagram with many of these changes.

 

Lynn


 

0 Kudos
Message 7 of 8
(3,251 Views)

Here is the file saved for version 8.0.  I did not have some of the subVIs so you may need to restore those.  I did not open it in version 8.  I saved it back from LV2010.

 

Lynn

0 Kudos
Message 8 of 8
(3,235 Views)