[SOLVED]First project - Arduino, RPI and PMW Computer Fan

Hello!

I was given an Arduino Uno as a gift and have been toying around with it.

I am comfortable with the programming side of things, however my knowledge in electronics and circuits is non-existant.

I have tried reading about my following question but I find I end up not really knowing if I actually found the right solution or not so I decided I'd ask here hoping for some help (and keep this as short as possible).

Simply put, I have a Rasberry Pi powered by it's own PSU connected to the Uno, talking and powering via USB. All working fine.

I also have a 4 pin 12v computer fan that I took from an unused computer which after some investigation managed to power up using an ac power adapter I had lying around.

From my research I found out I should be able to adjust speeds using the PWM pin with the arduino. I'm yet to figure out how to do that but I feel that I understand the coding needed behind the pins in order to provide the result I expect. But, I am really unsure about how to connect everything without causing any damage.

Is it just a matter of keeping the arduino powered by the pi (which will be connected in my final setup anyway), powering the fan through the second adapter and connecting the PWM cable to the Arduino directly?

I sometimes read about people connecting fans to arduinos and use resistors and diodes and that confuses me...

Thanks for your help!

The Arduino outputs are too weak, for powering a fan you need a driver module (MOSFET or half H bridge). Search the Forum and Learning sections for details.

Check this link

http://www.instructables.com/id/Use-Arduino-with-TIP120-transistor-to-control-moto/

Thank you for your replies! I will look into them further as I want to learn more about the electronic side of things indeed.

I was never intending to power the fan through the Arduino, which is why I was using the separate 12v ac adapter.

So, I managed to get it working for my needs. I have now the rpi and arduino powered on one end by their own power supply and the fan by a separate one.

My code (from: http://arduino.stackexchange.com/questions/25609/need-help-to-set-pwm-frequency-to-25khz) does a perfect job at adjusting the speed of the fan and got rid of a high pitch noise it was originally doing:

My final question is whether my connections are safe. I am hoping to place this fan inside a chamber and run constantly at low speeds and occasionally have it run faster for short times. I don’t know if my connections are good as they are if I were to leave it running unattended.

Pi is running on it’s own supply, arduino is powered by the pi through usb. The fan is powered by an ac adapter, the ground of which is also connected directly to the arduino GND. The PWD is also connected directly to the arduino pin 9.

I am not using any other connections in between.

Thanks for your help again!

If it makes it a little clearer. Attached to this: A crude drawing showing how everything is working right now (and the exact models I’m using if visible…)

Black: Ground
Blue: PWM
Yellow: +12v

Thanks!

No that is not a safe circuit. You are exposing the Arduino pin to 12V I am supprise it is not dead already. You need a transistor to drive the fan.

Grumpy_Mike: No that is not a safe circuit. You are exposing the Arduino pin to 12V I am supprise it is not dead already. You need a transistor to drive the fan.

Where am I exposing it to 12V? I seem to read that the PMV line has an absolute maximum 5.25V level.

That is the only line besides the ground connected to the Arduino.

Then again, I just started learning about all of this and I may be misinterpriting the information so any tip will be greatly appreciated.

Thanks!

You are using the Arduino output to sink current 1) this is draining way more current than the Arduino is designed for. Any more than 40mA will damage the Arduino. When the output pin is high it is not sinking current it has 5V on it. BUT it is also connected to 12V through the motor windings. 2) this is way more voltage than the Arduino can withstand. The maximum voltage is 0.5V above the chip's supply voltage.

Do not confuse the idea of maximum, it means you must not let it exceed that value NOT it will not exceed that value.

Thanks again for the informative info!

I spent most of the day reading about it and the importance of certain elements (such as transistors, resistors and diodes) so I will include those to make the setup safer and avoid damage to the board.

However, there seems to be so many variations of each that it confused me further. I don't expect for the calculations to be done to me, but you could point me in some direction to figure out which elements I do need and why that would be extremely helpful.

First off you need a transistor, you connect the emitter to ground and collector to the end of the fan not connected to the plus 12V.

You need a diode, use a 1N4001, and connect the anode, the end with the stripe to the plus 12V and the other end to the other side of the fan / collector. This prevents large voltages being generated when you turn the motor off.

Finally connect one end of a 1K resistor to the base of the transistor and the other end to the Arduino output. You can use a 2N5555 transistor, but many other types will work. Make sure you connect the negitave of the 12V to the Arduino ground.

Thank you very much once again. This information will help me keep moving forward safely.

This also useful as reference as I want to still have a better understanding of why those specific models and start learning about electronics in order to help me in following projects.