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?
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)
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?
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
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?
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.
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 sorry about everyones else suggestions didnt really help
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 sorry about everyones else suggestions didnt really help
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.