Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Ticker never stops

Solved!
Go to solution

Hi all! I'm some "months old" with LabVIEW and, obviously, I'm having some problems. After looking for at the forums I found no problem like mine so...

 

I think it's very important to say I didn't develop the actual vi. Someone did it but left the company and now, I have to "clean" it and make it work ASAP. I usually program using Objective-C and Assembler. Let's say LabVIEW is "slightly" different 😉

 

 

Just for explanation purposes let's say I have to send a signal to close a contact on a relay, check the voltage on the contacts and check again if it's physically closed. After all I have to measure how long it took.  To go through this process the vi is using two sequences on different case loops. On first case - first sequence there is a ticker to take the actual ms value, on last sequence - second case there is a second ticker to do the subtraction and give some ms as result. it is a very fast process; it usually takes no more than 20ms

 

The most of the times it works but very randomly, the second ticker looks like is never stopping. And, obviously, the subtraction is not working correctly.

 

First sequence - first caseLast sequence - second case

Maybe someone can tell me why is the ticker (I replaced them for the OpenG versions) never stopping! 😉

 

Thx for your time in advance!

 

BenRoura

0 Kudos
Message 1 of 15
(6,786 Views)

BenRoura,

 

When you say that it looks like the second "ticker" never stops, exactly what do you see? The Tick Count function returns one value each time it is called, so there is nothing to stop. Sequence structures are almost never needed in well-written LabVIEW code (although a one- or two- frame sequence structure can be used as in your left image).

 

The two images appear to be parts of different sequence structures. How are they related? Does one have a data dependency on the other?  The right image has a bit of a while loop border showing. What controls the loop?  Can you post the entire VI? is is difficult to troubleshoot a fragment of an image.  Think of someone posting 2/3 of the characters in lines 30-57 and 595-633 of your Assembler code.

 

Lynn

0 Kudos
Message 2 of 15
(6,774 Views)

Hi Johnsold,

 

First of all, thx for taking your time to answer my post. I'll try to clear all your questions.

 

To check the Ticker count I added two probes, one at each output from both tickers. The one on the left image "stops" (and yes, you're right, it's not the right verb) so I have an exact ms value. But the one on the right image is always  increasing its output value and therefore the subtraction is not done. 

 

I'm agree with you regarding the Sequence structures but, pls, notice that for a lot of people like me, coming from structured languages like C or Assembler, a Sequence is our last "hope" 'cause we're not used to the data flow programming language.

 

I admit it's not easy to debug a vi just with two images but I didn't want to post the complete mess I received from my former colleague. As I said, I must solve it and I'm not so experienced on LabVIEW... But, there it goes! Any, and I mean ANY, suggestion is welcome, for this VI or for the next coming ones.

 

Thanks again!

0 Kudos
Message 3 of 15
(6,766 Views)

Hi,

 

You have to take a look at the while loop.

In the lower right corner theres a stop condition which has a lot of logic connected to it.


Your timer doesnt "stop" because your program is stuck in that while loop and keeps calling all the functions in the loop (including the timer and all the subtractions).

 

 

Try running your program with the highlight mode enabled (lightbulb near the start button) this will show you in which order everything is executed.

 


Due to the dataflow model a function is not called twice on its own. I can assure you that the subtractions are also executed if the timer gets executed a 2nd time.

0 Kudos
Message 4 of 15
(6,758 Views)

Hi Felix,

thx for your answer.

I assume you're referring to this loop:

LV4.jpg

 

0 Kudos
Message 5 of 15
(6,747 Views)

Hi Felix,

thx for your answer.

I assume you're referring to this loop:

LV4.jpg

 

0 Kudos
Message 6 of 15
(6,743 Views)

Sorry, last two posts were cut...

 

"

The exit condition is based on two main conditions: All signals coming from 4 different inputs (read by AI Quali) must be bigger than 3,6 V and the time it took us to achieve them must be smaller than our desired IL Timeout. I also
tried to "force? the two outputthreads from For loop through the sequence to be 100% sure the thicker makes its calculations before the logical conditions are evaluated. But no success. Sometimes, a probe at the output of the ticker
will show a "never ending" count.
I'll keep looking for it...

"

Ben

0 Kudos
Message 7 of 15
(6,738 Views)
Solution
Accepted by BenRoura

structure.png

I tried to imply the order your loop gets executed.

It starts with the sequence. This sequence can’t be cancelled. This one will run through before anything else gets executed (1,2,3)

After this the functions outside the sequence will be executed (your logic).

 

So your ticker is getting called before the logic or the subtractions.

The data flow prohibits a function to be called before every input of a function has data (it will not use a default value)

 

Your loop is being called roughly about every ms (because of the wait+the execution time)

When you see the ticker increasing that is because the loop is being executed a second time. Not just the ticker - everything get called a 2nd time.

 

You can easily track that by using the highlight mode, as I explained above.

 

The ticker is not your problem; something in your logic is not stopping the loop.

 

 

I made you a short example that should make it easier for you to use the highlight mode to see in what order functions get executed

 

 

Message 8 of 15
(6,733 Views)

Hi Felix,

 

Now I understand what you mean. I'll try to test it on the real system to debug it with the highlight on and I'll come back to the forum.

 

But there's one thing I don't get...According to, let's say, "data flow rules", why is the loop (ant therefore the sequence and the ticker inside) called again if the exit condition wasn't yet evaluated? As I understood, the ticker is called a second time before the logic is executed. Am I right?

 

Thx again!

 

Ben

0 Kudos
Message 9 of 15
(6,730 Views)

Sorry, the ticker doesnt get called a 2nd time before the exit condition is evaluated.

It gets called again in the 2nd run of the entire loop.

 

There are no functions in LabVIEW that get executed a 2nd time, unless it sits in a loop. Then the entire loop is being executed again.

0 Kudos
Message 10 of 15
(6,725 Views)