en-us_commands:reference:ipidreset
This is an old revision of the document!
Table of Contents
IpidReset()
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
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 thesampleMsinterval has elapsed. It may be called repeatedly inloop().- 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
idfor only one control loop.
Built-in Commands in the Same Category
en-us_commands/reference/ipidreset.1788796400.txt.gz · Last modified: by 127.0.0.1
