arduino controlled fan driver
this fandriver is easy to build
A fandriver is easy to do with an Arduino as an active ontroller.
In this circuit, the Arduino Pro-Mini has been chosen, it is one of the smallest versions and for almost no money for sale.
To measure the temperature we use an ordinary diode. This is connected to the 5V via a resistor and read with A1 on the processor. The voltage over the diode is nominal 600mV which makes it possible to use the internal reference voltage of the ic. That is 1100mV so the voltage per step for the 10-bit ad converter is 1.1mV. The temperature sensitivity of a diode is about -2.2mV / K so the resolution of the whole is about 0.5K.
Because both the reference voltage and the diode properties vary by model, it is necessary to complete a number of calibration points during commissioning.
The hardware does not matter, see the diagram below.
As shown in the diagram, a small choke and a freewheel diode are located at the output, which makes the fan more quiet.
There are still connections for a led and optocoupler or second led (on D8 and D6) and the I2C is also available on a connector so that a serial LCD can be connected.
The software is not yet ready but the setup is as follows:
/*
Analog input temperatuur sensor diode, analog output pwm , serial output controle
de doorlaatspanning van een diode geeft de temperatuur aan.
Doorlaatspanning meten in ijswater en kokend water, beide sensorwaarden noteren
Daarmee wordt het nulpunt vastgelegd en hoeveel de goevoeligheid (eenheden/graad)
Tot circa 30 grdn staat de fan op 20%,
van 30 tot 45 grdn staat de fan op 60%
boven 45 grdn staat de fan op 100%
wanneer de temperatuur nog hoger wordt (grenswaarde 55 grdn) wordt een alarmuitgang hoog.
Het PWM signaal wordt via een smoorspoel an de motor toegevoerd, bij de smsp een diode en een elco
het circuit:
tor met ce aan massa, b is met 3k3 aan 5V,
ingang A0
pwm uitgang pin9
alarmled op 8
created 14-2-2017
*/
// These constants won't change. They're used to give names
// to the pins used:
const int analogInPin = A0; // Analog input pin that the basis tor is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to
const int ledPin = 8; // output pin that the LED is attached to
const int alarmnivo = 35;
int sensorValue = 0; // value read from the diode
int outputValue = 0; // value output to the PWM (analog out)
int sensorValue0 = 680; //waarde invulln bij sensor in ijswater
int sensorValue100 = 500; //waarde invullen bij sensor in kokend water
int rekenwaarde = 0; // =600 - sensorValue
int omvang = 0; // Value0 - Value100
int temperatuur = 0;
#include
#include
#include
#define I2C_ADDR 0x23 // Define I2C Address for controller
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
#define BACKLIGHT 3
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
void setup() {
pinMode(ledPin, OUTPUT);
// initialize serial communications at 9600 bps:
Serial.begin(9600);
analogReference(INTERNAL); // interne referentie 1,1V
lcd.begin (16,2); // initialize the lcd
// Switch on the backlight
lcd.setBacklightPin(BACKLIGHT,POSITIVE);
lcd.setBacklight(HIGH);
}
void loop() {
// Reset the display
lcd.clear();
delay(10);
lcd.home();
//bereken de omvang:
omvang = sensorValue0 - sensorValue100;
// read the analog in value:
sensorValue = analogRead(analogInPin);
rekenwaarde = sensorValue0 - sensorValue;
temperatuur = 100*rekenwaarde / omvang;
outputValue = 20;
// change the analog out value:
analogWrite(analogOutPin, outputValue);
// if the temperatuur is high enough, turn on the LED:
if (temperatuur > alarmnivo) {
digitalWrite(ledPin, LOW);
} else {
digitalWrite(ledPin, HIGH);
}
if (temperatuur >30 && temperatuur < 35)
{
outputValue = 40;
analogWrite(analogOutPin, outputValue);
}
else if (temperatuur >= 35)
{
outputValue = 99;
analogWrite(analogOutPin, outputValue);
}
else
{
outputValue = 20;
analogWrite(analogOutPin, outputValue);
}
// print the results to the serial monitor:
Serial.print("sensor = ");
Serial.print(sensorValue);
//Serial.print("\t rekenw = ");
//Serial.print(rekenwaarde);
Serial.print("\t temp = ");
Serial.print(temperatuur);
Serial.print("\t output = ");
Serial.println(outputValue);
// Print on the LCD
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("temp=");
lcd.setCursor(7,0);
lcd.print(temperatuur);
lcd.setCursor(0,1);
lcd.print("sensorw.=");
lcd.setCursor(10,1);
lcd.print(sensorValue);
// wacht 1000 milliseconden voor de volgende loop
delay(1000);
}
In this circuit, the Arduino Pro-Mini has been chosen, it is one of the smallest versions and for almost no money for sale.
To measure the temperature we use an ordinary diode. This is connected to the 5V via a resistor and read with A1 on the processor. The voltage over the diode is nominal 600mV which makes it possible to use the internal reference voltage of the ic. That is 1100mV so the voltage per step for the 10-bit ad converter is 1.1mV. The temperature sensitivity of a diode is about -2.2mV / K so the resolution of the whole is about 0.5K.
Because both the reference voltage and the diode properties vary by model, it is necessary to complete a number of calibration points during commissioning.
The hardware does not matter, see the diagram below.
As shown in the diagram, a small choke and a freewheel diode are located at the output, which makes the fan more quiet.
There are still connections for a led and optocoupler or second led (on D8 and D6) and the I2C is also available on a connector so that a serial LCD can be connected.
The software is not yet ready but the setup is as follows:
/*
Analog input temperatuur sensor diode, analog output pwm , serial output controle
de doorlaatspanning van een diode geeft de temperatuur aan.
Doorlaatspanning meten in ijswater en kokend water, beide sensorwaarden noteren
Daarmee wordt het nulpunt vastgelegd en hoeveel de goevoeligheid (eenheden/graad)
Tot circa 30 grdn staat de fan op 20%,
van 30 tot 45 grdn staat de fan op 60%
boven 45 grdn staat de fan op 100%
wanneer de temperatuur nog hoger wordt (grenswaarde 55 grdn) wordt een alarmuitgang hoog.
Het PWM signaal wordt via een smoorspoel an de motor toegevoerd, bij de smsp een diode en een elco
het circuit:
tor met ce aan massa, b is met 3k3 aan 5V,
ingang A0
pwm uitgang pin9
alarmled op 8
created 14-2-2017
*/
// These constants won't change. They're used to give names
// to the pins used:
const int analogInPin = A0; // Analog input pin that the basis tor is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to
const int ledPin = 8; // output pin that the LED is attached to
const int alarmnivo = 35;
int sensorValue = 0; // value read from the diode
int outputValue = 0; // value output to the PWM (analog out)
int sensorValue0 = 680; //waarde invulln bij sensor in ijswater
int sensorValue100 = 500; //waarde invullen bij sensor in kokend water
int rekenwaarde = 0; // =600 - sensorValue
int omvang = 0; // Value0 - Value100
int temperatuur = 0;
#include
#include
#include
#define I2C_ADDR 0x23 // Define I2C Address for controller
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
#define BACKLIGHT 3
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
void setup() {
pinMode(ledPin, OUTPUT);
// initialize serial communications at 9600 bps:
Serial.begin(9600);
analogReference(INTERNAL); // interne referentie 1,1V
lcd.begin (16,2); // initialize the lcd
// Switch on the backlight
lcd.setBacklightPin(BACKLIGHT,POSITIVE);
lcd.setBacklight(HIGH);
}
void loop() {
// Reset the display
lcd.clear();
delay(10);
lcd.home();
//bereken de omvang:
omvang = sensorValue0 - sensorValue100;
// read the analog in value:
sensorValue = analogRead(analogInPin);
rekenwaarde = sensorValue0 - sensorValue;
temperatuur = 100*rekenwaarde / omvang;
outputValue = 20;
// change the analog out value:
analogWrite(analogOutPin, outputValue);
// if the temperatuur is high enough, turn on the LED:
if (temperatuur > alarmnivo) {
digitalWrite(ledPin, LOW);
} else {
digitalWrite(ledPin, HIGH);
}
if (temperatuur >30 && temperatuur < 35)
{
outputValue = 40;
analogWrite(analogOutPin, outputValue);
}
else if (temperatuur >= 35)
{
outputValue = 99;
analogWrite(analogOutPin, outputValue);
}
else
{
outputValue = 20;
analogWrite(analogOutPin, outputValue);
}
// print the results to the serial monitor:
Serial.print("sensor = ");
Serial.print(sensorValue);
//Serial.print("\t rekenw = ");
//Serial.print(rekenwaarde);
Serial.print("\t temp = ");
Serial.print(temperatuur);
Serial.print("\t output = ");
Serial.println(outputValue);
// Print on the LCD
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("temp=");
lcd.setCursor(7,0);
lcd.print(temperatuur);
lcd.setCursor(0,1);
lcd.print("sensorw.=");
lcd.setCursor(10,1);
lcd.print(sensorValue);
// wacht 1000 milliseconden voor de volgende loop
delay(1000);
}
Discussion (0 commentaire(s))