How to measure small frequency LC oscillator changes

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would like to make a 200 liters (53 gallons) trash container volume indicator based on loose LC colpitts oscillator running at 100 kHz. The goal is to identify just four trash container levels: empty, 33%, 66% and full. I already tried TCB - Input Capture Frequency and Pulse-width Measurement with ATtiny202 successfully. Unfortunately the working TCB frequency is just 3.3 MHz witch is not enough to measure the frequency change >= 100 Hz. For 100 kHz LC colpitts oscillator I need to use the TCB frequency about 100 MHz (1/(1/99900-1/100000)). I am not sure if I can alter the fuse for TCB to use internal 20 MHz oscillator for detection >= 500 Hz LC oscillator changes. Maybe Microchip can have a specialized chip for frequency measurement. Any advice would be highly appreciated.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Some of the XMega chips have a clock multiplier and timer counters with (I think) optional 4 extra bits. That will give you much finer frequency count steps.

 

BUT, I think you will have bigger problems than that. Frequency stability, especially over temperature, could be a big issue. And, I think that there will be other problems (variation with bin content, for example - all paper vs all tin cans as extreme cases). 

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kevil wrote:

I would like to make a 200 liters (53 gallons) trash container volume indicator based on loose LC colpitts oscillator running at 100 kHz. The goal is to identify just four trash container levels: empty, 33%, 66% and full. I already tried TCB - Input Capture Frequency and Pulse-width Measurement with ATtiny202 successfully. Unfortunately the working TCB frequency is just 3.3 MHz witch is not enough to measure the frequency change >= 100 Hz. For 100 kHz LC colpitts oscillator I need to use the TCB frequency about 100 MHz (1/(1/99900-1/100000)). I am not sure if I can alter the fuse for TCB to use internal 20 MHz oscillator for detection >= 500 Hz LC oscillator changes. Maybe Microchip can have a specialized chip for frequency measurement. Any advice would be highly appreciated.

 

I'm not quite following, I think you mean you need to measure below 100Hz LSBs on 100kHz, which is 0.1% ?

Reciprocal counters allow any precision you like, and they measure the SysCLKs needed for N whole Fin cycles, then calculate using those 2 numbers : Cycles/TimeTaken = Frequency

SysCLK should be a crystal-like source, of as high a MHz as you can practically get. (In AVR that's 16~20MHz)

 

Or, you can divide down the 100kHz and simply measure period, using a CMOS divider device like HC4060, or the smaller new 74AHC1G42xx family come in SOT353  and can mount on your remote oscillator board easily.

74AHC1G42xx come in 2^8 thru 2^15 choices.  (2^15 gives 3.0517578125 Hz and  2^8 gives 390.625 Hz) 

This part can even do the LC oscillator too.

If the change you want to measure is known to be quite small, you can let a 16 bit counter overflow and ignore the lost MSBs, for simpler code.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@Who-me
74AHC1G4208 looks good but I don't understand how a divider can help me. I need to keep LSB and not lost them.

@ka7ehk

The stability of the LC oscillator is not a problem.  I just need to identify changes in frequency over time e.g. to wake-up ATtiny202 from deep sleep each hour and find out if the change of the frequency is caused by the change of the trash volume content by comparing mean value frequency value over time.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would like to make a 200 liters (53 gallons) trash container volume indicator based on loose LC colpitts oscillator running at 100 kH

How are you measuring how much trash is in the trashcan using an oscillator?  Is the amount of trash proportional to capacitance?    Ultrasonic could be a better approach

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kevil wrote:

@Who-me
74AHC1G4208 looks good but I don't understand how a divider can help me. I need to keep LSB and not lost them.

 

You then measure the period of the now much slower frequency, easy with a simple timer capture.

eg if we assume a 8Mhz crystal sysclk

 8M/(100k/2^8)  = 20480 period capture  which is 20x better than 1 part in 1000

 8M/(100k/2^10)  = 81920 this is 80x better, this overflows but that's fine if you know you have (say) 80~120kHz 
 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 I don't understand how a divider can help me

Lets say you still want to count pulses from your 100 KHz Osc, and not the reciprocal method mentioned above, where you measure the period of the incoming signal.

 

Your system changes weight slowing, and you are only sampling the weight once / hour.

So you can take as long as you like to measure the weight.

 

So, feed the 100,000 Hz zosc signal into a divide by 100 divider.

The output is now 1,000 Hz.

(That is a slow and low frequency for a micro running at 16 or 20 or 32 MHz !)

Count the pulses for 10 seconds and you get 10,000 counts.

 

A simple ISR (Pin change interrupt, for example, but you can do this 10 ways), can increment a counter for a 1,000 Hz signal without working up a sweat.

(Its trivial, the ISR takes a couple of microseconds and the ISR only fires once per mSec !!!)

 

Now dump some trash into the dumpster and change the Osc signal  by 100 Hz, it is now 100,100 Hz.

Divide that by 100 and you now have a signal that is 1,001 Hz.

Now count that for 10 seconds, like above, and the count is 10010 counts.

 

So you have a long (10 Second) gate period, (length of time you are counting the input signal's pulses), but you end up with a difference of 10 counts in your measurement for a 100 Hz change in the input signal's frequency.

 

The above divided down the input signal's frequency at the expense of using a long gate time to measure it, but the measurement then becomes easy.

 

You can apply the same technique to the reciprocal frequency measurement method.

You divide down the input signal's frequency so that its period is longer, then with a given micro's frequency you effectively increase your measurement ability.

 

On a side note, how is the 100 KHz osc physically coupled to the dumpster to give you the frequency that varies with the weight or fill level?

It has nothing to do with the original question, I am just curious as to how you actually generate the signal!

Separate question, is the trash a liquid, or random sized solid trash?

 

JC 

Last Edited: Tue. Feb 11, 2020 - 08:42 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@avrcandies
 

I know it is a little tricky to influence oscillator frequency by volume changes. I will test it of course. Ultrasonic sensor is a classic approach, but it is too big and can be easily damaged or stop to work because of fluid spillage. I would like to transmit data to IoT network.
 

I have already some experience, remote car voltage measurement & IoT (ATtiny202 & Wisol modem BRKWS01).
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@DocJC
 

1000 Hz is 1/1000 i.e. 1 ms. TCB Clock is 3.33 MHz 'CLK_PER (No Prescaling)'. For 1000 Hz it gives 3,333 counts (1/1000 / 1/3.33e6). For 16bit TCB I can extend the measurement max. 19x 3333 = 63 327 counts (65536 / 3333 = 19) not to overflow TCB. For 1001 Hz it gives 19x 3330 = 63 270 counts. Delta is 63 327 - 63 270 = 57.
 

It's worth a try. I will have a look on it more in detail. Thank you for explanation.