Table of Contents

IpidReset()

IpidReset() resets the PID integral value and internal state.

IpidReset command operation flow

void IpidReset(uint8_t id)

Commands

Command Arguments Return Value Operation
IpidReset(id) uint8_t id — PID loop number. Supports 0 ~ 255 void Resets the PID integral value and internal state.

Example

This example uses the MPINO-16A8R8T A0 value as the PID process value. When input D22 changes from LOW to HIGH, it resets the PID state once. It shows the result only in Serial Monitor. Check the A0 setting and D22 wiring against the product specifications.

const uint8_t PID_ID = 0;
 
void setup() {
  Serial.begin(115200);
  IpidSet(PID_ID, 2.0F, 0.4F, 0.1F, 100, 0.0F, 1023.0F);  // Set PID gains, sample interval, and output range.
}
 
void loop() {
  static bool wasHigh = false;
  const bool isHigh = digitalRead(22) == HIGH;
  if (isHigh && !wasHigh) IpidReset(PID_ID);  // Reset the PID state on the D22 rising edge.
  wasHigh = isHigh;
  const float currentValue = analogRead(A0);  // Read the raw ADC value from A0.
  const float result = IpidRun(PID_ID, currentValue, 512.0F);  // Calculate PID output from the A0 raw value and setpoint 512.
  Serial.println(result);
  delay(100);
}

Precautions

Built-in Commands in the Same Category

← Built-in Command List