LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dataflow, sequences, shift registers, and local variables

Ok I have a confession...for most of my LabVIEW career I have been an overuser of both sequences and local variables.  Slowly I have been going through some of my old code and trying to do things the right way, i.e., moving more towards shift registers and event structures.  One particular vi I that I made was a simple multiplot example.  I have seen many other examples on the forums dealing with this topic that are very well done.

 

In the interest of learner what I did wrong, I decided to post my code to see if some of you experts can pick it apart and show me how to do the same thing in one elegant frame 🙂

 

Regards,

 

-SS 



0 Kudos
Message 1 of 8
(3,542 Views)

Hi ShotSimon,

here is my solution for your vi.

Mike

Message 2 of 8
(3,532 Views)
Hi Mike & Simon,

I just prepared exactly the same example, but you were faster at uploading...


Message Edited by GerdW on 06-12-2008 04:08 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 8
(3,524 Views)

MikeS81,

 

Wow that was fast!  I guess I really have to change the way I think regarding LabVIEW programming.  GerdW was your solution identical?  It's one of those things after I see the solution it makes sense and it's easy...but before hand I honestly could not think of how to do it and not use a local variable 🙂

 

Do you think there is a considerable performance difference between my original code and the new code?

 

Thanks again for the quick response,

 

-SS



0 Kudos
Message 4 of 8
(3,508 Views)

Hi ShotSimon,

attached is the vi. Smiley Happy
So you can try it.

Mike

0 Kudos
Message 5 of 8
(3,503 Views)

Hello,

Well, I try to use the minimum as possible of local variables. See my idea.

Software developer
www.mcm-electronics.com





PORTUGAL
0 Kudos
Message 6 of 8
(3,501 Views)
Your original code is a typical example of what looks to be someone coming from a text programming background. Using local variables has a perfomance impact since the act of accessing the local variable causes a switch to the UI thread, which is slow. The program itself will eventually be slow even with the new implementation since you are always incrementing an array, requiring LabVIEW to shuffle memory to allow the array(s) to grow.
Message 7 of 8
(3,499 Views)
Hi Simon,

yes, my solution was identical (even the changed arrangement of the two stop buttons!).

Using less locals will make your code faster and use less memory - each local will create an additional memory buffer allocation...


Message Edited by GerdW on 06-12-2008 04:21 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 8
(3,495 Views)