Results 1 to 2 of 2

Thread: QTimer resolution in Windows

  1. #1
    Join Date
    Feb 2018
    Posts
    1
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows

    Default QTimer resolution in Windows

    Hi,

    I am using Qt 5.9.1 with MinGW 32bit compiler in Embedded Windows 64-bit platform.I need to use five timers for my application.
    The main timer should fire for every 31.25ms for reading the data,which means that I have to get 32 counts for one second.After reading 32 values,I need to pack data,send the data,log the data and display the data.For this four functionalities created four timers should fire for every 1000ms with 32msec intervals between the successive timers.

    The problem is,

    1.In Windows the timer does not times out at exact 1sec.The resolution of the timer is varying ~16ms(i.e.,In Qt Timer Class it is mentioned that the resolution of the timer depends upon the operating System).So it entirely changes the acquisiton timing,Obviously changes the all the other timings also.How to get the exact 1sec times out in Windows system?

    2.The Qtimer has taking the interval in integers.But I have to trigger it for every 31.25ms.

    3.Synchronization between the timers.It should be times out in the below order.

    Acquistion_timer -->Pack Timer --> send Timer --> Log Timer -->Display Timer.

    4.How the implement a nanosecond precision QTimer in Windows?

    So please kindly help me out to solve this problems as soon as possible.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QTimer resolution in Windows

    1.In Windows the timer does not times out at exact 1sec.The resolution of the timer is varying ~16ms(i.e.,In Qt Timer Class it is mentioned that the resolution of the timer depends upon the operating System).So it entirely changes the acquisiton timing,Obviously changes the all the other timings also.How to get the exact 1sec times out in Windows system?
    Yes, timer resolution depends on OS and underlying HW, and you have to take these limitation in account.
    Generally need to define/know the target system requirements, and use a system that meets these requirements.
    If you use a system that does not meet them, there should not be a surpize if the software deos not run as intended.

    2.The Qtimer has taking the interval in integers.But I have to trigger it for every 31.25ms.
    Amm... time is measured in discrete units, therefore int is fully sufficient.
    31.25 ms is 312.5 micro secs, and 3125 nano secs. - so you can represent your interval as an int.
    What you need is a timer with nano second resolution, and I am no sure your regular hardware can do that.
    Have a look at this MSDN documentation on how to determine the timer resolution your system can offer you.
    https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx
    This also looks like it has some good information you could use:
    https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. QTimer Usage in C++ Unix / Windows
    By rcanerA in forum Newbie
    Replies: 4
    Last Post: 15th May 2017, 06:53
  2. QTimer resolution problems under QWS
    By denizlitr in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 16th December 2011, 16:31
  3. QTimer Time Resolution
    By Ashutosh2k1 in forum Qt Programming
    Replies: 3
    Last Post: 1st July 2011, 14:17
  4. Line clipped on windows 7 at resolution 1280*1024
    By nikhil in forum Qt Programming
    Replies: 0
    Last Post: 9th June 2010, 12:29
  5. QTimer resolution.
    By Netich in forum Qt Programming
    Replies: 3
    Last Post: 31st March 2010, 20:08

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.