04-28-2012 12:16 PM
So I'm trying to compare two values, precisely numeric values generated by two different infinitely looped structures. I want to compare each of them everytime the loop executes (i.e infinitely) and then generate another output after the comparision, but I dont know how it should be done. I'm still novice to LabVIEW, so any help would be appreciated. Thank you very much.
04-28-2012 02:24 PM
04-28-2012 04:47 PM
Hi Sanjog,
From your description, there may be an easier way to solve your problem.
You seem to need to run the two loops in sync, so why not put them into one loop?
For example:
Each of your "loops" would run once for each iteration.
Just remove the looping structure from your two loops (or set them to only iterate one time).
steve
04-28-2012 05:08 PM
@Sanjog wrote:
So I'm trying to compare two values, precisely numeric values generated by two different infinitely looped structures. I want to compare each of them everytime the loop executes (i.e infinitely) and then generate another output after the comparision, but I dont know how it should be done. I'm still novice to LabVIEW, so any help would be appreciated. Thank you very much.
Since the two loops presumably run independently and at their own rate, it is not clear what kind of output you want and how ofter a comparison should be made and an output generated. Your statement only makes sense if the loops are synchronized, else there are many possible unpredictable scenarios.
You could synchronize the output to one of the loops and blindly compare with the current value from the other loop via a local variable.
Instead of specifying the problem by "operations", please explain what the program exactly does, why there are two loop, where the data comes from, and where the output is going.
Are these DAQ measurement? A control application? Simple logging?
04-28-2012 07:24 PM
04-29-2012 12:01 PM
You have a race condition between when the notifiers are fired, and when the local variables are read. Why don't you use the value that is in the notification rather than the local variable?
04-29-2012 12:09 PM - edited 04-29-2012 12:10 PM
I don't get it.
Why the local variables? What are you using the U32 notifiers for, exactly? You send a notification containing a U32 number from each of your top two loops, receive those notifications in the bottom loop, but then read and compare a couple of local variables instead of reading/comparing the data coming from the notifiers? If you're not going to use the data you send via the notifiers, why did you go to the trouble of including them? You're going to wind up with a race condition.
There's obviously some part of your solution that I don't understand. Use either the notifiers to transfer data (my preferred way of doing things), or the locals to transfer data. Not both.
If you get rid of the locals and instead compare the data transferred via the U32 notifiers, I'd say you had a pretty good solution.
04-29-2012 12:34 PM
I agree that this code is very convoluted and probably not suitable in general. Due to the two-way dependence of all three notifiers, the slowest loop will determine the rate of all others, which would seriously interfere with e.g. DAQ. There are too many loops trying to be master.
04-29-2012 02:16 PM - edited 04-29-2012 02:23 PM
my last version
try it, it works 100%
i use U32 notifiers
no loop trying to be master ... just like a flip/flop between (A-B) and C (sorry for my bad english)
now, no race condition.
04-29-2012 02:31 PM - edited 04-29-2012 02:34 PM