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

0 Members and 1 Guest are viewing this topic.

Offline kaljTopic starter

  • Contributor
  • Posts: 34
  • Country: se
Re: Stable and fast measurement of variable capacitor
« Reply #50 on: October 23, 2020, 09:39:49 pm »
So  when in doubt, instead of spending a bit of time learning about analog circuitry, replace a perfectly good design with one which probably won't work as well?------Bravo!

You can rant away all you want. I'm the first one to admit it was a great mistake to strip the original circuit. But it was many months ago and it really did look impossibly complicated to figure out what was wrong in the original circuit to me as a simple software guy. However, with all I've learned since, I would definitely have proceeded differently today.

I might look into a mechanical solution if the other approaches fail. At this point I see it as a fun project to see if I can solve it using the varcap. Besides, the stringed varcap - knob - indication display mechanism is quite complex and does definitely not seem like something which lends itself well for customization.
 

Online vk6zgo

  • Super Contributor
  • ***
  • Posts: 7588
  • Country: au
Re: Stable and fast measurement of variable capacitor
« Reply #51 on: October 24, 2020, 02:48:25 am »
So  when in doubt, instead of spending a bit of time learning about analog circuitry, replace a perfectly good design with one which probably won't work as well?------Bravo!

You can rant away all you want. I'm the first one to admit it was a great mistake to strip the original circuit. But it was many months ago and it really did look impossibly complicated to figure out what was wrong in the original circuit to me as a simple software guy. However, with all I've learned since, I would definitely have proceeded differently today.

I might look into a mechanical solution if the other approaches fail. At this point I see it as a fun project to see if I can solve it using the varcap. Besides, the stringed varcap - knob - indication display mechanism is quite complex and does definitely not seem like something which lends itself well for customization.

If you just need the dial reading to control the completely new  radio tuning, you could still use a rotary encoder & only need to retain the shaft & bearings in the capacitor, so the dial will work.

It would, perhaps be possble to remove some of the plates of the cap, somehow fit the rotary encoder to the shaft in their place & be good to go.
This sounds fiddly, but it may, be possible, depending upon the capacitor's construction, to partially dismantle it without detaching it from the  dial cord, so you can fit the encoder directly on the shaft.
(If it is one of the sealed "polyvaricons", you may be able to do something similar, but they are quite flimsy.)

It seems to me that all the really effective ways to do what you want would end up with a substantial component of mechanical work.

One semi-electronic way, if it is possible to remove plates from the cap, would be to reduce its capacitance range, use it to "pull" a crystal oscillator, then measure the resultant frequency.
This may be more stable than a self excited oscillator, or just trying to read the capacitance.



 

Offline IDEngineer

  • Super Contributor
  • ***
  • Posts: 1926
  • Country: us
Re: Stable and fast measurement of variable capacitor
« Reply #52 on: October 24, 2020, 03:19:09 am »
This is a very interesting and educational thread. But if the OP's actual goal is to measure the capacitance, why not just do so the most straightforward way: Charge with a constant current source for a known amount of time and measure the resulting voltage.

Wouldn't it be nice if there were a single chip, fully configurable solution that implemented that? Oh yeah, I already recommended it: The CTMU. And if you need more accuracy than your voltage regulator provides, add a dedicated voltage reference - another inexpensive single chip solution.

I seriously love all of the various schemes discussed herein, but it feels like we're getting rather esoteric and far afield from what the OP originally wanted to do. If his goal has changed, my apologies.
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16615
  • Country: us
  • DavidH
Re: Stable and fast measurement of variable capacitor
« Reply #53 on: October 24, 2020, 06:43:59 am »
This is a very interesting and educational thread. But if the OP's actual goal is to measure the capacitance, why not just do so the most straightforward way: Charge with a constant current source for a known amount of time and measure the resulting voltage.

The low capacitance involved makes that more difficult than some of the alternatives.  For instance a frequency output is more easily measured than a voltage output.

Even using a current and time is not required.  Charge up a reference capacitor, which is how the charge balancing designs we have discussed work, and then redistribute charge between the reference capacitor and variable capacitor and measure the resulting voltage.  This also allows temperature compensation if the temperature coefficients of the two capacitors are matched which could be relatively easy to do.
 

Offline pwlps

  • Frequent Contributor
  • **
  • Posts: 372
  • Country: fr
Re: Stable and fast measurement of variable capacitor
« Reply #54 on: October 24, 2020, 01:54:18 pm »
I'm posting below the third version of my LTC1043-based capacitance meter.
This iteration follows recent discussions with David Hess, let me first shortly recall the background.
NB. I started working on this yesterday evening and I see now there have been new posts since, I apologize for not taking them into account yet.

As David Hess pointed out there is an issue regarding the stability of the reference capacitor (C2).  I looked into this and it is not easy indeed to find relatively big (1uf) capacitors having low temperature coefficients. With 500 ppm/°C or more it would be difficult to keep the required 0.1% stability over a reasonable temperature range.

 The temperature drift could in principle be compensated using a PTC /NTC combination as suggested e.g. here :
https://www.tdk-electronics.tdk.com/download/530754/480aeb04c789e45ef5bb9681513474ba/pdf-generaltechnicalinformation.pdf
but there is also a huge humidity dependence so I'm not sure it would be reliable.

On the other hand David Hess recalled that 1) voltage references are much more stable than capacitors and are cheap today, 2) integrating designs can achieve high stability.  I have built on that for my new design.

There was also a suggestion of adapting a V/F converter.  Now I found some time to look more closely at the V/F converter example in the LTC1043 datasheet, this circuit is analyzed in the AD application note

https://www.analog.com/media/en/technical-documentation/application-notes/an03f.pdf

However I'm not sure it would still be good for capacitances as low as 15pF.
If I understand it correctly, it is basically a 555-like RC-discharge design albeit using precision components.  But like with all RC designs the weak point is in the comparator (here the comparator is hidden in the LTC1043 clock circuitry). A comparator is a high-gain device and as such it highly amplifies noise and produces jitter (I already mentioned the jitter problem of RC based oscillators in my post of Oct 20).  And we can reasonably guess that the smaller the available charge to drive the comparator inputs the bigger jitter will be (*). Finally the least frequently we have to compare anything the better the performance hence the idea of accumulating charge packets in a bigger capacitor.
(*) Here the charge is amplified by the LF356 opamp but I don't think it changes the problem fundamentally, I'm open to discussion though.

With a 10pF range capacitor even a high performance V/F converter like the one suggested in the appnotes will suffer,  we either need a very high switching frequency or very large resistances and ridicously small currents.   I strongly suspect that for 10pF range the performance would drop dramatically.

For these reasons I stick to the idea of accumulating charge packets in a bigger capacitor.
Now the problem is the big capacitor is varying - no problem, just measure it!  :)  In fact it is simpler to think in terms of charge measurement.   Charge can be measured using a stable voltage reference like in integrating ADCs: set a constant current using a voltage reference and a stable resistance and measure the time to charge it to a given voltage, the integral of the current will give the charge. (Of course we still need a stable resistance but here it seems much easier than for stable capacitors).

There are two phases in the measurement.  In fact three if I count the cold startup : before the first measurement the software would discharge C2 by connecting Vcomp+ to ground and then setting S1 in the right direction depending on the sign of Vcomp- until zero-crossing on the comparator input is detected.

The first phase is the same as in the previous version:  connect the opamp input to S2A and Vcomp+ to Vref+ , then wait until comparator trips counting the number of charge packets.
In the second phase Vcomp+ is connected to ground and the opamp input to Vref- through R2, the software then measures the time to discharge C2 at a constant current Vref-/R2.
Then S1, S2 are immediately set as in the first phase and the process repeats for the next measurement.

I think using two SPDTs with a single comparator should also bring the benefit of compensating for the comparator offset, although I did not attempt to study it more deeply.
 
If N is the number of packets and T the time to discharge the capacitor then we have :
Q(C2)=N * Q(Cvariable)
Q(C2)=|Vref-| * T / R2
Q(Cvariable)=Cvariable * Vref+

giving
Cvariable=|Vref-| * T / (N * Vref+ * R2)

(NB. If Arduino has differential analog inputs the formula can be made more precise measuring the residual voltage Vcomp- - Vref+, this would improve resolution for the highest capacitance values when N is relatively small)

I'm certainly reinventing the wheel here, there are apparently dozens of patents on capacitance measurement techniques, unfortunately reading patent texts is beyond my skills  :)

I'm eager to know your opinions about this new design.
« Last Edit: October 24, 2020, 11:34:33 pm by pwlps »
 

Offline CatalinaWOW

  • Super Contributor
  • ***
  • Posts: 5231
  • Country: us
Re: Stable and fast measurement of variable capacitor
« Reply #55 on: October 24, 2020, 02:13:44 pm »
You might want to think about how much accuracy you need.  In the era of this radio frequency markings were a general indication where to tune, and you searched around that area until you got the station you wanted.  Easy in areas with lots of stations, sometimes a problem in large urban areas.  Today's method of entering a three or four digit number and getting the station you want was not conceivable.
 

Offline IDEngineer

  • Super Contributor
  • ***
  • Posts: 1926
  • Country: us
Re: Stable and fast measurement of variable capacitor
« Reply #56 on: October 24, 2020, 02:35:51 pm »
The low capacitance involved makes that more difficult than some of the alternatives.  For instance a frequency output is more easily measured than a voltage output.

Changes in value in the single digit picofarads can be discerned with the CTMU. Even one of its appnotes openly discusses measuring changes of 10pF. The smaller the absolute value, the higher the current you select from the constant current source to yield a larger measurable charge. And you can lengthen the charge time period, too.

One of the products where I use the CTMU involves a capacitance range of ~100-300pF. That has been in continuous production for several years with many thousands of units in the field. While I don't have memorized values from my own work, one of the appnote examples describes a 500mV change from a ~10pF shift. Presuming a 10+ bit A/D, 500mV should be easily discerned.

'Nuff said. The option is available if anyone is interested.
 

Online mag_therm

  • Frequent Contributor
  • **
  • Posts: 681
  • Country: us
Re: Stable and fast measurement of variable capacitor
« Reply #57 on: October 24, 2020, 02:43:25 pm »
In post 13 I made a note about the accuracy required assuming 100 stations on Sweden.
Fortunately the frequencies are invariant.
I assume kalj will make a look up table containing the exact frequency, usually at every odd first decimal place across the band.

The capacitor read-out only has to give a pointer to select the record in the LUT.

And after this thread, I have the old radio with a free running oscillator ( AFC switched off) tuned to WKUF low power for 5 days . The frequency stay on the discriminator within a few hundred Hz all week, ( compared to the 100 kHz needed accuracy)  with the radio switched off and on every day.
So accuracy with a free running analog oscillator is not a problem.

I expect pwlps instrument will also be more than adequate.
Frequency goes by the sqrt(C), what does that do the the required error in C?
« Last Edit: October 24, 2020, 02:50:30 pm by mag_therm »
 

Offline pwlps

  • Frequent Contributor
  • **
  • Posts: 372
  • Country: fr
Re: Stable and fast measurement of variable capacitor
« Reply #58 on: October 24, 2020, 04:05:46 pm »
Frequency goes by the sqrt(C), what does that do the the required error in C?

I have mentioned it in one of my previous posts, as frequency goes by 1/sqrt(C) the absolute error on C goes by 1/C^3/2 (it's just a derivative of 1/sqrt) and accordingly the relative error by sqrt(C) to have a constant error on frequency (NB. for a radio it is the absolute frequency error and not its relative error which is relevant).
The smaller is C the better the relative resolution in C is needed to keep a constant resolution in f.  This is the main problem here.

Quote
I expect pwlps instrument will also be more than adequate.

I don't expect it to be that much more adequate for the lowest capacitance range.  My estimations remain qualitative, I prefer to wait until experimental results are available  :)
« Last Edit: October 24, 2020, 05:02:53 pm by pwlps »
 

Online mag_therm

  • Frequent Contributor
  • **
  • Posts: 681
  • Country: us
Re: Stable and fast measurement of variable capacitor
« Reply #59 on: October 24, 2020, 06:00:16 pm »
I am re-using an old variable capacitor from FM radio ,
 on an active antenna tuner with high Q ferrites for shortwave listening ( 3 ~20 MHz.)
I noticed quite a change in minimum capacitance between prototyping on a wood breadboard, and then into the metal case.
I had to pull turns off the  medium and high freq range  inductors which is not ideal.
Next time I take it apart I will try varicap diodes.

There is a capacitance between the moving blades and nearby metal.
This increases as the blades un-mesh toward  minimum capacitance.
Here, the resonant frequency actually reduces after about 80 degrees rotation, meaning there are 2 settings that give the same resonant frequency.

I think in the real FM radios that would have been compensated by customising the dial graduations,  and  by not using the last 20 degrees or so.

Anyway, I was thinking about spin -offs of kalj's smart idea, to old radio restoration,  on the bike ride this morning.
That is, for those who still like the smooth tuning dials on the old boat anchors.
I suppose there are not many left, as the serious amateurs were going to digital frequency "appliances", more than 30 years ago.
The first digitally tuned radio I saw was the USA Navy (and NATO?) an/urt-23 which was also used by the Australian Navy from about 1969 on.
 

Offline kaljTopic starter

  • Contributor
  • Posts: 34
  • Country: se
Re: Stable and fast measurement of variable capacitor
« Reply #60 on: October 25, 2020, 08:32:02 pm »
I plugged it into LTSpice using the HEF4007 model for the inverter with a 12V power supply and works over the 14pF to 680pF range. The Colpitts oscillator seems to require a lower ESR, than the Hartley, but it produces a better waveform, over the entire frequency range, not that it really matters.


Thanks for those simulation setups. I hadn't really played around with LT Spice until now, but boy was that a great tool. I tried simulating your circuit and it seems to be working great for the whole range 14pF-680pF, producing oscillations in the range 2-13Mhz which I suppose should be okay for the 74HC4060. However, as you say, it seems the Hartley one is sensitive to Rser in the inductors. In fact, using the 5V supply that I am targeting, the Hartley one needs around 9ms to get started, unless I lower the Rser of the inductors.

Speaking of the inductors, I am looking through the available ones at Mouser, and get a bit overwhelmed by all the types. I know now that DC resistance is crucial in this case. However, what else should I consider? I have heard that the Q factor (Q minimum) is of importance in oscillation circuits. For instance, how about this one with Qmin=140 and Rser=15mOhm?
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21686
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Stable and fast measurement of variable capacitor
« Reply #61 on: October 25, 2020, 08:45:47 pm »
That's quite a nice Q, and it's measured at a nearby frequency (2.52MHz) so should be nice.  Is rather big though.

Shouldn't the inductors be coupled, for Hartley?

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 
The following users thanked this post: kalj

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19522
  • Country: gb
  • 0999
Re: Stable and fast measurement of variable capacitor
« Reply #62 on: October 25, 2020, 09:21:34 pm »
I plugged it into LTSpice using the HEF4007 model for the inverter with a 12V power supply and works over the 14pF to 680pF range. The Colpitts oscillator seems to require a lower ESR, than the Hartley, but it produces a better waveform, over the entire frequency range, not that it really matters.


Thanks for those simulation setups. I hadn't really played around with LT Spice until now, but boy was that a great tool. I tried simulating your circuit and it seems to be working great for the whole range 14pF-680pF, producing oscillations in the range 2-13Mhz which I suppose should be okay for the 74HC4060. However, as you say, it seems the Hartley one is sensitive to Rser in the inductors. In fact, using the 5V supply that I am targeting, the Hartley one needs around 9ms to get started, unless I lower the Rser of the inductors.

Speaking of the inductors, I am looking through the available ones at Mouser, and get a bit overwhelmed by all the types. I know now that DC resistance is crucial in this case. However, what else should I consider? I have heard that the Q factor (Q minimum) is of importance in oscillation circuits. For instance, how about this one with Qmin=140 and Rser=15mOhm?
Don't take the simulation too seriously. The 74HC4060 has a much wider bandwidth than the HEF4007, so should work with a higher ESR inductor. The one you've found on Mouser appears to be suitable.

That's quite a nice Q, and it's measured at a nearby frequency (2.52MHz) so should be nice.  Is rather big though.

Shouldn't the inductors be coupled, for Hartley?

Tim
It will work with non-coupled inductors.
https://en.wikipedia.org/wiki/Hartley_oscillator
 
The following users thanked this post: kalj

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21686
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Stable and fast measurement of variable capacitor
« Reply #63 on: October 25, 2020, 11:54:17 pm »
That's quite a nice Q, and it's measured at a nearby frequency (2.52MHz) so should be nice.  Is rather big though.

Shouldn't the inductors be coupled, for Hartley?

Tim
It will work with non-coupled inductors.
https://en.wikipedia.org/wiki/Hartley_oscillator

I know it works without.  It might work over a wider range with.

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

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16615
  • Country: us
  • DavidH
Re: Stable and fast measurement of variable capacitor
« Reply #64 on: October 25, 2020, 11:56:52 pm »
Changes in value in the single digit picofarads can be discerned with the CTMU. Even one of its appnotes openly discusses measuring changes of 10pF. The smaller the absolute value, the higher the current you select from the constant current source to yield a larger measurable charge. And you can lengthen the charge time period, too.

One of the products where I use the CTMU involves a capacitance range of ~100-300pF. That has been in continuous production for several years with many thousands of units in the field. While I don't have memorized values from my own work, one of the appnote examples describes a 500mV change from a ~10pF shift. Presuming a 10+ bit A/D, 500mV should be easily discerned.

LTC1043 charge balancing voltage-to-frequency converters can easily achieve a resolution (not accuracy) of 18 bits and higher.  The best voltage-to-frequency designs perform comparably with 20 to 24 bit delta-sigma converters but the later are much less expensive now.  With a 1000 picofarad pumping capacitor, that yields a resolution of better than 0.003 picofarads and I have seen that kind of performance when tracking down linearity errors.  Accuracy is limited by temperature compensation of the capacitor which is where -120ppm/C resistors for compensating polystyrene capacitors come from.

The advantage of the CTMU is low cost and fast measurement speed.  It would be excellent in this application but not because of improved accuracy or resolution.

The LC oscillator method is also very suitable simply because that is what the radio originally used.
 
The following users thanked this post: kalj

Online mag_therm

  • Frequent Contributor
  • **
  • Posts: 681
  • Country: us
Re: Stable and fast measurement of variable capacitor
« Reply #65 on: October 26, 2020, 12:55:21 pm »
That's quite a nice Q, and it's measured at a nearby frequency (2.52MHz) so should be nice.  Is rather big though.

Shouldn't the inductors be coupled, for Hartley?

Tim
It will work with non-coupled inductors.
https://en.wikipedia.org/wiki/Hartley_oscillator

I know it works without.  It might work over a wider range with.

Tim
Solutions for the reactive components of the Hartley loops in the Class A case:
M is mutual inductance between the two inductors
 equations below are approximations

needed_volt_Gain_mu = [(L_o + M)/L_fb + M)]  + [resistive_loss_allowance]

F_resonant = [ 2*pi*sqrt(L_fb_ + L_o + 2*M) *C ]^-1

f_actual = F_resonant * ( 1 + resistive_components_inclusion)

Kalj will most likely use one of two choices:

Store bought separate inductors where M = 0 :
needed_volt_Gain_mu = [L_o /L_fb ]  + [resistive_loss_allowance]

A wound ferrite toroid with a feedback tap where M = sqrt(L_fb * L_o)
needed_volt_Gain_mu = [(L_o + M)/L_fb + M)]}  + [resistive_loss_allowance]

Simulator should show the above cases, and a hand calculation using the above can show that the oscillator is mostly in Class A.
That is because the tank circuit acts as a filter so the time varying output will appear sinusoidal even in Class C. 
If the oscillator runs toward Class C (meaning over-drive) , the efficiency improves, but accuracy reduces as non-linearity may be temperature dependant,
and rail voltage can have ripple etc.
« Last Edit: October 26, 2020, 12:56:57 pm by mag_therm »
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3359
  • Country: nl
Re: Stable and fast measurement of variable capacitor
« Reply #66 on: October 26, 2020, 01:13:52 pm »
A bit of TL:DR.

The combination of a current source and a 555 is not very good for stability.
The constant current source wil be somewhat stable regardless of power supply voltage, while the 555 thresholds change with the power supply voltage.

The CC circuit will also change current with the temperature of the transistor (Vbe changes about 2-mV/degree Celcius)

Replacing the CC circuit with a simple resistor will give more stable results, as then both charge rate and threshold voltage changes cancel each other out.

Some 15+ years ago there was a popular LC meter based on a LC oscillator  made from some passives and and opamp or comparator, and a microcontroller to to measure the frequency, but it seems previous posts already suggested similar directions.

Also: Probing around with your scope probe is not the best way to get accurate results. First, simply by attaching your scope probe you change capacitances, and just the proximity of your hands, and changing position of them may change the behavior of the circuit.





 

Offline IDEngineer

  • Super Contributor
  • ***
  • Posts: 1926
  • Country: us
Re: Stable and fast measurement of variable capacitor
« Reply #67 on: October 26, 2020, 04:00:06 pm »
The advantage of the CTMU is low cost and fast measurement speed.  It would be excellent in this application but not because of improved accuracy or resolution.
Agreed, and I wasn't suggesting it would yield vastly superior accuracy or resolution. But it would be sufficient (the definition of good Engineering), and would meet the OP's criteria:

Quote
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.... Additionally, for reasonable responsiveness, the measurement needs to be performed at least with say 10Hz rate.

The CTMU approach would give him what he asked for in a one-chip solution, plus give him significant flexibility in its control and behavior via firmware (on that same single chip). There are many possible solutions to this challenge (as evidenced by this thread) but so far the CTMU is the simplest, most straightforward, and most flexible given the OP's original criteria. Some of the other proposals herein are definitely more technically interesting and I'd love to pursue them for the personal enrichment, but I'm trying to keep my eyes on the OP's original plan without creeping featurism.
 

Offline kaljTopic starter

  • Contributor
  • Posts: 34
  • Country: se
Re: Stable and fast measurement of variable capacitor
« Reply #68 on: November 04, 2020, 07:57:11 pm »
I have been busy with other things, but finally now got the chance to look into this. I've built two circuits with a Hartley and a Colpitts oscillator respectively. In both cases, the component values in the simulation by Zero999 have been used, except for C1 in the Colpitts oscillator which was chosen as 1nF to increase the frequency range. I also added 100nF decoupling capacitors to both circuits. The IC is the CD74HCT4060E.

In both cases I get good oscillations in the 1-5MHz range, and the counter outputs are toggling correspondingly. However, in both cases the oscillation amplitude decreases sharply with high frequency / decreasing capacitance, to the extent that for the last 20% of the varcap the oscillations are to small to correctly trigger the counter.

To see if this was due to a too high frequency, I tried increasing the inductance in the Colpits oscillator, to 100µH instead of 10µH. The frequency was lowered as expected, but the amplitude attenuation seemed to behave the same, with oscillations dying out at the same capacitance.

Any clue what might be causing this problem? Can it be that 14pF is too low a value compared to the ESR of the circuit?
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3359
  • Country: nl
Re: Stable and fast measurement of variable capacitor
« Reply #69 on: November 06, 2020, 04:27:08 pm »
Why not simply build an oscillator with a 555?
 

Offline kaljTopic starter

  • Contributor
  • Posts: 34
  • Country: se
Re: Stable and fast measurement of variable capacitor
« Reply #70 on: November 06, 2020, 05:50:41 pm »
Why not simply build an oscillator with a 555?
You didn't read the first post did you?
 

Offline pwlps

  • Frequent Contributor
  • **
  • Posts: 372
  • Country: fr
Re: Stable and fast measurement of variable capacitor
« Reply #71 on: November 06, 2020, 05:55:25 pm »
Why not simply build an oscillator with a 555?

It has apparently been built already, see post #1. 

Quote
Replacing the CC circuit with a simple resistor will give more stable results, as then both charge rate and threshold voltage changes cancel each other out.
Which CC circuit ?
« Last Edit: November 06, 2020, 05:57:26 pm by pwlps »
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19522
  • Country: gb
  • 0999
Re: Stable and fast measurement of variable capacitor
« Reply #72 on: November 07, 2020, 12:43:24 pm »
That's quite a nice Q, and it's measured at a nearby frequency (2.52MHz) so should be nice.  Is rather big though.

Shouldn't the inductors be coupled, for Hartley?

Tim
It will work with non-coupled inductors.
https://en.wikipedia.org/wiki/Hartley_oscillator

I know it works without.  It might work over a wider range with.

Tim
Yes, coupled inductors would be better. A common mode choke could be used.
 

Offline andrewstuart

  • Newbie
  • Posts: 1
  • Country: au
Re: Stable and fast measurement of variable capacitor
« Reply #73 on: January 10, 2022, 08:09:51 pm »
I solved this using an esp8266 with the ADC and no extra components.

For reasons I have not been able to work out, I could not implement the same solution using any other microcontroller - the readings are too unstable to use. i tried an esp32 and an RP2040.

Here is the working Arduino code:


Code: [Select]
const int OUT_PIN = 16; //D0 // esp8266
const int IN_PIN = A0; // esp8266
int iteration = 0;
const int numReadings = 50; // the number of times we sample the tuning capacitor to smooth out jitters
const int capacitorValueRange = 130; // the range of numbers that can be obtained from the tuning capacitor
const int capacitorValueOffset = 760; // the range of numbers that can be obtained from the tuning capacitor
float frequencyTable[capacitorValueRange];      // a table of the count of the number of times each capacitor value occurs

// NOTE: the term "frequency" here has nothing to do with radio frequency, it is the count of times a reading is obtained

void setup() {
  Serial.begin(115200);
  pinMode(OUT_PIN, OUTPUT);
  pinMode(IN_PIN, INPUT);
}

void loop() {
    // zero out the frequencyTable
    for (int i = 0; i < capacitorValueRange; i++) {
      frequencyTable[i] = 0;
    }
    iteration = 0;
    while (iteration < numReadings) {
      // write some voltage to the tuning capacitor to charge it
      digitalWrite(OUT_PIN, HIGH);
      // read the value of the tuning capacitor
      int ADCValue = analogRead(IN_PIN);
      // count how many times we see each capacitor reading
      frequencyTable[ADCValue - capacitorValueOffset]++;
      // discharge the tuning capacitor
      digitalWrite(OUT_PIN, LOW);
      // a 10 millisecond delay seems to stabilize the value read from the ADC/variable capacitor/tuner
      delay(10);
      iteration++;
    };

    // the "mode" is a mathematical term refering to the most common number in a sequence of numbers
    // we use the mode to smooth out the little bit of jitter that comes when reading the tuning capacitor
    int mode = 0;
    int previousMaxFound = 0;
    for (int i = 0; i < capacitorValueRange; i++) {
      if (frequencyTable[i] > previousMaxFound) {
        mode = i;
        previousMaxFound = frequencyTable[i];
      }
    }
    Serial.print("mode: ");
    Serial.println(mode + capacitorValueOffset);
    delay(200);
}
« Last Edit: January 10, 2022, 08:26:14 pm by andrewstuart »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf