LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Restarting counter in Timed Loop

I have a timed loop inside a state machine, used to start/stop a data acquisition sequence.

It works fine, but I'm monitoring the "i" count and Actual End [i-1] values and after the start/stop/start sequence

these values continue to grow and don't get reset to zero.  I would expect a While Loop to reset the "i"

variable every time is is called, but I don't see any option for resetting the time looped.

 

I can get around it, but I would expect a reset method for this loop, so I'm just wondering if I'm missing something.

Maybe I need to use "Create Timing Source" instead of the setting it iin the dialog box?

 

Labview 2010f1 on Windows Vista SP2 PC

 

0 Kudos
Message 1 of 10
(5,501 Views)

Hi,

 

Not sure why your Iteration Count ("i" terminal) is not resetting. If you stop a Timed Loop and then restart it, the iteration counter should reset just like a normal while loop does.

 

To have the "Actual End [i-1] values" reset you were on the right track - if you use a Create Timing Source.vi for the Timing Source, you can stop the created clock source when you exit the Timed Loop.

 

Check out the attached example in LV2009.

 

To use: Start the vi, then press Start Loop to start the Timed Loop. When you press Stop Loop, the Timed Loop will stop and display the values for the Iteration Counter and Actual End [i-1].

 

steve

 

 

----------------------------------------------------------------------------------------------------------------
Founding (and only) member of AUITA - the Anti UI Thread Association.
----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 2 of 10
(5,482 Views)

Okay, that's that works and does what I want.  Thanks, this solves my issue.

 

I've attached a modified version of your example to demonstrate the problem that I was having.

I expect that after a Timed Event is "Stopped" and then re-entered, that it will zero the iteration counter and timer.

At least this is the behavior for a normal "while loop", an example of which I've also attached.

 

I'll use the additional "Create Timing Source", "Stop Timed Structure", and "Clear Timing Source" Vi's to get around this.

Too bad you can use "Clear Timing Source" just on "Source Name", without having to Create a timing source first.

 

Download All
0 Kudos
Message 3 of 10
(5,473 Views)

In regard to your "timed loop interation.vi",...how does it work such that the name for the Stop Timed Structure.vi is "bob" and the name for the Create Timing Source.vi is "Clock", yet it still works, but if I change "bob" to "Clock", then it does not work.  Very odd.

 

 

0 Kudos
Message 4 of 10
(5,455 Views)

Sorry, I don't have LV2010 installed so I can't look at your example. If you save it for LV2009 I can check it out.

 

I think the reason that NI does not give you the ability to reset or disable the internal clock of a Timed Loop is to protect the user from hanging their application. If a timed loop is running and you stop the clock that drives it, how would it exit?

 

As far as the naming question ...

 

As long as the Timing Loop name and the Stop Timed Structure name match (and are unique) it should work.

The same goes for the Create Timing Source and Clear Timing Source vis (names must match).

 

So if you change the clock to "bob" and change BOTH the Timed Loop name AND the name for the Stop Timed Structure

to "clock" it should work.

 

steve

----------------------------------------------------------------------------------------------------------------
Founding (and only) member of AUITA - the Anti UI Thread Association.
----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 5 of 10
(5,436 Views)

>If a timed loop is running and you stop the clock that drives it, how would it exit?

    I would think that stopping the clock would exist all associated loops, but

    I guess that not how it works and that the clock running is separate from the loop active.

 

>As long as the Timing Loop name and the Stop Timed Structure name match (and are unique) it should work

 

That was the point I was trying to make about your example and the previous PNG image.

      http://forums.ni.com/ni/attachments/ni/170/549495/1/timed%20loop%20interations.vi

      http://forums.ni.com/ni/attachments/ni/170/549600/1/time%20loop%20interations.png

 

 The names don't match.  Your original "stop" name is "bob".  The "Loop" name is "Clock".

  I don't understand how THAT combination was successful.

 

LV2009 version attached

 

0 Kudos
Message 6 of 10
(5,429 Views)

This might help. Here is a part of the png file you posted. I put in "Structure Name>" to point to the Structure Name input. Notice that the name "bob" is listed as the Structure Name. You must be on Win7 which uses different fonts than XP - that's probably why the name is only half visible.

 

Note that the Clock name is connected to the (timing) Source Name input.

 

I'm attaching an updated version of the file with the Timing Loop name wired directly.

 

Copy of time loop interations.png

 

 

Thanks for posting your timed loop interations3 program in 2009. When I run this code, the Iteration Count DOES reset when the Timed Loop is restarted.

 

steve

----------------------------------------------------------------------------------------------------------------
Founding (and only) member of AUITA - the Anti UI Thread Association.
----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 7 of 10
(5,406 Views)

Ah, I completely over looked that "bob" text in the "Configure Time Loop" dialog and I use 125 DPI large fonts so that I can read the text on a 1400x1050 screen, but National Instruments doesn't adjust this particular text like they do their other text, which is why it wasn't obvious.  

 

So the Timing Source Name is seperate from the Timer Structure Name, so that you can use a single timer source in multiple location (for synch'ing), but only stop one of many timer structures that use that particular source.  Now I understand.  That's for the enlightenment.

 

 

0 Kudos
Message 8 of 10
(5,380 Views)

What's the appropriate method for wiring the Error through a Timed Loop.

 

If I add the Error wire to the previous example, restarting the Timed Loop Fails.

 

        Error -816 LabVIEW: Timed Structure aborted or attempted to execute another iteration of the following aborted Timed Loop. "bob".

 

Also, is there a way to change the <---> left/right, horizontal length of the Timed Loop Structure without changing the left/right dimension of every other item on the screen?  I've tried the alt and ctrl keys, but nothing seems to let me change the size without affecting everything else on the page.

 

With all these hassles with the timed loop, maybe it's easier just to use a normal While loop and put it in a VI with pumped up priority.

This has been more hassle than it is worth.

 

 

0 Kudos
Message 9 of 10
(5,371 Views)

I talked to NI Tech Support and they just said to trap and clear the -816 error, as shown below.

0 Kudos
Message 10 of 10
(5,351 Views)