Hey, first post, so I hope I'm in the right topic.
I have 6 4-wire pc fans that I would like to control individually. To fans have a dedicated powersupply, and the speed is set by the PWM signal.
I found a tutorial from Hackster, that I have working allready. right now I have hooked op a potentiometer. I use this to control to pwm signal.
However, I can't really understand how to generate 6 individual signals. Is it possible to do this simply by coding? Right now I'm using an uno. Perhaps i need another board, or several boards. Or is there a shield of some kind that can generate these pwms. I found a couple of pwm modules, but they seem to include display and control buttoms. I'm not really interested in that, as my end goal is to control these fans remotely from a server.
Any suggestions?
I've added the code below... Let me know if I did some wrong formatting or I need to add some info.
Thanks Anders
int pwmPin1 = 3; // digital PWM pin 9
int pwmVal = 1; // The PWM Value
int potPin = 2; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int val = 0; // variable to store the value coming from the sensor
unsigned long time;
unsigned int rpm;
String stringRPM;
String stringOne;
void setup()
{
// declare the ledPin as an OUTPUT
pinMode(ledPin, OUTPUT);
// generate 25kHz PWM pulse rate on Pin 3
pinMode(pwmPin1, OUTPUT); // OCR2B sets duty cycle
// Set up Fast PWM on Pin 3
TCCR2A = 0x23; // COM2B1, WGM21, WGM20
// Set prescaler
TCCR2B = 0x0A; // WGM21, Prescaler = /8
// Set TOP and initialize duty cycle to zero(0)
OCR2A = 79; // TOP DO NOT CHANGE, SETS PWM PULSE RATE
OCR2B = 0; // duty cycle for Pin 3 (0-79) generates 1 500nS pulse even when 0 :
digitalWrite(2, HIGH); // Starts reading
Serial.begin(9600);
}
void loop()
{
unsigned int x;
val = analogRead(potPin); // read the value from the sensor
OCR2B = val/13;
getRPMS ();
delay(5000);
/*
// ramp up fan speed by increasing duty cycle every 200mS, takes 16 seconds
for(x = 0; x < 80; x++) {
OCR2B = x; // set duty cycle
getRPMS();
Serial.println(x);
delay(2000);
}
while (Serial.available() == 0);
int val = Serial.parseInt();
if (val > 0 && val < 80) {
OCR2B = val;
}
*/
}
char getRPMS() {
time = pulseIn(2, HIGH);
rpm = (1000000 * 60) / (time * 4);
stringRPM = String(rpm);
//if (stringRPM.length() < 5) {
Serial.print("rpm = ");
Serial.println(rpm, DEC);
Serial.print("Pot = ");
Serial.println(val, DEC);
//}
}