LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Occur only once when it's true

Solved!
Go to solution

Hi,

 

I know my title is quite similar to other one, but I've almost read all the post about this, tried the several methods suggested in the other post, but I don't succed to solve my problem, in each way, the same problem happens.

 

I've got a condition "In the fly in the area" which send "True or False".
What I would like, is each time it enters the area, so it goes to false from true (or opposite), it adds +1. (If it counts also +1 when it goes outside the area, it's not a problem, I can divide by 2 then round. 

 

So here is what I did :

 

Fly On Area : Yes/No

 

With this code, when the fly is on the area, nothing happens ==> good

When the fly join the area (condition is true), it adds +1, then again +1, again +1 all the time the fly is on the area so it goes to something like 10-100 while it should stay at 1. Then if it enters again, going to 2.

What I would like, is that it only add +1 ONCE it's true, and I really don't understand what I'm doing wrong.

 

Thank you very much.

Sébastien.

0 Kudos
Message 1 of 8
(2,818 Views)

I am noticing an output tunnel on your case structure is set to Use Default If Unwired.  I'm guessing there's a case where that guy isn't wired and the TRUE in your shift register is being changed to FALSE (the default for a Boolean).  Change the configuration of that tunnel and link it to the input tunnel.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 8
(2,813 Views)

I'm not exactly sure this is your solution but I think it will help.  It sounds like you want an edge detection, when the state goes from low to high or high to low.  This VI does this function:  <vi.lib>\ptbypt\Other Functions.llb\Boolean Crossing PtByPt.vi

 

Additionally OpenG has one that is a little easier to understand.  OpenG also has a Value Change? function that accepts any data type and will be True if it changed from the last time it was called.

Message 3 of 8
(2,811 Views)

Just in case you don't know where to start with OpenG and this daunts you, find the useful VI attach to this post.  You should take some time in the future to install "OpenG" by starting with VIPM (free and very useful).

 

Take some time to understand the VI and you can look up "Functional globals" and "Reentrant VI".

0 Kudos
Message 4 of 8
(2,802 Views)

Thank you for your help.

 

@crosszulz : I set it to "Use default if unwired" because I don't know what I can do differently.

I'm quite new to LabView, and I don't exactly get what you mean.

How do I change the input tunnel and to what should I change it?

 

Because I have like 10 case structures, and I don't want to have to set it for each of them, so I did that "Use default if unwired".

 

@Hooovahh & OliverL : Thank you for your advice, I'll check this tomorrow when I'm back at work.

0 Kudos
Message 5 of 8
(2,795 Views)
Solution
Accepted by topic author Zepiii

This is what I mean.  If you right-click on the tunnel, there's a menu to link the tunnel to another.  You need to keep your status through all of the cases.  So they need to have the value wired through.  If you link the tunnels, then when you create a new case the vlue will automagically be wired through.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 8
(2,782 Views)

Another random thought.  If this is the only place you care about the previous value with, change the shift register into a Feedback Node.  The feedback node can just be in the one case you care about.  No more need to wire all of the other cases up.

See here for an example of what I mean: http://forums.ni.com/t5/LabVIEW/Counting-only-once-when-a-case-structure-is-true-in-a-while-loop/m-p...


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 8
(2,779 Views)

Dear crossrulz,

 

Thank you very much,

You solved my problem !

 

Kudos for you 🙂

0 Kudos
Message 8 of 8
(2,746 Views)