[sdiy] Frequency follower idea. Question about FM.

Tom Wiltshire tom at electricdruid.net
Mon Sep 13 14:54:39 CEST 2010


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.

My €0.02.
T.


On 13 Sep 2010, at 12:23, cheater cheater wrote:

> On Mon, Sep 13, 2010 at 13:07, Tom Wiltshire <tom at electricdruid.net> wrote:
>> What links did you find, cheater?
>> 
>> I've had a look since this topic interests me too, but I didn't find much. Might have helped if I knew what the P, I, or D in PID stood for!
>> 
>> Thanks,
>> Tom
> 
> I just searched for PID Controller. There's a wikipedia entry for it:
> 
> http://en.wikipedia.org/wiki/PID_controller
> 
> PID stands for Proportional - Integral - Derivative. You have your
> signal and you take part of that signal, some of its integral, and
> some of its derivative, you blend it together in a blender, and you
> feed it back into the generating system.
> 
> Cheers,
> D.




More information about the Synth-diy mailing list