Shop OBEX P1 Docs P2 Docs Learn Events
Measure frequency ~ 6 MHz ? — Parallax Forums

Measure frequency ~ 6 MHz ?

RaymanRayman Posts: 14,651
edited 2015-01-18 19:43 in Propeller 1
I'm thinking about how to make a cheap film thickness monitor and need a frequency counter to measure the frequency of a 6 MHz crystal.

Way it works is that you expose the crystal to the deposition and it changes frequency as it gains mass.

So, I need a really precise measurement of the change in frequency...

Can the Prop do this?

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2015-01-18 08:52
    Program a counter to count rising edges. Clear phsa. Let it count for one second, then read phsa. Longer count intervals => more precision.

    -Phil
  • RaymanRayman Posts: 14,651
    edited 2015-01-18 09:17
    Thanks Phil! If you say it can be done, I believe it.

    This might save me about $3100...

    I found a 1978 paper on how to do the crystal part.
    The oscillator circuit is very simple, just a transistor and some passives.
    But, it needs to be close to the crystal. Looks like most people are using a thin semi-rigid coax cable about 1.5 feet long between crystal and oscillator circuit.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2015-01-18 09:36
    Just to be clear: you can get as much precision as you want by extending the sample time. The accuracy, however, will depend upon the accuracy of the Propeller's time base. Since you seem to be more interested in the change in frequency, I assumed the absolute accuracy was not as important.

    -Phil]
  • RaymanRayman Posts: 14,651
    edited 2015-01-18 11:31
    yes, it's just the change in frequency that is important. So, I guess I need precision, but not absolute accuracy...
  • jmgjmg Posts: 15,173
    edited 2015-01-18 12:14
    Rayman wrote: »
    I found a 1978 paper on how to do the crystal part.
    The oscillator circuit is very simple, just a transistor and some passives.
    But, it needs to be close to the crystal. Looks like most people are using a thin semi-rigid coax cable about 1.5 feet long between crystal and oscillator circuit.

    I would use a 1GX04 or similar, which is a Unbuffered gate + schmitt in one smd package.
    Drive the cable with a modest resistor to reduce ringing, but not slow down the edges too much

    The old 1 second gate gives a simple counter, but you can do better, if chasing ppb.

    A Reciprocal Counter measures Cycles and Time, and captures time aligned to an edge of Fin.
    'Gate Time' is thus nominal, and rounds or snaps to whole cycles.
    Frequency = CyclesRead/TimeTaken

    eg If you can resolve to 10ns, this gives a 10ppb-sec product.
    ie in one second, you get 10ppb, 100ms ius 100ppb.,

    If you can be careful enough to not miss any edges, then you can run Dual rate Reciprocal Counting,
    eg show rapid 100ms updates, but also run a 10s total, which gives 1ppb

    It may be tricky to avoid missing edges at 6MHz, but the good thing about edge timing, is you can divide the Fin with no loss of precision, as the edges are what matters (& those resolve to ~10ns)
    - so a small fixed divider is ok, to get to 1~10us say

    That would suggest a LV4060 or HC6323 at the crystal end (and allows you do experiment with almost any crystal)


    Of course, you need a good TXCO for the master timebase, and I'm not sure how good the Prop PLL is ?.
    Probably ok to stay << 10ns, as the PLL divide ratio is small.

    You could also measure a 1pps GPS on another COG, to allow a cheap crystal to be used, and that also proves your ppb levels.


    On a Prob you code as
    Wait for Fin Edge - capture Time and Edge
    Wait for NominalGateTime
    wait for FinEdge - capture Time and Edge
    Calculate ChangeinEdge/ChangeinTime

    Numeric precision can also matter here, if you send raw 32b values to a PC and calculate in 64b reals, you can get a numeric LSB of 0.2ppb, but a 32b real has a numeric LSB of about 60ppb
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2015-01-18 12:21
    jmg wrote:
    Of course, you need a good TXCO for the master timebase,
    He's already stated that absolute accuracy is unimportant.

    -Phil
  • jmgjmg Posts: 15,173
    edited 2015-01-18 12:42
    He's already stated that absolute accuracy is unimportant.

    Yes, but plating is not a fast process, and any timebase drift is directly thickness error.
    You certainly want a Reference that you know does not wander, and TCXO are not expensive.
    eg FOX924B is just $2.73 1+ for 2.5ppm out of the box precision.
    Even VCTXCOs are affordable, (eg ASVTX-09 ~ $3.47 1+) if you want to trim things using the GPS 1pps


    I see even now a MEMS VCTCXO (SIT5000AICGD-33N0-25.000000Y) for $1.89 claims 2.5ppm
    - tho I'd be wanting to test a MEMS part, the data claims a 2.5ppm precision with 12.5ppm pull range, which is impressive for that price.
    A thirsty part at 33mA

    Any TCXO/VCTCXO would use a SO8 HC6323 for scaling, as sub 10MHz is outside the market sweet spot.
  • RaymanRayman Posts: 14,651
    edited 2015-01-18 14:55
    Thanks for the options. I'll try it the regular way first and see how bad the drift is...
  • jmgjmg Posts: 15,173
    edited 2015-01-18 19:43
    Rayman wrote: »
    Thanks for the options. I'll try it the regular way first and see how bad the drift is...

    An alternative approach, since you do not want a frequency number, and you know Fin scale to start with, is to use a HC4060 at the crystal probes (as OSC + Divider), and use SW to time (say) 366 cycles of the 2.7ms period that the 4060 outputs.
    With a 100MHz sysclk, the ~1s update time of 366 cycles resolves Period deviations to ~ 10ppb
    Or, as before, timing ~37 cycles updates @ about 100ms, with 100pb resolution.

    #Cycles is locked in code, and Period gives better precision than Frequency, without the equation of Reciprocal Counting.
  • RaymanRayman Posts: 14,651
    Just an update... It works!

    Using circuit from paper "A simple and inexpensive method of measuring thin film thicknesses".
    Circuit is simple, just a single BC109 transistor and a few passives hooked up to the 6 MHz crystal.a

    Sending this to a high-speed rail-to-rail opamp with single 3.3V rail and one input tied to ground to from a comparator to ground. This turns the ground biased sine wave into a 0 to 3.3V square wave.

    When update rate is one second, only seeing variations of +/- 1 digit out of 6 million. Pretty good...

    Using Propeller counter module makes code very simple (attached). This actually saves a lot of money as the boxes you can buy to do this job costs $1700.
  • Rayman,
    Let me be the first to congratulate you on job well done!
    I love productivity improvement stories like this!
Sign In or Register to comment.