Controlling noise in frequency shift capacitance measurement

Thread Starter

Kossi Nouwakpo

Joined Jul 23, 2017
11
Hi,

I am trying to develop a capacitance probe. I am taking advantage of the external RC oscillator capability of an AVR ATTINY26 to design this probe. The probe is built into a network of capacitors couple with a resistor to form the RC oscillator of the TINY26. The nominal frequency F of the TINY26 is around 8MHZ and varies slightly based on the capacitance at the probe. The TINY26 is programmed to send a pulse train through one of its pins at a frequency F/n. Another AVR microcontroller/transceiver (ATMEGA256RFR2) is used to count the F/n pulse train and send the data to a coordinator. To ensure long term stability, the ATMEGA controls a digital switch that connects the capacitor network cyclically to (1) an 18pf 1% capacitor then the corresponding frequency fc is measured, then to (2) ground to measure the base capacitance fb and finally (3) to the probe leads to measure fs. The frequencies fs, fb and fc are radio-transmitted to a coordinator and a variable y = (fb-fs)/(fb-fc) calculated.
I tested the probe in soil to use as a soil moisture sensor. The data was however excessively noisy (see graph). In the graph, y values should drop from ~1.3 before water was added to the soil and should gradually increase back up as the soil dries out. The true signal can be seen during intermittent quieter moments in the circuit. I have to mention that the circuit has been printed on a 4 layer board and I followed as much as possible guidelines to reduce EMI noises (with filters, ferrite beads and decoupling capacitors). I have tried to document things I have done that could effect noise emission and/or pickup during the monitoring. These are marked by the orange markers and labelled on the graph. Adding a decoupling capacitor to the battery did not help. I also replaced the straight wires connecting the probe leads to the board with twisted wires and wrapped the whole board in aluminum foil (connected to ground) to no avail.
I have been working on this issue for some time now but with little success. Does anyone have any idea what the issue might be? Why does the signal quiet down sometimes and then get very noisy others? Could this be an issue with the TINY26 not being stable enough to maintain a steady frequency? If so, what is a low cost compact alternative?
Your suggestions are greatly appreciated.
Thanks
Clipboard01.jpg Clipboard01.jpg
 

DickCappels

Joined Aug 21, 2008
6,542
Are you using the on-chip oscillator? In any case, make sure your power supply is clean.

Some of the on-chip oscillators are noisy. On the average, the frequency is stable, but cycle-to-cycle it can be . A couple of ways around this are to average over a lot of cycles, such as by adding 32 consecutive measurements then shift right five times, or even better use a 74HC14 as a Schmitt trigger RC oscillator -again be careful to keep the power supply clean. If any of the controller clock leaks out to the 74HC14 the oscillator will tend to cog on sub-harmonics which will give you flat spots in the capacitance-to-frequency response.

Some waveforms are shown at the link below. You can click on the Translate this page link in the upper-right of the page.
http://www.microsofttranslator.com/bv.aspx?from=ja&to=en&a=http://elm-chan.org/docs/avr/jitter.html
 

Thread Starter

Kossi Nouwakpo

Joined Jul 23, 2017
11
DickCappels,

Thank you for your response. On the ATtiny26, I am using the external RC oscillator option i.e. XTAL1 is connected to VCC via the resistor R and to GND via the capacitor C. I believe the chip has some internal components that use the external R and C to generate the oscillations. Very few ATMEL chips have the external RC oscillator option. I will try a longer averaging window. I am not sure though what you mean by "shift right five times". If increasing the averaging window does not help, I might consider developing a new board based on the 74HC14 Schmitt trigger RC oscillator.
 

DickCappels

Joined Aug 21, 2008
6,542
Shifting the accumulated value five times to the right divides the value by 32. That's what I do in assembly language. If you are using C you can be more direct in the way you divide.

As I tried to indicate, the 74HC14 approach is not foolproof and is susceptible to interference.
 
Top