2 Sep 2007

Use method of count. As every cycle, there will be a constant of time taken to execute the cnt = cnt +1 statement and the delay statement, we put it as const, and use this formula cnt*delay + cnt*const = real value read from oscilloscope. Then we have the following table from several trials.

delay (us) count seen by oscilloscope(ms) constant
100 87 8.9 2.29
100 163 16.76 2.82
36 233 8.87 2.06
36 440 16.81 2.20
36 233 8.89 2.15
36 446 17.00 2.11
75 116 8.89 1.64
75 220 17.00 2.27

We eliminate values 2.82 and 1.64 to get rid of the ones that are too far away from the rest, the average value of the constant from the rest of the 6 values is 2.18us. Now, in our program, whatever cnt we get for either t1 or t2, we have to add a constant value of const*cnt to get the real value that is closest to the value reading from the oscilloscope.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.