LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Program speeds up when moving mouse

Solved!
Go to solution

I'm running a program of some simple stripcharts and have put a timer on the screen to measure the milliseconds per program cycle.  I have noticed that when I don't move the mouse, it takes about 33mS to run through the loop but when I move the mouse around, it drops down to 8mS.  The stripcharts speed up as well.  I really need the program to run at the faster speed to get a decent amount of data to display (Nyquist rate issues).  Has anyone seen this type of issue before?

 

Also, is there a better way to send data to 5 stripcharts using PlotStripChartPoint 5 times?

 

I'm running V8.0 on a PC104, 1.4GHz Pentium M, Windows XP.

 

Thanks for all your help over the past 6 months.

0 Kudos
Message 1 of 4
(3,732 Views)

Hi Ryan,

I'm not sure about it, but it seems to me that this discussion reports a very similar behaviour: look at the first answer from Jonathan for a (possible) explanation of what's happening and make some trials with the sleep policy as he suggests.

Please remember that if you are running a multithreaded application you must call SetSleepPolicy in every thread that you want to speed up (possibly leaving the main thread sleep policy to VAL_SLEEP_SOME in order to not overcharge the system with unnecessary tasks). As far as I can remember, this attribute cannot be set for threads in the default thread pool, so you will need to create a new thread pool for your threads.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 4
(3,711 Views)

it seems to me that your program architecture is bad: your acquisition should run fast but i don't see the point of displaying very fast since the user will never be able to follow at that speed: a 8ms period represent a refresh rate of 125Hz, twice the refresh rate of a standard screen. unless your application is for testing a screen, data display is not subject to Nyquist rate.

 

i would suggest rethinking the application. one thread should be in charge of acquiring the data as fast as possible, and post them into a queue. another thread should be in charge of displaying chunks of data from the queue at a slower speed. for displaying data, you should consider using the PlotStripChart() function, which will allow you to plot a number of points at once with only one screen refresh at the end (a screen redraw is a slow operation, the less you refresh, the less you load the processor).

 

also, please note that Windows XP is NOT A REAL TIME OS: timing may vary greatly depending on hardware, software and operating system load.

0 Kudos
Message 3 of 4
(3,698 Views)
Solution
Accepted by topic author Ryan C.

Thank you so much for the your help.

 

I have tried the multithreading solution and the PlotStripChart solution and while both somewhat helped, I was still having my main problem, missing peaks.  I wasn't so much concerned with displaying all the data in real time, just needed something for the user to help see what was going on.  The final solution I came to was to use PlotStripChart and set SetSleepPolicy to VAL_SLEEP_NONE.  This GREATLY increased my program speed to even faster than when I was moving the mouse.

 

I do realize that Windows is not a RTOS, but this application really didn't require going that far.  Most of the data I'm looking for is around 1 to 20 Hz and this will easily suffice.

 

Once again, thank you.

Message Edited by Ryan C. on 09-24-2009 04:03 PM
0 Kudos
Message 4 of 4
(3,673 Views)