Quote from: dewster on 12/4/2024
I've seen the DPLL lock to harmonics as you describe. It happened with a particular batch of 74AHC04 ICs which I presume (didn't test this to confirm) had more hysteresis than normal. Process variations like this are another reason I'd like to go to LVU and/or discrete transistors.
I'm using 74LVC04 (SN74LVC2G04), which should be similar to AHC, so this could be the reason.
Quote from: dewster on 12/4/2024
"One advantage of it over using standalone oscillator is it may be able to provide better phase alignment."How so?
Without feedback, it's hard to provide an exact 90° phase shift, or to synchronize the drive signal with a sense signal exactly. All active components have delay, the value of all passive components are not exact. Even if we tune a circuit to provide exactly the required delay, if the delay is constant, it will only work for a particular frequency. (D)DLLs and (D)PLLs have feedback, so they can dynamically adjust and compensate for the inaccuracies.
Quote from: dewster on 12/4/2024
For DPLL, I wonder if some sort of watchdog that senses harmonic locking could be designed to automatically re-position the operating frequency?
The most straightforward way would be limiting the frequency range. The range can be calculated from the nominal frequency, and the nominal frequency can be set manually, like what's done in D-Lev now, or determined automatically if we start the oscillation in some other ways.
I think it's beneficial to have a better startup process. In the FPGA source of D-Lev's DPLL, I don't see it does anything to start the oscillation. It seems that the frequency is just reset to 0, and when the reset is de-asserted, it simply starts normal operation, without deliberate attempt to e.g. find the resonance frequency. Did I miss something?
Finding the resonance frequency before oscillation starts can be something of a chicken and egg problem. Before oscillation starts or when the amplitude is low, the quad feedback is invalid or at least unreliable, so the DPLL may not have the information needed to adjust the frequency. But without an at least relatively accurate driving frequency, the amplitude will not build up. I'm actually a bit surprised by how well the inverters are able to amplify the small signals, even though the datasheets state that the input is invalid in a relatively large range. But obviously this amplification is not guaranteed, so it's probably better not to rely on it too much.
When I test the DPLL, I found that if I connect neither zero nor quad, the output will be a rapid frequency sweep from a rather low frequency to a high frequency, then it goes back to low frequency again. This seems to be the natural consequence of the XOR outputting a constant, and the frequency accumulator wraps around. Similar thing happens if I don't connect the inductor, and connect both inputs or only the quad. If I connect only the zero, then the output frequency will drift slowly, because the XOR output will be high and low both approximately a half of the time, but not exactly.
If I connect everything normally, reset it, then it will output a waveform of gradually increasing frequency, starting from a very low frequency. Looks like it just wait for the frequency to drift to the correct point. The quad did get some input initially, though the integrity is obviously not great, and because the frequency difference is too large, there isn't a meaningful phase relationship between the two inputs. And here's an issue: since the frequency is initially low, and gradually increases, it will reach fractions of the resonance frequency before reaching the actual resonance frequency, and it will have quite a bit of chance to lock with these!
Maybe the frequency just happened to be increasing in this case. It may also be possible for it to be decreasing in some other cases, then it will reach the resonance frequency first, and the oscillation will probably start without an issue.
Edit: The low_f signal will force the frequency to increase until it reaches the lower limit, only after which the change depends on the input.
Edit2: On the first clock cycle after reset, low_f is actually 0, because it's reset to 0. However, on the same cycle, xor_f is also 0, because it's also reset to 0, so freq_inc will still be 1. But for consistency, maybe it's better to reset low_f to 1 if freq_o is reset to 0?
As I mentioned before, using a(n inverter with) delay may be a good way to start the oscillation, and after the oscillation starts, we will be able to determine the nominal frequency, which could be useful for the operation of the DPLL. Alternatively, it can do a controlled frequency sweep, and determine at which frequency the quad input is the least noisy and the phase difference is closest to 90°. But if you want to save a bit of FPGA resource, then manually setting a frequency range should also work.
A pulse counting based watchdog is another option. Pulse counting is sensitive to edge noise, so if there's noise in the input, it needs to be filtered out.