How can we compare different capacitance sensors?

Posted: 8/23/2021 6:10:53 AM
andreyrogatkin

Joined: 1/27/2021

Hello,

I am planning to design a digital theremin. At this first stage of the project I only look at it as a problem of constructing a good sensor which converts capacitance to digits. Reading this forum I can’t find the answer to the main designer question: what parameter is to be optimized? And how can we compare different designs? I am not interested in how many octaves an instrument has, how long is its neck, how good is its linearity, how bright is its sound etc. I believe that having a good capacitance sensor it is not a problem to make your own setup. But what does it mean – a good capacitance sensor? Can we compare different capacitance sensors using one quantity? The first thing that comes to mind is the ratio E^2/F where E is the standard deviation of measurement error and F is the sample rate. Here we have E squared because it is possible to do averaging. If we average for example 4 measurements, F becomes 4 times smaller and E becomes 2 times smaller. So we have to sqare E to obtain "frequency-independent" quantity. The smallest ratio = the best sensor. Please correct me if I am wrong. I want to evaluate something theoretically before I start to build an instrument. 

Posted: 8/23/2021 12:47:06 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

andreyrogatkin, there are many criterion for the fitness of a C sensor.  The three that are perhaps the most important (in no order):

1. Useful numerical resolution.
2. Oscillator instability / environmental noise within the GB (gestural bandwidth: DC to maybe 50Hz).
3. Antenna voltage swing.

Specific interferers within the GB like mains hum can be digitally notch filtered.  Noise above the GB can be digitally low pass filtered, and the cutoff of this filter can be further lowered when playing lower pitches, where pitch perception is degraded.  This is a tracking filter arrangement, and is quite useful for lowering noise in the far field where resolution poops out.

Obviously, the useful resolution will increase the more one low pass filters (averages) so these are connected.  You can make a good sensor with just about anything if you drastically lower the GB to 2Hz (like the Theremini) but it will feel quite sluggish to play.  But the upper resolution limit is established by the sensitivity of the sensor and the resolution of the measurement.  Errors in measurement can appear as noise, systematic errors tend to be worse as they stymie averaging and can alias into the GB.

I've seen that many (most?) LC oscillators become more unstable with lower C.  Lowering any stray or padding C will directly increase sensitivity, but perhaps at the cost of instability in the gestural bandwidth region, such as oscillator tearing, which is much more disruptive than simple thermal phase noise.  This is one reason that I push plates in digital Theremins, the intrinsic C is increased along with mutual C, giving a more stable and sensitive oscillator.  (And, unlike rods, plates don't require any adjustment of one's playing technique over the entire field, but I digress).

And then there is voltage swing at the antenna, the higher this is the better (though I believe with diminishing returns above some tens of volts) as it tends to swamp environmental interference, and is a direct product of the Q, or selectivity, of the LC tank.

When your hand is some distance from the antenna the delta C for a given hand movement will be extremely small, and this is where you will run into resolution problems.  Lowering the GB here helps, but isn't a cure-all.  But all Theremins becomes increasingly difficult to play well in the far field, as the body (and other environment) more and more dominate the C situation, and the hand less and less.  Linearizing the near field, quite doable in a digital instrument, opens up this extremely desirable region (very high resolution and very controllable by the hand) for easier playing.

[EDIT] There are many real issues that are best attacked theoretically, but there's a lot of seat-of-the-pants stuff too that you can't easily predict.

Posted: 8/23/2021 2:45:37 PM
andreyrogatkin

Joined: 1/27/2021

dewster,

thanks!


There are many real issues that are best attacked theoretically


So can we discuss them? For example sample rate. How fast should we update frequency so that human ear couldn't recognize frequency steps? Is 100 Hz enough for example?
What about resolution? Wikipedia says that frequency resolution of the ear is about 3.6 Hz within the octave of 1000-2000 Hz. If we have for example 4 octaves does this mean that 11 bit is enough for pitch? (9 bits for one octave, 2000 Hz*2^(1/2^9) - 2000 Hz = 2.7 Hz). 

I realize that noise is not white and noise structure is critically important at low frequencies. Do you have any spectrogram of typical low-frequency noise of capacitance sensors? Can't we consider it as flicker noise (maybe plus mains hum)? If so, we could compare different sensors using only one quantity.

Why are you talking about LC oscillators? Can't we use RC circuit to measure capacitance charge time?

Posted: 8/23/2021 3:36:31 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

"For example sample rate. How fast should we update frequency so that human ear couldn't recognize frequency steps? Is 100 Hz enough for example?"  - andreyrogatkin

Ideally you would update it at the DSP rate so as to put a zero there, making it completely inaudible.  For instance, the D-Lev updates the audio oscillator pitch at 48kHz.

"What about resolution? Wikipedia says that frequency resolution of the ear is about 3.6 Hz within the octave of 1000-2000 Hz. If we have for example 4 octaves does this mean that 11 bit is enough for pitch? (9 bits for one octave, 2000 Hz*2^(1/2^9) - 2000 Hz = 2.7 Hz)."

The ear perceives both pitch and volume logarithmically, not linearly, so the presumably linearized position information from the antennas must be exponentiated before use.  Hand capacitance change is rather exponential, which is how analog Theremins work.  You'll generally end up with excess precision for the near field and insufficient precision for the far field, but since these are correlated with high and low pitch, it more or less works out, because pitch perception goes to hell on the low end.  I realize that doesn't answer your question - you want all the useful (non-noisy) bits you can get your hands on, and the far field will always be "chunky" past a certain point, the goal / trick is to get this to happen in the subsonic region of pitch.

"I realize that noise is not white and noise structure is critically important at low frequencies. Do you have any spectrogram of typical low-frequency noise of capacitance sensors? Can't we consider it as flicker noise (maybe plus mains hum)? If so, we could compare different sensors using only one quantity."

The vast majority of it is mains hum, with the vast remainder interference between the two oscillators, and rhythmic leakage from the digital electronics (DSP audio rate current slugs).  Digital filtering can introduce truncation noise too, particularly when clocked at a really high rate with a really low cutoff.

"Why are you talking about LC oscillators? Can't we use RC circuit to measure capacitance charge time?"

If you can get the RC voltage high enough, something that's fairly trivial to do with LC.  But any oscillator instability is noise in the SNR equation.  LC frequency unfortunately only varies as the square root of C, but is much more stable, largely determined by Q (atomic clocks have astronomical Q).  There are C sensing solutions in between LC and RC, such as the RLC spread spectrum C sensor [LINK] but there are upsides and downsides all around.  C shielding could really improve LC sensitivity by reducing the intrinsic, but it's a rather large add-on in terms of technology.  (The spread spectrum C sensor does shielding, but does it in a way that increases intrinsic.)

Posted: 8/24/2021 7:32:48 PM
Buggins

From: Theremin Motherland

Joined: 3/16/2017


I am planning to design a digital theremin.
At this first stage of the project I only look at it as a problem of constructing a good sensor which converts capacitance to digits.
Reading this forum I can’t find the answer to the main designer question: what parameter is to be optimized?
And how can we compare different designs?
I am not interested in how many octaves an instrument has, how long is its neck, how good is its linearity, how bright is its sound etc.
I believe that having a good capacitance sensor it is not a problem to make your own setup.
But what does it mean – a good capacitance sensor?
Can we compare different capacitance sensors using one quantity?
The first thing that comes to mind is the ratio E^2/F where E is the standard deviation of measurement error and F is the sample rate.
Here we have E squared because it is possible to do averaging.
If we average for example 4 measurements, F becomes 4 times smaller and E becomes 2 times smaller.
So we have to sqare E to obtain "frequency-independent" quantity. The smallest ratio = the best sensor.
Please correct me if I am wrong. I want to evaluate something theoretically before I start to build an instrument.

To build theremin, you need to measure capacity of antenna.
Typically, capacity of rod antenna when there is no hand nearby is 8-10pF (let's call this value C_ant).
When hand is close to antenna, capacity increases by 1.5-2pF (let's call this value C_hand).
Increasing of hand to antenna distance by 10cm decreases C_hand by 3.5 times. So, each 10cm of playable distance requires 2 more bits of sensor output.
E.g. at 20cm from antenna, C_hand=0.122pF, on 70cm C_hand=0.000233139 (log scale, decreased exponentially).
To be usable, sensor should measure capacitance changes 0.00001pF or even 0.000001pF of 10pF in realtime.

To measure C, you can use either RC (f ~ 1/(R*C)) or LC (f ~ 1/sqrt(L*C)) approach.
However, RC sensitivity is too low - suitable for 10-20 cm ranges only.
All theremins are based on LC sensor - it is sensitive enough for theremin playable hand ranges.

LC tank resonance frequency is being changed with change of C as 1/sqrt(L*C).
We can measure resonant frequency and use it as sensor value.

Theremin sensor requires good inductor, usually 1..5mH. Air core inductors have better stability.

It makes sense to keep most of LC capacity in antenna (otherwise, e.g. having additional caps in oscillator affecting LC, it would reduce relative sensitivity).

LC frequency is decreased by ~8% when hand approaches antenna - higher 4 bits of measured LC frequency from sensor will be constant.
2 bits per 10 cm * 8 = 16 base bits for 80cm
To sense small movement on max range, add at least 4 bits : 20 meaningful bits needed.
Total number of bits from sensor, including non-changing higher 4 bits becomes 24.

There are two methods to measure LC resonance:
1) build LC oscillator and measure its frequency
2) pass some reference frequency to LC and measure it's response (phase shift), optionally - correct reference frequency according to measured phase shift to drive signal near to resonance (phase locked loop).

It's a good idea to simulate oscillator in LTSpice before building of real hardware.

In digital theremin, oscillator board (analog part) can be connected to digital part (MCU or FPGA) with 3 wires - GND, Vcc, OSC_OUT.
Separate oscillator board would allow you to test different schematics of oscillators.

Approach with PLL needs 5 pins for connecting of analog part: GND, Vcc, Drive, Ref_out, Shift_out

Digital part of sensor requires measure of signal frequency with high precision.
If you are going to use microcontroller board, choose one with highest available CPU and BUS frequency.
I've tried Teensy 4.0/4.1 with 800MHz CPU and 200 MHz bus allowing to capture frequency with 200MHz sampling precision timer, and DMA to transfer data from timer.

You can find some results of MCU based sensor testing in thread Teensy 4.1 MCU based theremin

Averaging is working fine. I've got enough bits from sensor. But after 40-60cm, main hum noise becomes more visible than hand movements.

Additional averaging of sensor output using 50Hz or 60Hz period (moving average) reduces this noise good enough. (See last posts in this thread).
Averaging by 50Hz actually introduces 10ms (100Hz) delay between hand movement and filtered sensor data.
This 50/60Hz noise signal is highly periodic. Probably, we can predict its waveform and subtract it from sensor data in advance, w/o introducing of high latency.

With FPGA, it's possible to sample sensor signal with higher frequency (e.g. 1.2GHz on my Zynq FPGA, or even more with subsampling).

As well, with FPGA it's easy to implement phase-locked-loop (PLL) LC sensor.
It's expected that PLL has smaller noise level.


Now I'm working on Zynq Z7020 based FPGA theremin

Schematic is ready, I've designed and ordered PCBs. So far, unsoldered.

I hope my digital theremin design would be most powerful theremin ever.
Phase locked loop analog front end is connected to FPGA via differential pairs (assuming it could reduce noise).

FPGA part in Zynq 7020 has A LOT of resources. Dual 600MHz ARM cores and 512MB sdram - for GUI and non-critical code.
Controls board with 4.3inch LCD with resistive touch, 8 encoders, 8 pots.
On board, there is an audio codec providing line in / out, and phones out. As well, there is S/PDIF optical out.

Would you like to join this project?

Posted: 8/25/2021 7:10:46 AM
andreyrogatkin

Joined: 1/27/2021

I want to measure capacitance measuring its discharge time.

Assume that antenna is charged to voltage V+. Then it starts discharging through a resistance R until a voltage threshold VT is reached. The discharge time is T. As we have some voltage noise (let's call it epsilon), we have an uncertainty in T measurement (delta_T). I've done some calculations and obtained that delta_T / T is proportional to epsilon and inversely proportional to V+.

I estimated epsilon using this calculator for 1GHz frequency and 200KOhm resistance.

If I use a microcontroller with capture timer with ~5 nanosecond time resolution, I evaluate I can have 18 meaningful bits on 100 samples/second rate charging antenna to only 3 Volts.

18 bits, using Buggins's calculations, would be enough for 50cm hand to antenna distance and 4 octaves. Isn't it the simplest method of measuring antenna capacitance? Has anyone tried it? Maybe my evaluation of 18 bits is not correct? If 18 bits is not enough, one can always increase V+ to tens of volts and get more bits. 

[EDIT] How do you insert pictures in your posts???
[EDIT] Problem with the picture fixed

Posted: 8/25/2021 1:39:12 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

"How do you insert pictures in your posts???"  - andreyrogatkin

Click the "insert an image" picture icon at the top right of the "Post Reply" edit box, and copy the web address of the picture in the URL entry area.

You can make photo albums here at TW and link to those too.

Posted: 8/25/2021 1:52:40 PM
andreyrogatkin

Joined: 1/27/2021

"Click the "insert an image" picture icon at the top right of the "Post Reply" edit box, and copy the web address of the picture in the URL entry area:You can make photo albums here at TW and link to those too.

I have done exactly this thing but the picture is not present in my post. May it be because I am not validated as a non-spam user?

Posted: 8/25/2021 5:46:55 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

I had to use the full real link to it to get it to show up: https://i.ibb.co/1rkjGnP/20210825-095137.jpg

Posted: 8/25/2021 5:58:22 PM
andreyrogatkin

Joined: 1/27/2021

I had to use the full real link to it to get it to show up: https://i.ibb.co/1rkjGnP/20210825-095137.jpg

Thanks! That is the trick.

You must be logged in to post a reply. Please log in or register for a new account.