xShadowDanx Posted April 25, 2009 Report Share Posted April 25, 2009 Download File:post-15220-1240543404.vi I got a vi that takes a temperature measurement once every second until i stop the vi. but instead of taking the measurement once every second, how can i change the code so that it take the measurement every 5 seconds ? my version- 7.1.1 (thanks in advance) Quote Link to comment
xShadowDanx Posted April 25, 2009 Author Report Share Posted April 25, 2009 oh thanks.. Quote Link to comment
xShadowDanx Posted May 9, 2009 Author Report Share Posted May 9, 2009 I ask about the question in the earlier post is a vi that takes a fixed period of temperature measurement .. How can i actually take the measurement accordingly to the period adjustment? For eg. I create 1 more control which is the period(seconds)..and then i want to save the measurement accordingly to how many seconds i want and then it will automatically save. Can it work if i do that? Quote Link to comment
Tim_S Posted May 9, 2009 Report Share Posted May 9, 2009 QUOTE (xShadowDanx @ May 7 2009, 10:56 PM) How can i actually take the measurement accordingly to the period adjustment? For eg. I create 1 more control which is the period(seconds)..and then i want to save the measurement accordingly to how many seconds i want and then it will automatically save. Can it work if i do that? You can wire a control that contains the milliseconds to delay to the Wait primitive. You could also have a control that has seconds (which more operators understand) and then multiply by 1000 to get milliseconds. Tim Quote Link to comment
xShadowDanx Posted May 13, 2009 Author Report Share Posted May 13, 2009 Hmm, i tried creating the period control using the Wait vi but still nothing happen. In fact now the Start Button auto run by itself without me even pressing on it.. do i need to put a loop too? Quote Link to comment
GregFreeman Posted May 23, 2009 Report Share Posted May 23, 2009 QUOTE (xShadowDanx @ May 12 2009, 09:39 AM) Hmm, i tried creating the period control using the Wait vi but still nothing happen. In fact now the Start Button auto run by itself without me even pressing on it.. do i need to put a loop too? I haven't looked at your VI, I don't have Labview on here. However, using a wait doesn't seem like a good way to do this. If you want to stop your program and you press stop, you may have to wait up to 5 seconds for your program to end. Why not use a elapsed timer.vi and wire the time has elapsed booleanto a case structure. Inside the true case put all your data taking proceedures. QUOTE (Tim_S @ May 8 2009, 01:46 PM) You can wire a control that contains the milliseconds to delay to the Wait primitive. You could also have a control that has seconds (which more operators understand) and then multiply by 1000 to get milliseconds. Tim I got your code open. I have attached a simple example of how you can take data every 5 seconds. I would say though that there is some bad code in yours. Why do you have error, wired to a not, wired to continue while true? Why not just wire the error status to a stop if true? Rube Goldberg code. Also, how are you stopping your program? Does it just run until there is an error? You should wire a stop control and the error to an OR then wire that result to the stop sign of the while loop. It looks like you are using the abort on the front panel to stop which is a no-no. Anyways, here you go using an xy graph. Little messy but you should get the idea. You can change the 5 constant to a control to change how often the data is taken. If you want to write to a file you would also put that in the true case. Quote Link to comment
peteski Posted May 23, 2009 Report Share Posted May 23, 2009 QUOTE (for(imstuck) @ May 21 2009, 07:07 PM) Why do you have error, wired to a not, wired to continue while true? Just a little bit of trivia, way back in the dark ages, like before LabVIEW had the "Undo" feature, this is the only way "while loops" worked. I wonder if this example has some old heritage to it? -Pete Liiva Quote Link to comment
GregFreeman Posted May 23, 2009 Report Share Posted May 23, 2009 QUOTE (peteski @ May 22 2009, 02:38 PM) Just a little bit of trivia, way back in the dark ages, like before LabVIEW had the "Undo" feature, this is the only way "while loops" worked. I wonder if this example has some old heritage to it?-Pete Liiva Haha, the funny thing is I posted this on the NI forums as an example of rube goldberg and got the same response! How could i have known, im only 22 lol. Quote Link to comment
peteski Posted May 23, 2009 Report Share Posted May 23, 2009 QUOTE (for(imstuck) @ May 22 2009, 11:08 AM) Haha, the funny thing is I posted this on the NI forums as an example of rube goldberg and got the same response! How could i have known, im only 22 lol. No worries! Dang... I was 25 when I first started to use LabVIEW, so in one way of looking at it you have a head start on me! -Pete Liiva Quote Link to comment
GregFreeman Posted May 23, 2009 Report Share Posted May 23, 2009 QUOTE (peteski @ May 22 2009, 04:15 PM) No worries! Dang... I was 25 when I first started to use LabVIEW, so in one way of looking at it you have a head start on me! -Pete Liiva However, back to the most important point...setting a wait for next ms multiple to 5000 ms is not a good way to control how often you take data, as it will cause you a considerable wait time when trying to stop the program . I learned this the hard way in the first program i did when i wanted to take data every 120 seconds lol Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.