LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

State Machine - unexpected timing problem

Solved!
Go to solution

Hello - as usual, one problem gets solved another appears! I've built a simple State Machine to take a measurement for a user-defined period of time (X) and pause/wait for a user-defined period of time (Y) before taking another measurement. It works perfectly well if X>Y, but for some reason when X<Y, after the first pause it takes a single data-point every Y seconds. Any ideas appreciated, Cheers.

 

 

0 Kudos
Message 1 of 7
(2,971 Views)
Solution
Accepted by topic author RNG

Look closely. It isn't working in either case.

 

The issue is that it resets and counts your "wait time" as part of its "measurement time".  So put measure 10 sec, wait 9 sev and you will see that it only measures for 1 sec after the first measurement.

 

Unwire the auto reset on your timer function, and instead reset when i = 0.

0 Kudos
Message 2 of 7
(2,954 Views)

I don't have the LINX VI's but it appears that this program takes samples for the Sample Time (X) and then wait for Y amount of time due to the while loop in your measurement case.  Is it one sample you want or several?  The read vi is potentially called thousands of times per second in that delay loop. 

 

Also, the elapsed time Vi is set to auto reset, so it will have reset when Y>X.  You probably just want to use the reset control.

 

Without the measurement VIs I can't say how your instrument is configured, but usually you would configure the VI to take a measurement for sample time so that when you call a read, it takes as long as it needs to to return the sample.

 

 



This avatar was scraped from an instance of good public spending: http://apod.nasa.gov
0 Kudos
Message 3 of 7
(2,948 Views)

Thanks for the quick reply, I see the problem now - how does one reset when i = 0, though? The input for Reset only allows T or F constants...

0 Kudos
Message 4 of 7
(2,924 Views)

@RNG wrote:

Thanks for the quick reply, I see the problem now - how does one reset when i = 0, though? The input for Reset only allows T or F constants...


Oh come on. You can figure that out...

 

Spoiler
0 Kudos
Message 5 of 7
(2,914 Views)

Haha, I had that "end-of-day" confusion. That's it sorted, thanks very much!

0 Kudos
Message 6 of 7
(2,872 Views)

Thanks for the help qzerror as well.

0 Kudos
Message 7 of 7
(2,868 Views)