Hi, I am new to PID controllers. I am creating a thermal control system that involves a resistive heater in series with a transistor. I have a thermistor in a Wheatstone bridge to measure the temperature of a flat plate on top of the heater. I have adapted the Basic PID code to allow for the input to be the output of the Wheatstone bridge. I started with the Ziegler-Nichols Method to tune the controller, but no matter how high I set Kp (I have gone up to 100,000), I still get zero response in the system. The power supply I am using shows that there is zero current flowing, so the transistor is not being turned on. I know that it is not a hardware issue because I coded an open loop system and when I run that code the system operates perfectly fine. If anyone could help me solve this problem that would be greatly appreciated. Here is my code:
#include <PID_v1.h>
#define PIN_INPUT 5
#define IN_CONST 0
#define PIN_OUTPUT 3
// Thermistor Setup
unsigned long rd = 50;
unsigned long ptrd = 0;
//Define Variables we'll be connecting to
double Setpoint, Input, Output;
//Specify the links and initial tuning parameters
double Kp=200, Ki=0, Kd=0;
PID myPID(&Input, &Output, &Setpoint, Kp, Ki, Kd, DIRECT);
void setup()
{
//initialize the variables we're linked to
Input = analogRead(PIN_INPUT)-analogRead(IN_CONST);
Setpoint = 321;
//turn the PID on
myPID.SetMode(AUTOMATIC);
Serial.begin(115200);
}
void loop()
{
Input = analogRead(PIN_INPUT)-analogRead(IN_CONST);
myPID.Compute();
analogWrite(PIN_OUTPUT, Output);
unsigned long currentTime = millis();
if((currentTime-ptrd)>=rd){
ptrd = currentTime;
Serial.print(ptrd);
Serial.print('\t');
Serial.println(Input);
}
}
Thank you for any help!
Ethan