they are 4 wire, but i'm only using 2,
i've had great trouble wrapping my head around the whole PWM thing and using the sense lines and messing with the signal hz/khz stuff and all the "do it this way/ do it that way" and all the half information that i can find around.....
but in the end I managed to get it to run this way....
i'm using pin 9 and 10 now as mentioned previously (1 per fan) to trigger the transistors which allows me to control the fan via opening and closing the ground(if i understand that correctly), the 12 +ve is connected constantly and it only completes the ground when told to.,...
after adding in the diodes as suggested by WattsThat and outsider, and going back to my code and reworking the same few little bits and banging my head a few more times.......
i am now able to complete the circuit to the fan, then it allows me to control the fan the same way you would for a sense wire, but i'm guessing by pulsing the negative feed, which may not be the best for the fan long term but as it is a fancy Noctua PMW fan i figure it'll handle it for a while...
i can guarantee its not the cleanest way to do it, but its a way i can understand and for now....
I am very happy to say IT WORKS!
i can also say my code probably isn't the "best practice" but again, it works and i can always clean it up as i continue to learn better ways.
its not 100% finished, as i'm waiting for a multiplexer to arrive so i can run my second screen (i got i2c non-addressable) but as far and doing what i need... it does.
heres the current version (still to be cleaned) but maybe it'll help someone someday.
#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <TimerOne.h>
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
#define cFanControlPin0 10
#define cFanControlPin1 9
// Used as a baseline OFF point for fan control
const uint8_t FanOff0 = 35; //**************amp cutoff***********************
const uint8_t FanOff1 = 33; //**************xbox cutoff**********************
// OLED display TWI address
#define OLED_ADDR 0x3C
Adafruit_SSD1306 display(-1);
#if (SSD1306_LCDHEIGHT != 32)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
void setup() {
// Serial.begin(9600);
Timer1.initialize(40); // 40 us = 25 kHz
//Turn on the Temp Sensors
sensors.begin();
// Initialize and clear Display Buffer
display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR);
display.clearDisplay();
delay(500);
//set pins for fan control
pinMode(cFanControlPin0, OUTPUT);
analogWrite(cFanControlPin0, 0);
pinMode(cFanControlPin1, OUTPUT);
analogWrite(cFanControlPin1, 0);
}
void loop()
{
//GET THE TEMPERATURES FROM ALL SENSORS
sensors.requestTemperatures();
//GIVE THEM TIME TO READ
delay(1000);
//********************;***********************
// FAN AMP
// Controlled by pin #10
//
//*******************************************
// IF the TEMP on AMP is LESS THAN #FanOff0
// then clear the display and shut the fan off
float temp0 = round(sensors.getTempCByIndex(0));
if (temp0 < FanOff0)
{
display.clearDisplay();
display.display();
analogWrite(cFanControlPin0, 0);
}
//ELSE is the TEMP on AMP in a range
// set the speed accordingly and display the temp
else if (temp0 >= 36 && temp0 <= 40)
{
analogWrite(cFanControlPin0, 40);
printfinish();
display.setTextSize(4);
display.setTextColor(WHITE);
display.setCursor(41,1);
display.print(round(sensors.getTempCByIndex(0)),DEC);
delay(1000);
display.setTextSize(1);
display.setCursor(110,22);
display.print("F");
display.display();
}
else if (temp0 >= 41 && temp0 <= 46)
{
analogWrite(cFanControlPin0, 120);
printfinish();
display.setTextSize(4);
display.setTextColor(WHITE);
display.setCursor(41,1);
display.print(round(sensors.getTempCByIndex(0)),DEC);
delay(1000);
display.setTextSize(1);
display.setCursor(110,12);
display.print("A");
display.setCursor(110,22);
display.print("F");
display.display();
}
else if (temp0 >= 47)
{
analogWrite(cFanControlPin0, 255);
printfinish();
display.setTextSize(4);
display.setTextColor(WHITE);
display.setCursor(41,1);
display.print(round(sensors.getTempCByIndex(0)),DEC);
delay(1000);
display.setTextSize(1);
display.setCursor(110,2);
display.print("N");
display.setCursor(110,12);
display.print("A");
display.setCursor(110,22);
display.print("F");
display.display();
}
//*******************************************
// FAN XBOX
// Controlled by pin #9
//
//*******************************************
// IF the TEMP on XBOX is LESS THAN #FanOff1
// then clear the display and shut the fan off
float temp1 = round(sensors.getTempCByIndex(1));
//Serial.print(temp1);
if (temp1 < 32)
{
// display.clearDisplay();
// display.display();
analogWrite(cFanControlPin1, 0);
}
// start the fan and display the temp
else if (temp1 >= 33 && temp1 <= 36)
{
analogWrite(cFanControlPin1, 40);
}
else if (temp1 >= 37 && temp1 <= 40)
{
analogWrite(cFanControlPin1, 120);
}
else if (temp1 >= 41)
{
analogWrite(cFanControlPin1, 255);
}
//Prints the DEG symbol
// printfinish();
//Sets up the display font and prints the TEMP from Probe#2
// display.setTextSize(4);
// display.setTextColor(WHITE);
// display.setCursor(1,1);
//
// display.print(round(sensors.getTempCByIndex(1)),DEC);
// display.display();
// delay(1000);
//clears display buffer
// display.clearDisplay();
}
void printfinish()
{
//Function to build the DEG and FAN marking on the displays
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(90,-3);
display.print("o");
}
thanks everyone for the feedback and the suggestions, and now i only have to tidy up all the loose ends, finish the code, test it with 2 screens, get it off the breadboard, build the thing properly, make a housing,
fit it all up and complete the task...
crap, that sounds like more work than i thought, lol.