I have been trying to use sleep() and kernel32.QueryPerformanceCounter together; I want to delay until a particular tick without trying up the CPU badly.
However, while time.sleep(.001) relieves the CPU, it has wildly unpredictable delay, and sleep(.0001) delays almost nothing at all! (I'm watching the parallel port on a scope).
If I use a while and just count ticks with QueryPerformanceCounter(), it is very stable and as desired - but it uses 100% CPU.

RTAI LINUX has a nanosleep() function that does it all very nicely on our Debian install, is there a parallel in Win32?
The MS Sleep() function is in integer milliseconds...

sample code:
___________________________________________________________________

TTLHighDur = ticksPerMs/2
currTicksPerRot = fsTicksPerRot
qPC(byref(c0))
tick0 = c0.value # initial count
nextTTL = tick0
## make a TTLOUT
endTick = tick0+pF* 15 #seconds
rotN = 0

while(True):
    nextTTL = currTicksPerRot+nextTTL
    sleep(.0001)# sleep for most of the time needed
    while(True): #loop until the exact tick
        qPC(byref(c1))
        if c1.value>nextTTL: break
    out(0x378, 0xFF) #set all bits high
    while(True): #loop until the exact tick
        qPC(byref(c1))
        if c1.value>nextTTL+TTLHighDur: break
    out(0x378, 0x00) #set all bits low
    rotN += 1
   
    if c1.value>endTick: break


Ray Schumacher
Blue Cove Interactive
8580 Production Avenue, Suite B
San Diego, CA 92121
858.695.8801
http://Blue-Cove.com


Disclaimer ;-)
By sending an email to ANY of my addresses you are agreeing that:

  1. I am by definition, "the intended recipient"
  2. All information in the email is mine to do with as I see fit and make such financial profit, political mileage, or good joke as it lends itself to. In particular, I may quote it on USENET.
  3. I may take the contents as representing the views of your company.
  4. This overrides any disclaimer or statement of confidentiality that may be included on your message.
_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to