====== IpidReverse() ====== ''IpidReverse()'' selects direct or reverse PID action. {{:en-us_commands:reference:ipidreverse.svg?900|IpidReverse command operation flow}} ''void IpidReverse(uint8_t id, bool reverse)'' ===== Commands ===== ^ Command ^ Arguments ^ Return Value ^ Operation ^ | ''IpidReverse(id, reverse)'' | ''uint8_t id'' — PID loop number. Supports ''0'' ~ ''255''\\ ''bool reverse'' — ''false'': direct control, ''true'': reverse control | ''void'' | Selects direct or reverse PID action. | ===== Example ===== void setup() { IpidSet(2, 4.0, 0.2, 0.0, 100, 0, 255); // Set PID coefficients, calculation interval and output range. IpidReverse(2, true); // Select direct or reverse PID action. } void loop() { float pv = ntcRead(4) / 10.0; // Return the NTC 3950 10kΩ sensor temperature as an integer in 0.1°C units. float sv = 25.0; int output = (int)IpidRun(2, pv, sv); // Calculate the PID output from the current value and setpoint. analogWrite(11, output); } ===== 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 Commands in the Same Category ===== * [[:en-us_commands:reference:ipidset|IpidSet() View detailed description]] * [[:en-us_commands:reference:ipidrun|IpidRun() View detailed description]] * [[:en-us_commands:reference:ipidreset|IpidReset() View detailed description]] * [[:en-us_commands:reference:ipiditermlimit|IpidItermLimit() View detailed description]] * [[:en-us_commands:reference:ipidoutput|IpidOutput() View detailed description]] [[:en-us_commands:builtin|← Built-in Command List]]