Problem with compiling

Hello,
I have a problem with compiling the code. I have Arduino ver 1.0.5-r2 on Windows7
I uploaded the library as PID and PID Library Front-End using Processing from this page.
Turning to the heart of the matter, my programming language is not good and I don't know exactly what the error is.
And here I am counting on your help, it will show me an error and say what's going on.
I'm sorry if you are here for some linguistic errors, and compatible with the establishment topic.

When I try to compile pop up errors:

Autotiunig_PID:17: error: 'PID_ATune' does not name a type
Autotiunig_PID.ino: In function 'void loop()':
Autotiunig_PID:59: error: 'aTune' was not declared in this scope
Autotiunig_PID.ino: In function 'void changeAutoTune()':
Autotiunig_PID:104: error: 'aTune' was not declared in this scope
Autotiunig_PID:112: error: 'aTune' was not declared in this scope

Program code looks like this:

#include <PID_v1.h>
#include <PID_AutoTune_v0.h>

byte ATuneModeRemember=2;
double input=80, output=50, setpoint=180;
double kp=2,ki=0.5,kd=2;

double kpmodel=1.5, taup=100, theta[50];
double outputStart=5;
double aTuneStep=50, aTuneNoise=1, aTuneStartValue=100;
unsigned int aTuneLookBack=20;

boolean tuning = false;
unsigned long  modelTime, serialTime;

PID myPID(&input, &output, &setpoint,kp,ki,kd, DIRECT);
PID_ATune aTune(&input, &output);

//set to false to connect to the real world
boolean useSimulation = true;

void setup()
{
  if(useSimulation)
  {
    for(byte i=0;i<50;i++)
    {
      theta[i]=outputStart;
    }
    modelTime = 0;
  }
  //Setup the pid 
  myPID.SetMode(AUTOMATIC);

  if(tuning)
  {
    tuning=false;
    changeAutoTune();
    tuning=true;
  }
  
  serialTime = 0;
  Serial.begin(9600);

}

void loop()
{

  unsigned long now = millis();

  if(!useSimulation)
  { //pull the input in from the real world
    input = analogRead(0);
  }
  
  if(tuning)
  {
    byte val = (aTune.Runtime());
    if (val!=0)
    {
      tuning = false;
    }
    if(!tuning)
    { //we're done, set the tuning parameters
      kp = aTune.GetKp();
      ki = aTune.GetKi();
      kd = aTune.GetKd();
      myPID.SetTunings(kp,ki,kd);
      AutoTuneHelper(false);
    }
  }
  else myPID.Compute();
  
  if(useSimulation)
  {
    theta[30]=output;
    if(now>=modelTime)
    {
      modelTime +=100; 
      DoModel();
    }
  }
  else
  {
     analogWrite(0,output); 
  }
  
  //send-receive with processing if it's time
  if(millis()>serialTime)
  {
    SerialReceive();
    SerialSend();
    serialTime+=500;
  }
}

void changeAutoTune()
{
 if(!tuning)
  {
    //Set the output to the desired starting frequency.
    output=aTuneStartValue;
    aTune.SetNoiseBand(aTuneNoise);
    aTune.SetOutputStep(aTuneStep);
    aTune.SetLookbackSec((int)aTuneLookBack);
    AutoTuneHelper(true);
    tuning = true;
  }
  else
  { //cancel autotune
    aTune.Cancel();
    tuning = false;
    AutoTuneHelper(false);
  }
}

void AutoTuneHelper(boolean start)
{
  if(start)
    ATuneModeRemember = myPID.GetMode();
  else
    myPID.SetMode(ATuneModeRemember);
}


void SerialSend()
{
  Serial.print("setpoint: ");Serial.print(setpoint); Serial.print(" ");
  Serial.print("input: ");Serial.print(input); Serial.print(" ");
  Serial.print("output: ");Serial.print(output); Serial.print(" ");
  if(tuning){
    Serial.println("tuning mode");
  } else {
    Serial.print("kp: ");Serial.print(myPID.GetKp());Serial.print(" ");
    Serial.print("ki: ");Serial.print(myPID.GetKi());Serial.print(" ");
    Serial.print("kd: ");Serial.print(myPID.GetKd());Serial.println();
  }
}

void SerialReceive()
{
  if(Serial.available())
  {
   char b = Serial.read(); 
   Serial.flush(); 
   if((b=='1' && !tuning) || (b!='1' && tuning))changeAutoTune();
  }
}

void DoModel()
{
  //cycle the dead time
  for(byte i=0;i<49;i++)
  {
    theta[i] = theta[i+1];
  }
  //compute the input
  input = (kpmodel / taup) *(theta[0]-outputStart) + input*(1-1/taup) + ((float)random(-10,10))/100;

}

Hi Przemyslaw

It could be that the PID library is installed OK for the Arduino IDE but the autotune library is not.

Can you post a copy of the autotune .h and .cpp files that you downloaded? Or a link to where you downloaded them from.

Regards

Ray

I download all Library from: Arduino Playground - PIDLibrary
Thanks for your interest in my problem.

Hi there

On that page, there is the following:

PID Library

Latest version (now hosted on GitHub): v1.0.1

Is that where you downloaded from? If so, it only contains the PID library files PID_v1.h and PID_v1.cpp.

If you want to use the autotune library, you need to find and download that too.

I Googled and found this. It looks like the right thing but I have never used PID so can't be sure.

I have downloaded

PID Library

Latest version (now hosted on GitHub): v1.0.1

and

PID Front-End using Processing.org

Latest version: v0.3

I downloaded the file in yours link and Autotune does not work. I have the same error.
I try find this right library on internet.
Thanks for help.

I'm surprised you are getting exactly the same compiler error. The files PID_AutoTune_v0.h and PID_AutoTune_v0.cpp from the link I posted contain a class called PID_ATune, which is what the compiler could not find.

Did you put the two files (plus the examples folder) in a folder /arduino/libraries/PID_AutoTune_v0 and restart the Arduino IDE after installing them?

All the best.

Okay, this error has disappeared and a new is:

#####\Arduino\libraries\PID_v1\PID_v1.cpp: In constructor 'PID::PID(double*, double*, double*, double, double, double, int)':
####\Arduino\libraries\PID_v1\PID_v1.cpp:26: error: 'millis' was not declared in this scope
####\Arduino\libraries\PID_v1\PID_v1.cpp: In member function 'void PID::Compute()':
####\Arduino\libraries\PID_v1\PID_v1.cpp:43: error: 'millis' was not declared in this scope

Check weather PID_v1.cpp/.h includes Arduino.h or WProgram.h

If neither are there, include Arduino.h.
If WProgram.h is there, replace it with Arduino.h

The github version is correct, you are using different file names/library?

Okay I found the problem. I modify in wrong libraries folder.
Thank you for your help and patience
Topic to close.