LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Draw Multiple Line for Large data

Solved!
Go to solution

Thank you Altenbach, Ben, and Bob Schor for your contributions.

 

  1. When I changed the linewidth from 2 to 1, the data was drawn much faster and the VI did not crash.
  2. I modified the Draw multiple line VI to the Draw Point VI, and it successfully drew all the data without any issues.
  3. By drawing the data in smaller chunks, I was able to avoid memory issues with a line width of 2.
  4. Unfortunately, setting Defer front panel updates did not help resolve the issue.

My objective is to obtain data from a DAQ and exhibit it in a picture control. The process works smoothly when I continuously draw the data from the DAQ buffer in the picture control. However, when I attempt to load the complete data from a file into the picture control, it consumes a substantial amount of memory. I am striving to achieve a similar outcome as the pen plotter application. In this application, there is a predefined template that includes axis scales, notes, annotations, limit lines and images. My goal is to draw the acquired data within this predefined template.

 

Find the Template and update vi attached

Balaji PK (CLA)
Ever tried. Ever failed. No matter. Try again. Fail again. Fail better

Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.
0 Kudos
Message 11 of 33
(661 Views)

I haven't looked at the code other than the screenshot, which doesn't show using the template picture. Here are a couple of directions which may help you:

 

  1. Use an XY graph. Set your template as the background image (using the Plot Images.Back property) and draw on top of that as a graph. The graph has methods for converting from XY to pixels. This can work if you know how your template is built (which you probably need to anyway).
  2. The picture datatype is a list of opcodes for how to draw and the picture VIs manipulate that list. It might be possible for you to do it more efficiently (see here, for example), although a long list of commands will probably still be hard for the picture control to render.
  3. You could try to use a .NET picture to display this, which might be more performant. The code for interacting with it is usually not as clean.
  4. You could probably try calculating the pixel values yourself and update the 2D array of pixels directly, but I doubt that's worth it.

___________________
Try to take over the world!
Message 12 of 33
(629 Views)

Hello, Balaji.

 

     Your signature says it all.  You have gotten consistent advice that the Picture Control is (spectacularly) not suited for the task you want to give it.  But you persist, and fail.  I can only hope (for your sake) you are your own boss.  I hope you resolve your difficulties to your satisfaction.

 

Bob Schor

Message 13 of 33
(616 Views)
Solution
Accepted by topic author Baji

 

I made a test case to evaluate the picture control performance.

 

I acquired data from my DAQ module at the rate of 1 KHz and continuously plotted the data in the picture control for around 30 minutes (1200000 samples), I didnt faced any performance issues. I recorded the data stream and loaded the recorded data into the picture control and I dont face any performance issues, after I changed the line width and plotting in chunks.

 

Perviously I tried with 45 seconds data (45000 samples) and it crashed.

 

I attached the data plot

 

 

Balaji PK (CLA)
Ever tried. Ever failed. No matter. Try again. Fail again. Fail better

Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.
0 Kudos
Message 14 of 33
(599 Views)

Thank you for your interesting statistics.  Just for fun, I generated one million points that created a circular ring by plotting r exp(i theta), where r was a random dbl between 250 and 300 and theta was another random dbl between 0 and 2 pi.  The whole thing, generating and plotting 1 million points on an XY graph (using the really tiny dot symbol) took 0.12 seconds.  It did not hang up anything.  If I plotted lines instead of points, it went a little faster.  But that was just a single test of each. 

 

So I tried a billion points!  Oops, memory is full.  But 10 million takes (as one might expect) about a second.

 

Bob Schor

Message 15 of 33
(585 Views)

Note that the picture control's line width makes a huge difference.

 

In your original VI, 30000 lines with 2 pixel width actually messes up my system. 50000 lines at 1 pixel is no problem.

 

This is a GDI problem, so there's not much LabVIEW can do about it. 

 

See: Simple graphics bring LV to it's knees - NI Community  (TL;DR: Lines with width >1 are apparently drawn as polygons. )

Also mentioned here: Solved: Draw picture slow down - NI Community

 

I have applications where I draw multiple 1 pixel lines, as that's still faster than one 2 pixel line.

 

And of course, implementing your own Bresenham’s Line Generation Algorithm - GeeksforGeeks is a lot of fun! Takes me back to the '90's 👴.

0 Kudos
Message 16 of 33
(566 Views)

The Draw multiple lines have some strange code in it, i assume at some time Array size had an I16 as output and the rearraging loop can at least be parellellized, if not simplified with a Word switch.

 

All that is moot though, as simply plotting in an XY graph is very fast and easy and you can inject the full array without issue.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 17 of 33
(535 Views)

Strange!

I wanted to mess with the VI so i saved a copy and it's instant! Somehow the LLB causes issues? Or just the recompile did it?

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 18 of 33
(530 Views)

Ok, so i just resaved the VI outside the LLB and removed the unnessecary I32 convertions and now i can do a Plot All in 17ms!

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 19 of 33
(525 Views)

@Yamaeda wrote:

Ok, so i just resaved the VI outside the LLB and removed the unnessecary I32 convertions and now i can do a Plot All in 17ms!


With a line width of 2 and 40000 coordinates, this still completely ruins my entire PC, to a point even the mouse pointer isn't moving.

 

It's the GDI bug...

0 Kudos
Message 20 of 33
(520 Views)