Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Timer/ Multitasking??

Timer/ Multitasking??

Scheduled Pinned Locked Moved C / C++ / MFC
c++performancedatabasecomdata-structures
5 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    weehau
    wrote on last edited by
    #1

    Hello , I am new to VC++ 6.0 I am now developing a MFC dialog based project which will display the signal information in real time and signal strength. [IMG]http://i176.photobucket.com/albums/w196/well\_aisec/image-1.jpg\[/IMG\] I need to have 1 analog meter which will constantly update the signal strength value as well as an oscilloscope which will graph the received signal in real time. What I will do to set a Timer which will trigger every 250ms for update and display in Analog meter. At the same time I need to perform real time graphing for the signal. Meaning the two task is perform asynchronously. Now here's come the problem. As the timer is triggered in fast speed, my program seems very laggy to perform both operation in parallel. May I know what's the problem and solutions?The timer consume a lot of memory space and processing speed? How to improve the program so that it can progress smoothly. Thanks

    R 1 Reply Last reply
    0
    • W weehau

      Hello , I am new to VC++ 6.0 I am now developing a MFC dialog based project which will display the signal information in real time and signal strength. [IMG]http://i176.photobucket.com/albums/w196/well\_aisec/image-1.jpg\[/IMG\] I need to have 1 analog meter which will constantly update the signal strength value as well as an oscilloscope which will graph the received signal in real time. What I will do to set a Timer which will trigger every 250ms for update and display in Analog meter. At the same time I need to perform real time graphing for the signal. Meaning the two task is perform asynchronously. Now here's come the problem. As the timer is triggered in fast speed, my program seems very laggy to perform both operation in parallel. May I know what's the problem and solutions?The timer consume a lot of memory space and processing speed? How to improve the program so that it can progress smoothly. Thanks

      R Offline
      R Offline
      Roger Stoltz
      wrote on last edited by
      #2

      What hardware do you use to collect the signal strength values? Probably you should have a worker thread waiting on a waitable timer or multimedia timer event. When the timer expires a signal strength value sample is created and assigned a time stamp and put in a queue to be read by the main thread which should be responsible for the presentation. In cases like this it's usually the data gathering which is time critical. It doesn't matter if the GUI is running 50ms late, the user won't notice anyway but the data would be correct (or as accurate as possible).


      "It's supposed to be hard, otherwise anybody could do it!" - selfquote

      W 1 Reply Last reply
      0
      • R Roger Stoltz

        What hardware do you use to collect the signal strength values? Probably you should have a worker thread waiting on a waitable timer or multimedia timer event. When the timer expires a signal strength value sample is created and assigned a time stamp and put in a queue to be read by the main thread which should be responsible for the presentation. In cases like this it's usually the data gathering which is time critical. It doesn't matter if the GUI is running 50ms late, the user won't notice anyway but the data would be correct (or as accurate as possible).


        "It's supposed to be hard, otherwise anybody could do it!" - selfquote

        W Offline
        W Offline
        weehau
        wrote on last edited by
        #3

        The signal strength values comes from a receiver, very much like a radio which will be connected to our serial port. I am not sure the method you were referring( maybe you can further elaborate in a simple way which i can easily understand?). What I did was my program will be collect signal strength values at the predefined frequency. As the signal strength value of a fixed frequency keep on changes, I created a timer with 250ms time interval to read and update the display. This timer will trigger an event to collect signal strength and update the meter -- modified at 11:05 Tuesday 6th February, 2007

        W R 2 Replies Last reply
        0
        • W weehau

          The signal strength values comes from a receiver, very much like a radio which will be connected to our serial port. I am not sure the method you were referring( maybe you can further elaborate in a simple way which i can easily understand?). What I did was my program will be collect signal strength values at the predefined frequency. As the signal strength value of a fixed frequency keep on changes, I created a timer with 250ms time interval to read and update the display. This timer will trigger an event to collect signal strength and update the meter -- modified at 11:05 Tuesday 6th February, 2007

          W Offline
          W Offline
          Waldermort
          wrote on last edited by
          #4

          Take a look at these[^] articles. They are aimed at game developers and outline some of the timing issues related to running games at the same speed on various PC's. I feel they relate quite closely to what you are trying to do.

          1 Reply Last reply
          0
          • W weehau

            The signal strength values comes from a receiver, very much like a radio which will be connected to our serial port. I am not sure the method you were referring( maybe you can further elaborate in a simple way which i can easily understand?). What I did was my program will be collect signal strength values at the predefined frequency. As the signal strength value of a fixed frequency keep on changes, I created a timer with 250ms time interval to read and update the display. This timer will trigger an event to collect signal strength and update the meter -- modified at 11:05 Tuesday 6th February, 2007

            R Offline
            R Offline
            Roger Stoltz
            wrote on last edited by
            #5

            Your main problem is that the application slow and inresponsive, right? Is your application multithreaded? How do you interface with the serial port? Does the receiver require you to request each sample, or is it sent automatically? Are you using overlapped I/O? If you're not, then each call to ::ReadFile() will "hang" the application until something is received if the call is made from the primary thread. There's a fairly large risk that it's the serial communication part that's causing you troubles. Have a look at Joe Newcomer's article on serial communication and see if that helps: clickety[^].


            "It's supposed to be hard, otherwise anybody could do it!" - selfquote

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups