I'm trying to construct something useful with PID tuning, that's when I found the PID library.
The problem I'm encountering is that it's leaving me with an output value of 0.00. "IE not doing anything"
Does anybody want to shed some light on the situation?
/********************************************************
* PID Basic Example
* Reading analog input A0 to control analog PWM output 5
********************************************************/
#include <PID_v1.h>
//Define Variables we'll be connecting to
double Setpoint, Input, Output;
//Specify the links and initial tuning parameters
PID myPID(&Input, &Output, &Setpoint,2,5,1, DIRECT);
int sens;
void setup()
{
//initialize the variables we're linked to
Input = analogRead(A0);
sens = analogRead(A4);
//turn the PID on
myPID.SetMode(AUTOMATIC);
}
void loop()
{
sens = analogRead(A4);
Setpoint = (sens\4);
Input = analogRead(A0);
myPID.Compute();
analogWrite(5,Output);
}
sketch_feb09a:29: error: stray '' in program
sketch_feb09a.ino: In function 'void loop()':
sketch_feb09a:29: error: expected `)' before numeric constant
Dividing by four"4", to represent a output format when done. Instead of 0-1023, we need 0-255 for the output.
That would be an input value, not an output, and for PID, it is quite a bad idea to reduce the resolution of the input measurements, even if you coded the divide correctly.
For PID you would like the input measurements to have at least ten times the resolution of the output values.