PID Output remain to Output = 0!

Good evening,

i come to you about a problem that makes me crazy !!!

I have arduino Mega with CAN Bus Shield on top and PID to calculate PWM (Speed) according to PID Calculation,

#include <PID_v1.h>

//Define Variables for PID calculation
double Output;
//PID Parameters
double aggKp=4;                     
double aggKi=0.2;
double aggKd=1;
double consKp=1;
double consKi=0.05;
double consKd=0.25;
unsigned int PID_Gap = 5;   // PID Parameter to setup between Aggressive and Conservative parameters (distance from Speed_Value and Idle_Speed)

// PINOUT Description
#define EVP_FWD_PIN           14     // EVP Pin for FWD Direction (RED Wire)
double Speed_Value =         0;      // Variable to store Truck Speed (Value X100)
unsigned int Min_EVP  =     50;      // Minimum Prop.valve open sent to Danfoss Plus 1
unsigned int Max_EVP  =    255;      // Maximum Prop.valve open sent to Danfoss Plus 1
double Target_Speed =        0;      // Target Speed to reach during Decel function

int Ratio =                  0;      // Ratio to calculate Target of PID
double Ratio_PID =           0;

PID myPID(&Speed_Value, &Output, &Target_Speed, consKp, consKi, consKd, DIRECT);

void setup()
{
    Serial.begin(115200);     // Serial connexion
    myPID.SetMode(AUTOMATIC); // Turn PID ON
    myPID.SetOutputLimits(Min_EVP, Max_EVP);
}

void PID_Compute(unsigned int Target_Speed)
{
  double gap = abs(Target_Speed - Speed_Value); //distance away from setpoint
  Serial.print ("PID Gap : "); Serial.println (gap);
  if (Debug){Serial.print ("PID Gap : "); Serial.println (gap);}
  if (gap < PID_Gap)
  { 
    //if (Debug == 1) {Serial.println ("Conservative PID");}
    Serial.println ("Conservative PID");
    myPID.SetTunings(consKp, consKi, consKd);
  }
  else
  { 
    Serial.println ("Aggressive PID");
    //if (Debug == 1) {Serial.println ("Aggressive PID");}
    myPID.SetTunings(aggKp, aggKi, aggKd);
  }
  //CAN_Receive();
  Serial.println ("PID BEFORE: ");
  Serial.println(Target_Speed);
  Serial.println(Speed_Value);
  Serial.println(Output);
  myPID.Compute();
  Serial.println ("PID AFTER: ");
  Serial.println(Target_Speed);
  Serial.println(Speed_Value);
  Serial.println(Output);
  Serial.print ("Output: "); Serial.println (Output);

}

void FWD_Fast ()
{
  analogWrite (EVP_FWD_PIN, Max_EVP);
  analogWrite (EVP_REV_PIN, 0);  
}

void REV_Fast ()
{
  analogWrite (EVP_REV_PIN, Max_EVP);
  analogWrite (EVP_FWD_PIN, 0); 
}

void CAN_Receive ()
{ 
   Ratio_PID = Ratio;
}

void loop()
{
  if (FWD_IN)
  { 
     PID_Compute(Speed_Target);
     Serial.print ("Run FWD PWM : "); Serial.println (Output);
     analogWrite (EVP_FWD_PIN, Output);
   }
}

Sorry, but i have clean the code, possible to have discrepencies.

Output of my PID is always 0,

Serial datas:

PID BEFORE: 
0
0.00
50.00
PID AFTER: 
0
0.00
50.00
Output: 50.00
Run FWD PWM : 50.00
Ratio: 1
PID Gap : 1.00
Conservative PID
PID BEFORE: 
1
0.00
50.00
PID AFTER: 
1
0.00
50.00
Output: 50.00
Run FWD PWM : 50.00
Ratio: 8
PID Gap : 8.00
Aggressive PID
PID BEFORE: 
8
0.00
50.00
PID AFTER: 
8
0.00
50.00
Output: 50.00
Run FWD PWM : 50.00
Ratio: 16
PID Gap : 16.00
Aggressive PID
PID BEFORE: 
16
0.00
50.00
PID AFTER: 
16
0.00
50.00
Output: 50.00

i tried to monitor Values before and after myPID.compute (), remain the same.

Please do you have any idea about the issue ???

Thanks for help

Your code does not compile so it is difficult to say...

Your setpoint is 0 and your input is 0 so they match! The code needs to adjust the input value (Speed_Value) if you want the PID to react.

Thank you for reply

I found my problem, it was discrepancy between target_speed and speed_target

It works !

Regards