07-30-2006 01:00 PM
07-30-2006 01:17 PM
07-30-2006 08:16 PM
05-06-2008 12:24 PM
05-07-2008 01:14 PM
I've run into the same issue with CVI's Async Timers.
The timers seem to be "serviced" in order and there is a 16 timer limit as mentioned before. No timers are freed or changed until the end of the "service loop". (so far as I can tell). When you change the interval on a timer (I think) a new timer is created and requires 1 more timer "resource" to be free (of the 16 available). The same is true if you create a new timer from within a Timer. I had an application that used to use "one shot" Async Timers that would each start a new "One Shot" timer from within their callback. When you do this, you are essentially limited to 8 Timers since each Timer, needs another timer slot free in order to start the new one. (by either creating one or changing the timer interval)
If you will always be running on Windows, I suggest you look into the Timing functions in the Windows SDK. They are much more powerful and don't have any arbitrary limits. The non-intuitive/undocument behavior of CVI's Async Timers has caused me a lot of headaches in the past.
Greg
05-30-2008 08:00 PM
Can someone from NI answer the issues discussed in this thread for us?
AsyncTimer is an important function for multi-tasking. How come NI make it so hard to use it?
Daniel
06-01-2008 05:10 AM
As it says in the CVI help, the asynchronous timer is implemented using the Windows 'Multimedia Timer' resource. The limits you are seeing are the limits imposed by Windows: each process may only have 16 multimedia timers active.
Now, once a Windows multimedia timer is created you cannot change its time interval. So the code to change the interval of an asynch timer must involve the destruction of one multimedia timer and the creation of another. Whether it is a good idea to try to create the new timer before the old timer is destroyed could be debated, but it appears to be the way NI have done things. It would be nice if this aspect of behaviour were documented (that - IMO - applies to quite a lot of CVI), but in any case it could be argued that an application that uses that many asynchronous timers either doesn't need to be implemented that way or is trying to do things that shouldn't be done in Windows.
06-02-2008 10:15 AM
There are certainly many other ways to time events then using the Async timers. As mentioned, if the documentation of the CVI implementation was more complete you might realize that an application timing more then 8-16 things needs to use another tool. To say that you should not use windows to time that many things is a bit of an overstatement. The resolution and frequency of events, of course, more the limiting factor for windows rather then the total number. In my particular application I was had about a dozen things generating software interrupts on different time periods on the order of a few seconds each. Windows is certainly capable of servicing hundreds of such time intervals.... You just can't do with CVI's Async timers which was at the time my default timer tool.
Greg