[Dprglist] PID-tuned Clock in Python?

John Swindle swindle at compuserve.com
Fri Feb 19 11:43:31 PST 2021


Folks:
Looks like I stuck a stick in an ant hill.
Karim used the word I couldn't think of: normalizing. Normalizing the calculated measurements to the actual time interval. It makes the code much more resilient. Fewer hardcoded parameters.
As with Dave, most of my stuff is dependent on the clocks of the audio hardware, not the CPU's clock. With several independent audio devices, I've had to provide a sync, a metronome. With purpose-built hardware, or professional audio hardware, an external clock can run everything, but I'm trying the use the cheapest stuff available, just to prove that it is possible.
Regarding a sync, Murray added an external interrupt to time the loop (not to timestamp the sensors together as I am doing). For the loop timing, why not use the hardware timers built into the local interrupt controllers instead of an external source? Maybe I'm wrong here (because I haven't tried it, and I don't need to try it), but all of the local interrupt controllers that I've read about have hardware timers that can be programmed to give repeating interrupts. I see that this is available on Android. I read that the Android average timing will be the programmed timing unless the ISR takes more time than the interval between interrupts. One interrupt can be posted, but a second interrupt at the same level is discarded if the first has not been cleared. Makes sense.
One of my points earlier this week was that the average time between loops would be, say, 50ms, even if the jitter was high. I was assuming a hardware interrupt, not a programmed delay.

Do rabbits get along with fire ants?
Later,John Swindle

-----Original Message-----
From: Karim Virani via DPRGlist <dprglist at lists.dprg.org>
To: Murray Altheim <murray18 at altheim.com>
Cc: DPRG <dprglist at lists.dprg.org>
Sent: Fri, Feb 19, 2021 8:19 am
Subject: Re: [Dprglist] PID-tuned Clock in Python?

David, I agree with everything you said. Your crotchety oldfartdom is too rich for me. I fold. I was bluffing all along.
Murray, good luck with the bottomless rabbit holery! You've descended beyond my depth.
On Fri, Feb 19, 2021 at 12:29 AM Murray Altheim via DPRGlist <dprglist at lists.dprg.org> wrote:

On 19/02/21 6:16 pm, David Anderson via DPRGlist wrote:
> Howdy
> 
> Karim, I can certainly match your downright nitpickery and am therefore
> all in with crotchty oldfartdom.
Man you crotchety old guys are _hard_core_. And nitpickery.

I manage to wrangle my mean clock error down to about 0.09ms per 50ms loop
(measured over 1000 iterations, even under system load), so less than a
tenth of a millisecond error on a 50ms loop is just not good enough?!

Woof. Woof woof and more woof.

But *clearly* Ima gonna havata do bettera, or its le scarpe di cemento.
Maybe down to una microsecondo prima del molo dei pescatori è il mio destino.

I've updated the code so it's now a proper class with YAML configuration,
etc. and updated the github repo at:

    https://github.com/ifurusato/ros/blob/master/ext_clock_test.py
    https://github.com/ifurusato/ros/blob/master/lib/ext_clock.py

[For those of us building robots on platforms that don't have access to
fancy hardware clocks, we have to make do somehow. Ima tryin.]

Cheers,

Murray

...........................................................................
Murray Altheim <murray18 at altheim dot com>                       = =  ===
http://www.altheim.com/murray/                                     ===  ===
                                                                    = =  ===
     In the evening
     The rice leaves in the garden
     Rustle in the autumn wind
     That blows through my reed hut.
            -- Minamoto no Tsunenobu

_______________________________________________
DPRGlist mailing list
DPRGlist at lists.dprg.org
http://lists.dprg.org/listinfo.cgi/dprglist-dprg.org

_______________________________________________
DPRGlist mailing list
DPRGlist at lists.dprg.org
http://lists.dprg.org/listinfo.cgi/dprglist-dprg.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dprg.org/pipermail/dprglist-dprg.org/attachments/20210219/ebfad4f3/attachment-0001.html>


More information about the DPRGlist mailing list