Author Topic: Generating a clean 10kHz sine wave from PWM  (Read 7889 times)

0 Members and 1 Guest are viewing this topic.

Offline robcaTopic starter

  • Frequent Contributor
  • **
  • Posts: 257
Generating a clean 10kHz sine wave from PWM
« on: June 30, 2022, 12:01:44 am »
(not sure if this belongs here or in Beginners)

I'm quite familiar with digital logic and microprocessors, get lost in the analog part...

I'm working with a prototype sensor that changes impedance when environmental conditions change (sorry, can't provide too many details on the sensor itself).

Currently the sensor is read by generating a 10kHz sine wave, and measuring the phase difference using two fast comparators and a digital 12 bit counter with a 2MHz clock. The comparators generate a pulse on zero crossing, one starting and one stopping the counter. The sensor value is read as a 12 bit value from the counter. I did not work on that circuit

I'm now trying to use a microprocessor to, as much as possible, duplicate the entire functionality. Everything runs at 1.8V. I can generate a PWM sine wave at 10kHz (albeit with only 40 values, and 40 steps to define the wave). I plan to use an active lowpass filter to generate as clean a sine signal as possible, 0.9V centered (1.8V Vpp). Then the sine wave is used to excite the sensor, which behaves like a variable inductance, and the excitation signal is fed into the microprocessor differential comparator 1, using 0.9V as a reference to detect zero crossing. That event will automatically start a 16MHz timer, no software needed.

The other end of the sensor is fed into another differential comparator, and the zero crossing there will stop the timer and generate an interrupt so that I can read the value in my code. The timer value is directly proportional to the phase difference, which is directly proportional to the sensor value, in turn reflecting an environmental value.

I tried using a basic lowpass RC filter to clean up my sine, with poor results and a very low Vpp as a result of the filtering. Please note that I don't really need a super-clean sine in the top and bottom part, which from everything I know it's the hardest to achieve. I need the cleanest possible signal at zero crossing, where the curve slope is almost linear and should be the easiest to achieve with a lowpass filter.

I've tried to explain my idea in the drawing below. I used a "mystery opamp filter", because I think that an active filter will help me achieve the best results, and help get a sine as close to 1.8V as possible. I can use up to 3 individual opamps and as many passives as needed, but keeping to BOM simple is a nice to have. One of the opamps in the quad opamp is needed to create a 0.9V reference for the sine wave/sensor. I might need to amplify further the sensor signal, if the sensor/resistor results in a too small signal. If not, probably I could use a dual opamp, not a quad one.

Please note that I'm aware that there is a logical circuit simplification: since I'm controlling the PWM signal, in theory I don't need the first comparator. I could start the timer for the phase difference when the PWM signal generator starts the wave from the 0 point. But I know that filters add a phase offset, so I plan to build the circuit, use the first comparator to get a reading of the offset, and use that in the future to calculate the actual phase difference due to the sensor. So the final circuit will only have one comparator. I designed it with two, to clarify better.

In any case, a clean 10kHz sine wave is a requirement. Can you please help me figure out a good active filter and help pick the passive values for my frequency? A single PWM pulse is 16MHz, and I use 40 pulses to represent values 0 to 40. So the PWM frequency is 400kHz. I have a 40 items LUT, to build the sine

Any type of input is appreciated

« Last Edit: June 30, 2022, 12:04:47 am by robca »
 

Online mawyatt

  • Super Contributor
  • ***
  • Posts: 3250
  • Country: us
Re: Generating a clean 10kHz sine wave from PWM
« Reply #1 on: June 30, 2022, 12:44:54 am »
Interesting concept.

Just a question, could you just use a squarewave and measure the edge shift?

If you require an active LPF then and simple Sallen Key might be in order. You have 40 samples per waveform period so the sampling harmonic content should be far out frequency wise. Maybe a 2nd, 3rd order Butterworth SK might suffice. Watch out for the SK LP feedthru since these unwanted waveform artifacts will be relatively high frequency, and maybe high enough for considering a passive LC filter, or hybrid (active & passive).

SK LP feedthru is when the input couples thru the feedback capacitor since the op-amp output impedance isn't low enough. There are several ways to deal with this, use an op-amp with very high GBW product relative to the desired waveform frequency, bleed current from the output or add an output buffer to the op-amp to lower the output impedance, or use a topology where the input "sees" an RC lowpass before the feedback cap (3rd order).

Anyway, hope this helps.

Best,
Curiosity killed the cat, also depleted my wallet!
~Wyatt Labs by Mike~
 
The following users thanked this post: Someone, robca

Offline Someone

  • Super Contributor
  • ***
  • Posts: 4527
  • Country: au
    • send complaints here
Re: Generating a clean 10kHz sine wave from PWM
« Reply #2 on: June 30, 2022, 01:00:10 am »
I plan to use an active lowpass filter to generate as clean a sine signal as possible, 0.9V centered (1.8V Vpp).
How many orders/stages/poles were you planning? Whats the PWM counter frequency and length/range options?

You are probably fine to just generate a 10kHz square wave and round it off with the active filter (5th order lowpass is cheap enough)
 
The following users thanked this post: robca

Offline robcaTopic starter

  • Frequent Contributor
  • **
  • Posts: 257
Re: Generating a clean 10kHz sine wave from PWM
« Reply #3 on: June 30, 2022, 01:26:36 am »
I plan to use an active lowpass filter to generate as clean a sine signal as possible, 0.9V centered (1.8V Vpp).
How many orders/stages/poles were you planning? Whats the PWM counter frequency and length/range options?

You are probably fine to just generate a 10kHz square wave and round it off with the active filter (5th order lowpass is cheap enough)
Well, how many poles is kind of the question :) That's what I'm trying to figure out. The simplest circuit that gets me a good enough slope to measure phase offset

As I mentioned the fastest PWM pulse frequency is 16MHz. I determined that using 40 possible pulses to represent 0-40 and 40 LUT points to define the values of the sine is the best compromise. That results in a 400kHz PWM frequency with 40 possible values. Using 40 points LUT, results in a neat 10kHz sine

From my point of view, the "cost" of using PWM or a square wave is the same. Once I program the microprocessor registers with the right values, the generation uses no CPU cycle. So I assumed that to get a clean sine, starting from a PWM sine would be better than a square wave. But that's an area I know very little
 

Offline robcaTopic starter

  • Frequent Contributor
  • **
  • Posts: 257
Re: Generating a clean 10kHz sine wave from PWM
« Reply #4 on: June 30, 2022, 01:33:40 am »
Interesting concept.

Just a question, could you just use a squarewave and measure the edge shift?
In speaking with the sensor developer, he thinks that a sine wave is the best, given that we are dealing with an organic polymer that might not like the steep voltages in a square wave. Not sure I understood the chemical explanation, but intuitively it makes sense to me. And I'm also trying to approximate the existing circuit as much as possible, as least as a starting point (to avoid adding even more variables)

Thanks for all your other comments. If I may ask: I'm not sure I understand what frequency I should target for my lowpass filter. I'm sure it's a silly question, but that's one of the areas  I get lost. In playing with the passive RC lowpass, a filter frequency of 5kHz seemed to work better than a 10kHz one. Given the passive filter slope, it kinda makes sense, but I still can't figure out what I should be shooting for, without trying a lot of values, if you had to filter a 400kHz signal with 16MHz pulses in order to get a clean 10kHz sine, what filter frequency would you start from?
 

Offline Someone

  • Super Contributor
  • ***
  • Posts: 4527
  • Country: au
    • send complaints here
Re: Generating a clean 10kHz sine wave from PWM
« Reply #5 on: June 30, 2022, 01:51:38 am »
I determined that using 40 possible pulses to represent 0-40 and 40 LUT points to define the values of the sine is the best compromise. That results in a 400kHz PWM frequency with 40 possible values. Using 40 points LUT, results in a neat 10kHz sine

From my point of view, the "cost" of using PWM or a square wave is the same. Once I program the microprocessor registers with the right values, the generation uses no CPU cycle. So I assumed that to get a clean sine, starting from a PWM sine would be better than a square wave. But that's an area I know very little
So its an autonomous timer with DMA? or some circular buffer to feed the pattern of pulse widths? Those are the details that decide what is possible for frequency. How did you decide that division/rate is optimal when you havent included the filter design?
if you had to filter a 400kHz signal with 16MHz pulses in order to get a clean 10kHz sine, what filter frequency would you start from?
Those arent the frequencies I would describe the system by (from your explanation so far). There are a range of "clever" modulation methods/techniques (even within "PWM") that reduce the demands on the anti aliasing filter. But since you have a 10kHz signal as the measurement, thats a fixed gain point, and any other signal is "noise" that needs to be reduced to some (unspecified) level relative to the fundamental/signal.
 

Offline Someone

  • Super Contributor
  • ***
  • Posts: 4527
  • Country: au
    • send complaints here
Re: Generating a clean 10kHz sine wave from PWM
« Reply #6 on: June 30, 2022, 01:54:31 am »
You are probably fine to just generate a 10kHz square wave and round it off with the active filter (5th order lowpass is cheap enough)
Well, how many poles is kind of the question :) That's what I'm trying to figure out. The simplest circuit that gets me a good enough slope to measure phase offset
Also "cheap" depends on other constraints of unit cost vs engineering time, size/power constraints, etc etc etc.
 

Offline robcaTopic starter

  • Frequent Contributor
  • **
  • Posts: 257
Re: Generating a clean 10kHz sine wave from PWM
« Reply #7 on: June 30, 2022, 02:05:08 am »
You are probably fine to just generate a 10kHz square wave and round it off with the active filter (5th order lowpass is cheap enough)
Well, how many poles is kind of the question :) That's what I'm trying to figure out. The simplest circuit that gets me a good enough slope to measure phase offset
Also "cheap" depends on other constraints of unit cost vs engineering time, size/power constraints, etc etc etc.
Fair enough, you are right "cheap" means nothing. It's a proof-of-concept prototype, so I'm just trying to minimize components. Ideally I'd like to use the TSZ122 (dual opamp) or TLV9004 (quad) I already have in my box of random components. One opamp is gone for the voltage reference at midpoint (0.9V), so that leaves one or 3 opamps to play with. Passives as many as needed, but since I'll be point soldering cockroach style, the fewer, the better. Power for now is not a concern, but it has to work at 1.8V (the current prototype is 5V, but the sensor should work just fine at lower voltages)

Not production-level optimization. Just a prototype that shows that a circuit currently using 22 ICs and 75 odds passives plus a microprocessor, can be reduced to a microprocessor plus a few opamps and passive. To be fair, the original circuit was designed to fully validate the sensor, so it has a lot of additional features to handle multiple frequencies, etc. So I'm not dissing the original one. But it's still a complex circuit now that we know the range of operation and are dealing with a well understood sensor
« Last Edit: June 30, 2022, 02:12:15 am by robca »
 

Offline Someone

  • Super Contributor
  • ***
  • Posts: 4527
  • Country: au
    • send complaints here
Re: Generating a clean 10kHz sine wave from PWM
« Reply #8 on: June 30, 2022, 02:50:11 am »
Ideally I'd like to use the TSZ122 (dual opamp) or TLV9004 (quad) I already have in my box of random components. One opamp is gone for the voltage reference at midpoint (0.9V), so that leaves one or 3 opamps to play with. Passives as many as needed, but since I'll be point soldering cockroach style, the fewer, the better. Power for now is not a concern, but it has to work at 1.8V (the current prototype is 5V, but the sensor should work just fine at lower voltages)
Those opamps have pretty high output impedance, so you'll be fighting to get them to work as an active filter. As above, I'd be stuffing a mostly passive filter in there with the opamp just for gain and "solving" the quality of the sine wave in the modulation.
 
The following users thanked this post: robca

Offline iMo

  • Super Contributor
  • ***
  • Posts: 4780
  • Country: pm
  • It's important to try new things..
Re: Generating a clean 10kHz sine wave from PWM
« Reply #9 on: June 30, 2022, 06:05:22 am »
FYI - MAX7400/7401 (Elliptic/Bessel) 8th order low pass filter.
For 10kHz corner  you would need 1MHz clock to feed into the chip (100:1 clock to corner ratio). Also add a simple RC on their outputs to filter out the clock.
 

Offline emece67

  • Frequent Contributor
  • **
  • !
  • Posts: 614
  • Country: 00
Re: Generating a clean 10kHz sine wave from PWM
« Reply #10 on: June 30, 2022, 06:42:41 am »
.
« Last Edit: August 19, 2022, 05:37:56 pm by emece67 »
 
The following users thanked this post: pardo-bsso, robca

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 14192
  • Country: de
Re: Generating a clean 10kHz sine wave from PWM
« Reply #11 on: June 30, 2022, 06:53:10 am »
There are 2 general concepts, both with pros and cons:
A) use PWM as a kind of DAC and try to sample the sine wave with this. Ideally this would be a kind of 1 bit SD data stream.  This gives quite a bit of higher frequency (e.g. > 100 kHz) amplitude, but not very much below. In theory this makes this filter simpler.

B) start with a simple 10 kHz square wave and apply the fitler directly to that. With little filtering one may get closer to a triangle wave than a sine, but that may be good enough for the sensor.
If the sensor is OK with a not so perfect signal this can be the much easier solution.
The filters have to cope with less higher frequency energy.

Active filters have a somewhat hard time at higher frequencies, like >100 kHz. The real OP amp circuit may no longer behave ideal as the basic therory. An unwanted feed through via the feedback path is common problem with active SK filters if the OP-amp is relatively slow. The simple SK low pass does not work well much above GBW / 10.

The <100 kHz range is however also the range where classic LC fitlers are not yet that attractive, as the inductors get quite bulky, but they get simpler for the higher frequencies. RC filters are OK, but loose some amplitude. This is however not a big deal, as one can amplify later on. A sharp cross over is also not needed, just a good suppression of the high frequency part.

Especially for the path A) one may have to consider a combination of first a passive filter (maybe LC with some 100-200 kHz cross over) to get rid of most of the higher frequencies and only than use an active filter. Active filters want a GBW much higher than the frequency of interest. A 1 MHz OP is far from ideal for 100 kHz and higher.
 
The following users thanked this post: robca

Online Slh

  • Regular Contributor
  • *
  • Posts: 121
  • Country: gb
Re: Generating a clean 10kHz sine wave from PWM
« Reply #12 on: June 30, 2022, 08:29:36 am »
There's a trick you can do by adding a digital inverter and AC coupling the output with the pwm output to reduce the output ripple. I think I found it in the Art of Electronics. It might reduce the required output filter by a factor of 10 or the pwm frequency by the same amount.
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 14192
  • Country: de
Re: Generating a clean 10kHz sine wave from PWM
« Reply #13 on: June 30, 2022, 08:36:27 am »
There's a trick you can do by adding a digital inverter and AC coupling the output with the pwm output to reduce the output ripple. I think I found it in the Art of Electronics. It might reduce the required output filter by a factor of 10 or the pwm frequency by the same amount.
This trick adds effectively an other order to the low pass filter. It may still be somewhat simpler than another filter stage, but not much and a single OP active filter is usually 2nd order.
 

Online voltsandjolts

  • Supporter
  • ****
  • Posts: 2298
  • Country: gb
Re: Generating a clean 10kHz sine wave from PWM
« Reply #14 on: June 30, 2022, 08:48:45 am »
Just another option: DDS sine gen
Search ebay for AD9833 ...oh wow, DigiKey actually has stock too!
 

Online mawyatt

  • Super Contributor
  • ***
  • Posts: 3250
  • Country: us
Re: Generating a clean 10kHz sine wave from PWM
« Reply #15 on: June 30, 2022, 01:10:08 pm »
If I understand correctly you are measuring the zero crossing shift cause by the sensor inductive reactance changing with what's being monitored. Maybe consider using the chip-set utilized by the LCR meters like the DE-5000 which is based upon a synchronous technique and produces the measured phase shift?

Best,
Curiosity killed the cat, also depleted my wallet!
~Wyatt Labs by Mike~
 
The following users thanked this post: robca, JPortici

Offline Picuino

  • Frequent Contributor
  • **
  • Posts: 725
  • Country: 00
    • Picuino web
Re: Generating a clean 10kHz sine wave from PWM
« Reply #16 on: June 30, 2022, 01:27:54 pm »
If the purpose of the circuit is to measure inductance, I think it is simpler from a hardware point of view and much more accurate to make an oscillator by placing a capacitor in parallel to the inductance. Then you can measure the frequency of the LC oscillator and calculate the inductance from there.

It is similar to what this circuit does:
https://electronics-diy.com/lc_meter.php



Edit:
You can remove SW2, the relay and first 1000pF capacitor
« Last Edit: June 30, 2022, 01:31:51 pm by Picuino »
 
The following users thanked this post: robca, spostma

Offline Picuino

  • Frequent Contributor
  • **
  • Posts: 725
  • Country: 00
    • Picuino web
Re: Generating a clean 10kHz sine wave from PWM
« Reply #17 on: June 30, 2022, 01:39:48 pm »
Another option is to use a VCO (Voltage Controlled Oscillator) and a PLL (Phase Locked Loop) matched with the 10kHz PWM signal.

AN-263 Sine Wave Generation Techniques https://www.ti.com/lit/an/snoa665c/snoa665c.pdf

The sine wave can be obtained from a rounded triangular signal with a suitable circuit.
For example as does the old ICL8038 (https://www.mit.edu/~6.331/icl8038data.pdf)
Or Exar  XR2206 (https://www.sparkfun.com/datasheets/Kits/XR2206_104_020808.pdf)
With 0.5% of distorsion.
« Last Edit: June 30, 2022, 01:59:38 pm by Picuino »
 

Offline robcaTopic starter

  • Frequent Contributor
  • **
  • Posts: 257
Re: Generating a clean 10kHz sine wave from PWM
« Reply #18 on: June 30, 2022, 04:33:02 pm »
Thanks everyone for all the input so far. Lots to digest and experiment with, thanks. I need to play with a few options and see how clean of a signal I can get, if I plan to use my original approach

If the purpose of the circuit is to measure inductance, I think it is simpler from a hardware point of view and much more accurate to make an oscillator by placing a capacitor in parallel to the inductance. Then you can measure the frequency of the LC oscillator and calculate the inductance from there.

After reading this (and the similar one from mawyatt), I slapped myself hard. I was so focused on reproducing/simplifying the original circuit, that I did not think about alternative approaches like an LC oscillator. Measuring a frequency is much simpler using a microprocessor. This is really promising, looking into the linked project now

As for the suggestions to use a dedicated chip to generate the sine, that's something I ruled out for many reasons. I'm familiar with, for example, the AD9833 and I have a working module. But it would add one more chip to the BOM, and more importantly will require using two comparators and my microprocessor has only one :) Generating the sine with the processor means I can start the hw timer with the PWM and stop it with the single comparator. An external generator would add complexity.

Will update this post once I have made some progress
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 14192
  • Country: de
Re: Generating a clean 10kHz sine wave from PWM
« Reply #19 on: June 30, 2022, 04:41:01 pm »
An analog filter does cause some phase shift and depending on the details this phase shift can drift with temperature. To keep this effect small one should avoid a sharp bandpass and for the low pass filter consider the cross not too close to 10 kHz. So even with PWM and filter a 2nd comparator may be a good idea.  Alternating between in the sensor and drive path may be an option here.
A DDS could run in sync with the µC. I would still consider this overkill.
 

Offline robcaTopic starter

  • Frequent Contributor
  • **
  • Posts: 257
Re: Generating a clean 10kHz sine wave from PWM
« Reply #20 on: June 30, 2022, 04:50:48 pm »
An analog filter does cause some phase shift and depending on the details this phase shift can drift with temperature. To keep this effect small one should avoid a sharp bandpass and for the low pass filter consider the cross not too close to 10 kHz. So even with PWM and filter a 2nd comparator may be a good idea.  Alternating between in the sensor and drive path may be an option here.
A DDS could run in sync with the µC. I would still consider this overkill.
Yes, you are right. I oversimplified my explanation. I will need to ensure I periodically "zero out" the PWM/filter phase drift, otherwise I will have erroneous readings. And your suggestion is what I planned to do, appreciate you confirming the approach

Assuming I get a good enough sine from the PWM, my code will first use the only comparator to stop the timer and read zero crossing i.e. the filter phase using a pin connected to the filter output (the "drive path"), store that value as the actual starting point of the zero crossing of the signal to the sensor.

Then switch the comparator input pin to the sensor output, and use that to stop the timer (the timer starts with the PWM generation in both cases). Subtracting the two values will give me the phase difference due to the sensor value. Every second or so, re-read the drive path to minimize drift.

Using a free running oscillator requires to program the processor to program the comparator to start a time on zero crossing for pin 1, then immediately after the timer is started, reprogram the comparator on the fly to stop the timer using pin 2. It can be done, but requires very precise IRQ handling and won't work for mall phase difference. It was my initial approach, but I realized it could be done smarter using your approach

And, yes, a programmable DDS can be synced, but it's a lot of pain and, as you say ,overkill
 

Online mawyatt

  • Super Contributor
  • ***
  • Posts: 3250
  • Country: us
Re: Generating a clean 10kHz sine wave from PWM
« Reply #21 on: June 30, 2022, 05:01:26 pm »
Using a free running oscillator requires to program the processor to program the comparator to start a time on zero crossing for pin 1, then immediately after the timer is started, reprogram the comparator on the fly to stop the timer using pin 2. It can be done, but requires very precise IRQ handling and won't work for mall phase difference. It was my initial approach, but I realized it could be done smarter using your approach

Another thought.

If you select a free running (~10KHz) oscillator with the variable inductance, then you could use a frequency divider and measure the divider period with the microprocessor. This would give very good resolution and depends on how long a period (division ratio) you select.

Best,
Curiosity killed the cat, also depleted my wallet!
~Wyatt Labs by Mike~
 

Offline robcaTopic starter

  • Frequent Contributor
  • **
  • Posts: 257
Re: Generating a clean 10kHz sine wave from PWM
« Reply #22 on: June 30, 2022, 05:07:09 pm »
Using a free running oscillator requires to program the processor to program the comparator to start a time on zero crossing for pin 1, then immediately after the timer is started, reprogram the comparator on the fly to stop the timer using pin 2. It can be done, but requires very precise IRQ handling and won't work for mall phase difference. It was my initial approach, but I realized it could be done smarter using your approach

Another thought.

If you select a free running (~10KHz) oscillator with the variable inductance, then you could use a frequency divider and measure the divider period with the microprocessor. This would give very good resolution and depends on how long a period (division ratio) you select.

Best,
Unless I misunderstand you, are you suggesting to build an oscillator with the sensor inductance as part of the circuit, then measure the oscillator frequency? If so, it's in line with the "LC oscillator" measurement technique. Completely change my approach and instead of measure phase difference, measure a frequency generated by a circuit driven by the sensor inductance.

Is that what you are saying, or am I missing your point completely?
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14464
  • Country: fr
Re: Generating a clean 10kHz sine wave from PWM
« Reply #23 on: June 30, 2022, 06:19:59 pm »
Just thinking out loud - whether PWM here would yield lower distortion than a simple square wave going through some low-pass filter, that may not be as trivial as it sounds.
You may in particular consider whether harmonic or non-harmonic distortion is better in your specific application.
 

Online mawyatt

  • Super Contributor
  • ***
  • Posts: 3250
  • Country: us
Re: Generating a clean 10kHz sine wave from PWM
« Reply #24 on: June 30, 2022, 06:44:02 pm »
Using a free running oscillator requires to program the processor to program the comparator to start a time on zero crossing for pin 1, then immediately after the timer is started, reprogram the comparator on the fly to stop the timer using pin 2. It can be done, but requires very precise IRQ handling and won't work for mall phase difference. It was my initial approach, but I realized it could be done smarter using your approach

Another thought.

If you select a free running (~10KHz) oscillator with the variable inductance, then you could use a frequency divider and measure the divider period with the microprocessor. This would give very good resolution and depends on how long a period (division ratio) you select.

Best,
Unless I misunderstand you, are you suggesting to build an oscillator with the sensor inductance as part of the circuit, then measure the oscillator frequency? If so, it's in line with the "LC oscillator" measurement technique. Completely change my approach and instead of measure phase difference, measure a frequency generated by a circuit driven by the sensor inductance.

Is that what you are saying, or am I missing your point completely?

Yes that's the concept. What Picuino indicated using the sensing inductor in an oscillator except don't try and measure the oscillator frequency directly but the period after it's been divided down. The measured period will be D/F, where F is the oscillator frequency and D is the division ratio. This eliminates the need for a comparator and only requires a CMOS divider chip, some CMOS divider chips even have an oscillator gain element (usually a separate inverter) available. Select D for the resolution required based upon the microprocessor clock and ability to measure pulse widths on the I/O pin.

Best,

Edit: A little math to show how this might be implemented.

Freq ~ 1/[Sqrt(LC)]
Period = 1/F ~ Sqrt(LC)
dP/dL ~ [(1/2)*C]/[Sqrt(LC)]
dP ~ [(1/2)*C*F]*dL

So the change in Period is directly proportional to the change in inductance, with a proportionality constant of (1/2)*C*F.

With the divider then this becomes:

dP ~ D*[(1/2)*C*F]*dL

Where D is the division ratio and acts like "Gain" in the system to improve resolution.

Of course this assumes the math is correct ???

Best,
« Last Edit: June 30, 2022, 07:07:25 pm by mawyatt »
Curiosity killed the cat, also depleted my wallet!
~Wyatt Labs by Mike~
 
The following users thanked this post: robca


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf