RGB LED Fan Controller (custom electronics project)

Status
Not open for further replies.

CalcProgrammer1

Fully Optimized
Messages
2,363
Location
Illinois, USA
I haven't been on Tech Forums in a while, mainly because I got interested in electronics projects and spent a lot of time playing with microcontrollers and stuff. However, I recently got a new case for my server and a blue LED fan to light up the front of it. However, the blue LED fan had a burned out LED and it also ran really loud so I decided to take on a project that I had thought of before. I decided to make a custom fan controller that would also include multi-colored LED's, control the fan speed, and read back RPM's all through the computer (no switches or buttons on the case or inside of it, everything is controlled through the PC itself).

To do this project, I started with an Atmel ATMega168 microcontroller (which is about $5) and a level converter for the serial port (about $1). Add to that 2 transistors to control the higher voltage for the fan, a 5 volt regulator to provide a stable power supply for the chips, and some resistors (all these parts around $1 total). The other stuff is a custom PCB I'm going to make once I figure out how to print them and some RGB LED's (found them cheap on eBay) and of course the 120mm blue LED fan with the blue LED's removed.

To connect to the PC I found that my server's motherboard has a second serial port pinned out internally that I could plug into with some basic pin connectors without even using any external ports. Serial connections are great for microcontrollers because USB is more complex and involves more expensive stuff.

I have a program written for controlling the 4 LED's and the fan speed but I am still working on reading the RPM accurately. If anyone else here has any experience with microcontrollers I'll post the code when it's finished as well as pictures of the controller. If it works well, I may figure out how to chain multiple microcontrollers together and come up with a protocol for whole-case lighting control which would be awesome (change the color of the LED's at any time or have some kind of color loop that fades continuously).
 
Dude, this is a relatively simple project, you should be able to do it with one PIC easy.

I'd suggest scrapping the manual control of the fan RPMs and just using a digital potentiometer. Then you'll be able to control it via software on the pc.
Also, you won't need a 5v regulator, the PC power supply is already stable enough. Just use the 5v pin from any of the molex connectors (or pins 7-9 on a sata power cable)
As to the rpm, you'll need an IR LED and an IR receiver probably, one on either side of the fan blades.
 
PIC, AVR, same thing really, both are cheap microcontrollers, just I know how to program AVR's and haven't tried PIC's yet. I'm not trying to control the RPM, just read it the same way the motherboard does (by counting pulses on the third sensor wire) which should be easy (AVR's have counters built in) but there's noise on the line from PWM frequency, though a capacitor absorbs that and I think I finally got a stable count. With the RPM readout to the PC and the PC able to control the power, it should be easy enough to make some sort of feedback loop to control the RPM directly but I don't plan on making one. If I use molex I will probably eliminate the regulator (using one now just because I'm using a 12V adapter to power everything) as linear regulators just waste power as heat.

As for why the mega168 I tried a smaller, cheaper Atmel microcontroller (tiny2313) but it didn't have enough memory for a color fading routine I found as well as the rest of my code, plus the mega has enough pins to drive LED's, the fan, and read the RPM.
 
*facepalm* somehow I forgot about the third wire. epic fail lol.

Um and yeah, I tend to use the terms PIC and AVR interchangeably.

What language are you writing the program in?
 
C (avr-gcc), I'm not good enough for assembly, it just looks confusing. I tried it a while back on TI calculators after I got interested in programming from playing with TI BASIC but every program I ever wrote in assembly crashed the emulator and I never bothered to get back into it, I figure I'll be taking a more advanced programming class eventually where I'll learn it, but C is a good language. Using AVR Studio and then a parallel port programmer I made because I'm too cheap to buy a real one.
 
lol :grin:
Yeah don't bother with assembly. TBH it's not that hard, you only need to know about 35 different commands and that's it. The bad thing is you have to do everything one step at a time, and it's not a very powerful language.

So, what step are you working on atm? Just putting the hardware together?
 
It's all on breadboard right now, I have the AVR and MAX232 serial chip hooked up, I have the AVR outputting PWM through 2 transistors (NPN to PNP to step up 5V to 12V) that is connected to the fan. For the LED's, I ordered a 50 pack of RGB common-cathode ones on eBay because they were cheaper than ordering 4 of them through Mouser (an online electronic parts store here where I got the rest of the parts). I found a software PWM routine to create an "analog" signal on any pin I need so I can control 12 channels (3 per LED, 4 LED's total) and implemented it, then also found a color fading routine that slowly fades between two colors. I'm going to put the fading on the chip itself so you just tell it to fade a certain LED to a new color, probably have the AVR send back a "done" message to the PC.

As for counting the RPMs, I got what I think is a steady signal input (checked it with a scope and it looks clean) but using interrupts to count sometimes fired wrong. I found a bit of code for the Arduino board that ran an accurate frequency counter up to several MHz and I tested it and got better numbers than my code did so I need to figure out what it's doing and implement it. After I get it working I'll draw up a PCB on Eagle CAD (or some other program if I can find a better one) and try the laser printer PCB technique to make a custom board. If I like how it works I'll probably make more for future builds (I have enough parts to at least build 2 and enough of everything other than the microcontroller and serial chip to build a lot more than 2).
 
fanleds.gif


I finally installed some RGB LED's in a fan. I ran out of wire so I only got to install 2 of the LED's, the other 2 are still on the breadboard. I also just drew up a PCB layout that should work, though I have a little work left on counting RPMs before I finalize the board. The base code is done (driving LED's, fan speed control, serial communication) except for reading the RPM, all I need to do after that works is come up with a protocol and then write a program for the PC to control it, if it tests OK then I'll create a PCB and install in my server. If it works well, I'll add one to the side panel as well.
 
Status
Not open for further replies.
Back
Top Bottom