Hello
I am programing a PID temperature controller and i managed to program the Proportional to keep the actual temperature around 37 deg ( 36.5-37.5), which is different from the temperature readings in the sketch . but i want some advice on how to program the rest of the code like the integral to give a smoother value and not keep rotating .
There is a problem with the thermocouple that rotates around (0.25-0.75) everytime it reads a value . and that causes me a major problem with coding the PID..
the values of the temps are

thank you very much
I am programing a PID temperature controller and i managed to program the Proportional to keep the actual temperature around 37 deg ( 36.5-37.5), which is different from the temperature readings in the sketch . but i want some advice on how to program the rest of the code like the integral to give a smoother value and not keep rotating .
There is a problem with the thermocouple that rotates around (0.25-0.75) everytime it reads a value . and that causes me a major problem with coding the PID..
Code:
#include <SPI.h>
#include "Adafruit_MAX31855.h"
#define CS 13 // pin 1 connect to pin 13
#define MISO 12 // pin 3 connect to pin 12
#define SCLK 10 // pin 4 connect to pin 10
double input,setpoint, integral , proportional,piderror,pidvalue;
Adafruit_MAX31855 Temp(SCLK, CS, MISO); // function for PID
const int pin=3; //output pin
double cumerror=0; //start of the integral
double kp=150; // proportional value
double ki=0; // integral value
void setup()
{
setpoint=37.5;
Serial.begin(9600);
delay(500);
}
void loop()
{
input=Temp.readCelsius()-1.5;// reading temperature from the thermcoupole (MAX31855)
piderror=setpoint-input;
cumerror+=piderror; // did not use the integral
integral=ki*cumerror;
proportional=kp*piderror;
pidvalue=proportional+integral; // i just made the integral =0
if (pidvalue<=0)
{
pidvalue=0;
}
if (pidvalue>255)
{
pidvalue=255;
}
Serial.print("Temperature en C = "); Serial.println(input); // acquisition de la température en degré Celcius
analogWrite(pin,pidvalue);
delay(1000);
cumerror=cumerror;// did not use the integral
}

thank you very much