module: leadlagfilter_clocked
parameters: double fz, double fp, double gain, double clk_freq
inputs: double in, double_interp clk
outputs:  double out
static_variables:
classes: Filter filt("1","1"),EdgeDetect clkedge()
init: 

// check for divide by zero error
if (fabs(clk_freq) < 1e-12)
   {
    printf("error in 'leadlagfilter_clocked':\n");
    printf("   parameter 'clk_freq' cannot be so close to zero\n");
    printf("   in this case, clk_freq = %5.3e\n",clk_freq);
    exit(1);
   }
if (fabs(gain) < 1e-12)
   {
    printf("error in 'leadlagfilter_clocked':\n");
    printf("   parameter 'gain' cannot be so close to zero\n");
    printf("   in this case, gain = %5.3e\n",gain);
    exit(1);
   }
filt.set("1+1/(2*pi*fz)s","C3*s + C3/(2*pi*fp)*s^2","C3,fz,fp,Ts",
          1/gain,fz,fp,1/clk_freq);
code:
if (clkedge.inp(clk))
  {
   filt.inp(in);
   out = filt.out;
  }

module: first_order_difference
parameters: double kd
inputs: double in double clk
outputs: double out
classes: Filter diff("1-z^-1","1"), EdgeDetect clkedge()
static_variables:
init:
code:
if (clkedge.inp(clk))
  {
  diff.inp(in);
  out=kd*diff.out;
  }




