LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically detect a value change event

Sorry to be a pain but there is a bug with your implementation. It will fire once when changing to 6 but when he goes back down to 5 and then to 6 it is not captured as the 6 remains in the shift register, 5 to 6 is only ever captured once. He actually implements what you are trying to do in his example at the top also but using a boolean through a shift register.

 

Rgs,

 

Lucither.

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 11 of 21
(2,694 Views)

Hi Lucither,

No need to say sorry. I accept what you are saying. Actually I was lazy enough to not check each possibility.

This will definitely take into consideration the point you mentioned.

Let me know if you find any bug in this.Smiley Wink

Gaurav k
CLD Certified !!!!!
Do not forget to Mark solution and to give Kudo if problem is solved.
Message 12 of 21
(2,686 Views)

Thats better, if we look at the original post though the OP appears to only want to enter the TRUE case when going from less or equal 5 to greater than 5 and back. At the moment every value you enter that is different but greater then 5 will trigger the TRUE case. for example, if he recieves: 4 then 5,6,7,8, he only wants to trigger true once, not 3 times. I have attached an example of what i think he needs:

 

Transition snippet.png

 

The Small vi inbetween the output from the greater than function and the case structure is:

 

Transition pulse vi.png

 

 

 

Is basically a small vi that will give a single pulse on a transition from TRUE to FALSE and visa versa. I personally prefer making these small vi's rather then having the shift registers and logic in the main loop. Seems cleaner.

 

Rgs,

 

Lucither.

 

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
Message 13 of 21
(2,670 Views)

With all respect, Lucither its not about entering true or false case. It is about triggering event using value signaling event.

It does not matter if it happens in true case or false case.

According to the author he wants to trigger event when "data (x) changes and it is greater than 5."

so if he receives 6..7..8 it will trigger event thrice.

This is what I think. Now just have to wait for Fibo's reply.

 

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

Ok, we will agree to disagree Smiley Tongue

 

If you look at his code though he actually has implemented himself what he needs, to trigger the event when the value go's higher or lower. In his event case all he is doing is flagging 'Larger' or 'Smaller', he does not need to constantly update 'Larger' each time a larger value comes in like your code would do, this is completely unnecessary. The main crux of his problem is not how to trigger this event (which, again, he has managed actually more efficiently then your version as he is only catching the event on the transitions), but how to do it without the need of polling in the event structure loop. Which is why I posted my suggestion on having a separate loop for his DAQ reading. The only reason i posted the code to capture the transition is because Fibo could use this in his DAQ loop to trigger the user event.

 

But you could be right, would definitely not be the first time I'm wrong Smiley Very Happy 

 

Rgs,

 

Lucither.

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
Message 15 of 21
(2,657 Views)

It is good to argue sometimes Smiley Happy..But ultimately author should get what is required.

Because there can me number of solutions to one problems..Or number of ways to code.

I am not questioning about your post of separate daq loop. But sometimes Authors don't like to code again.

They just need temporary solution which they can implement and just complete the assignment. (Specially new users)

Yours is example of good programming practice which he should implement for sure.

But we don't know if he has that much time.

 

May be I would want to know views of author..who has left us for fighting on our posts...Smiley Very Happy

 

Gaurav k
CLD Certified !!!!!
Do not forget to Mark solution and to give Kudo if problem is solved.
0 Kudos
Message 16 of 21
(2,649 Views)
0 Kudos
Message 17 of 21
(2,629 Views)

LabOOP,

 

Your vi will only work when x is changed via a user input, ie entering a value into the control. It needs to update programatically. If you change it so x updates programatically then you will have the original problem of x value change event being constantly updated. Also you are simply firing another event from inside an event, in that case you may as well put the logic in the second event in the first event.

 

Rgs,

 

Lucither.

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 18 of 21
(2,623 Views)

Thanks for all the replys

 

The code I posted here was just to illustrate how I'm triggering my event, but I really don't care about something being larger or smaller than 5, I just threw that in there so I could have the event case do something.

 

Lucither, I've never used two while loops with one while loop triggering events and the other handling events, this looks like it may be promising and I will look into the code you posted.  Thanks.

 

I've never used, user events, queues, or producer/consumer templates.... these are the things I'm looking into to see if something can do what I'm trying to do.

 

much thanks.

0 Kudos
Message 19 of 21
(2,596 Views)

Might be a bit complex to begin with, but I discussed User Events for communication between loops in this nugget of mine.

I suggest you to start a bit simpler than above framwork.

Also note that my nugget on producer/consumer is discussing some advanced issues, and doesn't cover the basic design of producer/consumer. There are some technical papers by NI (search for design patterns) that cover the basic design.

 

Felix

0 Kudos
Message 20 of 21
(2,588 Views)