PID Control

My output is always being set to 0 whenever it does myPID.compute(). Why is this the case?

#include <PID_v1.h>
double Setpoint;
double Input;
double Output;
double Kp=0.256, Ki=29.412, Kd=-0.0008439;

PID myPID(&Input, &Output, &Setpoint, Kp, Ki, Kd, DIRECT);
void setup() {
// put your setup code here, to run once:
Setpoint = 1000000;
myPID.SetMode(AUTOMATIC);
myPID.SetTunings(Kp, Ki, Kd);
pinMode(A1,OUTPUT);
pinMode(A0,INPUT);
Serial.begin(9600);
analogWrite(A1,900);
delay(5000);
}

void loop() {
// put your main code here, to run repeatedly:
Input = analogRead(A0);
myPID.Compute();
analogWrite(A1,Output);
//Serial.print(Input);
Serial.print(" ");
Serial.println(Output);
//Serial.print(" ");
//Serial.println(Setpoint);

}

Double is implemented as float, no extra range or precision. Can that affect Your cide?

Pid needs to be connected in a control loop - an output and an input to show meaningful values .

Also , you may need to change the control sense normal/reversed .

It's your negative Kd setting. Running your code on an Uno with nothing on A0, I get zeros too. As soon as I make Kd non negative, it gives 255, which given your huge set point, makes sense.

You'll need to dig into the library to see why, perhaps take a copy and then put some Serial prints in there to see what it's doing.

I'm no PID expert; does a negative Kd actually make sense?