Interfacing with a fan

Hello,

I want to control the speed of a fan using a PWM signal. The fan (SanyoDenki San Ace 80) has a dedicated PWM input for this purpose.

It wants a PWM signal with a frequency of 25kHz, which I think I achieved using the following code:

void setup(){
  pinMode(11, OUTPUT);
  pinMode(3, OUTPUT);
  TCCR2A = _BV(COM2A0) | _BV(COM2B1) | _BV(WGM21) | _BV(WGM20);
  TCCR2B = _BV(WGM22) | _BV(CS21);
  OCR2A = 79;
  OCR2B = 39;
}

void loop(){
  // noop
}

This SHOULD in my opinion result in a 25kHz signal and a duty cycle of 50% on pin 11.
I based my code on the ideas in the article "SecretsOfArduinoPWM"

The problem is, that the fan doesn't decrease its speed when connected to pin 11.

I am a software developer with amateurish knowledge of electronics, so I hope I can get some help here.

The datasheet of the fan tells me the following about its desired pwn input:

  • Source Current: 1mA Max. at control voltage 0V
  • Sink Current: 1mA Max. at control voltage 5.25V
  • Control Terminal Voltage: 5.25V Max. (Open Curcuit)
  • This fan speed should be controlled by PWM Input signal of either TTL input or open collector, drain input

i GUESS the last point might be my issue. As as far as I know the atmel doesn't provide an open collector output. But - as you can see - there is way too much superficial knowledge here. I am still trying to gather as much knowledge as I can, but time is running out, so I hope, some nice person here might give me some hints in the right direction.

Thanks a lot in advance for your time.

Greetings,
Matthias

Probably a silly question but are the grounds of the arduino and the fan controller connected?

Probably a silly question but are the grounds of the arduino and the fan controller connected?

I don't know exactly what you are after. There is no specific connection to the grounds. But to be more precise:

The fan has four connections. Two are used to provide the power (12V - using a CLG-150-24A).
The other two are the pwm controller input and a sensor. I've connected the controller directly to the pin 11 of my arduino, which itself is powered by the usb connection.
I tried using a pull-down-resistor between the arduino and the controller, which however haven't had any positive effect.

To be clear: the fan and the arduino are both running. It's just that the fan is ignoring the signal I feed it from the arduino.

So there is no gound connection between the fan and any ground pins on the Arduino? - if so I think you need one. Electrically, if the only connection is between pin 11 and the controller you're going to need to connect the ground of the arduino to the fan to complete the circuit.
See which side of the fan power connector is at 0v and hook ground up to that and see if it helps.

Thank you for your reply.

There is a connection from the fan to the ground but not through the arduino, but via the power connection (the separate 12V one). I couldn't think of any other way of connecting the fan to the ground as there are only two connections left - the controller and the sensor.

Am I terribly missing something here? Does it have to be connected to the ground pin on the arduino as well? I couldn't see either how nor why, but - as I said - superficial knowledge is all around.

If the fan and the Arduino board share the same powersupply then the grounds are already conneted, otherwise you need a connection from the fans ground to Arduinos ground.

Connect the aduino ground to the fan ground (they may have to share a connection or some other cludge). The fan is definitely 12v DC right? Be absolutely sure you're connecting to the right rail on the fan.

If it helps consider a circuit to drive a transistor from an arduino output - the ground of the arduino must be connected to the emitter of the transistor too (NPN). Just connecting your output to the base won't work as there's not a completed circuit.

The fan is definitely 12v DC right?

Yes it is.

If it helps consider a circuit to drive a transistor from an arduino output - the ground of the arduino must be connected to the emitter of the transistor too (NPN). Just connecting your output to the base won't work as there's not a completed circuit.

Ah! Now I see what you mean. I thought, that's exactly what an open collector is, or am I wrong? So my initial thouht, that I need to build an open collector output from my arduino wasn't that wrong after all.
The question is, do I have to build it myself (and if so, which parts should I use), or is there a way to set the output of the arduino to do this sort of thing? I couldn't find anything helpful in the datasheet of the atmel chip.

Don't get me wrong, I don't expect you to do the work for me, it's just that I don't know much about electornics (yet) and I am trying to learn a lot in a very short amount of time. It's important for me to understand what I am doing, not just to copy a solution given to me. So thank you for taking the time. It would be great if you could point me to some directions so I can finally solve this problem. :slight_smile:

Greetings,
Matthias

Sorry I think I may have confused matters by mentioning a transistor. You need to connect the ground of the arduino to the 0v/ground of the fan. If the fan can accept a logic level pwm input then the arduino pin should be sufficient to control the fan. You need to connect the fan and arduino ground though!

OK, I'll try that. and there won't be a problem for the (5V) arduino when doing this (as the fan is powered by a 12V voltage)? (sorry, this may sound stupid, but I want to be sure not to bake my arduino because I missed something, that might be obvious for others).

This might be useful for further investigation. It's from the datasheet of the fan:

As long as you just connect the grounds and ensure that the positive sides are kept seperate.

That did it!
Thank you very much for your time and patience.
Highly appreciated. :slight_smile:

Greetings,
Matthias

You had better put a resistor between the PWM pin and the input of the fan control as there is nothing to limit the current in the base of the transistor. It will still work for a while but you are drawing too much current from the arduino's output pin. A 1K resistor would be fine.

You had better put a resistor between the PWM pin and the input of the fan control as there is nothing to limit the current in the base of the transistor. It will still work for a while but you are drawing too much current from the arduino's output pin. A 1K resistor would be fine.

I'll do that, thank you for the advice.

Hi sorry for hijacking this thread, I am trying to do the same thing as bestform except all i want to do is turn the fan on or off.

What i have done so far is to connect the fan directly to the arduino and turn it on and off by setting the output of pin of my choice to either HIGH or LOW.

The problem I am having is that the fan spins extremely slow , this I understand is because it requires 20V of power. But before i connect it to a 20V power source (in this case my PC, its a PC fan) I want to know if there is anything i need to take into consideration so that i dont blow the arduino or even worse the PC.

Any help would really be apprciacted , please keep in mind i am really new to this.

Thanks

Stop!

hammer time

Stop!

hammer time

I lol'd. ;D