Table of Contents

IpidOutput()

IpidOutput() returns the last calculated PID output value.

IpidOutput command operation flow

float IpidOutput(uint8_t id)

Commands

Command Arguments Return Value Operation
IpidOutput(id) uint8_t id — PID loop number. Supports 0 ~ 255 float Returns the last calculated PID output value.

Example

This example reads the raw A0 analog value (0–1023) on MPINO-16A8R8T for the PID calculation. It shows the result only in Serial Monitor and does not drive an output. Check the A0 voltage/current setting for the connected sensor.

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() {
  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.
  const float lastResult = IpidOutput(PID_ID);  // Read the most recently calculated PID output.
  Serial.println(lastResult);
  delay(100);
}

Precautions

Built-in Commands in the Same Category

← Built-in Command List