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

Next revision
Previous revision
en-us_commands:reference:ipidoutput [2026/09/07 21:52] – 만듦 - 바깥 편집 127.0.0.1en-us_commands:reference:ipidoutput [2026/09/14 20:30] (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>
-bool IpidSet(uint8_t idfloat kpfloat kifloat kdunsigned long sampleMsfloat outMinfloat outMax); +const uint8_t PID_ID = 0; 
-float IpidRun(uint8_t idfloat pvfloat sv); + 
-void IpidReset(uint8_t id); +void setup() { 
-void IpidReverse(uint8_t id, bool reverse); +  Serial.begin(115200); 
-void IpidItermLimit(uint8_t idfloat iMinfloat iMax); +  IpidSet(PID_ID2.0F0.4F0.1F1000.0F1023.0F);  // Set PID gainssample intervaland output range. 
-float IpidOutput(uint8_t id);+
 + 
 +void loop() { 
 +  const float currentValue = analogRead(A0);  // Read the raw ADC value from A0. 
 +  const float result = IpidRun(PID_IDcurrentValue512.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); 
 +}
 </code> </code>
  
Line 32: Line 42:
   * ''IpidReset()'' resets the integral term, previous PV and previous output value.   * ''IpidReset()'' resets the integral term, previous PV and previous output value.
   * Use the same ''id'' for only one control loop.   * 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:ipidreverse|IpidReverse() View detailed description]]
 +  * [[:en-us_commands:reference:ipiditermlimit|IpidItermLimit() View detailed description]]
  
 [[:en-us_commands:builtin|← Built-in Command List]] [[:en-us_commands:builtin|← Built-in Command List]]
  
en-us_commands/reference/ipidoutput.1788785567.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki