Forum Rule: Always post complete source code & details to reproduce any issue!

# Thread: Measuring frequencies on two separate pins??

1. ## Measuring frequencies on two separate pins??

Hey everyone,
I'd like to use my Teensy 3.2 to measure the frequency of two separate audio signals. I see that the FreqMeasure and FreqCount library are hard-coded onto a single pin.. (the LED pin??). Is there any way to use these libraries on different pins at the same time? Or can anyone recommend any other way to measure frequency on other pins?

Here's some details that will hopefully help:

- The audio I'm trying to measure is a clean sine or triangle wave, direct input. Not a guitar and not picked up from a microphone.

- The range of the audio I'm trying to measure is between 100Hz and 4000Hz. For accuracy, I'd love to see +/- .1Hz accuracy @ 100Hz and +/- 1Hz accuracy @ 4000Hz.

2. Then, look at the FreqMeasureMulti library. It can work on up to eight pins (5,6,9,10,20,21,22,23) if I remember well.
BTW: The FreqCount library works like a “classic” frequency counter, which means that you need a gate time of 1s for 1Hz Resolution and 10s for 0.1Hz... The FreqMeasure and FreqMeasureMulti libraries work differently: They measure the period duration in ticks of the 48MHz bus clock and do some math afterwards to get the frequency. This makes that you get much more precise results much quicker, as long as the input frequency is smaller than 5000Hz.

3. Originally Posted by gatheround
For accuracy, I'd love to see +/- .1Hz accuracy @ 100Hz and +/- 1Hz accuracy @ 4000Hz.
FreqMeasureMulti should do it. The period is measured using F_BUS, so at 4000 Hz you'll get 12,000 cycles of the 48 MHz F_BUS frequency on Teensy 3.2.

4. Originally Posted by Theremingenieur
Then, look at the FreqMeasureMulti library. It can work on up to eight pins (5,6,9,10,20,21,22,23) if I remember well.
BTW: The FreqCount library works like a “classic” frequency counter, which means that you need a gate time of 1s for 1Hz Resolution and 10s for 0.1Hz... The FreqMeasure and FreqMeasureMulti libraries work differently: They measure the period duration in ticks of the 48MHz bus clock and do some math afterwards to get the frequency. This makes that you get much more precise results much quicker, as long as the input frequency is smaller than 5000Hz.
Oh perfect, thank you! I didn't even see FreqMeasureMulti listed on the main page. It's on the FreqMeasure page, but easy to pass by.

Is FreqMeasureMulti rolled into teensyduino? Maybe just get rid of the old FreqMeasure and turn FreqMeasureMulti into the new version?? If it's exactly the same function but you're able to specify the pin, why keep the old one around??

5. If you have an ongoing project measuring those 2 signals using FreqMeasureMulti, or even start selling commercial product (which is allowed)... and then we come up with an even better library that does even more than FreqMeasureMulti, how would you feel if we just get rid of the FreqMeasureMulti you're still using in your product's code?

Thousands of people have indeed used FreqMeasure in their projects over the years.

6. Originally Posted by PaulStoffregen
If you have an ongoing project measuring those 2 signals using FreqMeasureMulti, or even start selling commercial product (which is allowed)... and then we come up with an even better library that does even more than FreqMeasureMulti, how would you feel if we just get rid of the FreqMeasureMulti you're still using in your product's code?

Thousands of people have indeed used FreqMeasure in their projects over the years.
Totally, I understand Paul. I'm not suggesting getting rid of any existing Library at this point, I'm just suggesting that in cases like this the extended functionality could have been incorporated into the existing library instead of an entirely new library that requires a separate help page and examples just to handle one additional parameter. Like if FreqMeasure operates as expected unless a pin# is specified then it acts like FreqMeasureMulti? Do it however you want Paul, I'm happy to enjoy the product and code.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•