Author Topic: DIY frequency counter  (Read 14027 times)

0 Members and 1 Guest are viewing this topic.

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3508
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
DIY frequency counter
« on: May 11, 2015, 05:08:21 pm »
So another of my DIY gear posts. Here instead of DMM or voltage reference with some volt nuttery, this is about frequency and slight time nuttery. I am thinking about rolling a frequency counter.

Specs: 10Hz to 100MHz, 10Vp-p max input voltage.

The MCU is ATmega32U4. USB is used to talk to a computer. (I think it is obvious now that my projects usually talks to a computer, so data logging and digital calibration can be made real easy, and heavy-haul calculation is allowed with a computer attached)

Questions:

1) Is DS3231 a good enough time base alone?

2) Since my time base emits 32768Hz, how to measure frequencies orders of magnitude above, below or around the same of the reference clock? How does the math pan out? Which pin is to interrupt and which pin is to count?
 

Offline kjs

  • Regular Contributor
  • *
  • Posts: 97
  • Country: de
Re: DIY frequency counter
« Reply #1 on: May 11, 2015, 06:39:28 pm »
It all depends on what you want to achieve. For my purposes that time-base would be utterly useless as I need 10E-12 worst case. The good thing is that with that thermometer as a reference you won't have to worry about differences in the gate transition time (vs temp and voltage).
 

Offline lincoln

  • Regular Contributor
  • *
  • Posts: 161
  • Country: us
Re: DIY frequency counter
« Reply #2 on: May 11, 2015, 07:02:15 pm »
Here is a good primer: http://www.npl.co.uk/upload/pdf/20060209_t-f_johansson_1.pdf
There is a lot of interest over at the time nuts using this chip and an integrator :http://www.acam.de/tdc-gp22/
 

Offline dom0

  • Super Contributor
  • ***
  • Posts: 1485
  • Country: 00
Re: DIY frequency counter
« Reply #3 on: May 11, 2015, 07:16:22 pm »
A 32 kHz reference clock is, honestly, just shit for a bench frequency counter. You'll get, with the usual reciprocal technique, only 4.5 digit/seconds out of it. Use at least a 10 MHz ref clock.
,
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3508
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: DIY frequency counter
« Reply #4 on: May 11, 2015, 08:57:21 pm »
A 32 kHz reference clock is, honestly, just shit for a bench frequency counter. You'll get, with the usual reciprocal technique, only 4.5 digit/seconds out of it. Use at least a 10 MHz ref clock.

Those 10MHz ref clocks get real expensive real fast if treading into TCXO or OCXO lands. The Maxim chip, despite its lower frequency, is cheap and provides a good DTCXO. Also 4.5 digits performance is okay with me.
 

Offline dom0

  • Super Contributor
  • ***
  • Posts: 1485
  • Country: 00
Re: DIY frequency counter
« Reply #5 on: May 11, 2015, 09:07:29 pm »
New, certainly, used and thus nicely aged you can get very good OCXOs at the usual frequencies for 30 bucks or less.

You must be a patient man if you're willing to not only use but tediously build a counter so slow that you need to wait just short of a full hour for a eight digit reading that a more properly designed counter can obtain in a few seconds or less. And that's just the effect of a single design parameter you fixed to some unreasonable value for... what exactly?
,
 

Offline Dragon88

  • Regular Contributor
  • *
  • Posts: 88
Re: DIY frequency counter
« Reply #6 on: May 12, 2015, 12:07:59 am »
Those 10MHz ref clocks get real expensive real fast if treading into TCXO or OCXO lands. The Maxim chip, despite its lower frequency, is cheap and provides a good DTCXO. Also 4.5 digits performance is okay with me.

You can get a semi-decent 10MHz OCXO for $30 on eBay, that will swim laps around any watch crystal in terms of stability and usefulness in a counter. And the design of the counter itself is not trivial. Trying this project with an RTC module will just be wasting your...time. (pun intended)

You're better off buying a good used HP frequency counter on eBay, and learning how it works. Really study the theory of operation. Far more will be learned from that.
 

Offline Liv

  • Regular Contributor
  • *
  • Posts: 139
  • Country: by
Re: DIY frequency counter
« Reply #7 on: May 12, 2015, 07:31:46 am »
There is a lot of interest over at the time nuts using this chip and an integrator :http://www.acam.de/tdc-gp22/

In a frequency counter I used a simple interpolator scheme based on two current sources: DIY interpolating reciprocal frequency counter FC-510.
PSU PSL-3604 Pulse gen. PG-872 Freq. cnt. FC-510
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3508
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: DIY frequency counter
« Reply #8 on: May 12, 2015, 12:33:54 pm »
New, certainly, used and thus nicely aged you can get very good OCXOs at the usual frequencies for 30 bucks or less.

You must be a patient man if you're willing to not only use but tediously build a counter so slow that you need to wait just short of a full hour for a eight digit reading that a more properly designed counter can obtain in a few seconds or less. And that's just the effect of a single design parameter you fixed to some unreasonable value for... what exactly?

30 bucks is three times the price point I am aiming.

Cost. DS3231 costs less than 25 US cents here.
 

Offline smjcuk

  • Frequent Contributor
  • **
  • Posts: 464
  • Country: gb
Re: DIY frequency counter
« Reply #9 on: May 12, 2015, 01:22:03 pm »
A 10.000MHz standard xtal will give you better precision than that IC as the period is only likely to be relevant once per second and the number of cycles is a lot higher. If you use a precision frequency standard/OXCO with a low reference clock speed, you're going to have to make pretty large guesses on high frequencies. Plus you have I2C bus latency to consider there and the fact that it's a time standard, not a frequency standard.

In fact if you have a 10.000MHz standard xtal, at 100MHz you're looking at 10.0Hz precision. 32768Hz source, you're looking at 3KHz precision. These are only approximate magnitudes of difference and I'm not rounding properly but you get the idea.

Plus you can do this with just plain old TTL with a prescaler, some counters and display drivers, LED displays and a shit crystal for $50 or so or as someone said, buy one.
 

Online daqq

  • Super Contributor
  • ***
  • Posts: 2339
  • Country: sk
    • My site
Re: DIY frequency counter
« Reply #10 on: May 12, 2015, 01:24:28 pm »
Quote
Those 10MHz ref clocks get real expensive real fast if treading into TCXO or OCXO lands. The Maxim chip, despite its lower frequency, is cheap and provides a good DTCXO. Also 4.5 digits performance is okay with me.
If you want it as a one shot project then go to ebay - you'll find lots of OCXO for reasonable prices. You can also build a thermostat around your average oftheshelf crystal or TCXO which are considerably cheaper. Don't know about the long term characteristics though.
Believe it or not, pointy haired people do exist!
+++Divide By Cucumber Error. Please Reinstall Universe And Reboot +++
 

Offline edavid

  • Super Contributor
  • ***
  • Posts: 3699
  • Country: us
Re: DIY frequency counter
« Reply #11 on: May 12, 2015, 03:42:29 pm »
You can also build a thermostat around your average oftheshelf crystal or TCXO which are considerably cheaper.

That doesn't work, because crystals that are not intended to be ovenized are cut with turnover near room temperature.
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3508
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: DIY frequency counter
« Reply #12 on: May 12, 2015, 04:12:32 pm »
A 10.000MHz standard xtal will give you better precision than that IC as the period is only likely to be relevant once per second and the number of cycles is a lot higher. If you use a precision frequency standard/OXCO with a low reference clock speed, you're going to have to make pretty large guesses on high frequencies. Plus you have I2C bus latency to consider there and the fact that it's a time standard, not a frequency standard.

In fact if you have a 10.000MHz standard xtal, at 100MHz you're looking at 10.0Hz precision. 32768Hz source, you're looking at 3KHz precision. These are only approximate magnitudes of difference and I'm not rounding properly but you get the idea.

Plus you can do this with just plain old TTL with a prescaler, some counters and display drivers, LED displays and a shit crystal for $50 or so or as someone said, buy one.

Can I run digital temperature compensation using a normal HC49/S crystal oscillator and a temperature sensor like DS18B20, tucking the SOT-23 device between the pins of the crystal, and thermally bond them together using a bit of heatsink compound?
« Last Edit: May 12, 2015, 04:14:44 pm by technix »
 

Offline Liv

  • Regular Contributor
  • *
  • Posts: 139
  • Country: by
Re: DIY frequency counter
« Reply #13 on: May 12, 2015, 04:13:49 pm »
That doesn't work, because crystals that are not intended to be ovenized are cut with turnover near room temperature.

Then use the heating/cooling TEC instead heater :)
PSU PSL-3604 Pulse gen. PG-872 Freq. cnt. FC-510
 

Offline smjcuk

  • Frequent Contributor
  • **
  • Posts: 464
  • Country: gb
Re: DIY frequency counter
« Reply #14 on: May 12, 2015, 04:34:22 pm »
A 10.000MHz standard xtal will give you better precision than that IC as the period is only likely to be relevant once per second and the number of cycles is a lot higher. If you use a precision frequency standard/OXCO with a low reference clock speed, you're going to have to make pretty large guesses on high frequencies. Plus you have I2C bus latency to consider there and the fact that it's a time standard, not a frequency standard.

In fact if you have a 10.000MHz standard xtal, at 100MHz you're looking at 10.0Hz precision. 32768Hz source, you're looking at 3KHz precision. These are only approximate magnitudes of difference and I'm not rounding properly but you get the idea.

Plus you can do this with just plain old TTL with a prescaler, some counters and display drivers, LED displays and a shit crystal for $50 or so or as someone said, buy one.

Can I run digital temperature compensation using a normal HC49/S crystal oscillator and a temperature sensor like DS18B20, tucking the SOT-23 device between the pins of the crystal, and thermally bond them together using a bit of heatsink compound?

No. Get a canned xtal and some snips and take one to bits. You'll find it suspended inside the can on the two leads. There will be a temp gradient between the xtal itself and the case so a delta-t in the time it takes to measure or compensate. Also then you can only adjust out the xtal with something like a varactor.

Just use a normal xtal for version 1.
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3508
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: DIY frequency counter
« Reply #15 on: May 12, 2015, 04:43:15 pm »
A 10.000MHz standard xtal will give you better precision than that IC as the period is only likely to be relevant once per second and the number of cycles is a lot higher. If you use a precision frequency standard/OXCO with a low reference clock speed, you're going to have to make pretty large guesses on high frequencies. Plus you have I2C bus latency to consider there and the fact that it's a time standard, not a frequency standard.

In fact if you have a 10.000MHz standard xtal, at 100MHz you're looking at 10.0Hz precision. 32768Hz source, you're looking at 3KHz precision. These are only approximate magnitudes of difference and I'm not rounding properly but you get the idea.

Plus you can do this with just plain old TTL with a prescaler, some counters and display drivers, LED displays and a shit crystal for $50 or so or as someone said, buy one.

Can I run digital temperature compensation using a normal HC49/S crystal oscillator and a temperature sensor like DS18B20, tucking the SOT-23 device between the pins of the crystal, and thermally bond them together using a bit of heatsink compound?

No. Get a canned xtal and some snips and take one to bits. You'll find it suspended inside the can on the two leads. There will be a temp gradient between the xtal itself and the case so a delta-t in the time it takes to measure or compensate. Also then you can only adjust out the xtal with something like a varactor.

Just use a normal xtal for version 1.

The digital compensating is done by mathematically applying a coefficient that is a function of the temperature, as read from the temperature sensor, to crystal signal count. It is all math inside the microcontroller.
 

Offline Nuno_pt

  • Frequent Contributor
  • **
  • Posts: 435
  • Country: pt
Re: DIY frequency counter
« Reply #16 on: May 12, 2015, 04:55:30 pm »
You can get OCXO's of 10MHz like Isotemp or Marion very cheap, Marion 89a it's an DOCXO and it cost around $20, the 103 around $10, and it's a lot better.
Nuno
CT2IRY
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3508
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: DIY frequency counter
« Reply #17 on: May 12, 2015, 05:00:41 pm »
You could always use whatever the best local oscillator you wish to afford & install and have a little PPS or radio clock receiver that is used for calibrating the local oscillator and/or for permitting longer interval reciprocal counting with relatively good accuracy.  I guess if spending an extra $12US is too much you probably aren't going to get a good PPS source for much less than that, so that leaves radio clock input.  Someone here in another thread recently mentioned making a $1US WWV "receiver".  That would be about the minimum needed I suppose for a little resonator/filter, wire antenna of sorts, and feed that into your MCU for time extraction.

I do have a u-blox 6010 GPS module with TTL-level 9600 baud UART and PPS output...
 

Offline Richard Crowley

  • Super Contributor
  • ***
  • Posts: 4319
  • Country: us
  • KJ7YLK
Re: DIY frequency counter
« Reply #18 on: May 12, 2015, 05:05:19 pm »
Are there any GPS receivers that output an HF reference (10MHz, etc.)?
1 Hz (1 PPS) is fine for wall-clock time-keeping, but is GPS useful for laboratory testing?
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3508
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: DIY frequency counter
« Reply #19 on: May 12, 2015, 05:07:54 pm »
You can get OCXO's of 10MHz like Isotemp or Marion very cheap, Marion 89a it's an DOCXO and it cost around $20, the 103 around $10, and it's a lot better.

The cheapest 10MHz TCXO I can find is US$1.5/each SMT ones.
 

Offline Nuno_pt

  • Frequent Contributor
  • **
  • Posts: 435
  • Country: pt
Re: DIY frequency counter
« Reply #20 on: May 12, 2015, 05:14:21 pm »
Are there any GPS receivers that output an HF reference (10MHz, etc.)?
1 Hz (1 PPS) is fine for wall-clock time-keeping, but is GPS useful for laboratory testing?

Some, you'll see them on eBay, but they are very expensive.
The best to do it's take some GPS board like Navman Jupiter, and similar and take the 10kHz signal run it trough some dividers 74H and then join an OCXO and voilĂ , you've and GPSDO, Google it.

The GPS will give long term stability and the OCXO the short term, the power supply have to be well filter, because of the jitter.

The first one are G3RUH with Isotemp, but you can put an Morion, very suite for laboratory test gear.
Nuno
CT2IRY
 

Offline Vgkid

  • Super Contributor
  • ***
  • Posts: 2753
  • Country: us
Re: DIY frequency counter
« Reply #21 on: May 12, 2015, 05:18:11 pm »
Are there any GPS receivers that output an HF reference (10MHz, etc.)?
1 Hz (1 PPS) is fine for wall-clock time-keeping, but is GPS useful for laboratory testing?
The u-blox 6T will run from 1Hz to 10MHz.
If you own any North Hills Electronics gear, message me. L&N Fan
 

Offline Liv

  • Regular Contributor
  • *
  • Posts: 139
  • Country: by
Re: DIY frequency counter
« Reply #22 on: May 12, 2015, 05:46:39 pm »
The digital compensating is done by mathematically applying a coefficient that is a function of the temperature, as read from the temperature sensor, to crystal signal count. It is all math inside the microcontroller.

Frequency counter - is a device that does not require the exact value of the reference frequency generator, for example, 10.000 MHz. It requires only know exactly the real oscillator frequency, and then in calculating the indicated value to use it. So the idea of passive temperature compensation is quite right to life. Usually MCXO use dual-mode oscillator for quartz self-sensing temperature. But if the demands are not as high, you can use an external thermometer. But it should have high resolution and be isothermal together with the resonator. Once the calibration is required to pass the entire range to produce correction table.

The u-blox 6T will run from 1Hz to 10MHz.

But with huge jitter.
« Last Edit: May 12, 2015, 08:07:30 pm by Liv »
PSU PSL-3604 Pulse gen. PG-872 Freq. cnt. FC-510
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3508
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: DIY frequency counter
« Reply #23 on: May 14, 2015, 10:13:33 am »
Rounding up suggestions, I will want to use a higher frequency time base for this. So will my 50MHz crystal oscillator (one of those 4-pin cans) help?

Also since DS3231 have a far better accuracy than the 50MHz XO, can I use the DS3231 to digitally compensate the errors and provide a stable gate control?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf