Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 13 of 13

Thread: Problem FreqCount Lib No read after 12MHz

  1. #1
    Junior Member KE4EST's Avatar
    Join Date
    Nov 2017
    Location
    Far Western NC, USA
    Posts
    8

    Problem FreqCount Lib No read after 12MHz

    Hello All first time poster.
    I have searched and search so I apologize if this has been asked or explained before.
    I am using the FreqCount library that Paul wrote on a teensy 3.5.
    It works really great until after about 10 MHz. Then it starts losing accuracy and then after 12 MHz it starts showing a drop in frequency.
    Hit somewhere around 16-17 MHz and it just shows 0. I am using the library and example just just as Paul has it.
    I am also using the buffer circuit on the same page, only thing different is I am using a 2N2222, but am using a 74HC14.

    Has anyone ran into this? Is my transistor too slow? Wanted to ask before I start changing out parts.
    According to the description the teensy 3.0 and 3.1 show be able to go to 65MHz. Is there something different with the 3.5?
    I need to at least be able to go to 40MHz for the time being, I could use a divider, but wanted to know what is going on?
    Thanks

  2. #2
    Junior Member
    Join Date
    Mar 2017
    Location
    Colorado Springs, CO
    Posts
    8
    About a year ago I was experimenting with counting frequency using an Arduino and a Teensy LC. I did not keep great notes but I do recall that I was having problems counting as the frequency was increased. I was also using the buffer circuit similar to what you described. When I quit using the buffer, I was able to reliably count up to 16 MHz with the Teensy LC. The Arduino was only able to get 5 or 6 MHz.

  3. #3
    Junior Member KE4EST's Avatar
    Join Date
    Nov 2017
    Location
    Far Western NC, USA
    Posts
    8
    Thanks for the reply! Funny how you just posted this and not only 10 minutes ago I bypassed the 74HC14 buffer. Still have the transistor circuit in place but now it is worse, it starts cutting out at around 5 MHz just like an Arduino uno.
    I looked at the data sheet for a 2N2222 and it says it can switch up to 100MHz so I am still at a loss here as to what is going on.

  4. #4
    Junior Member KE4EST's Avatar
    Join Date
    Nov 2017
    Location
    Far Western NC, USA
    Posts
    8
    OK, getting somewhere here! Using an Si5351 circuit and rotary in encoder on another board as a test I got it to read up to 65MHz.
    I bypassed the circuit all together and fed the signal out of my test setup straight into the pin on the teensy, watching that voltage didn't go over 3.3V.
    Trying other signal sources though it would not read. So an pre-amp still needs to be used, I just have to do some more experimenting.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    17,022
    I just did a test here too, got up to about 65 MHz. I made a video, it's uploading now....

    Edit: here's the test I did.

    Last edited by PaulStoffregen; 11-24-2017 at 04:22 AM.

  6. #6
    Junior Member KE4EST's Avatar
    Join Date
    Nov 2017
    Location
    Far Western NC, USA
    Posts
    8
    Thank you very much Paul, for making the video and thoroughly checking this out!
    The whole goal here is to make a full homebrew Frequency counter.
    Now if I could just come up with a divider circuit that can handle at least 150MHz.
    I tried the 74HC4017 and after around 50MHz I got erroneous readings, quick look at the data sheet and it said if I recall 49MHz max. Heck the teensy 3.5 can count higher.
    I would like a counter that would be able to got up to at least the 2 meter ham band, but 440 would be nicer.

  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    17,022
    Maybe something like Digikey 220-1007-ND, if you bypass the PLL and only use its divider & buffers?

    https://www.digikey.com/product-deta...8I/220-1007-ND

    Or perhaps 576-1537-5-ND

    https://www.digikey.com/product-deta.../576-1537-5-ND

  8. #8
    Junior Member KE4EST's Avatar
    Join Date
    Nov 2017
    Location
    Far Western NC, USA
    Posts
    8
    Thanks Paul. Looking at the data sheets, I really like the first one. I may just give that a try.
    Was hoping for a DIP chip but I can make that work.

  9. #9
    Junior Member KE4EST's Avatar
    Join Date
    Nov 2017
    Location
    Far Western NC, USA
    Posts
    8
    Paul I have another question. Could the library be optimized for the teensy 3.x boards that are a real 32-bit.
    Or perhaps have a library just for 3.x boards. Just thinking out loud here.
    The accuracy of the counter gets worse the higher in frequency you go, still pretty good for a home-brew counter mind you.
    If I feed it a stable 60MHz signal for example it is reading about 66-68 Hz too low.
    Is this a hardware limitation causing this, or could accuracy be improved using say double instead of float or uint64_t instead of uint32_t in the library ... or am I way off.

  10. #10
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    17,022
    Quote Originally Posted by KE4EST View Post
    Could the library be optimized for the teensy 3.x boards that are a real 32-bit.
    It already is. 32 bit numbers are used, even on the 8 bit AVR chips.

    Is this a hardware limitation causing this
    Good question. Honestly, Freescale's documentation on the LPTRM timer leaves quite a lot to be desired.

    There's reason to believe it might be doing some sort of clock sync that loses accuracy above F_BUS/2 (which would be 30 MHz).

    or could accuracy be improved using say double instead of float or uint64_t instead of uint32_t in the library
    The library uses uint32_t, which could count up to 4.29 GHz over a 1 second gate interval, so numerical precision just isn't an issue here.

  11. #11
    Junior Member KE4EST's Avatar
    Join Date
    Nov 2017
    Location
    Far Western NC, USA
    Posts
    8
    Quote Originally Posted by PaulStoffregen View Post

    Good question. Honestly, Freescale's documentation on the LPTRM timer leaves quite a lot to be desired.

    There's reason to believe it might be doing some sort of clock sync that loses accuracy above F_BUS/2 (which would be 30 MHz).
    That makes sense. I will just compensate in software.

    Quote Originally Posted by PaulStoffregen View Post

    The library uses uint32_t, which could count up to 4.29 GHz over a 1 second gate interval, so numerical precision just isn't an issue here.
    Of course, I was just using that as an example, probably not the best. Yes, uint32_t is plenty.

  12. #12
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    17,022
    Quote Originally Posted by KE4EST View Post
    I will just compensate in software.
    If it really is hardware sampling metastability, there probably isn't any reliable software compensation. The only solution would be keeping the input below 30 MHz (or half of whatever F_BUS speed you use).

    Of course, that's based on a big "if". Freescale's documentation has conflicting and confusing info in this particular case.

  13. #13
    Junior Member KE4EST's Avatar
    Join Date
    Nov 2017
    Location
    Far Western NC, USA
    Posts
    8
    Thanks for your thoughts. If this is the case that is most likely true.

Posting Permissions

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