NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Knight of NI
altenbach
Posts: 23,141

Update, update!

[ Edited ]
Interesting constructs found in:
 
(A) Here we spin a loop at double-speed doing nothing but writing local variables to their own terminal (Reminds me of C programming). :smileywink: The LabVIEW equivalent of a short circuit! If we would delete that loop and delete all the local variables in it, nothing (nothing!!!) would change (except better performance and cleaner diagram).
(B) Here we spin a loop updating a chart every 500ms. If we would eliminate that loop and place the bundle in the other loop at (C), it would update at the same rate, exactly!.
(C) See (B)
(D) Since we have all these extra loops, we cannot use a latch action boolean, so let's do something funky! Interestingly, the actual stop button wire is not even used anywhere.
 
All the big loops needs is a few shift registers containg arrays.
 
 
 
 

Message Edited by altenbach on 09-17-2007 05:41 PM


LabVIEW Champion . Do more with less code and in less time .

Active Participant
Gabi1
Posts: 634

Re: Update, update!

that one is a beauty :smileyhappy:

isnt it there a very bad race condition in (C), (values in the case structure vs out)

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
Knight of NI
altenbach
Posts: 23,141

Re: Update, update!

Yes, the "tanks" should be in shift registers and the chart outside the case if it should get updated even if there is no new data (functionality of the original code)
 
Not really a race condition, though (if I understand you right). We have only a single writer in the main loop and the chart is simply asynchronous. Things will be in the right order in all cases. :smileywink:

LabVIEW Champion . Do more with less code and in less time .

Active Participant
Gabi1
Posts: 634

Re: Update, update!

i was assuming the other cases also has same locals, with different inputs. i played long ago with similar configuration, (LV5 tough), and found out that depending on the case chosen ( and actually the position of the locals within the cases :smileyhappy: ), the write would be before or after the read just after the case structure. that would totally destroy the order (altough keep a pattern :smileyvery-happy: ).
maybe i will try that again...
-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
Knight of NI
altenbach
Posts: 23,141

Re: Update, update!



Gabi1 wrote:

isnt it there a very bad race condition in (C), (values in the case structure vs out)


Ah, now I see it! I thought you were talking about the big case structure.!

Yes, you are absolutely correct. :smileyhappy: There is no guarantee that these green locals going to the subVI are read after they get updated in the small case structure. Most likely, they get read even before the small case executes, thus calling the subVI with stale values. :smileyhappy:


LabVIEW Champion . Do more with less code and in less time .

Knight of NI
altenbach
Posts: 23,141

Concatenate an array of strings

[ Edited ]

(Adapted from: http://forums.ni.com/ni/board/message?board.id=170&message.id=273436#M273436)

There are many ways to concatenate the elements of a string array.

  1. Some involve FOR loops, an initialized shift register and other trimmings.
  2. Some just use a simple atomic operation. :smileyhappy:

Message Edited by altenbach on 09-21-2007 11:27 AM


LabVIEW Champion . Do more with less code and in less time .

Active Participant
Gabi1
Posts: 634

Re: Concatenate an array of strings

[ Edited ]

i did not expect to see that one!

remark, one could have understood the dynamic to double to dynamic, as a result of several iterations of testing, but the double to double ?

edit: source thread

Message Edited by Gabi1 on 09-28-2007 05:14 PM

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
Knight of NI
RavensFan
Posts: 13,414

Crazy Concatenation and the alternative

Trusted Enthusiast
LV_Pro
Posts: 2,820

Re: Rube Goldberg Code

One very late night of coding, several years ago, having had the program "blow up" several times during testing, I created an icon for the top level vi that was a picture of the U.S.S. Maine on a fateful night in Havana harbor.  It is probably still there (the icon). 
Putnam Monroe
Certified LabVIEW Developer

Senior Test Engineer
Currently using LV 6.1-LabVIEW 2012, RT8.5


LabVIEW Champion



Knight of NI
Posts: 18,064

Re: Rube Goldberg Code

[ Edited ]
The hard way to negate:


From http://forums.ni.com/ni/board/message?board.id=170&message.id=277103#M277103

Message Edited by smercurio_fc on 10-10-2007 12:01 PM

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page