0
\$\begingroup\$

Is it possible to use a microcontroller to read an input frequency? Please explain how?

\$\endgroup\$
  • 4
    \$\begingroup\$ Can you give us an idea of the range of input frequencies you wish to measure, as well as the voltage levels and waveform? Are we talking a 100Hz 0-5V square wave or a 350Mhz 120mV peak-to-peak signal? They both necessitate very different handling. \$\endgroup\$ – drxzcl Apr 19 '11 at 7:20
  • \$\begingroup\$ possible duplicate question: electronics.stackexchange.com/questions/2811/… \$\endgroup\$ – vicatcu Apr 19 '11 at 15:49
  • \$\begingroup\$ Which micro controller you are using? if PIC then use TMR0 as counter and count the pulses. \$\endgroup\$ – MrAlpha_SU Jan 29 '15 at 4:15
  • \$\begingroup\$ Welcome to the site. Please realise this is not a free design house, homework-answering service or an on-line technical encyclopedia, copied out to you on demand. People will help you take the next step if your question shows you've done as much as you possibly could on your own - which yours doesn't, I'm afraid. Please edit your question and greatly improve it. Ask a specific question, showing your work and findings so far in considerable detail with any schematic. The better the quality of question, the better the quality of the answers you will attract. Again, a warm welcome to the site. \$\endgroup\$ – TonyM May 13 '18 at 20:40
10
\$\begingroup\$

You can use a timer capture to detect edges. If the selected edge of the signal occurs the timer value will be latched and the controller will get an interrupt. Read and store the timer value and wait for the next interrupt. Read the new timer value and subtract the previous one. You now have the signal's period. Calculate 1/period to find frequency.

Notes:

  1. I'm assuming that you have a decent digital signal
  2. You'll have to take the timer's overflow(s) into account
  3. Also make sure that the timer is clocked by an appropriate clock
| improve this answer | |
\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.