1

I am using PWM to control the speed of the fan on my RPi 2. The problem is, when I am PWMing it, a clicking sound can be heard from the fan.

I am using a 6v power supply for a 5v fan to compensate for the voltage drop over the transistor. Even when I am using a 5v supply the clicking sound can be heard. Here is how I have it set up:

enter image description here THERE IS A MISTAKE IN THE SCHEMATIC: I am using a NPN transistor not a PNP

My code (or at least the important part of it) is shown below:

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(32, GPIO.OUT)
base=GPIO.PWM(32,10) #this defines board pin 32, gpio pin 12, and makes the PWM 10 times per second, I think
base.start(0)
base.ChangeDutyCycle(0)

...

if temp>40000:
    #set fan speed to 80%
    base.ChangeDutyCycle(80)

How do I do this so that the fan makes no clicking sound?

  • Why are you using a PNP transistor in common collector mode? – Milliways Oct 5 '15 at 0:47
  • @Milliways I drew the schematic wrong, it is a NPN transistor sorry. – Patrick Cook Oct 5 '15 at 1:27
  • 1
    Just wondering: why are you using a fan anyhoo? – Kachamenus Oct 5 '15 at 4:40
  • @Shojan because my Pi is over-clocked to 2Gz and is constantly running at about 80% CPU. – Patrick Cook Oct 5 '15 at 16:00
  • @PatrickCook Whoa, Nice. Gotcha – Kachamenus Oct 5 '15 at 17:59
3

Check that your fan works properly when plugged directly into 5V, and also if you set your PWM cycle to 100%.

If it works when you plug it in directly, it might be that your motor doesn't like being driven with PWM. Many fans operate on a brushless DC motor, which incorporate some electronics to control the motor's stator coils. PWM switches the power on and off very rapidly, and that can disrupt the fan's electronics. It's sort of like an annoying sibling switching your lights on and off while you're trying to solve a complicated maths problem.

  • The fan works fine when directly powered and when at PWM 100. It's just when the PWM<100%. – Patrick Cook Oct 5 '15 at 15:59
  • @PatrickCook 100% PWM is the same as directly powered (no switching on and off). Perhaps your fan doesn't like being rapidly switched on and off, in other words it just isn't suited to speed control. – joan Oct 5 '15 at 18:45
  • @joan could you point me in the right direction to find a 40mmx40mm fan that is suitable for speed control? I can't seem to find one. – Patrick Cook Oct 5 '15 at 20:05
  • @PatrickCook Not my field I'm afraid. Why not leave the fan on full speed when it gets hot and switch the fan off when it gets cool again? Is it just too noisy even without the clicks? – joan Oct 5 '15 at 20:22
  • @joan bingo, the clicks are still quieter than the fan at full speed. – Patrick Cook Oct 5 '15 at 21:46
4

At a PWM frequency of a nominal 10 Hz I'm not surprised you can hear clicks. You will be switching the fan on and off 10 times a second.

Experiment with frequencies in the range 100 to 1000 Hz.

  • The higher the frequency, the most clicks, and the louder they are. Once I get to about 400 the fan stops and just makes a high pitch squeal. – Patrick Cook Oct 5 '15 at 15:59
  • What sort of fan are you using? How many wires does it have? I'd certainly try hardware timed PWM rather than software timed PWM but I'm not convinced jitter is the reason for the noise. – joan Oct 5 '15 at 16:27
  • The fan has 2 wires, power and ground. I do not know what type of fan it is, it just came with my case. – Patrick Cook Oct 5 '15 at 18:24
0

This might just be a problem with the fan itself. Make sure the fan casing is clear of wires and other miscellaneous items. If there's no interference, then try a different fan if you can. I can't really see a way in which PWM would cause a clicking noise itself...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.