Go Down

Topic: Controlling PWM fans with arduino and mains power (Read 225 times) previous topic - next topic

ByteTech

Oct 13, 2017, 11:11 am Last Edit: Oct 13, 2017, 02:36 pm by ByteTech
I'm working on building an enclosure for my 3D printers but want to be able to control the internal temperature using quiet PC case fans.

I'm looking at using these fans which use PWM.

For full power they require 12V input.

I've not made an arduino project which uses mains power before (with the exception of a pains power going straight into the arduino itself)

I've tried to do a bit of research and it sounds like it's fairly straight forward to control a PMW fan with an arduino. But I've seen some suggestions that arduino's may not be able to deliver fast enough PMW speeds to allow fans such as this to perform at their full potential (which I will require). Is this true?

If I can properly control these fans with an arduino (Uno is my intention), how would you recommend I power the fans from the mains power? Should I just get a basic computer PSU, or is something else more suitable?

If an arduino natively can't supply the PWM signals required, how would you recommend approaching this challenge?

Thanks!

pylon

Quote
I've tried to do a bit of research and it sounds like it's fairly straight forward to control a PMW fan with an arduino. But I've seen some suggestions that arduino's may not be able to deliver fast enough PMW speeds to allow fans such as this to perform at their full potential (which I will require). Is this true?
If you simply use analogWrite() the PWM frequency is set to 1kHz which is not sufficient for operating the PC fan. But you definitely can achieve the needed 25kHz signal with the hardware of an Arduino UNO.

Quote
If I can properly control these fans with an arduino (Uno is my intention), how would you recommend I power the fans from the mains power? Should I just get a basic computer PSU, or is something else more suitable?
I would expect your 3D printer to already contain some sort of 12V power supply. If ever possible I would use that one.

ByteTech

If you simply use analogWrite() the PWM frequency is set to 1kHz which is not sufficient for operating the PC fan. But you definitely can achieve the needed 25kHz signal with the hardware of an Arduino UNO.
How would I go about achieving the 25kHz signal without using analogWrite()? I will have 5 separate fans, each will need to be controlled separately depending on a switch status and readings from one of two temperature sensors. Would it be possible to control all 5 fans from the same arduino? How would I control them? Thanks


I would expect your 3D printer to already contain some sort of 12V power supply. If ever possible I would use that one.
Unfortunately I need to keep these separate from the printers. The printers will be powered on and off at times when the fans need to remain active. Equally, there will be times that the printers need to be easily removed from the enclosures.

Thanks for your help by the way.

wvmarle

12V you can get from a regular adapter, or of course a computer PSU if you happen to have one around. Or indeed maybe the printer has excess power available.

You'll also need a MOSFET to control the power to/from the fans, an n-channel, logic level type, such as the IRL540. You can't connect them to the Arduino pins directly.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

wvmarle

How would I go about achieving the 25kHz signal without using analogWrite()?
You can set the PWM frequency that your pins put out. That 1 kHz is the default.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

ByteTech

You can set the PWM frequency that your pins put out. That 1 kHz is the default.
Ah, so I can simply set (I'm presuming in setup) for my PWM pins to output at 25kHz? Would this be able to then output 25kHz to 5 separate PWM pins or is that asking too much from a humble Uno?

You'll also need a MOSFET to control the power to/from the fans, an n-channel, logic level type, such as the IRL540. You can't connect them to the Arduino pins directly.
Presumably this is literally to turn them on and off, and the PWM signal is then used to control their speed?
Also, forgive me, I am very new to electronics and still trying to wrap my head around all of this. Just so I understand correctly, MOSFET's have 3 pins. One is for power in, one for power out, and one which you feed a low level power to from the arduino which allows the higher level power to flow?

wvmarle

MOSFETs can be used for power on/off and also for PWM signals controlling current to the fans - some fans have drivers built in, so PWM goes on a third wire to the fan. Check the spec sheet of your particular fans on how yours work, and what voltage level is needed on the control wire if you have one.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

ByteTech

These fans appear to have PWM build in so presumably I'd have the power one linked with a mosfet, a standard digital pin out from the arduino to power the fan on and off via the mosfet, then use a PWM pin from the arduino directly connected to the PWM wire of the fan to send the signal?

ByteTech

Ok so currently I'm picturing this is going to require multiple arduinos to achieve but please correct me if I'm wrong.

The setup I'm looking to build is as below:

- 5 PWM fans in total.

- Fans 1 and 2 will always be used at the same time and their % power can always be the same (Although they are different fans). Effectively this is one fan going into the enclosure and one out.

- Fans 3 and 4 do the same as fans 1 and 2 but in a separate compartment of the enclosure so need to be controlled independently of them.

- Fan 5 needs to come on at full strength any time any of the other fans are active.

- 2 LCD screens (one for each enclosure compartment) giving me a temperature reading from a TMP36 in each compartment along with current fan speeds

- 2 potentiometers to control the fans for each compartment (ie. 1 pot will adjust the relative speed for both fans in compartment 1, and the other for both in compartment 2) taking them from completely powered off, right up to full power


----------

Now from what I've managed to gather from bits I've read, it's only possible to control 2x PWM fans at 25mHz with a single Arduino Uno, so I'm imagining to do this I'd need 3 Unos? One for each pair of fans, then an overall arduino which controls the final fan as well as the two screens and reads the temperature sensors and potentiometers.

wvmarle

In that case you can also get a PWM port expander. Much easier to handle than multiple Arduinos. I haven't checked the specs of that one, just given as example.

Other than that a fairly straightforward build. Do look for LCDs with I2C backpack, or you're bound to run out of pins and end up with a massive rats nest on your desk.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

pylon

Quote
Now from what I've managed to gather from bits I've read, it's only possible to control 2x PWM fans at 25mHz with a single Arduino Uno, so I'm imagining to do this I'd need 3 Unos? One for each pair of fans, then an overall arduino which controls the final fan as well as the two screens and reads the temperature sensors and potentiometers.
One Mega2560 should be enough to control at least 8 fans.

If I understood your description correctly you need to control only 3 PWM signals, an UNO should be able to handle that. If you take I2C LCD moduls the rest should be no problem too.

ByteTech

One Mega2560 should be enough to control at least 8 fans.

If I understood your description correctly you need to control only 3 PWM signals, an UNO should be able to handle that. If you take I2C LCD moduls the rest should be no problem too.
If the value you supply a fan is a relative figure rather than an exact figure this would be the case. From what I understand, when controlling an PWM fan, you supply it with a figure of 0-255 (off to full speed)? If this is the case, then I could send the same value (eg 122) to both the in and out fans of one section (even though they are different fans capable of different top speeds) and this would set them both to 50%?

A Mega does sound an attractive option if it will be capable of supplying 25mHz PWM to all my fans from a single device without it struggling, especially if it can also cope with the rest of my requirements!

In that case you can also get a PWM port expander. Much easier to handle than multiple Arduinos. I haven't checked the specs of that one, just given as example.
That one doesn't seem to be capable of 25mHz but I'm guessing others are out there. Are these easy to work with in terms of programming multiple PWM devices through one of these?

pylon

Quote
If the value you supply a fan is a relative figure rather than an exact figure this would be the case. From what I understand, when controlling an PWM fan, you supply it with a figure of 0-255 (off to full speed)? If this is the case, then I could send the same value (eg 122) to both the in and out fans of one section (even though they are different fans capable of different top speeds) and this would set them both to 50%?
A PWM signal is a rectangle wave where the percentage of the HIGH value of one cycle is equal to the PWM value. So if you set the value to 127 you should get a PWM signal with 50% duty. The translation of this PWM to actual rotations is done by the fan.

Quote
A Mega does sound an attractive option if it will be capable of supplying 25mHz PWM to all my fans from a single device without it struggling, especially if it can also cope with the rest of my requirements!
I don't see any problems here.

Quote
Are these easy to work with in terms of programming multiple PWM devices through one of these?
Yes, these chips are quite easy to work with. The problem might be to get one that support 25kHz.

ByteTech

A PWM signal is a rectangle wave where the percentage of the HIGH value of one cycle is equal to the PWM value. So if you set the value to 127 you should get a PWM signal with 50% duty. The translation of this PWM to actual rotations is done by the fan.

I don't see any problems here.

Yes, these chips are quite easy to work with. The problem might be to get one that support 25kHz.
You have been an amazing help! Thank you so much for all this.
When everything's arrived and I'm struggling to get it to function as intended I may be back but for now, thank you!

Go Up