Input Capture Max input time

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is this the correct way to determine the maximum time between edges using the input capture on an atmega8.

8000000/256 = 31250 ticks/second
so 65535/31250 = 2.09 seconds

Is it correct that the maximum time between pulses the input capture could detect with these settings would be about 2 seconds and how does a timer overflow affect the calculation?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You use 8MHz?
then you can use a divider of 1024.
making 7812.5 ticks/second.
with the 16 bit your max. time measurement (without overflow detection) can be 8.39 seconds.

just sample two capture values and subtract the first form the second as "unit16" values.
The result is valid as long as your time is not more than the 8.39 seconds. independent of counter overflow.

If you need to take measure more than the 8.39 seconds then you can increment an SW overflow_counter within the overflow ISR.
This is software (timer/counter overflow ISR).

Also you need to capture the overflow counter with every hardware capture.
This also is software (capture ISR).

The only thing you need to do is to extend all the 16 bit capture values with your captured overflow_counter_values before subtraction.

Klaus
********************************
Look at: www.megausb.de (German)
********************************

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I only have to delay for milliseconds, but I just wanted to make sure I was doing the calculation correctly and that the timer overflowing wouldn't affect the result as long as it was shorter than the calculated timing. Thanks for the help.