Hi
I wish to measure duration of frequency, say 9khz, using uno. I have connected the frequency input to pin 8, and used pulseIn function to measure high and low time, inverse of the addition of these two time will lead to frequency. But this take around 4 full Cycles to Estimate the frequency.
Kindly help me with another faster method.
Further, for example, when I receive 9KHz frequency, I want to make pin 12 high, and as long as I receive 9KHz, pin 12 should be high, other wise low.
And when I receive 11 KHz, make pin 13 high otherwise low.
So two frequencies will be isolated by respective pin, 12 and 13.
Kindly provide me a example code for my problem.
I doubt anyone will sit down and generate some code for you, but will help with your attempts. suggest you post your code for comment , some indication of the project may help too.
Look at how to use the forum and how to post code.
As long as the waveform goes over 0.7Vcc once and drops below 0.3Vcc once in each cycle, the actual waveform doesn't matter. Block, sine, sawtooth, whatever - all will work just fine because the RISING interrupt will fire at the same point of the waveform.
This calculates the frequency based on a single cycle - two interrupts - and stores it in the variable frequency.
You can get 16x better resolution by using timer2 to count clock cycles (at 9 kHz one cycle takes about 111 µs).
It isn't a good idea to post code to help a student cheat on his school work
when he hasn't shown any attempt at doing the work himself.
ieee488:
good point, though I prefer them failing sooner than later
.
Failing later always brings other people into the picture and it is not pleasant. I have had to clean up after so-called systems annalists have screwed up systems so bad I had to basically through the design out and start over. Same with programmers.
My manager spends many hours a week trying to help electronic engineers straighten out their designs so the can actually be built. We always audit every kit brought in by engineers because with very few exceptions, there is something wrong or missing. One customer wanted to purchase the components themselves, but after a year they gave up and pay us to do it.
I would much rather have someone fail early on, so they can learn from their failures before impacting other people.