ph_pid PowerHome formula function
Description
Allows for calculating a PID (Proportional Integral Derivative) control value 
Syntax
ph_pid ( as_id, ad_setpoint, ad_input, ad_outmin, ad_outmax, ad_p, ad_i, ad_d )
Argument Description
as_id String. The ID you would like to use for this particular PID control loop. If the ID has not been used before, a new entry is created in the PID table. The ID can only contain the following characters A-Z, 0-9, _, -, or space characters and must be 25 characters or less in length
ad_setpoint Double. The SetPoint wish to control to. This is the desired value you hope to achieve by sequentially applying the output of repeated calls to this function
ad_input Double. The current value of what you're trying to control. Ideally, the ad_input value will reach and stabilize at the ad_setpoint value
ad_outmin Double. The minimum control output adjustment that the function should return
ad_outmax Double. The maximum control output adjustment that the function should return
ad_p Double. The Proportional constant you wish to use
ad_i Double. The Integral constant you wish to use
ad_d Double. The Derivative constant you wish to use
Return value
Double. Returns the calculated control output to be applied in an effort for the ad_input value to equal the ad_setpoint value. Returns -99999999 if the ID contains invalid characters or is too long
Usage
Use this function to enable PID control loops. A good explantion of PID control can be found at this Wikipedia entry: https://en.wikipedia.org/wiki/PID_controller. This type of control algorithm and feedback loop is typically used in industrial automation. 
Examples
The following examples demonstrate typical syntax/usage for this function.
• ph_pid("TESTPID",75,70.3, -4,4,0.3,0.02,0) - Returns a value between -4 and 4 depending upon currently stored internal values from previous executions of the function. In this hypothetical example, our setpoint is 75 and the current value is 70.3 which will likely return a value of 4. Based upon how that effects the current value, the output will be adjusted accordingly until equilibrium with each successive call to the function. This example illustrates the most commonly used control loop of PI (Proportional Integral) control since the Derivative value is set to 0.