dcsimg
Results 1 to 9 of 9

Thread: Hi resolution timer

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Posts
    352

    Hi resolution timer

    Hello Group,

    I know this has been discussed and I have searched, but I have come up with nothing relevant..

    I have a multi threaded activeX exe and need my main timer to be triggred more accuratly. I am currently using "setTimer" api call. 80% of the time my timer is on time, but 20% it can get off.

    I was wondering if anyone has found an elegant/easy bu accurate way to make sure the timer calls are as exact as possible.

    I found the solutions using the multimedia timer.. but my concern is I have to distribute a .tlb file with it ( and have very little knowledge about what this is) also this solution seems to require a user control which does not seem to be able to work in my multi threaded activeX exe project.

    any suggestions?

  2. #2
    Fanatic Member Spooman's Avatar
    Join Date
    Mar 2017
    Posts
    869

    Re: Hi resolution timer

    Axisdj

    Could you elaborate on the nature of "it can get off" .. ie, by how much?
    Also, it might help if you post a code snippet to show where the "it can get off" occurs.

    EDIT

    I take it that you are using the Interval property, ie ..

    Code:
    Timer1.Interval = 1000     ' milliseconds, ie, 1 second
    .. and setting it to some "appropriate" smaller value.

    Spoo
    Last edited by Spooman; Apr 10th, 2017 at 10:55 AM.

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    33,917

    Re: Hi resolution timer

    You'll also have to define "exact as possible". After all, one would presume that all the system timers are exact as possible within the limitations imposed on them. Windows is going to be inherently inexact with timers because there are higher level interrupts that can throw off very precise timing. The OS could bump your thread right off the CPU for longer than your timer interval. It may not be likely to happen, but the more precision you want, the more likely that a preemptive multi-tasking OS will foil your plans. I've heard of people using dedicated hardware timers for higher precision stuff, such as some oscilloscopes, and the like. It all comes down to how precise you need to be, and what your tolerances are.
    My usual boring signature: Nothing

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Posts
    352

    Re: Hi resolution timer

    So...

    The timer is set to 50ms using setTimer api call...

    Most of the time the time elapsed between calls is .0625, but every second the time eleapsed between calls goes to .203.. .056... then back to .0625

    The timer updates the user interface etc... but the call that needs the accuracy pulls audio data through an audio engine.

    I tried separating the timer call to another timer, but with the same results.

    I guess something in the main thread where the timer is calling back is getting stalled. I will look deeper to see if the stall is in my program or windows not calling on time.

  5. #5
    Frenzied Member
    Join Date
    Feb 2017
    Posts
    1,727

    Re: Hi resolution timer

    High resolution timer: http://www.vbaccelerator.com/home/VB...r/article.html

    The link to the download goes to an empty file, but you can download it from here.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Posts
    352

    Re: Hi resolution timer

    Quote Originally Posted by Eduardo- View Post
    High resolution timer: http://www.vbaccelerator.com/home/VB...r/article.html

    The link to the download goes to an empty file, but you can download it from here.
    Thank you...

    I would like to try it.. but would like to fully understand it. Can someone enlighten me on the tlb / odl file stuff.

    Thanks!

  7. #7
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    18,234

    Re: Hi resolution timer

    Couple notes:

    Don't worry about a tlb. You don't redistribute it, it gets compiled into your app. Consider the odl file as source code

    One of the reasons a standard timer could be failing you is that timer events are about the lowest priority messages; they can be delayed getting to your routines.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Posts
    352

    Re: Hi resolution timer

    thank you LaVolpe for the concise answer.. I feel much better about using this timer and will do so...

  9. #9
    Lively Member
    Join Date
    Jun 2016
    Posts
    68

    Re: Hi resolution timer

    Quote Originally Posted by axisdj View Post
    thank you LaVolpe for the concise answer.. I feel much better about using this timer and will do so...
    .... I had good experiences with the freeware RSTimer OCX. Very easy to use.
    more infos see: http://www.vbforums.com/showthread.p...-Timer-2-1-0-1

    I don't find a download location for now, if you can't find it, I could mail it to you.

    I use it for a MIDI/OSC Sequencer/Beatmachine. Still some jitter, but I think just the unavoidable one, due to VB6 is only single threading.

    btw. LaVolpe if you are reading this, may be you could have a look at:
    http://www.vbforums.com/showthread.p...onality-broken

    Any hints or comments would be highly apprecciated!!!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width