Author Topic: Possible to make a quality universal timer/counter using $12 PIC counter+GPSDO?  (Read 7781 times)

0 Members and 1 Guest are viewing this topic.

Offline cdevTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 7350
  • Country: 00
Thank you for those HP Journal articles.

It would be great to be able to visualize how this process works.

"What the large print giveth, the small print taketh away."
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3802
  • Country: au
What you will find is that a microcontroller has a limited ability to be a good frequency counter. I will try and describe what a micro may be able to achieve.

Here is the article about the 5315A counter

http://www.hpl.hp.com/hpjournal/pdfs/IssuePDFs/1979-01.pdf

I have attached a block diagram of the counter IC.

If you want to use a micro to do the counting, the micro has to implement similar functionality. The interesting thing about this diagram is that it differentiates the dark blue high speed logic that has to be done in hardware with the light blue low speed that can be done in micro memory via interrupts.

So to do as much as possible in a micro, you will need at least two hardware counters - preferably 16 bit. If the counters can have a count input and a separate input that can gate the counter (ie start and stop it), that is more promising. The hardware counter cannot store the full 8 or more digits of resolution you will want, so when one of the counters overflows, it generates an interrupt and a bigger counter in micro memory gets incremented.

A third thing that is needed is the gate time which in this counter is just done with a RC circuit. So you could use a simple NE555 timer circuit with an attached potentiometer if you wanted to.

So here is the sequence to try and match the 1974-type technique. In the following, the word "input" means the actual signal input into the frequency counter with the unknown frequency.

The 555 goes high:
Counter1 starts counting at a 10MHz rate the first time the input goes high.
Counter2 starts counting the number of low to high transitions from the input.

When the 555 output goes low:
Counter1 stops counting on the first high transition of the input after the 555 goes low.
Counter2 stops counting as soon as the 555 output goes low.

Now what you have is that Counter2 has the number of input cycles that happened during the 555 high time. Lets call in N cycles.
Counter1 has the period in increments of 100ns of N cycles.

The period of each input cycle will be Counter1/Counter2

The frequency will be the inverse - Counter2/Counter1

As long as the gate time is longer then the period of the signal on the input, this method will always return a precision of reading that is near to Gating period x 10MHz.

So if the gating period is 1 second you can get 6 or 7 digits of resolution
If the gating period is 10 seconds, you get 7 or 8 digits of resolution
100 seconds can give 9 digits.

To measure frequencies higher then the micro can count directly, add divider ICs between the input and the micro.

Now if you feel like taking the step to a FPGA, you can fully implement the counters of any length in hardware, you can run at 200MHz or more, you can add the exact gating and sequencing logic you need, and you can come back later and change the FPGA design to improve the counter without changing any hardware. It is just an option as the best way to learn FPGA's is to have an interesting project. You can just get a FPGA demo board and use it directly in you project.

« Last Edit: February 03, 2018, 03:24:06 pm by amspire »
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16615
  • Country: us
  • DavidH
100ns timing resolution from a 10MHz clock will give you 7 digits per second of gate time.  This is what the HP5315A series of counters deliver and many microcontrollers can handle this easily without an external counter.

10ns timing resolution from a 100MHz clock will give you 8 digits per second of gate time but pretty much requires external logic for the first counting stage.  Offhand I do not know of any microcontrollers which can handle this internally.  Commercial counters that operated with a 100MHz or higher clock are not common.

An easier method is to add interpolation between reference clock cycles and some microcontrollers like the PIC18F26K22 that I mentioned have this built in.  I would be disappointed if it could not achieve 9 digits per second using a 10MHz reference which is the performance of a counter like the Racal-Dana 1992.
 
The following users thanked this post: cdev

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3802
  • Country: au
An easier method is to add interpolation between reference clock cycles and some microcontrollers like the PIC18F26K22 that I mentioned have this built in.  I would be disappointed if it could not achieve 9 digits per second using a 10MHz reference which is the performance of a counter like the Racal-Dana 1992.
An interesting chip.

Do you have any description on how you could use the CTMU (Charge Time Measurement Unit) to increase resolution?

Looking at the possibilities, it can charge at 55uA and the inherent capacitance is something like 4pF so that means you can potentially get a charge rate a bit over 1V in 100ns. Then using the A/D, you can definitely resolve to sub nanosecond levels.

Not sure I can get my head around how to actually do it. If you are going to measure the exact period of 1000 input frequency cycles for example, you have to use the CTMU to capture the time difference between the incoming frequency edges and the 10MHz clock edges both at the start of the 1000 cycle sequence and at the end.

It would be great if there is an example of using the CTMU in an application like this. It does seem possible, but I am not sure how easy or hard it will be.
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16615
  • Country: us
  • DavidH
Do you have any description on how you could use the CTMU (Charge Time Measurement Unit) to increase resolution?

Not sure I can get my head around how to actually do it. If you are going to measure the exact period of 1000 input frequency cycles for example, you have to use the CTMU to capture the time difference between the incoming frequency edges and the 10MHz clock edges both at the start of the 1000 cycle sequence and at the end.

It is just doing the same thing that the PICTIC II does externally.  It would take two CTMUs to capture the start and end differences unless the pulse width or gate time was long enough to make two measurements in series using one CTMU.

Quote
It would be great if there is an example of using the CTMU in an application like this. It does seem possible, but I am not sure how easy or hard it will be.

I have not seen anybody use one this way but the CTMU application notes from Microchip cover what needs to be done.  Anybody who can do this using a CTMU can design the rather simple circuit for doing it discretely.
 

Offline KE0LFX

  • Contributor
  • Posts: 12
  • Country: us
Well, I have success on the TruePosition GPSDO Arduino Control........Thanks to all of you that answered my questions........65 second cold boot to GPS lock.....

https://youtu.be/c35RCqOOulY
 
The following users thanked this post: cdev

Offline texaspyro

  • Super Contributor
  • ***
  • Posts: 1407
Lady Heather + RasPI + PI Touchscreen (800x480) is sexier    8)
 
The following users thanked this post: cdev

Offline cdevTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 7350
  • Country: 00
Beautiful!


Well, I have success on the TruePosition GPSDO Arduino Control........Thanks to all of you that answered my questions........65 second cold boot to GPS lock.....

https://youtu.be/c35RCqOOulY




Lady Heather + RasPI + PI Touchscreen (800x480) is sexier    8)

Looking forward to its release.

I have an older Pi that would be just perfect for that.
"What the large print giveth, the small print taketh away."
 

Offline Squiddaddy

  • Regular Contributor
  • *
  • Posts: 90
  • Country: us
I am interested in the new Lady Heather that supports the TruePosition.
I have a later board with firmware 12.1.1.
Just getting started with it.
 

Offline texaspyro

  • Super Contributor
  • ***
  • Posts: 1407
I am interested in the new Lady Heather that supports the TruePosition.
I have a later board with firmware 12.1.1.
Just getting started with it.

https://www.eevblog.com/forum/metrology/lady-heather-v6-beta-for-windows-exe/msg1434005/#msg1434005
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf