DC Fan Help

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

MadMatt:
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.

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

//

Have you put a resistor in series with arduino output?

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

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?

y = map(x, 1, 50, 50, 1);

First parameter is expected to be variable.
http://arduino.cc/en/Reference/Map

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 :confused: it gets annoying as well

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?

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

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.

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.

making a hearable noise

The pwm frequency is too high.

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.

thanks soo much that really worked :smiley: sorry about everyones else suggestions didnt really help :confused:

The simplest things can sometimes make the biggest differences.

MadMatt:
sorry about everyones else suggestions didnt really help :confused:

np, wont bother again

next time google + motors, good luck

MadMatt:
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.

thanks soo much that really worked :smiley: sorry about everyones else suggestions didnt really help :confused:

That solution has two problems: (a) you are probably exceeding the current rating of the transistor, because there will be a surge of current to charge the capacitor every time the transistor turns on; (b) you will probably find that you have only a small amount of control over the fan speed, it will mostly run near full speed.

If you want to control a PC-type fan, the best solution is to buy a 4-pin fan designed for PWM control. These have a separate PWM input. They are designed to work using a PWM frequency around 25KHz, so you need to increase the Arduino PWM frequency.

sorry about everyones else suggestions didnt really help :confused:

Don't feel bad for others, feel bad for yourself for missing a good chance to learn.

dc42:

MadMatt:
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.

thanks soo much that really worked :smiley: sorry about everyones else suggestions didnt really help :confused:

That solution has two problems: (a) you are probably exceeding the current rating of the transistor, because there will be a surge of current to charge the capacitor every time the transistor turns on; (b) you will probably find that you have only a small amount of control over the fan speed, it will mostly run near full speed.

If you want to control a PC-type fan, the best solution is to buy a 4-pin fan designed for PWM control. These have a separate PWM input. They are designed to work using a PWM frequency around 25KHz, so you need to increase the Arduino PWM frequency.

i do have one actually it was the one i was using in the first place :stuck_out_tongue: i already set it up for pwm control however the pwm control of the fan has limits so i decided not to use it anymore and went back to the positive and negative side of the fan also about the transistor dont worry it has a current rating of 1 amp so dont worry yourself there bro XD i know my electronics its just i forget about these things sometimes :stuck_out_tongue_winking_eye:

HazardsMind:
The simplest things can sometimes make the biggest differences.

could not have said it better myself :smiley:

Osgeld:

MadMatt:
sorry about everyones else suggestions didnt really help :confused:

np, wont bother again

next time google + motors, good luck

sheesh ill say thank you then for everyone who tried to help (i think i did already so sorry if i didnt :frowning: i really did like everyones suggestions but i guess the capacitor one really did work for me :slight_smile: )

dhenry:

sorry about everyones else suggestions didnt really help :confused:

Don't feel bad for others, feel bad for yourself for missing a good chance to learn.

ive learnt alot from this experience thank you very much >:\