User Tools

Site Tools


en-us_commands:reference:ipidoutput

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en-us_commands:reference:ipidoutput [2026/09/08 00:53] – 바깥 편집 127.0.0.1en-us_commands:reference:ipidoutput [2026/10/25 08:41] (current) – external edit 127.0.0.1
Line 14: Line 14:
  
 ===== Example ===== ===== 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.
  
 <code cpp> <code cpp>
 const uint8_t PID_ID = 0; const uint8_t PID_ID = 0;
-const float SETPOINT_C = 45.0F; 
  
 void setup() { void setup() {
   Serial.begin(115200);   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. +  IpidSet(PID_ID, 2.0F, 0.4F, 0.1F, 100, 0.0F, 1023.0F);  // Set PID gains, sample 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() { void loop() {
-  const float temperature = ntcReadf(0);  // Return the NTC 3950 10kΩ sensor temperature as a floating-point value in °C. +  const float currentValue = analogRead(A0);  // Read the raw ADC value from A0. 
-  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 result = IpidRun(PID_ID, currentValue, 512.0F);  // Calculate PID output from the A0 raw value and setpoint 512. 
-  const float demand = IpidRun(PID_ID, temperature, SETPOINT_C);  // Calculate the PID output from the current value and setpoint. +  const float lastResult = IpidOutput(PID_ID);  // Read the most recently calculated PID output. 
-  const float lastDemand = IpidOutput(PID_ID);  // Return the last calculated PID output value. +  Serial.println(lastResult); 
-  IanalogWritef(0, 0.0F, 100.0F, lastDemand);  // Map the user's floating-point value to the analog output range and output it. +  delay(100);
-  delay(20);+
 } }
 </code> </code>
Line 47: Line 45:
 ===== Built-in Commands in the Same Category ===== ===== Built-in Commands in the Same Category =====
  
-  * [[:en-us_commands:reference:ipidset|IpidSet() View detailed description]] +  * [[:en-us_commands:reference:ipidset|IpidSet() reference]] 
-  * [[:en-us_commands:reference:ipidrun|IpidRun() View detailed description]] +  * [[:en-us_commands:reference:ipidrun|IpidRun() reference]] 
-  * [[:en-us_commands:reference:ipidreset|IpidReset() View detailed description]] +  * [[:en-us_commands:reference:ipidreset|IpidReset() reference]] 
-  * [[:en-us_commands:reference:ipidreverse|IpidReverse() View detailed description]] +  * [[:en-us_commands:reference:ipidreverse|IpidReverse() reference]] 
-  * [[:en-us_commands:reference:ipiditermlimit|IpidItermLimit() View detailed description]]+  * [[:en-us_commands:reference:ipiditermlimit|IpidItermLimit() reference]]
  
 [[:en-us_commands:builtin|← Built-in Command List]] [[:en-us_commands:builtin|← Built-in Command List]]
  
en-us_commands/reference/ipidoutput.1788796400.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki