Skip to main content
. 2024 Sep 28;24(19):6285. doi: 10.3390/s24196285
Algorithm 1 Cubic Hermite interpolation for DDFS.
Input: Phase accumulator, ROM //Phase increment and ROM with nodes and derivatives
Output: Output waveform value
  • 1:

    Main Function: DDFS

  • 2:

       Initialize phaseincrement, ROM

  • 3:

    while system running do

  • 4:

          phase=phase+phaseincrement

  • 5:

          adjusted_phase adjustPhase(phase)

  • 6:

          xk,fk,fk ROM[adjusted_phase]

  • 7:

          xk+1,fk+1,fk+1 ROM[adjusted_phase + 1]

  • 8:

          waveform_value sign· cubicHermiteInterpolation(phasexkxk+1fkfk+1fkfk+1)

  • 9:

          output waveform_value through DAC and LPF

  • 10:

    end while

  • 11:

     

  • 12:

    Function cubicHermiteInterpolation(xxkxk+1fkfk+1fkfk+1):

  • 13:

       t=xxkxk+1xk //Calculate the relative position

  • 14:

       h0=2t33t2+1 //Hermitian basis function

  • 15:

       h1=t32t2+t

  • 16:

       h2=2t3+3t2

  • 17:

       h3=t3t2

  • 18:

       interpolated_value=h0·fk+h1·(xk+1xk)·fk+h2·fk+1+h3·(xk+1xk)·fk+1

  • 19:

       return interpolated_value

  • 20:

     

  • 21:

    Function adjustPhase(phase) //Adjust phase using single-quadrant storage method

  • 22:

    if  phase<π2  then

  • 23:

            sign=1

  • 24:

            adjusted_phase=phase

  • 25:

    else if phase<π then

  • 26:

            sign=1

  • 27:

            adjusted_phase=πphase

  • 28:

    else if phase<3π2 then

  • 29:

            sign=1

  • 30:

            adjusted_phase=phaseπ

  • 31:

    else

  • 32:

            sign=1

  • 33:

            adjusted_phase=2πphase

  • 34:

    end if

  • 35:

    return  adjusted_phase,sign