07-14-2009 03:25 PM
When I run my vi, it usesa subvi CreateGraph.vi, but the export image doesn't seem to be working on the first try. When this subvi is called, the .bmp file that is created ends up being an all white image showing no lines or anything. I can then go to this subvi, and click run, and it will go through the code again, except this time it will actually get the image of the graph. I have included attachments of creatgraph.vi and a screenshot of what the front panel looks like after its first run, when it doesn't get the right image. If anyone can see what Im doing wrong I would appreciate it.
Thanks.
07-15-2009 02:20 PM
07-15-2009 02:55 PM
07-17-2009 08:28 AM
I have attached a second version that includes the data as default values. To answer your question:
I had it saving twice because the program would work the second time it was run, so I figured saving it twice might fix the problem, but it didn't.
I use mathscript because I originally had the entire program in matlab, but I found out they wanted it in labview, so I converted half of it to labview code, and kept mathscript for some of it.
The mathscript node calculates y points at the x coordinates for the trendline. It also calculates R^2, to show how accurate the trendline is. It also formats the title with everything that is needed on the graph.
07-17-2009 09:20 AM
Unfortunately, I don't have 8.5. When I ran your VI in 8.6 I got an image. I back-saved it for 8.2 and ran it with that version and I got an image. Maybe it's an 8.5 thing.
Additional comments:
07-17-2009 10:56 AM - edited 07-17-2009 11:00 AM
I tried and it also works just fine in 8.5.1. Of course it will only write one image, because most of your autoindexing inputs are size=1 arrays, thus limiting the iteration count of the big FOR loop to one iteration.
I guess it's OK to recycle old matlab code, but many of you LabVIEW constructs are plain horrifying. 😮
There is way too much code!!!
Why are you writing to a boolean and then read from a local variable of same in the next frame? If you would use a plain wire, the data dependency would eliminate the need for the sequence. You actually don't need to create the file if it does not exist. It will be create automagically. Look at your small for loop: you are stopping if the condition is met, so you could wire directly from the comparison to the stop terminal. You are writing to a terminal in one case and to a local variable of the same terminal in the other case. Wouldn't it make more sense to simply write to the terminal and eliminate the case structure entirely? Same difference!
Here's a very quick rewrite to show you some techniques on how to inprove the code a bit. See if it gives similar results. Look: No locals and big sequences. The small sequence frame ensures that the picture is taken after the graph is written. Please verify correct operation and modify as needed.
07-17-2009 11:17 AM - edited 07-17-2009 11:17 AM
One small correction. It seem you are creating the folde if it does not exist. This needs to be done only once outside the loop. Here's the corrected cide.
07-17-2009 12:13 PM
Thanks. I am used to coding in C++ and this is my first labview program. It seems I tend to put in a bunch of nonsense.
I am plugged your VI into the main VI and am testing it now. It will be around 24 hours before I get the results.
07-17-2009 01:30 PM - edited 07-17-2009 01:33 PM
smot678 wrote:Thanks. I am used to coding in C++ and this is my first labview program. It seems I tend to put in a bunch of nonsense.
I am plugged your VI into the main VI and am testing it now. It will be around 24 hours before I get the results.
No problem, we've all started once. The best way to learn is from mistakes. 😄
There is something similar to Moore's law in LabVIEW: Your next program will do twice as much with half the code!
Please make sure things work as expected and do some dry tests before doing a 24 hr run.
It is possible that it needs a tweak here and there. e.g. make sure that we get column vs. row correct, etc.
You can also remove the caption.justify property. Once you set it to centered, it will stay that way forever. 🙂
07-17-2009 01:41 PM - edited 07-17-2009 01:42 PM
Back to the original problem. Still trying to rationalize your observations.
Does the first image fail always or just whenever you create a new folder?
Are you writing the file locally or to a network location?
In the worst case, you could create a dummy image before the loop and delete it later.