How to delay until a next increment of time occurs ?

R.Wieser address at not.available
Wed Nov 13 15:20:46 EST 2019


Rob,

> 300us is getting on towards realtime.

Not really.  Translated to a frequency (toggeling the pin) it would be just 
1.6 KHz.   Thats rather slow for an ARM machine running on 1.4 Ghz (about a 
million times as fast).

> I've never tried it that fast.

I've already got it running it using the standard sleep() command, but I 
would like to make the used delay value independant of the Pi board it runs 
on (had to tweak it when I went from a C++ program on a 3B to a python 
program on a 3B+).    And possibly get a bit more stability of the output 
signal.

> That said, I'll throw out a different option than the threading based ones 
> people have suggested.  Trap SIGALRM with signal.signal and use 
> signal.setitimer to create an interval timer.

(googeling it) Yup, looks like I have to try that out.  Thanks.   And that 
automaticaly repeating signal is pretty-much the best solution I can think 
of.

> Also, does the rPi have any PWM or counter pins that you can just set and 
> forget, rather than trying to keep it going yourself?

Not possible: the 300 uSec is the basic timing, but the pin isn't always 
changed on every tick of it (the result is a code train).

Regards,
Rudy Wieser




More information about the Python-list mailing list