Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/21/05 07:31
Read: times


 
#85460 - counter overflow problem?
Responding to: ???'s previous message
James Krushlucki said:
I wrote a basic program last night to calculate the speed of an object as it passes through two infrared emitter/detectors. The first detector starts a 16 bit timer and the second detector stops the timer and sends the program to calculate speed based on elapsed time.

This way you have to make sure that the speed of the object is fast enough for it to pass between the two sensors before timer/counter overflows. This might be the problem, so you have to change your approach of programming.
You could do it like this, when object passes under first sensor, you start a 1msec timer say and clear software speed counter. Eeach time 1 msec timer overflows you get an interrupt incrementing speed counter in msecs. when object passes under second sensor timer interrupt is disabled and a speed ready flag is set, you take your software counter and convert it into speed.
Mahmood



List of 9 messages in thread
TopicAuthorDate
Calculating time required for interrupt            01/01/70 00:00      
   Distance between two infrared e/r?            01/01/70 00:00      
      Program Simulator            01/01/70 00:00      
         Simulation            01/01/70 00:00      
   counter overflow problem?            01/01/70 00:00      
      No overflow problem            01/01/70 00:00      
   BSIC for microseconds ???            01/01/70 00:00      
      Sloppy compilers            01/01/70 00:00      
   Clock cycles            01/01/70 00:00      

Back to Subject List