Skip to main content
. 2023 Jan 14;23(2):979. doi: 10.3390/s23020979
Algorithm 1 Processing of the given signal. Using the following algorithm, we gather large statistical data
  • Part 1.

  • whileTs=0▹ continue until the settling time Ts is determined

  • tt+Δt.▹ increasing time by Δt

  • The first mechanism of recording t˜ (orange dots on Figure 11):

  • ifnf(t)/0.1<n+1then▹ where [ ] represents the floor function

  •     n++;t˜=(2t+Δt)/2; ▹ when the signal crosses decimal values a reference time is recorded (orange dots on Figure 11).

  •     if n+k=1 then ▹ if this is the first a reference time t˜ is recorded, then

  •         tmin=t˜;tmax=t˜; ▹ assign this value to both tmin and tmax

  •     else

  •         tmax=t˜; ▹ renewing only the maximum reference time

  •     end if

  • end if

  • Δt=tmin/N;▹ calculate time step

  • See Part 2 for further explanation.

  • Part 2.

  • The second mechanism of recording t˜ involves an extremum search (green dots on Figure 11). Since the function f(t) is continuous, a moment of time when the derivative f(t) changes sign implies a local extremum.

  • iff(t)·f(tΔt)<0thenf(t) changes sign, so a local extremum occurs in (tΔt,t)

  •     tkex=(2t+Δt)/2;k++; ▹ record the local extremum time and the number of them

  •     fkpeak=f(tkex); ▹ amplitude at the extremum

  •     if fkpeakfk1peak then ▹ we have found a larger peak

  •         PO=(fkpeak1)·100% ▹ percentage overshoot

  •     end if

  •     if k>1 then ▹ if there are multiple extremums

  •         OAk=|fkpeakfk1peak| ▹ the amplitude difference between the neighbor oscillations

  •         OAmax=max(OAk,OAmax) ▹ recording the maximum OA

  •     end if

  •     if k=1 then ▹ if this is the first extremum. This is done so that the tmax does not increase uncontrollably.

  •         tmax=max(tmax,tkex); ▹ the condition k=1 is needed so that tmax does not increase uncontrollably

  •     else

  •         t˜=tkextk1ex;▹ record the time between oscillations for additional accuracy (Nyquist theorem)

  •         tmin=min(tmin,t˜);tmax=max(tmax,t˜); ▹ in case this time is lower that the current tmin or larger than the current value of tmax

  •     end if

  • end if

  • Δt=tmin/N;▹ calculate time step

  • Cont.

  • At last, let us describe the test for finding Ts.

  • iff(t)[0.97,1.03]then▹ the signal appeared in the 3% range

  •     t3%=t;m=0; ▹ record the time and assign zero to the logic parameter m needed for the following cycle

  •     while tt3%+tmax AND m=0 do ▹ starting from t3% for the time length of tmax we check for the 3% criteria

  •         t=t+Δt

  •         if f(t)[0.97,1.03] then ▹ the signal exited the 3% area

  •            m=1; ▹ therefore, the test for settling time stops and the algorithm resumes its work

  •         end if

  •     end while

  •     if m1 then ▹ if the 3% condition did not break once during this test

  •         Ts=t3% ▹ we have found the settling time

  •     end if

  • end if