bonjour,
je souhaite faire varier la vitesse d'un ventilateur en fonction de la temperature mesurée...
j'ai un capteur de temperature ds18b20, j'arrive a lire la temperature...pas de probleme(j'y reviendrai plus tard)
j'ai acheté un ventilo avec controle PWM inclus (noctua NF-P12 PWM)
je pensais betement pouvoir controler avec la fonction analogwrite..
il y a 4 fils...12v (rouge), masse (noire),PWM (bleu), tachometre (vert) ....j'ai relié a une alimentation externe en 12v, le fil bleu a une sortie pwm de l'arduino et le vert ...a rien...
premiere question, faut il relier ce fil (qui donne la vitesse RPM si j'ai bien compris) a quelque chose?...j'ai lu un sujet ou il me semble qu'il la reliait a une sortie digital (sans aucun composant entre la carte et le fil) url=http://forum.myduino.com/viewtopic.php?f=1&t=20 quelqu'un peut il me confirmer?
j'ai lu pas mal de sujet, avec des ventilos ayant 3 fils mais quasi rien avec ceux a 4 fils.
Avant de compliquer le code, je souhaite juste voir si j'arrive a modifier manuellement la vitesse par la commande analogwrite.
j'ai lu egalement qu'il fallait modifier le timer
je teste actuellement un petit prog trouvé Snootlab - Essai de l'Arduino i2C Power proto shield : Controlleur PWM de ventilateurs asservis à la température avec des capteurs 1Wire DS1820 - Civade.com (que j'ai un peu modifié): il ne s'agit pas d'un ventilo avec 4 fils...je n'ai pas utilisé de VN67AF
/*
Fanduino: 2 channels DS1820 based temperature fan controller
Fans are controlled by a PWM output connected on
* D3 for Fan 1 (PinA)
* D11 for fan 2 (PinB)
Onewire lib reads is values on D10
Sample drive circuit for pwm outputs :
+12V
N CHANNEL FET |
D11 (ex:VN67AF) ------------ |
or __-----------| -fan +fan |
D3 Gate / \ Drain ------------
---\/\/\/---*---| | 12V Fan
on 120ohms | \ /
arduino \ --
/ 10K | Source
\ |
/ |
| |
GND GND
DS1820 wiring :
1: GND
2: D10 on arduino. A pull up of 4K7 MUST be wired also on pin 10.
3: VCC (5V)
TOP VIEW
---
/ \
| |
-------
1 2 3
v1.0 creation
V1.1 Add softstart, and stop under Tmin
*/
#include <OneWire.h>
#include <DallasTemperature.h>
int pinA = 11; // pin 3 and 11 are PWM output controled by Timer2
//int pinB = 11; // connect pinA/B to H-Bridge
// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 49
// Setup a oneWire instance to communicate with any OneWire devices aa(not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature tempbacsensor(&oneWire);
// Compute linearization constant
// Fan1
float Fan1Min=50; // PWM is between 40 and 255 for that fan (8 bit pwm)
float Fan1Max=255;
float Temp1Min=20.0; // relinearization will be done between 20 Celcius (pwm=Fan1Min)
float Temp1Max=25.0; // to 48 celcius (pwm=Fan1Max)
/* // Fan2
float Fan2Min=50;
float Fan2Max=255;
float Temp2Min=25.0;
float Temp2Max=50.0;
*/
//
float K1=(Fan1Max-Fan1Min)/(Temp1Max-Temp1Min);
// float K2=(Fan2Max-Fan2Min)/(Temp2Max-Temp2Min);
//
boolean Fan1Active=FALSE;
// boolean Fan2Active=FALSE;
float tempbac;
void setup(){
// See wxxxxxxxxxxxxxxx
//__________________________________TIMER2_for_Motor_PWM_________________________________
// set TIMER2 for PWM 31 kHz
//
// clear all prescaler bits in TCCR2B = the last 3 Bits
// leave other bits as set by arduino init() in wiring.c
byte mask = B11111000;
TCCR2B &= mask; // TCCR2B is now xxxxx000
//
// set CS22:20 in TCCR2B see p 156 of datasheet
TCCR2B |= (0<<CS22) | (0<<CS21) | (1<<CS20); // same as TCCR2B |= B00000001; TCCR2B is now xxxxx001
//__pinmode
pinMode(pinA,OUTPUT);
// pinMode(pinB,OUTPUT);
// start serial port
Serial.begin(9600);
Serial.println("Fanduino: DS1820 based temperature fan controller");
// Start up the library
// sensors.begin();
tempbacsensor.begin();
}
void loop() {
// call sensors.requestTemperatures() to issue a global temperature request
//sensors.requestTemperatures(); // Send the command to get temperatures
tempbacsensor.requestTemperatures();
// read sensors values
tempbac = tempbacsensor.getTempCByIndex(0);
// float T1 = sensors.getTempCByIndex(0);
// float T2 = sensors.getTempCByIndex(1);
// skip conversion error
if ( tempbac>0 )
// if ( ( T1>-127.00 ) && ( T2 > -127.0) )
{
// print them on serial
Serial.print("Temp1: ");
Serial.print(tempbac);
// Serial.print(" Temp2: ");
// Serial.print(T2);
boolean SoftStart=FALSE;
// Softstart with hysterisis 0.3 degrees
if ( (tempbac > Temp1Min+0.3) && !Fan1Active) {
Fan1Active=TRUE;
SoftStart=TRUE;
analogWrite(pinA, 200);
}
/*if ( (T2 > Temp2Min+0.3) && !Fan2Active) {
Fan2Active=TRUE;
SoftStart=TRUE;
analogWrite(pinB, 200 );
} */
if (SoftStart)
delay (750);
// normalize values between TempXMin and TempXMax
if (tempbac < Temp1Min) {
tempbac = Temp1Min;
if (Fan1Active) {
Fan1Active=FALSE;
}
}
if (tempbac > Temp1Max)
tempbac = Temp1Max;
/* if (T2 < Temp2Min) {
T2 = Temp2Min;
if (Fan2Active) {
Fan2Active=FALSE;
}
}
if (T2 > Temp2Max)
T2 = Temp2Max;
*/
// compute pwm value
// when temp will be from TempXMin celcius to TempXMax, pwm will be from FanXMin to FanXMax
float Pwm1=0;
// float Pwm2=0;
if (Fan1Active)
Pwm1=((tempbac-Temp1Min)*K1)+Fan1Min;
// if (Fan2Active)
// Pwm2=((T2-Temp2Min)*K2)+Fan2Min;
// print pwm values on serial for debugging
// Serial.print (" PWM1: ");
// Serial.print ( Pwm1 );
// Serial.print (" PWM2: ");
// Serial.print ( Pwm2 );
// if (Fan1Active) Serial.print ( " 1" );
// if (Fan2Active) Serial.print ( " 2" );
// Serial.println ();
// Assign pwm
analogWrite(pinA, Pwm1 );
// analogWrite(pinB, Pwm2 );
// and sleep 1s until next computation
delay (1000);
}
}
Quelqu'un pourrait il m'aider ou m'indiquer un lien (ca me semble fou de ne pas trouver de tuto sur ce sujet) ?
merci