LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Quick While Loop Problem

Hello everyone,

 

Trying to work through a while loop problem I can't seem to get to work. 

 

I have a 3D plot that plots two sets of data.  The order of the program is as such:

 

1.  Plot original data

2.  User selects 3 points based on cursor that snaps to the data set

3.  Program caluclates and plots a plane based on the three points

4.  User can opt to change points and replot plane based on new data points. 

 

Right now having some trouble with point number 4.  If I change the points nothing happens.  And the program seems to crash when I hit the stop button.  Do I need to use shift registers?  Is putting plotting controls within the program use a lot of resources?

 

No data file since it's huge.

 

Would appreciate any advice!

Thanks,

Alex

0 Kudos
Message 1 of 15
(3,763 Views)

I wasn't able to open your vi as there is a video driver mismatch. If the program isn't too complex possibly posting an image of the diagram in .png or .jpg format would help as I suspect that anyone without an Nvidia video card will have the same problem.

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 15
(3,750 Views)

How "huge" is the datafile. What is the size of the plot? (Number of points in x and y)

 

 

  • In any case, you are hammering the CPU like crazy, recalculating the same data over and over again using 100% of the CPU. The graph only needs to be calculated only once in the while loop and then again when one of the controls changes.
  • The colormap style belongs outside the loop, since it does not change.
  • You are doing a complicated song and dance with complicated FOR loops that could be done with atomic operations. (For example one of your FOR loops could be replaced by a "reshape array" operation and one with "array subset", and so on.).
  • Don't use "delete from array" as a substitute for "index array". Use the right tool!
  • If you unconditionally add one element per iteration to an initially blank shift regsiter array in a FOR loop, you can get rid if all that (shift registers, built array, blank array constant, etc.) and autoindex at the loop boundary output tunnel instead.
  • I don't quite understand the math you're doing. Isn't there an easier way to get the determinant from the 9 inputs than building and manipulating all these matrices???
Can't you make a smaller data file so we have something to play with? I don't understand how you read the cursor.

 

 

0 Kudos
Message 3 of 15
(3,737 Views)

Thanks for taking such an in-depth look at my code and taking the time to make a bunch of comments.  All my LabVIEW knowledge is self taught, so I know a lot of stuff that I'm doing could be done better.  This helps a ton as far as becoming a more efficient coder!

- I deleted some data from the input file to shrink down the size.  It's a 1600 X 1200 array (original size).
- I reattached the code with a little bit more comments to explain what was going on with each for loop.

- I think I can figure out how to replace the for loops with the array functions like you were mentioning, but I'm not sure how to change the graphing features.

- The math is based on this website:  Plane Equation

Unfortunately, the code is pretty spread out, so I can't really take a good screenshot of it.    

I guess this isn't exactly a "quick" problem, but I'm learning a lot through this!

Alex

Download All
0 Kudos
Message 4 of 15
(3,703 Views)

Just went through the program and thought about how I can replace the for loops with the functions you mentioned.  Wow!  I can't believe how much I simplified my code. 

 

Also got rid of a decent amount of shift registers and build arrays by using the autoindex option.  Definitely a good change.

 

I'm going back through other programs I've written and making these changes.... my eyes have been opened! 🙂

 

New VI shows the changes I mde.  Still need some advice though on the graphing controls, hopefully I can get a little more direction here.  

 

 

0 Kudos
Message 5 of 15
(3,673 Views)

Ah, that looks much better ;). You are still hammering the CPU, so you should use an event structure that calculates the stuff on the while loop only when needed.

 

1600x1200x8bytes (dbl) is about 16MB and most likely you have quite a few data copes of it floating around. The size of your 3D graph is nowhere large enough to display all these details unless you are planning to zoom in dramatically. Are you? It might be worth decimating the data to a reasonable amount for display.

 

Note that you are using the activeX 3D graphing tools. In newer LabVIEW versions, they are now replaced by the openGL versions. I don't know how they differ in performance. They do everything in SGL, so potentially there is less memory use.

 

One note: "Read from spreadsheet file" has a "file open" built in, so you should delete that node. If you want a customized file dialog, use the "file dialog" from the advanced file IO palette and wire the resulting path the spreadsheet file node. You can even handle the case where the dialog is cancelled. (Most likely you want to skip the rest of the code if this happens, no need for pumping hot air ;))

 

Maybe I have time over the weekend to do some benchmarking with the openGL stuff.

Message 6 of 15
(3,641 Views)

@altenbach wrote:

...

 

Maybe I have time over the weekend to do some benchmarking with the openGL stuff.


Now THAT is something I would like to hear about. I just completed a "top-secret" demo yesterday for an app that renders flaws detected during non-destructive testing in 3-space. I am on the fence trying to decide if "the enemy I know (CW-3D Graph) is preferable to the enemy I don't know (new 3d version which to my knowlege unproven)."

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 15
(3,633 Views)

 


@Ben wrote:

@altenbach wrote:

...

 

Maybe I have time over the weekend to do some benchmarking with the openGL stuff.


Now THAT is something I would like to hear about.

 

Ben


Be sure to include some figures on how long it takes on your machine to load the 700 or so subVIs.  It is not pretty on my machine....

 

0 Kudos
Message 8 of 15
(3,626 Views)

I don't plan on zooming in on the graph too much, so decimating sounds like a good option.  Didn't even consider that!  I noticed there is a decimate array function, which cuts down the data significantly.  Is this the best way to do this?  Seems like I'd have to go through the input file row by row, decimate and build a new array.  Shouldn't be too difficult.   

I'm not too sure about the event structure that I have here.  It seems like the graphing controls should be inside the while loop, right?  The way I envision it is that the user selects three points, inputs them into the controls and hits ok.  If the plane isn't acceptable, then pick a different 3 points and hit ok.  When the plane is good, then hit the stop button to send it out of the while loop and finish the program.  Right now it doesn't seem to be working, either because my system is lagging or it's not wired up right.  Event structures have always confused me a bit.  

 

Definitely appreciating your insight!

Alex 

0 Kudos
Message 9 of 15
(3,603 Views)

oops, forgot to attach the VI

 

 

Download All
0 Kudos
Message 10 of 15
(3,602 Views)