Hi...
I'm a final year student and I face a little problem with my final project.
I want to make a device that can maintain the heating temperature at 37'C and display the current temperature on LCD..
I'm using the Peltier 12710 as the heating element and thermistor as my temperature sensor.
I also print the current temperature and plot the temperature graph on Matlab.
The problem is, I don't know why my LCD suddenly displayed weird character when it reached the Setpoint.
I set my setpoint = 636 which is equal to 37'C.
Please someone help me because I don't know what else to do. Already run out of ideas. =(
I'm a noob here, please help me~~
// Tuning parameters
float Kp=30; //Initial Proportional Gain
float Ki=0.000015; //Initial Integral Gain
float Kd=0; //Initial Differential Gain
double Setpoint, Input, Output; //These are just variables for storing values
PID myPID(&Input, &Output, &Setpoint, Kp, Ki, Kd, DIRECT); // This sets up our PDID Loop
const int sampleRate = 1; // Variable that determines how fast our PID loop runs
//// Communication setup
const long serialPing = 500; //This determines how often we ping our loop
//// Serial pingback interval in milliseconds
// Initialize the LiquidCrystal library with the numbers of the interface pins.
// LiquidCrystal(rs, e, d4, d5, d6, d7)
LiquidCrystal lcd(2, 3, 4, 5, 6, 7); //initialize the LCD library with the numbers of the interface pins
float pad = 9850;
float Thermistor(int RawADC) {
long Resistance;
float Temp; // Dual-Purpose variable to save space.
Resistance=((1024 * pad / (RawADC)) - pad);
Temp = log(Resistance); // Saving the Log(resistance) so not to calculate it 4 times later
Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
Temp = Temp - 273.15; // Convert Kelvin to Celsius
return Temp; // Return the Temperature
}
void setup(){
Serial.begin(9600); //Start a serial session
Setpoint = 636;
myPID.SetMode(AUTOMATIC); //Turn on the PID loop
myPID.SetSampleTime(sampleRate); //Sets the sample rate
myPID.SetOutputLimits(0,255);
lcd.begin(16,2); //set up the LCD's number of columns and rows
lcd.setCursor(0, 0);
lcd.print("Current Temp('C)"); //Current Temp to the LCD
}
void loop(){
Setpoint = 636; // 37.C @ analog 636
tempLevel = analogRead(ThermistorPIN); //Get the temperature
Input = map(tempLevel,0,1024,0,1024);
myPID.Compute(); //Run the PID loop
myPID.SetOutputLimits(0,255);
analogWrite(heater, Output); //Write out the output from the PID loop to our LED pin
DispTemp ();
}
void DispTemp (){
float displayTemp;
for(i = 0;i<=7;i++){ // gets 8 samples of temperature
samples[i] = Thermistor(analogRead(ThermistorPIN));
displayTemp = displayTemp + samples[i]; // do the addition for average temperature
delay(100); // wait 100ms
} //End for Loop
displayTemp = displayTemp/8.0;
Serial.println(displayTemp); // Send data to Matlab
lcd.setCursor(5,1);
lcd.print(displayTemp,1); //print the value to LCD
lcd.print("'C");
delay (100);
}