Author Topic: Stable and fast measurement of variable capacitor  (Read 18283 times)

0 Members and 1 Guest are viewing this topic.

Offline kaljTopic starter

  • Contributor
  • Posts: 34
  • Country: se
Stable and fast measurement of variable capacitor
« on: October 17, 2020, 10:30:11 am »
I am working on rebuilding an old radio (Sony CF-420L) with completely new modern digital electronics inside. The plan for this abomination is to use an Arduino with an TEA5767 and a Bluetooth module, combined with reusing the existing switches and knobs as controls.

The frequency dial of the radio is connected to a variable air capacitor (14-680pF) as well as a frequency indicator. I now want the Arduino to read the setting of the capacitor to then set the frequency of the radio module accordingly. The exact capacitance is not relevant, and it does not necessarily have to be linear, but it needs to be stable with relatively low noise. I want to map the measurement to the regular 87.5—108.0 MHz range accurately to the first decimal place. So roughly <0.1% noise is needed, unless I screwed up the estimate. Additionally, for reasonable responsiveness, the measurement needs to be performed at least with say 10Hz rate.

I have breadboarded two circuits to measure the capacitance, neither of which has worked satisfactory:

A. A cd40106 oscillator feeding a Cd4046 PLL, out of which I tap the CV to the PLL VCO. The CV is then low passed and then read with analogRead. With the components I chose, I get frequencies in the range 1.6kHz - 8 kHz. However, the frequency of the cd40106 oscillator seems to have a variation of at least 1% which makes the rest of the circuit kind of hopeless.

B. A 555 timer set up as a linear ramp using a constant current source:



With this, I can send in trigger pulses at the "trigger" pin, and then measure the length of the pulse coming out at "output". With the component values in the schematic, I get pulse lengths of 80us - 1100us. However, using my oscilloscope to check the pulse lengths at a given capacitance shows that the variation is a bit too high. At maximum capacitance I get 1.100ms-1.112ms, and at minimum capacitance 79.2us-80.2us, i.e. roughly 1%.

Does anyone have a clue what I can do to improve on the accuracy on either solution, or perhaps you have an idea of another solution?
« Last Edit: October 17, 2020, 10:33:55 am by kalj »
 

Offline MosherIV

  • Super Contributor
  • ***
  • Posts: 1530
  • Country: gb
Re: Stable and fast measurement of variable capacitor
« Reply #1 on: October 17, 2020, 10:39:11 am »
It sounds/looks like you are trying to measure rise time to measure capacitance.
Inherently unstable.

Try measuring the impeadance.
You using Arduino which has  timers on board which can be set up to create 1MHz (or even 10MHz) freq.
This can then be fed ito the cap. You can then use the same technique the $25 component tester uses to measure the impeadance and capacitance.
 

Online Twoflower

  • Frequent Contributor
  • **
  • Posts: 737
  • Country: de
Re: Stable and fast measurement of variable capacitor
« Reply #2 on: October 17, 2020, 10:40:37 am »
Since you remove the guts of that radio, why not replace the variable cap by a potentiometer? Or mechanically add a potentiometer in parallel? Just thinking.
 

Online coromonadalix

  • Super Contributor
  • ***
  • Posts: 5897
  • Country: ca
Re: Stable and fast measurement of variable capacitor
« Reply #3 on: October 17, 2020, 11:12:07 am »
the problem, in a radio you have more circuitry like a pll   "phase lock loop"  and other stabilisation circuitry

your small ne555 circuit  will never be stable, i doesnt have any frequency or pulse feedback ...   use a dds  as a generator insrtead ?

And  you have many arduinos  AM-FM applications out there to suit your needs   why complicate things ?

BUT

Do i understand  :

you want to read the capacitance to have a frequency readout of somekind of selection ??  to keep the look and feel of the radio ?
you want to match the dial cord tunning assembly and give it a digital tunning version ?

Like this

https://vintageautoradio.com/index.php?option=com_content&view=article&id=54&Itemid=64
https://www.tech-retro.com/aurora-design/home.html

But its done at an huge pricing ...
« Last Edit: October 17, 2020, 11:26:30 am by coromonadalix »
 

Online T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21680
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Stable and fast measurement of variable capacitor
« Reply #4 on: October 17, 2020, 11:29:38 am »
CMOS 555 is better (LMC555, 7555..).  Your CCS is so weak, the pin leakage (input bias current) is probably dominant.  Propagation delay (at the smallest C values) will also dominate, so that you end up measuring a combination of delay plus capacitance, not capacitance by itself, nice and proportional.

You can do the same thing with an MCU pin: set the pin output-low, then input-high (passive pullup).  Start timer at the same instant, and stop timer when pin crosses threshold (use an input capture pin, or pin-change interrupt to sample CNT, or get the analog comparator involved (if available), etc.).

Probably won't be very sensitive to small changes in capacitance, but you can repeat measurements to average out noise, and you can get arbitrarily long periods with an external pullup resistor rather than the internal pullup (which will also be more stable vs. temperature).

Better still than measuring single periods: measure frequency.  Small changes in timing are imperceptible from cycle to cycle, but accumulate over time.  Measuring frequency using the timer is more complicated, but there are numerous sketches showing how to do it.

To get frequency, you need an astable oscillator, which the 555 can still do, or the MCU can do to a certain extent, depending on available hardware.  (MEGA might not be able to do this with low latency, but XMEGA I think can pull it off, using events and analog comparator?  STM can probably do it as well.)

And yeah, consider replacing the varicap with a potentiometer.  What could be easier than using an ADC to measure a static voltage? :)

Speaking of ADC, and impedance as mentioned above -- you can set up a crude impedance divider, using GPIO pins, series resistors or capacitors, and the varicap.  By sampling the voltage on the varicap, at a reliable time delay, you'll sample some point along the RC (or other) discharge curve that the capacitance will go through when pulsed by those GPIOs.  I say GPIOs plural, because you may want to use several in parallel, with a range of series impedances (R or C), to cover that wide of a range.

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19519
  • Country: gb
  • 0999
Re: Stable and fast measurement of variable capacitor
« Reply #5 on: October 17, 2020, 11:40:28 am »
How about using an LC oscillator, rather than an RC? It's much more stable at higher frequencies and lower capacitance values. The 74HC4060 could be used if you want a lower frequency the MCU can handle.
« Last Edit: October 17, 2020, 05:54:09 pm by Zero999 »
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16615
  • Country: us
  • DavidH
Re: Stable and fast measurement of variable capacitor
« Reply #6 on: October 17, 2020, 05:48:13 pm »
Why not keep the original local oscillator and measure the output frequency?
 

Offline CatalinaWOW

  • Super Contributor
  • ***
  • Posts: 5231
  • Country: us
Re: Stable and fast measurement of variable capacitor
« Reply #7 on: October 17, 2020, 06:38:04 pm »
Or put the capacitor as feedback on op-amp and then give it charge packets (pulses from the arduino through a resistor).  Voltage out is then proportional to number of charge packets and inversely proportional to capacitance value.  You can either use a comparator to detect a known voltage or use a fixed number of packets and measure the voltage.   There are details like a discharge circuit to reset capacitor to known voltage, dealing with input offsets (voltage and current) on the op-amp but there is lots of material out on how to do this.  Search integrating A to D circuits.
 

Offline kaljTopic starter

  • Contributor
  • Posts: 34
  • Country: se
Re: Stable and fast measurement of variable capacitor
« Reply #8 on: October 17, 2020, 09:52:17 pm »
Since you remove the guts of that radio, why not replace the variable cap by a potentiometer? Or mechanically add a potentiometer in parallel? Just thinking.

I would really like to avoid that since the frequency since it is a quite complicated mechanical mechanism with strings, wheels, and springs. Also, I really prefer solving electronics problems rather than mechanical ones.
 

Offline kaljTopic starter

  • Contributor
  • Posts: 34
  • Country: se
Re: Stable and fast measurement of variable capacitor
« Reply #9 on: October 17, 2020, 09:56:23 pm »
It sounds/looks like you are trying to measure rise time to measure capacitance.
Inherently unstable.

Try measuring the impeadance.
You using Arduino which has  timers on board which can be set up to create 1MHz (or even 10MHz) freq.
This can then be fed ito the cap. You can then use the same technique the $25 component tester uses to measure the impeadance and capacitance.

Interesting. How come rise time is "inherently unstable"?

Could you elaborate a little on how to go about measuring the capacitance/impedance using the 1MHz square wave?
 

Offline kaljTopic starter

  • Contributor
  • Posts: 34
  • Country: se
Re: Stable and fast measurement of variable capacitor
« Reply #10 on: October 17, 2020, 09:57:48 pm »
Why not keep the original local oscillator and measure the output frequency?
That would probably have been easiest, but it is a little too late for that now. Unfortunately, I don't have much more of the original components than this variable capacitor.
 

Offline kaljTopic starter

  • Contributor
  • Posts: 34
  • Country: se
Re: Stable and fast measurement of variable capacitor
« Reply #11 on: October 17, 2020, 10:00:36 pm »
How about using an LC oscillator, rather than an RC? It's much more stable at higher frequencies and lower capacitance values. The 74HC4060 could be used if you want a lower frequency the MCU can handle.

Interesting, could you describe how such a circuit would function? Perhaps you have a link? I really don't know what to search for...
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19519
  • Country: gb
  • 0999
Re: Stable and fast measurement of variable capacitor
« Reply #12 on: October 17, 2020, 10:32:53 pm »
How about using an LC oscillator, rather than an RC? It's much more stable at higher frequencies and lower capacitance values. The 74HC4060 could be used if you want a lower frequency the MCU can handle.

Interesting, could you describe how such a circuit would function? Perhaps you have a link? I really don't know what to search for...
https://wiki.analog.com/university/courses/electronics/electronics-lab-21
 

Online mag_therm

  • Frequent Contributor
  • **
  • Posts: 669
  • Country: us
Re: Stable and fast measurement of variable capacitor
« Reply #13 on: October 17, 2020, 10:42:56 pm »
I like David's suggestion.
Sony CF-420L has a separate Hartley one transistor ( Q3) FM oscillator I suppose running from 97.8 to 118.7 MHz.
Re-use the Hartley coil to make an oscillator closely based on the existing one, nelecting AFC ( 6pF coupling)

Assuming station separation is in 200 kHz steps ( as in USA) starting at 87.5 MHz ( Sweden ?) , you will need a frequency counter of sufficient accuracy to create 100 entries in LUT.

Assuming the frequency counter is >> more accurate than the free running Hartley, the Hartley will need to have a drift < 100 kHz approx after warmup.
Well, I have an old tube FM receiver here that has 6DT8 FM osc,  stays close to the quadrature detector centre for long periods  even with the AFC off,
so would expect a transistor oscillator to be at least as stable as that.
 

Offline kaljTopic starter

  • Contributor
  • Posts: 34
  • Country: se
Re: Stable and fast measurement of variable capacitor
« Reply #14 on: October 18, 2020, 12:03:25 pm »
I like David's suggestion.
Sony CF-420L has a separate Hartley one transistor ( Q3) FM oscillator I suppose running from 97.8 to 118.7 MHz.
Re-use the Hartley coil to make an oscillator closely based on the existing one, nelecting AFC ( 6pF coupling)

Assuming station separation is in 200 kHz steps ( as in USA) starting at 87.5 MHz ( Sweden ?) , you will need a frequency counter of sufficient accuracy to create 100 entries in LUT.

Assuming the frequency counter is >> more accurate than the free running Hartley, the Hartley will need to have a drift < 100 kHz approx after warmup.
Well, I have an old tube FM receiver here that has 6DT8 FM osc,  stays close to the quadrature detector centre for long periods  even with the AFC off,
so would expect a transistor oscillator to be at least as stable as that.

I do in fact have most of the components left, so perhaps I can go this path. The problem is however that I have no experience at all with analog radio circuits like this, so I need all help I can get with understanding how to go about this. I have found this schematic of the radio:



Can you explain what part of the circuit I need to recreate, and how I could I go about measuring the frequency  of the oscillator?
 

Offline kaljTopic starter

  • Contributor
  • Posts: 34
  • Country: se
Re: Stable and fast measurement of variable capacitor
« Reply #15 on: October 18, 2020, 12:18:45 pm »
If we are talking about L2 and/or L4, I believe I might have lost them unfortunately. As I said previously, I was completely set on replacing the whole analog circuit with stuff that I understand. Do you think there is a way of replacing those coils?
 

Offline kaljTopic starter

  • Contributor
  • Posts: 34
  • Country: se
Re: Stable and fast measurement of variable capacitor
« Reply #16 on: October 18, 2020, 12:50:15 pm »
As and aside, I've had some suggestions that I should try the simplest and most obvious solution: Charging the capacitor from an Arduino pin, and using the internal comparator to trigger the timing. I did try such a circuit now, with mixed results. It does seem to produce decent accuracy in the time measurement. However, the charge time measured seems quite sensitive to external disturbances. By just touching some of the jumper wires, I was able to get the measured time to vary by around 10%.

Anyways, I still feel a bit lost, this circuit should be very similar to the 555-based one, so perhaps any difference in results are just from random differences in the wiring of my bread board design. I feel that I really need to solder something up on perf board to really evaluate how good a method really is.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19519
  • Country: gb
  • 0999
Re: Stable and fast measurement of variable capacitor
« Reply #17 on: October 18, 2020, 02:09:35 pm »
As and aside, I've had some suggestions that I should try the simplest and most obvious solution: Charging the capacitor from an Arduino pin, and using the internal comparator to trigger the timing. I did try such a circuit now, with mixed results. It does seem to produce decent accuracy in the time measurement. However, the charge time measured seems quite sensitive to external disturbances. By just touching some of the jumper wires, I was able to get the measured time to vary by around 10%.

Anyways, I still feel a bit lost, this circuit should be very similar to the 555-based one, so perhaps any difference in results are just from random differences in the wiring of my bread board design. I feel that I really need to solder something up on perf board to really evaluate how good a method really is.
Did you try the LC oscillator I suggested? It's much more stable than an RC time constant, irrespective of whether it's an oscillator, or charging the capacitor from an MCU output.
 

Offline kaljTopic starter

  • Contributor
  • Posts: 34
  • Country: se
Re: Stable and fast measurement of variable capacitor
« Reply #18 on: October 18, 2020, 02:49:54 pm »
Or put the capacitor as feedback on op-amp and then give it charge packets (pulses from the arduino through a resistor).  Voltage out is then proportional to number of charge packets and inversely proportional to capacitance value.  You can either use a comparator to detect a known voltage or use a fixed number of packets and measure the voltage.   There are details like a discharge circuit to reset capacitor to known voltage, dealing with input offsets (voltage and current) on the op-amp but there is lots of material out on how to do this.  Search integrating A to D circuits.
Wow that is a cool idea. I tried breadboarding up something, and I see how it could work in theory, but I am too inexperienced with this to have a clue of how to design a half decent circuit. If you have time to make a draft of something I could try I would be super grateful, but I perfectly understand if you don't have the time.
 

Online mag_therm

  • Frequent Contributor
  • **
  • Posts: 669
  • Country: us
Re: Stable and fast measurement of variable capacitor
« Reply #19 on: October 18, 2020, 02:51:10 pm »
You would have to recreate the circuit around Q3 out to and including L4
The temperature grades of C14 and C13 would have been selected to offset ( tend to null)  thermal drift in Q3 and L4.
So they are not necessarily NPO.

But if L4 has been discarded, it might be a job to do another stable oscillator.
"Synthetic Rock" comes to mind but you can search it for VHF versions, or otherwise look for 2 metre VFO circuits.

Perhaps someone on here versed in the statistics of it, can explain why a high Q oscillator is perhaps the best way to accurately measure L & C.

I like your original idea for restoration. I have some old vacuum tube receivers I restored, in good condition.
A very early 1940's Philco FM, here woodwork looks good, but is too far gone to receive FM properly, maybe a candidate for your idea.
 

Offline CatalinaWOW

  • Super Contributor
  • ***
  • Posts: 5231
  • Country: us
Re: Stable and fast measurement of variable capacitor
« Reply #20 on: October 18, 2020, 05:22:13 pm »
Or put the capacitor as feedback on op-amp and then give it charge packets (pulses from the arduino through a resistor).  Voltage out is then proportional to number of charge packets and inversely proportional to capacitance value.  You can either use a comparator to detect a known voltage or use a fixed number of packets and measure the voltage.   There are details like a discharge circuit to reset capacitor to known voltage, dealing with input offsets (voltage and current) on the op-amp but there is lots of material out on how to do this.  Search integrating A to D circuits.
Wow that is a cool idea. I tried breadboarding up something, and I see how it could work in theory, but I am too inexperienced with this to have a clue of how to design a half decent circuit. If you have time to make a draft of something I could try I would be super grateful, but I perfectly understand if you don't have the time.

I've got other things going on so won't try to detail a design for you, but google will be your friend here.  I will also mention that you can eliminate several sources of error by adding a known reference capacitor (presumably about mid range in your variable cap) and switching between them.  Then the unknown capacitance is just the ratio of the pulses in to charge the reference capacitor to a known voltage (or the delta voltage achieved with a fixed number of pulses).
 

Offline pwlps

  • Frequent Contributor
  • **
  • Posts: 372
  • Country: fr
Re: Stable and fast measurement of variable capacitor
« Reply #21 on: October 19, 2020, 12:03:46 am »
As and aside, I've had some suggestions that I should try the simplest and most obvious solution: Charging the capacitor from an Arduino pin, and using the internal comparator to trigger the timing. I did try such a circuit now, with mixed results. It does seem to produce decent accuracy in the time measurement. However, the charge time measured seems quite sensitive to external disturbances. By just touching some of the jumper wires, I was able to get the measured time to vary by around 10%.

Or put the capacitor as feedback on op-amp and then give it charge packets (pulses from the arduino through a resistor).  Voltage out is then proportional to number of charge packets and inversely proportional to capacitance value.  You can either use a comparator to detect a known voltage or use a fixed number of packets and measure the voltage.   There are details like a discharge circuit to reset capacitor to known voltage, dealing with input offsets (voltage and current) on the op-amp but there is lots of material out on how to do this.  Search integrating A to D circuits.

I think you can improve a lot the accuracy using the LTC1043 precision switched-capacitor block :  use it to charge a much bigger capacitor and count the number of cycles it needs to reach a reference voltage being a fixed fraction of the charging voltage.  This should be much easier to be made very accurate as it won't depend on the exact voltage value. The LTC1043 leakage currents are in the pA range therefore it shouldn't have problems even with very small capacitance values. The Arduino comparator will only see the big capacitor, and you can set the switching frequency high enough to make any errors due to the comparator input bias current negligible (the maximum usable frequency will be limited by the RC time constant but should still be high enough, it's getting too late here to try any calculations  :)).  To minimize external disturbances the switch and the big capacitor should be placed close to the variable capacitor being measured.
« Last Edit: October 19, 2020, 12:24:05 am by pwlps »
 

Offline MosherIV

  • Super Contributor
  • ***
  • Posts: 1530
  • Country: gb
Re: Stable and fast measurement of variable capacitor
« Reply #22 on: October 19, 2020, 08:05:50 am »
Quote
   I still feel a bit lost, this circuit should be very similar to the 555-based one, so perhaps any difference in results are just from random differences in the wiring

This is why it is unstable!

Regarding using square wave to measure capacitance  it actually measures AC impeadance.
I am not 100% certain how that us then converted into capacitance.
Need to go look up how the $20 component tester works or look up how lcr bridge works.
 

Offline pwlps

  • Frequent Contributor
  • **
  • Posts: 372
  • Country: fr
Re: Stable and fast measurement of variable capacitor
« Reply #23 on: October 19, 2020, 09:48:19 am »
Here is the idea of my previous post.
SW1 is a switch (any reasonably fast high isolation SPST switch, didn't have time to look what is available in my LTSpice library) to reset the measurement (discharging C2) just before starting counting.  R1,R2,R4 set the ratio charging voltage/comparator voltage, C3 is to filter power voltage fluctuations during a measurement cycle.
There is of course a tradeoff between the resolution and the measureement time (depending on the values of C2 and R4) but you can easily get a 4-digit resolution. Anyway I bet this will be orders of magnitude more accurate than any 555 crap (I hate 555s  ;D)

NB. The simulation won't work with a generic SW1, should be removed or replaced by a real one.

Edit: One question not to overlook is how the resolution of each measurement technique varies across the capacitance range.  Since the radio frequency varies like 1/sqrt(C)  the resolution on C should vary like 1/C^3/2 to get a constant resolution over the radio frequency range. In my circuit the resolution varies like 1/C but in time-constant measurements it would vary the wrong way (roughly proportional to C) making it difficult for small  capacitances.  With a 555 we should measure the frequency rather than the time constant (roughly equivalent to averaging many measurements).

Update : Today I did some simulations, see below (simulations are done with the last version capmeter2.asc, just removing the switch). The charging time even in the upper range of capacitance (I took 700pF) is below 2us so the max frequency is of order of 500kHz.
The topology of the first version wasn't optimal because the Vcomp+ reference voltage was taken from the supply of the charging pin (S1A) and was subject to spikes from the current pulses.  In the new version I just added a separate voltage divider for Vcomp+.   Even then the charging input S1A-S3A will have to be heavily decoupled  to keep Vcomp+ clean (here C5; some spikes are also present on Vss which should be decoupled too).
« Last Edit: October 23, 2020, 07:56:55 am by pwlps »
 
The following users thanked this post: kalj

Offline IDEngineer

  • Super Contributor
  • ***
  • Posts: 1926
  • Country: us
Re: Stable and fast measurement of variable capacitor
« Reply #24 on: October 19, 2020, 03:20:28 pm »
At first I thought the OP wanted to do this primarily with the hardware on an Arduino, but since the OP included fresh hardware involving 4000 family parts and the 555 I presume it's OK to suggest other new hardware.

Take a good look at the Charge Time Measurement Unit (CTMU) included in a bunch of Microchip PIC MCU's. I've used that in several designs and it's literally tailor made to do exactly what you want to do here: Measure capacitance. Everything you need in both the analog and digital domains is already on the chip, and this approach will give you the flexibility of firmware control over the entire process. It will also unburden the Arduino from requiring time-specific operations to measure C... just let the MCU handle it like it was specifically designed to do.

Once you're measuring C with the CTMU, having the MCU gives you lots of options to communicate the results to your Arduino. SPI, UART, roll your own, whatever you like.

I have successfully measured capacitance down into the low double digit picofarad range, and on the other end you can scale (dynamically in your firmware if necessary) to almost any upper value. Obviously you'll need to pay attention to layout but that's true of any method when measuring C down to ~14pF as mentioned in the first post.

In addition to the spec sheets for the MCU's that include the CTMU, there are at least two Microchip appnotes that focus specifically on it. Do a Google search. Lots of reading material and example applications to get you started. This is a one-chip answer to your question with nearly infinite flexibility.
 
The following users thanked this post: pwlps, kalj


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf