发布于 2003-11-04 16:05:31
0楼
事实上你理解错了(也有可能书翻错了)。
10 millisecond Resolution
The 10-ms timers count the number of 10-ms timer intervals that have elapsed since the active 10-ms timer was enabled. The execution of the timer instruction starts the timing; however the 10-ms timers are updated at the beginning of each scan cycle (in other words, the timer current and timer bit remain constant throughout the scan), by adding the accumulated number of 10-ms intervals (since the beginning of the previous scan) to the current value for the active timer.
Since the timer can be started anywhere within a 10-ms interval, the preset must be set to one time interval greater than the minimum desired timer interval. For example, to guarantee a timed interval of at least 140 ms using a 10-ms timer, the preset time value should be set to 15.
上面说的是,由于10ms计时器可能从头一个10ms周期内的任意时候开始计数(10ms周期是由系统底层提供),因此,你得到的时间精度误差总是在0~-10ms,无论你计多长时间。
所以,你如用10ms计时器计20ms,误差会很大。你可以用1ms的计时器,精度-1ms
毛主席教导我们:Good Good Study, Day Day Up!