09-09-2010 08:55 PM
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
09-09-2010 10:21 PM
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.
09-10-2010 12:08 AM
How "huge" is the datafile. What is the size of the plot? (Number of points in x and y)
09-10-2010 11:18 AM
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
09-10-2010 12:28 PM
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.
09-10-2010 02:54 PM
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.
09-10-2010 03:04 PM - edited 09-10-2010 03:08 PM
@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
09-10-2010 03:09 PM
@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....
09-10-2010 05:17 PM
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
09-10-2010 05:19 PM
oops, forgot to attach the VI