LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Detect value change in a wire

Hi, this seems pretty trivial, but I cannot find a clean way to do it, and i couldn't find anything in the forums. I want to detect a change in the value in a wire coming out of a "Get timestring VI", from iteration to iteration, and I dont think event structures quite help, because they detect changes only in front panel controls. I prefer not to use shift registers because they bring in unnecessary clutter. Is there a cleaner way to do this?

 

Thanks!

0 Kudos
Message 1 of 16
(14,891 Views)

Use a shift register. It's only cluttered if you make it so.

0 Kudos
Message 2 of 16
(14,888 Views)

Hmmm...so is there really no other way to do it? I was really hoping not to use shift registers, but I guess you are right..I can try and make it look less cluttered. Thanks a lot.

0 Kudos
Message 3 of 16
(14,884 Views)

A feedback node is a little less clutter because it is more localized.

 

Here's the code to detect a change in a numeric, but it works with any datatype. Modify as needed.

 

Message 4 of 16
(14,878 Views)

@sharmishtha wrote:

Hmmm...so is there really no other way to do it? I was really hoping not to use shift registers, but I guess you are right..I can try and make it look less cluttered. Thanks a lot.


Just curious for why you are so opposed to it? Just picking your brain because maybe the real issue is the structure of the code, not the fact that you need to use shift registers themselves.

0 Kudos
Message 5 of 16
(14,863 Views)

Oh well, i want to detect this change within a sub-vi which already has a lot of shift register inputs for other purposes: mostly keeping track of counts and stuff, and all these shift registers eventually have to get their inputs from the caller VI because the subVi does not have a while loop as such; so I did not want to put in an extra pin on my subVI as there are multiple instances of it in my caller VI. 

 

Did that explain the scenario? Sorry if that sounded confusing..if you want I can attach my VI, but it is pretty complicated as it is, so I dont want to confuse you further just for this small thing. Anyway, the feedback node is pretty helpful though...

 

Thanks everyone for all the help!

0 Kudos
Message 6 of 16
(14,858 Views)

Well, Altenbach's images show how you can do it in a subVI without a while loop using a feedback node.

 

You can still put a while loop in the subVI and wire a True constant to its stop terminal.  The while loop will have uninitialized shift registers to store your count.  Now you've created a functional global variable where you can store the value of counters in the shift register internal to the subVI between calls of the subVI.

0 Kudos
Message 7 of 16
(14,853 Views)

One suggestion, If you have many counters and other stuff...why don't you use a cluster. Put all counters in it. Use bundle / unbundle functions as and when required.

You BD will be less confusing.Smiley Very Happy

 

Gaurav k
CLD Certified !!!!!
Do not forget to Mark solution and to give Kudo if problem is solved.
0 Kudos
Message 8 of 16
(14,850 Views)

Oh wow thanks so much, I'm glad you said that...that gets rid of so much "clutter" on my VI now..I had totally forgotten that an uninitialized shift register remembers its value from the last run! Thanks a ton! So, just to clarify: an uninitialized shift register can remember its value how much before? Like if you used it a day before, will it still remember the value?

 

Thanks again.

0 Kudos
Message 9 of 16
(14,848 Views)

Oh yeah, I should have done that...maaan I am such a LabVIEW noob!! 😞 Thanks for the suggestion though...

0 Kudos
Message 10 of 16
(14,844 Views)