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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/02/09 14:03
Read: times


 
#171395 - Frequency Measure
Responding to: ???'s previous message
If using the timer 2 input capture mode you should setup the timer to free-run at 16 bits and simply roll over on its own from 0xFFFF to 0x0000. Next configure the timer to capture the edge event time from the free-run 16-bits into the capture holding register and generate a subsequent interrupt. In the firmware have the ISR code read the capture register value and subtract it from the previous reading which gets updated each interrupt time from the current reading. The difference is the input waveform period in units of the timer clocking rate.

This scheme eliminates the interrupt latency jitter problems that you get using systems where timer value is re-programmed each interrupt time.

Some of the 8051 MCU types have less capable TIMER 2's and may not directly support input capture mode from an input pin. For these you may want to look for an MCU that supports the PCA. A PCA can be setup to measure frequency in the same manner as I described above. I used the PCA on a recent project to measure the TACH output of my fan. The range of timer clocking rate of the PCA was very high and the TACH period has a huge dynamic range and so I had to use a software extension scheme to extend the capture counters out to 24-bits!! The measured frequency matched with what my scope said perfectly.

Michael Karas


List of 13 messages in thread
TopicAuthorDate
Using timer 2 for frequency measurement            01/01/70 00:00      
   Latencies            01/01/70 00:00      
      Big differences            01/01/70 00:00      
         I'm using a PLC and a Oscilloscope !!            01/01/70 00:00      
            2% jitter...            01/01/70 00:00      
            Try a free-running timer and average 10 periods            01/01/70 00:00      
               Dear Per            01/01/70 00:00      
                  You may use timer2 if you want            01/01/70 00:00      
      Latency...            01/01/70 00:00      
   Frequency Measure            01/01/70 00:00      
   now using timer 0 and ext intr 0            01/01/70 00:00      
      giving up without proof that ...            01/01/70 00:00      
      Your calculations are OK            01/01/70 00:00      

Back to Subject List