LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to modify how the while loop operates

I'm trying to do something using a while loop. And the way I'm trying to do it is probably not the best, and that's probably why I keep running into these problems. Here's what I wanna do:

 

I'm collecting data using NI USB-6009 from some source and I'm putting that though a moving average. All this happens in a while loop for continuous acquisition of data. Then, say if the output of the moving average filter is greater than 5, I send a command to some other serial port which in turn affects how the data source is positioned. Hence, this action affects the incoming data. However, it takes some time for this affect to take place due to the moving average. I want to pause the while loop during this time, for some calculated number of seconds. I tried "Wait(ms)", but I couldn't get it to work. I'm not even sure where to place it, inside or outside of the while loop?

 

Secondly, after the while loop pauses, the moving average value doesn't change. When I restart taking data, if the current value is the same as what it was right before the while loop paused, then the loop will pause again, creating an infinite chain of pauses. So I also wish to reset the moving average data upon continuing the while loop. I have no idea how to do that. I'm attaching an incomplete version of my progress.

 

Again, this may not be the best way to do this. Since, I'm relatively new to Labview, I don't know what the best way to do these things is. Basically, I need to [[get some data, smooth the incoming data, process it, send some commands if necessary]], and loop the things in double brackets. Feel free to comment on the way I approach this problem and offer some alternative solutions.

 

Thanks!

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

OK, I just thought of this:

 

If the condition is satisfied, I can replace the output of the moving average with a bunch of zeros for as long as I want to pause the thing. It's technically not a pause, but it'll have the same effect. Do you think that's a good solution?

 

If so, I'm going to need help with that as well. I don't know how to feed a bunch of zeros into the comparison thing instead of the output of the moving average. how would I do that?

 

 

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

You aren't too far off.

 

Add this snip to your code on the error chain where you want to wait

21908i1252E5BCFF991E66


"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 8
(2,661 Views)

A simple Case would take care of delaying, doing something, and resetting the average value.  Only thing is that the average is one iteration behind the signal generation.  It has to be that way in order to reset the signal values.  False case has wires straight through.

 

21910iA3D8D3E61F5C575C

- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 8
(2,648 Views)

Jeff Bohrer,

 

 I did that and that brings me back to the second issue I wrote in my original post. When I do that, this is what happens: I get the data. Say that boolean is true; then the loop waits for 5 sec. Then it takes one more reading. That's not enough to change the moving average due to the delayed nature of a moving average. The boolean is still true and the wait is activated again. I don't want that. I want to start getting a fresh set of readings after the wait has been activated once.

 

I hope that explanation is clear. Any thoughts?

0 Kudos
Message 5 of 8
(2,645 Views)

I think I would do it like this so I do not get hung in the code.

 

21912i48174F813AB7C00A

Tim
GHSP
0 Kudos
Message 6 of 8
(2,640 Views)

aeastet,

 

I have Labview 8.6, so i can't open your attachment. Is it possible for you to save it in a format which I can open?

I wanted to see the file because I don't know what those "time reset" VIs are called. I'm talkin about the ones with the DBL symbol attached to them. I don't understand those either..

 

Thanks!

0 Kudos
Message 7 of 8
(2,616 Views)

here is 8.5 version.

Tim
GHSP
0 Kudos
Message 8 of 8
(2,607 Views)