Arduino PID library is not working

Could you please help me to make the PID library to start working. Even when I am using an example sketch it gives me the following errors:

libraries/PID_v1/PID_v1.cpp: In constructor 'PID::PID(double*, double*, double*, double, double, double, int)':

libraries/PID_v1/PID_v1.cpp:26: error: 'millis' was not declared in this scope

libraries/PID_v1/PID_v1.cpp: In member function 'void PID::Compute()':

libraries/PID_v1/PID_v1.cpp:43: error: 'millis' was not declared in this scope

Scroll up. What is the very first message? (or all of the error messages; Ctrl+A works to Select All)

That is all I see:

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

Add

#include "Arduino.h"

On top of the library .h

It did not work, the same errors come up. Here is the code I have, it might help to understand my problem better:

/********************************************************
 * PID Basic Example
 * Reading analog input 0 to control analog PWM output 3
 ********************************************************/

#include "Arduino.h"
#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);

void setup()
{
  //initialize the variables we're linked to
  Input = analogRead(0);
  Setpoint = 100;

  //turn the PID on
  myPID.SetMode(AUTOMATIC);
}

void loop()
{
  Input = analogRead(0);
  myPID.Compute();
  analogWrite(3,Output);
}

Where and how did you store the PID_v1 library folder and files?

Lefty

I have got Mac, so I created a folder called Arduino in Documents, then there I created libraries, which is the place with the folder with PID libraries. Overall root is like that:

Documents/Arduino/libraries/PID_v1/

I am using some other external libraries in the same way, but they do not seem to produce any errors.

Arduino IDE version?

Do you have the PID library installed more than once? Perhaps in the Arduino directory?

I have got Arduino Mega 2560. Yea, I was trying to install those libraries from different places and some of them got left in the libraries menu. Is there way to delete them, thou I don't think it solves the problem?

Arduino IDE version?

Sorry, 1.5.2.

Just tried using 1.0.4 and it is still not working. For some reason when Arduino is giving me an error it points out the root to PID folder, which I did not use for libraries, it kind of creates a new one somewhere else...

Something is corrupted in your library. millis is not on line 26 or 43 in PID_V1.cpp.

It is on line 37 and 50.

Sometimes when you download it, it pulls in extra characters meant for the displaying of the data on a webpage. This will confuse the compiler.

Go here, and click on ZIP to properly download the files. Get rid of all other copies that you have:

Retroplayer, thank you so much! That worked. Probably the files I had were damaged or not debugged. Thanks a lot!

You're welcome. Glad I could help

You added the include into the ino file, not into the library h.

Probably the lid you dowloaded was old and works with ide until 0022

dvl12:
That is all I see:

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

how solve this compiler error.

The same way the other person did? This thread was last posted to in April 2013.

sketch_jan04a:8: error: 'PID' does not name a type
sketch_jan04a.ino: In function 'void setup()':
sketch_jan04a:17: error: 'myPID' was not declared in this scope
sketch_jan04a:17: error: 'AUTOMATIC' was not declared in this scope
sketch_jan04a.ino: In function 'void loop()':
sketch_jan04a:23: error: 'myPID' was not declared in this scope

this is the error I am getting

and, this is my code:

#include "Arduino.h"
#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);

void setup()
{
//initialize the variables we're linked to
Input = analogRead(0);
Setpoint = 100;

//turn the PID on
myPID.SetMode(AUTOMATIC);
}

void loop()
{
Input = analogRead(0);
myPID.Compute();
analogWrite(3,Output);
}

I downloaded the library which is metioned in this forum:

and imported it

pls help me out
thanks!