LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I use a timer without User Interface

I would like to know that in CVI8.0, can I use a Timer (also can start & stop it) without an User Interface ? Please provide an example (or links) if possible!
 
Thanks
0 Kudos
Message 1 of 7
(4,181 Views)
The standard cvi timer requires a panel handle so you really can not use it without some form of user interface (at least a hidden panel).  A windows async timer will work, look under help>>find examples and search for timer.  Select the asyncdemo project for an example of how to setup and use a windows async timer.  The async timers run in a separate thread which can be a good thing, or can complicate data movement depending on your programs design.

Message Edited by mvr on 01-04-2007 07:58 AM

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

Thanks for the explaination, I did take a look and it is good. However, what the differences if I call t_start = Timer() to start & t_stop = Timer()? Is it better or worse comparing with using Async. timer (regardless the Timer is never stop)?

Many thanks

0 Kudos
Message 3 of 7
(4,148 Views)
Are you trying to use a timer control or the function Timer()?
If you call the CVI RunUserInterface() function I would think that you could get Timer() to work the way you want.  The windows async timer acts a lot like a timer control.  It has a callback that is executed at the interval you specify.  You can suspend the timer callback if needed.   I believe it is a much higher resolution timer than the native CVI timer control. 
If you are trying to use the function Timer() without running the CVI RunUserInterface() you might want to look at the ansi function clock().  This returns the number of "ticks" that have elapsed since you program started.  It is not a high resolution timer but works well for most applications.   Use the value CLOCKS_PER_SEC to convert between seconds and ticks.  If the resolution is not high enough you should look at the windows high resolution timers (information can be found on the microsoft site), but unless you are targeting this application for a realtime OS they are probably overkill.

Message Edited by mvr on 01-04-2007 11:23 AM

0 Kudos
Message 4 of 7
(4,143 Views)

Thanks again,

1. I did use Timer() without using User Interface and it works!

2. I aslo try clock() as you suggested, it is also work!

*) What happen if I use the program 24-hour operation? Can the clock()  be over-lap? What you suggest (between the two)? 

Note: In CVI8.0 Library/ANSI_C ... why it does not include all ansi_c functions (ie: Timer(), clock() ...) ?

Thanks again

0 Kudos
Message 5 of 7
(4,137 Views)

clock() can be used for multiple days, I think the rollover for clock is around 49 days.  For handling really long time periods you can look at the ansi time() or other c functions may be more useful.  See this link for a list: http://www-ccs.ucsd.edu/c/time.html

#include <ansi_c.h> should get you access to all the ansi c functions from CVI.  Timer() is not an ansi function it is a CVI function.

0 Kudos
Message 6 of 7
(4,131 Views)
It is very clear to me now, thanks for being patient & helps Smiley Happy
0 Kudos
Message 7 of 7
(4,127 Views)