05-18-2012 12:01 PM
I have a program that plots multiple functions onto the same XY plot, and then uses the Export Image node to save the file to a .bmp.
The program was made to accomodate plots anywhere from a single function to 4 functions at once, so after each successive run, it asks the user to overwrite the previous save file as more charts build up.
The problem is that the save file always seems to be a step behind.
After the first run, the save file is blank, though the legend indicates there should be a single plot.
After the second run, the save file shows only 1 plot, with the 2 correct plot names in the legend.
After the 3rd run, the save shows only 2 plots, with the 3 correct plot names in the legend.
etc.
I thought it was a race condition I was having a problem with, so I threw in the flat sequence to try and force it to execute in the correct order, but no dice (originally there was no flat sequence at the end).
It's a big program, and a little bit of a mess, but really its only the stuff in the flat sequence that is the problem, as the export image seems to be reading the image before the graph is plotted (and even asks me if I want to overwrite the previous file BEFORE the new plot shows up on the chart in labview, even with the flat sequence structure).
Final note: yes there are local variables, I know that is like kryptonite to some of you out there, but please don't yell at me for using them unless it is the Sound Response Plot local and only if it is the cause of my problem. The active plot and the weighting locals are just fine.
05-18-2012 12:19 PM
@LarsUlrich wrote:
...Final note: yes there are local variables, I know that is like kryptonite to some of you out there, but please don't yell at me for using them unless it is the Sound Response Plot local and only if it is the cause of my problem. The active plot and the weighting locals are just fine.
Damn the kryptonite, I'll give it a go.
If you are updating the graph in the sub-VI with the ref wired to it (bottom left Edit graph?) then I would ask you to plese check (can't tell exactly with the image I was) if there is actual data dependacies between that code and where the invoke node is. It alomost looks like there is none and that sub-VI can run in parallel with the other code.
If you have data dependacy then it may be an issue with the graph just not being updated yet (they can be delayed if the UI thread is busy etc).
There have also been bugs relate to graphs not updating. For those bugs the "Jiggle the handle" approach sometimes helps.
"Jiggle the handle"
when upding a graph do the following
Defer FP updates (stops FP redraws)
set graph hidden
Apply update
Set graph visable
Undefer FP updates.
That's all I can offer at the moment.
Is it just me or is anyone else feeling hot?
Gotta run,
Ben
05-18-2012 12:29 PM
Lol Ben, nice pic.
The bottom left "Edit Plot" sub.vi doesn't do anything except for change some cosmetics of the XY plot.
It creates a caption, updates and sizes the legend, changes the colors, that kind of thing.
It is the first frame of the flat sequence structure that actually puts all of the data onto the chart itself.
With that said I'm not sure how the data dependency thing works out.
05-18-2012 12:35 PM
Pretend I am dense today.
I simply do not see the data being presented to the graph.
Data dependency...
Trace the wire from where the dat is presented to where you are getting the image and make sure the dat is posted before the invoke node.
Ben
05-18-2012 12:44 PM
http://forums.ni.com/t5/LabVIEW/XY-graph-help/m-p/1993919#M657215
I actually had a lot of trouble getting the graph to work in the first place. The thread above is where I figured it out in the context of a much smaller and less cluttered program.
Also, attached below is the same image as before, though I boxed them out in red. The first big red box contains the 2 data arrays, the top on is of frequencies (the x-coordinate) and the bottom is amplitude (the y coordinate). They are passed through the shift register and combined to a cluster.
Actually, I think I may see my problem.
After it is passed to the cluster, it is combined to the local variable in the 2nd red box... but now I don't think that is where the graph updates... now I think the graph updates with the FINAL local variable in the 3rd, right most red box... which IS after the invoke node.
Would not have noticed that if I didn't have to explain it to you.
Sounds right?
05-18-2012 12:49 PM
@LarsUlrich wrote:
http://forums.ni.com/t5/LabVIEW/XY-graph-help/m-p/1993919#M657215
I actually had a lot of trouble getting the graph to work in the first place. The thread above is where I figured it out in the context of a much smaller and less cluttered program.
Also, attached below is the same image as before, though I boxed them out in red. The first big red box contains the 2 data arrays, the top on is of frequencies (the x-coordinate) and the bottom is amplitude (the y coordinate). They are passed through the shift register and combined to a cluster.
Actually, I think I may see my problem.
After it is passed to the cluster, it is combined to the local variable in the 2nd red box... but now I don't think that is where the graph updates... now I think the graph updates with the FINAL local variable in the 3rd, right most red box... which IS after the invoke node.
Would not have noticed that if I didn't have to explain it to you.
Sounds right?
Sometimes all it takes is to try and explain it outloud.
I think you got it.
Ben