From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_00,MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f8311a3a7edd715 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-12-19 19:30:11 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.infoave.net!arclight.uoregon.edu!newsfeed.mathworks.com!news.maxwell.syr.edu!nntp2.deja.com!nnrp1.deja.com!not-for-mail From: Ted Dennison Newsgroups: comp.lang.ada Subject: Re: Using "delay until" in real-time Date: Wed, 20 Dec 2000 03:17:41 GMT Organization: Deja.com Message-ID: <91p8ci$3fb$1@nnrp1.deja.com> References: <915jl7$jt5$1@nnrp1.deja.com> NNTP-Posting-Host: 38.195.186.125 X-Article-Creation-Date: Wed Dec 20 03:17:41 2000 GMT X-Http-User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; 0.6) Gecko/20001205 X-Http-Proxy: 1.1 x56.deja.com:80 (Squid/1.1.22) for client 38.195.186.125 X-MyDeja-Info: XMYDJUIDtedennison Xref: supernews.google.com comp.lang.ada:3274 Date: 2000-12-20T03:17:41+00:00 List-Id: I finally did get a solution to this that worked to my satisfaction. In article <915jl7$jt5$1@nnrp1.deja.com>, Ted Dennison wrote: > o Figure out what the denominator is (60 in this case), and redo > the calculation every time that number of runs have happened. > > For instance, in the above code, I'd add something like: > Runs := Runs + 1; > if Runs >= Natural(Iteration_Hz) then > -- Adjust for drift due to rounding errors. > Runs := 0; > Run_Time := Run_Time + Ada.Real_Time.To_Time_Span (1.0); > Next_Time := Run_Time; > else > Next_Time := Next_Time + Iteration; > end if; This was close to my final solution, but not quite. Instead, it ended up causing *more* problems with missed clocks. The solution was to use the above code, except that all calls to "To_Time_Span" are replaced by calls to "Ada.Real_Time.Nanoseconds", which gives better accuracy. Real_Time.Microseconds would probably have been sufficient, but this works too, and is a bit more portable. -- T.E.D. http://www.telepath.com/~dennison/Ted/TED.html Sent via Deja.com http://www.deja.com/