キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

how to create event driven timer

Thanks for the great examples , everyone.
I just have some problems with the stopwatch vi which I modified and it would be great if you mike or anyone free can modify it.
I want my clock to stop and get reset to zero after every 20ms for which I made changes in the vi but it isn't working fine.
Attached is my vi for kind consideration,
Regards
0 件の賞賛
メッセージ11/56
5,985件の閲覧回数

You mean every 20s, not 20ms?

You should really use an event structure as in my example, because the button event will be much more accurate and you still don't need to spin the loop like crazy. Your stop button is not really hooked up at the moment, why not?

Why so complicated?

0 件の賞賛
メッセージ12/56
5,977件の閲覧回数
OK, here's a quick draft. Modify as needed.
 
0 件の賞賛
メッセージ13/56
5,969件の閲覧回数
Hi Thanks again for the reply,
Actually due to some complex code in my program every time I run my while loop in my attached vi. It takes different abount of time in ms(sometimes 750ms sometimes 760ms) so the time difference between the loops is different. How can I get that time difference known so that I can use it in my further processing in my while loop. Like if I could do present time and time of last iteration so that I can subtract both and get the time taken by present iteration. I tried adding element to my shift register but it says initialisation error.
Looking for help
Regards
0 件の賞賛
メッセージ14/56
5,960件の閲覧回数


@roiht wrote:
Hi Thanks again for the reply,
Actually due to some complex code in my program every time I run my while loop in my attached vi. It takes different abount of time in ms(sometimes 750ms sometimes 760ms) so the time difference between the loops is different.

I don't see anything that takes 750 or 760ms in the VI that you attached above. There is also only one loop so there cannot be a "difference between loops". It seems you attached the same old broken stopwatch monstrosity again.

Can you try to attach something more interesting? 🙂

0 件の賞賛
メッセージ15/56
5,946件の閲覧回数
Actually my code is a bit complex in my full vi and running on real time...so as you know it depends on the OS than... and thus I'm getting variable time differences everytime loop iterates. ....that's the problem and I wish to figure the time taken by everytime iteration which changes everytime....so attached the vi above . Could you please help me with that.




























0 件の賞賛
メッセージ16/56
5,936件の閲覧回数


@roiht wrote:
Actually my code is a bit complex in my full vi and running on real time...so as you know it depends on the OS than... and thus I'm getting variable time differences everytime loop iterates. ....that's the problem and I wish to figure the time taken by everytime iteration which changes everytime....so attached the vi above . Could you please help me with that.

Sorry, I cannot help because the VI you posted seems to have very little to do with the problem you just mentioned above.

You are talking about variable time differences per iteration, but the "stopwatch.vi" does not measure loop times, just the time between manual events. What kind of events are you measuring on your RT system? How are you measuring them?

So what do you actually want?

  1. If you want a loop that spins at a very regular rate, use a timed loop.
  2. If the loop time varies, it could be due to the fact that there are parallel loops that hog the CPU (especially if they don't contain a wait statement) and thus are starving the timed loop.
  3. It could also be that your loop contains many slow computations.
  4. Is there code that interacts with hardware?
  5. Maybe the loops actually spin very regularly, but your way of measuring the loop time is flawed?
  6. What else is running on the computer?

Do you actually need to see the timer progress, wasting time constantly updating the display, or is it sufficent to see the elapsed time once the timer stops? 

Message Edited by altenbach on 06-09-2007 09:43 AM

メッセージ17/56
5,928件の閲覧回数
Hello Everybody,

I am actually stuck in more or less same situation like rohit. Please find attached my vi. The place where you see pressure (a kind of regulator), I have a condition which I say when it is less than 0,03 and at the moment a shift register which is counter for 5 seconds and resetting always. When my pressure is less than 0,03 and the with respect to 5 sec of time has passed, I give a boolean signal to an array indexer and something funny happens afterwards. Likewise when the pressure remains more than 0,03 bar and 5 sec time has passed, I give a boolean signal. The program starts with array location 9 and depending on the value of pressure if it is more than 0,03 bar it goes in the negative array location (like 8, 7, 6 and so on) and depending on less than 0,03 bar it goes in the positive array location (like 10, 11, 12, 13 and so on).

At the moment the problem I have is (I thank Mr. Mikeporter, because I was not even this far with the timer before I posted this vi few hours ago), the timer is counting independent of the boolean output coming from the MORE THAN or LESS THAN conditioner for Pressure I have. Say, my pressure goes down to 0,03 bar, may be in this time, the timer has already counted upto 3 sec (or even 1 sec or even 4 sec), therefore the boolean operator to send signal to array indexer it takes just 2 secs. When I want this to be a exact no (in this case 5 sec) to have better control and better optimization possibility. So, I am looking for an option where I trigger a counter for 5 secs (it should count 5 secs and then reset back and it should continue counting till the pressure goes more or less than 0,03 again) when my boolean turns TRUE (from either the LESS THAN or MORE THAN condition) and it counts 5 secs, resets, counts, 5 secs till my boolean turns FALSE.
0 件の賞賛
メッセージ18/56
5,748件の閲覧回数
Sorry, you lost me there....
 
Can you go back to the diagram and add diagram comments to the various problem locations, describing the problem. It is easier for us to follow.
 
In the meantime, you can dramatically simplify your code. For example you have 24 different comparison operations and 1/4 mile of wire for no real purpose. Why don't you use an array of 24 false booleans and turn one of them to TRUE depending on the index number? You also don't need to invert the button if you set the termination condition to "stop if true". Do you really need to create the channel with every while loop iteration or could you do all that once outside the big loop?
 
Attached is a quick cleanup attempt (LabVIEW 8.2). I don't have DAQmx installed, so I took it out. Maybe you can add your problem description somewhere and reattach it again.
0 件の賞賛
メッセージ19/56
5,739件の閲覧回数
Dear Mr. Altenbach,

Please find attached the same vi with the required comments included in it.

Thanks once again for your assistance.

Jan
0 件の賞賛
メッセージ20/56
5,721件の閲覧回数