Pages: [1] 2   Go Down
Author Topic: DC Fan Help  (Read 1543 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

SE USA
Offline Offline
Faraday Member
**
Karma: 41
Posts: 3783
@ssh0le
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://provideyourown.com/2011/analogwrite-convert-pwm-to-voltage/
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

sorry but it didnt work i tried it while i was looking for an answer but thanks for trying smiley-grin
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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);
}

//
« Last Edit: January 01, 2013, 06:52:08 pm by MadMatt » Logged

Montreal
Offline Offline
Faraday Member
**
Karma: 29
Posts: 2591
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you put a resistor in series with arduino output?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Montreal
Offline Offline
Faraday Member
**
Karma: 29
Posts: 2591
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Queens, New York
Offline Offline
Faraday Member
**
Karma: 99
Posts: 3632
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
making a hearable noise

The pwm frequency is too high.
Logged

Pages: [1] 2   Go Up
Jump to: