User Tools

Site Tools


en-us_commands:reference:ipiditermlimit

This is an old revision of the document!


IpidItermLimit()

IpidItermLimit() limits the minimum and maximum of the PID integral term.

IpidItermLimit command operation flow

void IpidItermLimit(uint8_t id, float iMin, float iMax)

Commands

Command Arguments Return Value Operation
IpidItermLimit(id, iMin, iMax) uint8_t id — PID loop number. Supports 0 ~ 255
float iMin
float iMax
void Limits the minimum and maximum of the PID integral term.

Example

const uint8_t PID_ID = 0;
const float SETPOINT_C = 45.0F;
 
void setup() {
  Serial.begin(115200);
  if (!IpidSet(PID_ID, 2.0F, 0.4F, 0.1F, 100, 0.0F, 100.0F)) return;  // Set PID coefficients, calculation interval and output range.
  IpidItermLimit(PID_ID, -20.0F, 20.0F);  // Limit the minimum and maximum of the PID integral term.
  IpidReverse(PID_ID, false);  // Select direct or reverse PID action.
}
 
void loop() {
  const float temperature = ntcReadf(0);  // Return the NTC 3950 10kΩ sensor temperature as a floating-point value in °C.
  if (IdigitalRead(0, 5)) IpidReset(PID_ID);  // Read the input repeatedly and update only if all samples match. If HIGH and LOW are mixed, retain the previous stable state. / Reset the PID integral value and internal state.
  const float demand = IpidRun(PID_ID, temperature, SETPOINT_C);  // Calculate the PID output from the current value and setpoint.
  const float lastDemand = IpidOutput(PID_ID);  // Return the last calculated PID output value.
  IanalogWritef(0, 0.0F, 100.0F, lastDemand);  // Map the user's floating-point value to the analog output range and output it.
  delay(20);
}

Precautions

  • PID output can directly affect field equipment. Begin testing with a low output range and small gains.
  • IpidRun() retains the previous output until the sampleMs interval has elapsed. It may be called repeatedly in loop().
  • The integral term is automatically constrained by the output limits to reduce windup. Use IpidItermLimit() if additional limits are needed.
  • The derivative term is calculated from the PV change to reduce abrupt jumps caused by setpoint changes.
  • IpidReset() resets the integral term, previous PV and previous output value.
  • Use the same id for only one control loop.

← Built-in Command List

en-us_commands/reference/ipiditermlimit.1788791734.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki