# DeltaTime

Started by February 5, 2004
 I am trying to determine DT every time i sample an ADC from an analog input.... This is what i am doing... TimerTemp = Timer ' We store the timer value in TimerTemp to not get fluctations in the following lines. DT = TimerTemp - LastTime ' We determine DT LastTime = TimerTemp ' We store the value of the timer1 at the moment we reed it InputSample = InAdc(PinX) ' We read from PinX a 0 to 1023 value InputIntegral = InputIntegral + (InputSample * DT) ' We integrate the reading from a gyro. Would Timer (RealTimeClock) have enough resolution to detect changes at 180 hz???? I don;t know if i should use stopwatch instead, but i don;t think stopwatch is available in BX35? Thanks -- Este mensaje ha sido analizado con MailScanner y se considera que estlimpio.
 > ... Would Timer [] have enough resolution to detect changes at 180 hz? The RTC resolution is 1/512Second below about nine hours, when the LSB of the Timer Single float value is lost, 1/256Second from there to about 18 hours, when another LSB is lost, then 1/128Second from there to just before midnight. If you keep the Timer value below nine hours and your code is sufficiently fast, you'll always have 1/512Second resolution available, but I wonder if that is sufficient for your need. Your line InputIntegral = InputIntegral + (InputSample * DT) won't give you much accuracy at 180Hz since DT can only be 2 (512/180). At slower rates the accuracy will be greater but if you need good accuracy at 180Hz, you'll need a faster clock counter, I believe. An external oscillator and counter can provide whatever resolution and range you like, and you can avoid an external oscillator by dividing from the processor crystal drive, but that is not available on a pin; you'd need to tap it from the processor. You could also easily get a pretty stable - though not necessarily highly accurate - 10KHz or higher clock from a 555. Tom Tom Becker --... ...-- www.RighTime.com The RighTime Clock Company, Inc., Cape Coral, Florida USA +1239 540 5700