sTune PID Autotune Library


arduino-library-badge PlatformIO Registry

This is an open loop PID autotuner using a novel s-curve inflection point test method. Tuning parameters are typically determined in about ½Tau on a first-order system with time delay. Full 5Tau testing and multiple serial output options are provided.


Very useful information along with the visual representation. It would be even better if you could shed some light on the inflection point.


Well, looking at just the small tangent line, the first derivative is the slope. As the tangent moves along the curve, at first the slope keeps increasing. Then, at some point, the slope begins to decrease. This is the point of inflection (POI).

In order to detect this point, we just keep taking the second derivative and are interested only in when the sign changes from positive to negative.

If this were a cooling process, the graph would be flipped (top to bottom). In this case, the POI would be when the sign of the second derivative changes from negative to positive.

The test completes at the POI. From here, there is enough information to calculate remaining results, rather than waiting to take measurements. The test duration is about an order of magnitude less than testing to pvMax.

New version: sTune 2.4.0

Feature Summary:

  • 10 tuning methods
  • Get tuning results at the Inflection Point (very fast)
  • On-the-fly tuning and PID control
  • Software PWM function features optimum output control for SSR's
  • 13 example sketches
  • Various print and plot options

From Get_All_Tunings example:

 Controller Action: directIP

 Output Start:      0.00
 Output Step:       50.00
 Sample Sec:        1.0000

 Pv Start:          35.000
 Pv Max:            57.893
 Pv Diff:           22.893

 Process Gain:      2.289
 Dead Time Sec:     10.000
 Tau Sec:           255.555

 Tau/Dead Time:     25.6 (easy to control)
 Tau/Sample Period: 255.6 (good sample rate)

 Tuning Method: ZN_PID
  Kp: 6.698
  Ki: 0.050  Ti: 133.958
  Kd: 0.200  Td: 33.490

 Tuning Method: Damped_PID
  Kp: 7.368
  Ki: 0.014  Ti: 523.003
  Kd: 0.035  Td: 209.201

 Tuning Method: NoOvershoot_PID
  Kp: 6.698
  Ki: 0.004  Ti: 1711.645
  Kd: 0.200  Td: 33.490

 Tuning Method: CohenCoon_PID
  Kp: 3.067
  Ki: 0.032  Ti: 94.428
  Kd: 0.277  Td: 11.075

 Tuning Method: Mixed_PID
  Kp: 5.958
  Ki: 0.025  Ti: 237.163
  Kd: 0.178  Td: 33.462

 Tuning Method: ZN_PI
  Kp: 5.023
  Ki: 0.030  Ti: 167.446
  Kd: 0.000  Td: 0.000

 Tuning Method: Damped_PI
  Kp: 5.526
  Ki: 0.010  Ti: 543.118
  Kd: 0.000  Td: 0.000

 Tuning Method: NoOvershoot_PI
  Kp: 3.907
  Ki: 0.003  Ti: 1198.151
  Kd: 0.000  Td: 0.000

 Tuning Method: CohenCoon_PI
  Kp: 2.068
  Ki: 0.032  Ti: 63.662
  Kd: 0.000  Td: 0.000

 Tuning Method: Mixed_PI
  Kp: 4.131
  Ki: 0.019  Ti: 217.661
  Kd: 0.000  Td: 0.000

Example plot showing optimum output SSR control, which has the effect of reducing overshoot and maintaining tighter regulation at the setpoint:

1 Like

Hello . This library can use for motor ?

The library was developed to use with thermal type devices. I haven't done any testing with motors, so I don't know if it would be beneficial.

Have you created an autotune public library for the engine?

No, but this is the top hit when searching Arduino motor autotune ...
Arduino - PID Controller, Auto-tuning Library And Example for DC Motor

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.