| ??? 10/21/03 23:31 Read: times |
#57023 - RE: Visual Basic Connect to AT89C2051 Responding to: ???'s previous message |
Simon:
If I were working on the project that you describe I would go ahead and use the 11.0592 MHz crystal so you can achieve speedy baud rates between the PC and the microcontroller. The math to convert the measured time duration between the two sensors into microseconds resolution turns out to be fairly easy to do. First consider that even if you had used a 12.0 MHz crystal then the timer resolution would have been 1 usec at up to 16 bits of counts from say Timer 0. Now with the 11.0592 MHz the time per tick of the counters is 12/11059200 = 1.08506 usec. Using a technigue of integer scaling math (which has been discussed here many times) you could install a fixed point 16x16 multiply and a 32/16 divide routine (see the code library at this web site). Then all you have to do to convert the readings of the counter is to multiply the counter reading by 1085 and divide by 1000 to arrive at a count of microseconds. Clearly you could consider using a scaling of 10850/10000 to achieve greater accuracy but that seems not necessary to me. Michael Karas |



