Go Down

Topic: DC Fan Help (Read 1 time) previous topic - next topic

MadMatt

Hi im new to the forums (and arduino) and was having some trouble

i want to control a 12V DC CPU fan that i have setup. I can do so by varying the output to a transistor (BC338) but when i do the transistor tends to flick on and off and so does the fan(the fan gets horribly annoying when it does 0.o), and so i was wondering is there anyway to fix it. After all the things ive read, its to do with the pwm output where it doesnt change the voltage but changes the duty cycle so it is constantly switching on and off, so i was wondering if there is way to convert this to a certain voltage?

Thx in advance MadMatt


MadMatt

sorry but it didnt work i tried it while i was looking for an answer but thanks for trying :D

PeterH


when i do the transistor tends to flick on and off and so does the fan(the fan gets horribly annoying when it does 0.o)


The PWM frequency is high enough that the individual pulses should not be perceptible if it's working correctly, so I wonder whether there's something other than PWM happening here. Is it possible the Arduino is resetting for some reason? You could use trace output on the Serial port to find out.
I only provide help via the forum - please do not contact me for private consultancy.

MadMatt

#4
Jan 02, 2013, 12:42 am Last Edit: Jan 02, 2013, 12:52 am by MadMatt Reason: 1
im really new to C im surprised i could do what i did with arduino so how do i do that (i use game maker instead of C but i must say GML is a bit like C)

oh and this is my code:

//

const int transistorPin = 9;

void setup() {pinMode(transistorPin,OUTPUT);}

void loop()
{
  //int sensorValue = analogRead(A0);
  int outputValue = map(255,0,1023,0,255);
  analogWrite(transistorPin,outputValue);
}

//

Magician

Have you put a resistor in series with arduino output?

MadMatt

yes a 560 ohm resistor for the transistor or else the voltage is too high for it :/

PeterH

That sketch looks similar to the example in the documentation for analogWrite() and I'd expect the example to work. I see you've commented out the analogRead() part and are just outputting a constant 255 (100% duty cycle). Does this sketch actually show the problem?
I only provide help via the forum - please do not contact me for private consultancy.

Magician

Quote
y = map(x, 1, 50, 50, 1);
First parameter is expected to be variable.
http://arduino.cc/en/Reference/Map

MadMatt

yeah sorry that was the sketch of when i had the fan at high

//

const int transistorPin = 9;

void setup() {pinMode(transistorPin,OUTPUT);}

void loop()
{
  //int sensorValue = analogRead(A0);
  int outputValue = map(120,0,1023,0,255);
  analogWrite(transistorPin,outputValue);
}

//

this one is where the fan makes a horrible on/off noise because each time a cycle comes round (e.g 50%) it goes on/off each time so instead of adjusting the voltage it keeps on going on and off so it makes a noise when the fan keeps going on and off :/ it gets annoying as well

PeterH

Given that you are outputting a constant value, you might just as well put that value directly in the call to analogWrite() rather than map it from another constant.

When you say it's making a noise, do you mean the motor is stuttering on/off of that the motor moves smoothly but makes an audible noise? Can you describe the noise - is it steady and consistent?
I only provide help via the forum - please do not contact me for private consultancy.

MadMatt

yeah its going on and off like you said and it is making a hearable noise and is consistent any soloutions?

PeterH

Clarify - is the motor stuttering on and off, or is it moving steadily?

What is the noise like?

You can see and hear what's going on - we can only guess from your description, which hasn't told us much so far.
I only provide help via the forum - please do not contact me for private consultancy.

HazardsMind

You might need a capacitor to smooth out the output signal of the transistor, going to the motor. Just put a capacitor from the between the motor contacts, make sure you wire it correctly (polarized). It should get rid of any noise, unless the noise is not from the PWM but from a defect in the motor itself.

470uf should be more than enough.
Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

dhenry

Quote
making a hearable noise


The pwm frequency is too high.

Go Up