Click here to Skip to main content
15,883,841 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Sleep less than 1 ms Pin
Cedric Moonen5-Jan-10 9:15
Cedric Moonen5-Jan-10 9:15 
GeneralRe: Sleep less than 1 ms Pin
Adnan Merter5-Jan-10 9:17
Adnan Merter5-Jan-10 9:17 
GeneralRe: Sleep less than 1 ms Pin
Cedric Moonen5-Jan-10 9:20
Cedric Moonen5-Jan-10 9:20 
GeneralRe: Sleep less than 1 ms Pin
Adnan Merter5-Jan-10 9:21
Adnan Merter5-Jan-10 9:21 
AnswerRe: Sleep less than 1 ms Pin
CPallini5-Jan-10 11:25
mveCPallini5-Jan-10 11:25 
GeneralRe: Sleep less than 1 ms Pin
Adnan Merter6-Jan-10 4:05
Adnan Merter6-Jan-10 4:05 
GeneralRe: Sleep less than 1 ms Pin
CPallini6-Jan-10 5:08
mveCPallini6-Jan-10 5:08 
AnswerRe: Sleep less than 1 ms Pin
Luc Pattyn5-Jan-10 15:32
sitebuilderLuc Pattyn5-Jan-10 15:32 
Hi,

whatever sleep() function you use, you will get a stand-still for at least the time you specify, however it could be much longer as there are dozens of threads all running on a typical Windows system.

The only scheme that might work to some extent is this:
- assume a multi-core system;
- create a program (or a thread in an existing program) that contains busy loops, so it is simply getting and checking time all the time, then setting the output(s) as required. Of course you need a high-precision timer, maybe the PerformanceCounter stuff.
- make sure to elevate the thread's priority to PRIO_REAL_TIME, so nothing else is likely to steal the core.

WARNING: it is quite a hack, I do not consider this good enough to provide steps to a stepper motor; steps will vary, resulting in horrible noise, and shaky operation. Also, as you are going to move something that may harm humans, you have to provide fail-safes; those cannot be trusted when their function also is based on your Windows app.

Smile | :)

Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

Happy New Year to all.
We hope 2010 soon brings us automatic PRE tags!
Until then, please insert them manually.


GeneralRe: Sleep less than 1 ms Pin
Adnan Merter6-Jan-10 4:11
Adnan Merter6-Jan-10 4:11 
GeneralRe: Sleep less than 1 ms Pin
Luc Pattyn6-Jan-10 4:24
sitebuilderLuc Pattyn6-Jan-10 4:24 
GeneralRe: Sleep less than 1 ms Pin
Emilio Garavaglia6-Jan-10 21:02
Emilio Garavaglia6-Jan-10 21:02 
GeneralRe: Sleep less than 1 ms Pin
Adnan Merter7-Jan-10 8:38
Adnan Merter7-Jan-10 8:38 
GeneralRe: Sleep less than 1 ms Pin
Emilio Garavaglia7-Jan-10 19:58
Emilio Garavaglia7-Jan-10 19:58 
AnswerRe: Sleep less than 1 ms Pin
softwaremonkey6-Jan-10 11:49
softwaremonkey6-Jan-10 11:49 
GeneralRe: Sleep less than 1 ms Pin
Adnan Merter7-Jan-10 8:36
Adnan Merter7-Jan-10 8:36 
GeneralRe: Sleep less than 1 ms Pin
Adnan Merter7-Jan-10 9:53
Adnan Merter7-Jan-10 9:53 
GeneralRe: Sleep less than 1 ms Pin
softwaremonkey7-Jan-10 11:32
softwaremonkey7-Jan-10 11:32 
QuestionHow to send a msg between MainFrame and a view? Pin
Software20075-Jan-10 5:57
Software20075-Jan-10 5:57 
AnswerRe: How to send a msg between MainFrame and a view? Pin
Richard MacCutchan5-Jan-10 9:31
mveRichard MacCutchan5-Jan-10 9:31 
GeneralRe: How to send a msg between MainFrame and a view? Pin
Software20075-Jan-10 9:51
Software20075-Jan-10 9:51 
GeneralRe: How to send a msg between MainFrame and a view? Pin
Richard MacCutchan5-Jan-10 9:59
mveRichard MacCutchan5-Jan-10 9:59 
GeneralRe: How to send a msg between MainFrame and a view? Pin
Software20075-Jan-10 10:02
Software20075-Jan-10 10:02 
GeneralRe: How to send a msg between MainFrame and a view? Pin
Richard MacCutchan5-Jan-10 10:50
mveRichard MacCutchan5-Jan-10 10:50 
GeneralRe: How to send a msg between MainFrame and a view? Pin
Software20076-Jan-10 2:30
Software20076-Jan-10 2:30 
GeneralRe: How to send a msg between MainFrame and a view? Pin
Richard MacCutchan6-Jan-10 3:48
mveRichard MacCutchan6-Jan-10 3:48 

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.