Click here to Skip to main content
15,914,111 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: resource.h ??? Pin
Steve S19-Aug-03 21:57
Steve S19-Aug-03 21:57 
GeneralRe: resource.h ??? Pin
Max Santos20-Aug-03 1:20
Max Santos20-Aug-03 1:20 
GeneralImport a class from .DLL Pin
CND19-Aug-03 7:41
CND19-Aug-03 7:41 
GeneralRe: Import a class from .DLL Pin
John M. Drescher19-Aug-03 7:50
John M. Drescher19-Aug-03 7:50 
GeneralRe: Import a class from .DLL Pin
CND19-Aug-03 8:21
CND19-Aug-03 8:21 
GeneralRe: Import a class from .DLL Pin
igor196019-Aug-03 10:04
igor196019-Aug-03 10:04 
GeneralRe: Import a class from .DLL Pin
Anonymous19-Aug-03 10:13
Anonymous19-Aug-03 10:13 
GeneralWierd wierd multimedia timers Pin
Jon Hulatt19-Aug-03 6:40
Jon Hulatt19-Aug-03 6:40 
Hi All,

I've read the articles here on CP about timers and their flaws, the quantization effects and so on, but I still can't understand this:-

My program needs to read data from my special hardware at 25Hz (period = 40ms).

I'm using a periodic multimedia timer with a callback to do the read, and I am using QueryPerformanceCounter to assess how accurately on the mark the callback got called.

Heres a chunk of the output of my program:-

23	40.12739	40.000000		+0.318480%
-8	40.13270	40.000000		+0.331750%
-36	40.12544	40.000000		+0.313591%
-43	40.13130	40.000000		+0.328258%
-31	40.12655	40.000000		+0.316385%
0	40.12683	40.000000		+0.317083%
29	39.12418	40.000000		-2.189552%
34	40.12823	40.000000		+0.320575%
15	40.12851	40.000000		+0.321274%
-14	40.13270	40.000000		+0.331750%
-46	40.1240.	40.000000		+0.311496%
-66	40.12879	40.000000		+0.321972%
-66	40.12963	40.000000		+0.324068%
-45	40.12711	40.000000		+0.317782%
-10	39.12725	40.000000		-2.181869%


Columns are: Reading from device, actual time gap in ms, intended timegap, percentile error in time gap

The fact that I get an error is of no suprise to me, and the fact that the sum of my errors is 0 is also no suprise. But, even if I run my program for an hour, I get this odd 8 sample pattern- 7 "+" errors, followed by one "-" error which is equal in magnitude to the previous 7 "+" errors. I don't understand why the pattern should be so uniform... Why are my time events always ~+0.31% out, except the 8th sample which is always ~-2.18%?

According to GetSystemTimeAdjustment(), my system clock period is 10 milliseconds. 40 milliseconds is a multiple of this?!?!

Also, I start my timer with :
timeBeginPeriod(tc.wPeriodMin); // tc.wPeriodMin is 1 (ms)
timeSetEvent40,0,&CaptureProc,(DWORD) this,TIME_PERIODIC);


I know windows isn't realtime, but if I could achieve time accuracy of +/- ~.3% , 95% of samples, it would be good enough...

Any thoughts on why that pattern occurs? Or solutions?


Thansk

Jon

PS. WinXP Pro and Win2K give identical results.

Thanks



#include <beer.h>

GeneralRe: Wierd wierd multimedia timers Pin
stephen.hazel19-Aug-03 7:07
stephen.hazel19-Aug-03 7:07 
GeneralCreateDIBBitmap in Windows2000 Server Pin
sdfdsfa19-Aug-03 6:37
sdfdsfa19-Aug-03 6:37 
GeneralOnNotify and the MFCGrid Pin
John Oliver19-Aug-03 6:27
John Oliver19-Aug-03 6:27 
GeneralRe: OnNotify and the MFCGrid Pin
HPSI19-Aug-03 6:39
HPSI19-Aug-03 6:39 
GeneralRe: OnNotify and the MFCGrid Pin
John Oliver19-Aug-03 6:48
John Oliver19-Aug-03 6:48 
GeneralResource in static library Pin
Shah Shehpori19-Aug-03 5:56
sussShah Shehpori19-Aug-03 5:56 
GeneralRe: Resource in static library Pin
Shah Shehpori19-Aug-03 6:00
sussShah Shehpori19-Aug-03 6:00 
GeneralRe: Resource in static library Pin
HPSI19-Aug-03 6:09
HPSI19-Aug-03 6:09 
GeneralRe: Resource in static library Pin
David Crow19-Aug-03 7:40
David Crow19-Aug-03 7:40 
GeneralRe: Resource in static library Pin
HPSI19-Aug-03 10:43
HPSI19-Aug-03 10:43 
Questionare those xml parsers worth beans? Pin
stephen.hazel19-Aug-03 5:41
stephen.hazel19-Aug-03 5:41 
AnswerRe: are those xml parsers worth beans? Pin
Ryan_Roberts19-Aug-03 5:52
Ryan_Roberts19-Aug-03 5:52 
AnswerRe: are those xml parsers worth beans? Pin
HPSI19-Aug-03 6:00
HPSI19-Aug-03 6:00 
AnswerRe: are those xml parsers worth beans? Pin
Alexander Ruscle19-Aug-03 6:13
Alexander Ruscle19-Aug-03 6:13 
GeneralRe: are those xml parsers worth beans? Pin
Steve S19-Aug-03 21:49
Steve S19-Aug-03 21:49 
Questionwhy my menu items always are disabled? Pin
mizimizi19-Aug-03 5:18
mizimizi19-Aug-03 5:18 
AnswerRe: why my menu items always are disabled? Pin
HPSI19-Aug-03 6:05
HPSI19-Aug-03 6:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.