TomGeorge, that is one beautiful schematic! I have rebuilt the daughterboard and assembled everything. The hardware seems to be working. The thermistor responds appropriately to temperature changes and turns the fans on faster as temps climb. The only problem is the fans do not seem to be responding to PWM like I want by spinning faster than I think appropriate. However, it's probably my code. For your consideration, this is what I settled on after several nights of tinkering:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
int ThermistorPin = 0;
const int fan1 = 10; // the pin where fan 1 is
const int fan2 = 9; // the pin where fan 2 is
const int stage1 = 25; //the temp that stage 1 starts
const int stage2 = 30; //the temp that stage 2 starts
const int stage3 = 45; //the temp that stage 3 starts
const int overheat = 55; //things should never get this hot
const int stage1low = 10; //set to prevent low power stall
const int stage1hi = 126; //50% fan power
const int stage2low = 127;
const int stage2hi = 190; //75% fan power
const int stage3low = 191;
const int stage3hi = 255; //100% fan power
int fan1Speed = 0;
int fan1LCD = 0;
int fan2Speed = 0;
int fan2LCD = 0;
void setup() {
TCCR1A = 0b00000001; // 8bit [Black Magic I found on Google!!!]
TCCR1B = 0b00000001; // x1 phase correct [I have no idea how but it greatly reduces PWM whine]
lcd.init();
lcd.backlight();
pinMode(fan1, OUTPUT);
pinMode(fan2, OUTPUT);
pinMode(ThermistorPin, INPUT);
lcd.setBacklight(HIGH);
lcd.setCursor(2,0);
lcd.print("Temperature");
lcd.setCursor(2,1);
lcd.print("Control V3");
delay(3000);
lcd.clear();
lcd.setBacklight(LOW);
}
void loop() {
int Vo;
float R1 = 10000;
float logR2, R2, T, F;
float c1 = 1.303866579e-03, c2 = 2.019279251e-04, c3 = 2.326033351e-07;
//float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07; //old values
// found values:
//30800 ohm @ 1C;//9900 ohm @ 26C;//685 ohm @ 99C;
Vo = analogRead(ThermistorPin);
R2 = R1 * (1023.0 / (float)Vo - 1.0);
logR2 = log(R2);
T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
T = T - 273.15;
F = (T * 9.0)/ 5.0 + 32.0;
if ((T >= stage1) && (T <= stage2)) {
lcd.setBacklight(HIGH);
fan1Speed = map(T, stage1, stage2, stage1low, stage1hi);
fan1LCD = map(T, stage1, stage2, 0, 50);
analogWrite(fan1, fan1Speed);
fan2Speed = 0;
fan2LCD = 0;
analogWrite(fan2, fan2Speed);
} else if ((T > stage2) && (T <= stage3)) {
lcd.setBacklight(HIGH);
fan1Speed = map(T, stage2, stage3, stage2low, stage2hi);
fan1LCD = map(T, stage2, stage3, 50, 75);
analogWrite(fan1, fan1Speed);
fan2Speed = map(T, stage2, stage3, 0, stage2hi);
fan2LCD = map(T, stage2, stage3, 0, 75);
analogWrite(fan2, fan2Speed);
}
else if ((T > stage3) && (T <= overheat)) {
lcd.setBacklight(HIGH);
fan1Speed = map(T, stage3, overheat, stage3low, stage3hi);
fan1LCD = map(T, stage3, overheat, 75, 99);
analogWrite(fan1, fan1Speed);
fan2Speed = map(T, stage3, overheat, stage3hi, stage3hi);
fan2LCD = map(T, stage3, overheat, 75, 99);
analogWrite(fan2, fan2Speed);
}
else if (T > overheat) {
fan1LCD =99;
analogWrite(fan1, stage3hi);
fan2LCD = 99;
analogWrite(fan2, stage3hi);
}
else
{
lcd.setBacklight(LOW);
fan1LCD = 0;
analogWrite(fan1, 0);
fan2LCD = 0;
analogWrite(fan2, 0);
}
lcd.setCursor(0, 0);
lcd.print("Temp:");
lcd.print(T, 1); // display the temperature
lcd.print("C ");
lcd.setCursor(11, 0);
lcd.print(F, 1);
lcd.print("F ");
lcd.setCursor(0, 1); // move cursor to next line
lcd.print("Fan1:");
lcd.print(fan1LCD); // display the fan speed
lcd.print("%");
lcd.setCursor(8, 1); // bottom right
lcd.print("Fan2:");
lcd.print(fan2LCD);
lcd.print("%");
delay(1000);
lcd.clear();
}
The fans seem to come on aggressively as soon as the minimum temp is reached. I would also like to have some sort of threshold so the fans do not bounce on and off as the minimum temp is reached; in other words, once the activation temp is reached, it must be reduced a few degrees cooler than the minimum to turn off. I can live with it if necessary, but I figured I would ask people smarter!