FreqCount library counter every 2ms

Status
Not open for further replies.

Jonathan

Member
Hello,

I am working with a teensy 3.1. I have 2 light to frequency sensors with a maximum sensibility of 1Mhz

I am using the FreqCount library for measuring frequencies and I need to get the frequency every 2ms but
FreqCount.begin(time) accepts only time > 10ms. Can I just modify the source code for accepting values lower than 10ms ?

The only pin available for FreqCount is the led Pin 13, could I add an other input pin for my second sensor ?

I tried to use 2 intervalTimer with 2 attachInterrupt but the teensy is blocking when the frequency is too high.

Thanks for your help,

Best Regards
 
Last edited:
Sorry can you elaborate on I have 2 light to frequency sensors with a maximum sensibility of 1Mhz I'm having a hard time understanding what you're trying to do
 
What a strange chip. Freqcount uses the 16bit low power timer module of which there is only one so you can't have multiple freqcounts using this method.

Just out of interest though try removing line 39 and setting it to 2ms

EDIT-
Actually I just found this:
// IntervalTimer is capable of longer intervals, but
// LPTMR can overflow. Limiting to 1 ms allows counting
// up to 65.535 MHz... LPTMR on Teensy 3.1 can do 65 MHz!
With Teensy 3.x the refresh time is always 1ms
Perhaps you can do 1ms on each and alternate?

There is an alternative pin on PTA19 but this is unfortunately used for the 16MHz clock
 
Last edited:
Thanks for your answer ! I already removed line 39 and it's working but I didn't know if it was a "proper" solution. Yes it's a good idea to alternate 1ms each sensor. Thanks for your help :D
 
Hello I am new here. Thanks to all those who contibute time, effort knowledge and code. I read this thread. I tried to use this lib to modify an ino which used a different frequency counter lib called freqcounter. That lib did not support some hardware platforms which I wanted and the freqcount lib does. Original code used a 1ms gate time. When I switched the declarations and function calls to work with the freqcount lib the execution would always hang in the initialization. Then I changed the gate time to 10ms and everything worked, but I wish it could be faster. Is it possible to get it working with 1ms gate time? The hardware right now is with Uno, Pro-Mini and also MEGA arduino boards. I don't have line numbers so I couldn't follow the reference to line 39.

Joe
 
Status
Not open for further replies.
Back
Top