[sdiy] Frequency follower idea. Question about FM.

Magnus Danielson magnus at rubidium.dyndns.org
Wed Sep 15 20:48:27 CEST 2010


On 09/13/2010 02:54 PM, Tom Wiltshire wrote:
> The pseudocode part of that article makes it very clear how you'd actually go about implementing it:
>
> http://en.wikipedia.org/wiki/PID_controller#Pseudocode
>
> A quick look through that code makes me think that there's gains to be had by making sure dt=1.
> That simplifies it to:
>
> previous_error = 0
> integral = 0
> start:
>    error = setpoint - actual_position
>    integral += error
>    derivative = (error - previous_error)
>    output = (Kp*error) + (Ki*integral) + (Kd*derivative)
>    previous_error = error
>    wait(dt)
>    goto start
>
> ..which is a pretty straightforward algorithm and calculation.
>
> I've messed around with various algorithms for LFO sync, but I've been looking for ways of improving it. Simply timing the period of the sync signal and setting the LFO frequency based on that works, but you either have to ignore phase, or reset the phase. Resetting makes a glitch in some waveforms, which generally isn't the idea. However, something that spends many cycles "zooming in" on the right frequency and phase smoothly might actually be worse than something that just snaps directly to the correct frequency and phase once it's got it, given that LFO cycles can be quite long - you probably want this thing synced this side of two minutes later! Still, I'd have to hear it and play with it to be sure.

LFO is certainly within the range where you run into problems with 
integrator time constants, so this is certainly best handled in digital. 
Being able to measure phase-difference with sufficient speed and 
precision is important.

The relationship between I and P for instance will control the damping 
factor/Q-value of the loop while the I parameter will control the loop 
bandwidth of the PLL. The D term will provide for quicker pull-in time 
as it differentiates the phase error such that frequency errors is 
better tracked than the weak gain for large frequency errors. Some 
detectors has phase-frequency properties, so that can be a possibility 
for an analogue implementation.

A classic PLL chip is the 4046 PLL chip. It's versatile little thingie. 
It is well documented if you look around, but it is also plagued by 
numerous issues. It can be a good chip to do play with to get experience.

Anyway, the field is very extensively researched, but it can be a bit 
hard to navigate it all. The BEST book

http://www.amazon.ca/Phase-Locked-Loops-Roland-E-Best/dp/0071412018

is a classic introductional book. Wolaver and Garner should be good 
complementary books on top of that. Then there is more specific books 
and articles for many specializations.

Cheers,
Magnus



More information about the Synth-diy mailing list