LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

blank export image graph

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.

Download All
0 Kudos
Message 1 of 14
(3,622 Views)
smot678

This code will not run on my system.  This is due to the fact the count terminal for your for loops aren’t wired.  I would also suggest not using the sequence structures in this manner as it is not good for data flow.  These factors may be contributing to the reason your code is not working as you expect it to.

Regards,

Mike S
NI AE
0 Kudos
Message 2 of 14
(3,591 Views)
Well I can run the VI, but I have no data. The VI itself is a wiring mess. I don't understand why you're using a Mathscript node just to sort two arrays. That's what Sort 1D Array is for. I also don't understand why you're writing the image file twice.
0 Kudos
Message 3 of 14
(3,585 Views)

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.

0 Kudos
Message 4 of 14
(3,563 Views)

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:

  • Looking over your Mathscript code, there's nothing in there that can't be handled by LabVIEW, and more efficiently.
  • None of your local variables are needed. Use wires.
  • Your sequence frames are not necessary. Dataflow, dataflow, dataflow.  Smiley Wink

 

 

0 Kudos
Message 5 of 14
(3,557 Views)

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.

 

It is possible that you created table 1..3 for the sole purpose of serving as local variables. I left them in for debugging purpose, but they could be deleted in the final program.
Message Edited by altenbach on 07-17-2009 09:00 AM
Download All
Message 6 of 14
(3,546 Views)

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.

 

Message Edited by altenbach on 07-17-2009 09:17 AM
Download All
Message 7 of 14
(3,535 Views)

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.

0 Kudos
Message 8 of 14
(3,524 Views)

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. 🙂

Message Edited by altenbach on 07-17-2009 11:33 AM
0 Kudos
Message 9 of 14
(3,511 Views)

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.

Message Edited by altenbach on 07-17-2009 11:42 AM
0 Kudos
Message 10 of 14
(3,503 Views)