{"id":437,"date":"2018-01-08T18:01:19","date_gmt":"2018-01-08T22:01:19","guid":{"rendered":"http:\/\/blog.kortar.org\/?p=437"},"modified":"2018-01-08T18:01:19","modified_gmt":"2018-01-08T22:01:19","slug":"building-a-manual-pwm-fan-controller","status":"publish","type":"post","link":"https:\/\/blog.kortar.org\/?p=437","title":{"rendered":"Building a Manual PWM fan controller"},"content":{"rendered":"<p>I recently built a new home server, it&#8217;s a multipurpose box that will hold most of my infrastructure and also is a file server with a lot of hard drives (and room for more in the future) All of these drives meant this ended up being a very large machine so there was space to put them all. I ended up getting a <a href=\"http:\/\/www.caselabs-store.com\/magnum-thw10-customizable\/\">CaseLabs Magnum THW10<\/a> for the case, which has space for a ton of stuff in it.\u00a0 While the machine is working great and doing everything I need it to, there is one small problem with it. The front fans aren&#8217;t spinning fast enough.<\/p>\n<p><!--more--><\/p>\n<figure id=\"attachment_441\" aria-describedby=\"caption-attachment-441\" style=\"width: 474px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/blog.kortar.org\/wp-content\/uploads\/2017\/09\/IMG_20170901_171907-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-441 size-large\" src=\"http:\/\/blog.kortar.org\/wp-content\/uploads\/2017\/09\/IMG_20170901_171907-1-768x1024.jpg\" alt=\"\" width=\"474\" height=\"632\" srcset=\"https:\/\/blog.kortar.org\/wp-content\/uploads\/2017\/09\/IMG_20170901_171907-1-768x1024.jpg 768w, https:\/\/blog.kortar.org\/wp-content\/uploads\/2017\/09\/IMG_20170901_171907-1-225x300.jpg 225w\" sizes=\"(max-width: 474px) 100vw, 474px\" \/><\/a><figcaption id=\"caption-attachment-441\" class=\"wp-caption-text\">The server in my living room after the first boot. (the 2 liter soda bottle is for scale)<\/figcaption><\/figure>\n<p>The hard drives are mounted behind the front intake fans and I want to make sure they keep cool.\u00a0 All the output from the PWM fan headers on the motherboard, an <a href=\"https:\/\/www.asus.com\/us\/Commercial-Servers-Workstations\/Z10PED16\/\">ASUS <span id=\"ctl00_ContentPlaceHolder1_ctl00_span_model_name\">Z10PE-D16<\/span><\/a>,\u00a0 are tied to the CPU temperatures.\u00a0 But, the CPUs doesn&#8217;t really get too hot in the server so the case fans rarely (if ever) go above their minimum speed. My normal solution for this problem is to use the <a href=\"https:\/\/linux.die.net\/man\/8\/fancontrol\">fancontrol<\/a> utiltity which is part of <a href=\"https:\/\/github.com\/groeck\/lm-sensors\">lm_sensors<\/a>. However, lm_sensors is not able to detect any of the fan controllers on the motherboard. I think this is because the fan control is done by the\u00a0 BMC on the motherboard and lm_sensors doesn&#8217;t support the BMC. I wasn&#8217;t able to find an option for fan control in the BMC&#8217;s web interface, so I&#8217;m not sure. Either way I decided it would be much easier to just build a fan controller to be able to manually set a fan speed for the input fans.<\/p>\n<h2>Building a Fan Controller<\/h2>\n<p>The server has 8 front 120mm fans, 1 rear 120mm fan, and 6 top exhaust 140mm fans installed. However, because the motherboard only has a few fan headers I have 2<a href=\"http:\/\/silverstonetek.com\/product.php?pid=526&amp;area=en\"> Silverstone CPF04<\/a> powered splitters. The front 8 fans are connected to one splitter and the 6 top exhaust fans to the other. For this project I wanted to just stick a controller in between the motherboard 4 pin fan header that enable me to adjust the\u00a0 PWM control signal sent to the fans. This would only take power from the motherboard and generate it&#8217;s own independent PWM output. Since the splitters are independently powered I wouldn&#8217;t need to worry about routing power from the motherboard to the fans.<\/p>\n<p>There are commercial solutions out there, like the <a href=\"http:\/\/noctua.at\/en\/na-fc1\">Noctua NA FC1<\/a>, which are pretty close to what I was looking for. The problem with the Noctua controller for my use case was that it wouldn&#8217;t let me set full manual mode if the motherboard header was plugged in. I could create a custom cable that didn&#8217;t have the PWM pin connected, but then I would be paying for a bunch of features that I didn&#8217;t actually want.<\/p>\n<h3>Designing the controller<\/h3>\n<p>I did some searching on google to see what most people were doing because building a fan controller is hardly a unique thing. Most examples that I found built a circuit with a 555 timer in astable mode with a potentiometer to adjust the duty cycle of the output waveform. So I decided to do the same thing. After reading the <a href=\"http:\/\/formfactors.org\/developer\/specs\/4_Wire_PWM_Spec.pdf\">Intel specification for 4 wire PWM fans<\/a> I figured out my design constraints for the oscillator. The circuit needed to have an output frequency of ~25 kHz and operate at 5 volts. Given this I settled on this circuit:<\/p>\n<p><a href=\"http:\/\/blog.kortar.org\/wp-content\/uploads\/2017\/10\/555TimerCircuit.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-448\" src=\"http:\/\/blog.kortar.org\/wp-content\/uploads\/2017\/10\/555TimerCircuit-779x1024.png\" alt=\"\" width=\"474\" height=\"623\" srcset=\"https:\/\/blog.kortar.org\/wp-content\/uploads\/2017\/10\/555TimerCircuit-779x1024.png 779w, https:\/\/blog.kortar.org\/wp-content\/uploads\/2017\/10\/555TimerCircuit-228x300.png 228w, https:\/\/blog.kortar.org\/wp-content\/uploads\/2017\/10\/555TimerCircuit-768x1009.png 768w, https:\/\/blog.kortar.org\/wp-content\/uploads\/2017\/10\/555TimerCircuit.png 1338w\" sizes=\"(max-width: 474px) 100vw, 474px\" \/><\/a><\/p>\n<p>It was mostly borrowed from the circuits I found via searching the internet for similar projects. But I had to adjust some of the component values to meet fan control spec.<\/p>\n<p>From there I designed a PCB for this circuit using <a href=\"http:\/\/kicad-pcb.org\/\">KiCad<\/a>. I specifically designed the PCB to be easy to assemble, using all through hole components.\u00a0 While I could have easily made it much smaller using surface mount components I wanted this to be a good project for people just starting soldering. This isn&#8217;t a very complex project and I felt like there might be people out there with a similar need for it.\u00a0 But, even with this constraint the board is still fairly small at only 35mm x 44mm. (mostly because it&#8217;s a simple circuit.<\/p>\n<p>All the designs for this are open source and can be found on my github at:<\/p>\n<p><a href=\"https:\/\/github.com\/mtreinish\/pwmcontroller\">https:\/\/github.com\/mtreinish\/pwmcontroller<\/a><\/p>\n<h3>Putting together the Controller<\/h3>\n<p>After finishing a functional design I sent it out to <a href=\"https:\/\/www.elecrow.com\/\">elecrow<\/a> to get the board manufactured. A couple weeks later I got the boards delivered. (I cheaped out on the shipping which made it take longer, the boards were manufactured in &lt; 1 week)<\/p>\n<p><a href=\"http:\/\/blog.kortar.org\/wp-content\/uploads\/2017\/10\/IMG_20171011_160307.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-456\" src=\"http:\/\/blog.kortar.org\/wp-content\/uploads\/2017\/10\/IMG_20171011_160307-1024x952.jpg\" alt=\"\" width=\"474\" height=\"441\" srcset=\"https:\/\/blog.kortar.org\/wp-content\/uploads\/2017\/10\/IMG_20171011_160307-1024x952.jpg 1024w, https:\/\/blog.kortar.org\/wp-content\/uploads\/2017\/10\/IMG_20171011_160307-300x279.jpg 300w, https:\/\/blog.kortar.org\/wp-content\/uploads\/2017\/10\/IMG_20171011_160307-768x714.jpg 768w\" sizes=\"(max-width: 474px) 100vw, 474px\" \/><\/a><\/p>\n<p>Then I\u00a0 soldered the components onto the board<\/p>\n<p><a href=\"http:\/\/blog.kortar.org\/wp-content\/uploads\/2017\/10\/IMG_20171011_170645.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-457\" src=\"http:\/\/blog.kortar.org\/wp-content\/uploads\/2017\/10\/IMG_20171011_170645-1024x665.jpg\" alt=\"\" width=\"474\" height=\"308\" srcset=\"https:\/\/blog.kortar.org\/wp-content\/uploads\/2017\/10\/IMG_20171011_170645-1024x665.jpg 1024w, https:\/\/blog.kortar.org\/wp-content\/uploads\/2017\/10\/IMG_20171011_170645-300x195.jpg 300w, https:\/\/blog.kortar.org\/wp-content\/uploads\/2017\/10\/IMG_20171011_170645-768x499.jpg 768w\" sizes=\"(max-width: 474px) 100vw, 474px\" \/><\/a><\/p>\n<p>Then I installed the new controller in my server, and of course it didn&#8217;t work. So I took the PCB to my bench and tested it with an oscilloscope,\u00a0 a bench power supply and a spare fan. It turns out there were two\u00a0 issues. First, the 555 timer was\u00a0 outputting at 3.8-4.2V instead of the 5V called for in the spec. The second issue was that the output wasn&#8217;t really a square wave either:<\/p>\n<p><a href=\"http:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/SDS00003.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-489\" src=\"http:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/SDS00003-300x180.png\" alt=\"\" width=\"300\" height=\"180\" srcset=\"https:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/SDS00003-300x180.png 300w, https:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/SDS00003-768x461.png 768w, https:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/SDS00003.png 800w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h3>Second Attempt<\/h3>\n<p>To correct the issues I found from the first attempt, I modified my circuit slightly and added a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Schmitt_trigger\">schmitt trigger<\/a> on the output. This would have three advantages: it would clean up the square wave, make the rising and falling edges much faster, and it would ensure we have a stable 5V output.\u00a0 It&#8217;s actually pretty funny, I decided\/remembered to use the schmitt trigger because I had to write a fake app note for a class in college on using a schmitt trigger for switch de-bouncing.<\/p>\n<p>The modification to the circuit schematic was pretty simple. Just add the schmitt trigger to the output of the 555 and then wire that to the fan header:<\/p>\n<p><a href=\"http:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/Screenshot_2018-01-08_22-09-44.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-484\" src=\"http:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/Screenshot_2018-01-08_22-09-44-300x279.png\" alt=\"\" width=\"300\" height=\"279\" srcset=\"https:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/Screenshot_2018-01-08_22-09-44-300x279.png 300w, https:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/Screenshot_2018-01-08_22-09-44-768x715.png 768w, https:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/Screenshot_2018-01-08_22-09-44-1024x953.png 1024w, https:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/Screenshot_2018-01-08_22-09-44.png 1887w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The only complication to this came on the board layout. I was not able to find a single Schmitt trigger in a through hole package. The only through hole schmitt triggers that I found (granted I didn&#8217;t do an exhaustive search) was a 4 or 6 way in a DIP-14 package. Which would be by far the largest package on the board. I wanted the PCB to be simple, small, and easy to hand solder. This originally meant all through hole, but with the choice between a DIP 14 and increasing the board size or a single surface mount component I opted to go with the SMT components. I was able to find one from TI in a SOT-23-5 package, which honestly isn&#8217;t hard to solder, it just takes a little patience. (magnification helps)<\/p>\n<p>After finishing up the revised board layout (I shrunk it down a lot and cleaned things up at the same time) I sent it out to <a href=\"https:\/\/oshpark.com\/\">OSH Park<\/a> to get manufactured:<\/p>\n<p><a class=\"alignnone size-medium wp-image-487\" href=\"http:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/IMG_20180108_174737.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-487\" src=\"http:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/IMG_20180108_174737-300x225.jpg\" alt=\"\" width=\"300\" height=\"225\" srcset=\"https:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/IMG_20180108_174737-300x225.jpg 300w, https:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/IMG_20180108_174737-768x576.jpg 768w, https:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/IMG_20180108_174737-1024x768.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Then I soldered everything on:<\/p>\n<p><a href=\"http:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/IMG_20180108_190039.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-483\" src=\"http:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/IMG_20180108_190039-267x300.jpg\" alt=\"\" width=\"267\" height=\"300\" srcset=\"https:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/IMG_20180108_190039-267x300.jpg 267w, https:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/IMG_20180108_190039-768x863.jpg 768w, https:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/IMG_20180108_190039-911x1024.jpg 911w\" sizes=\"(max-width: 267px) 100vw, 267px\" \/><\/a><\/p>\n<figure id=\"attachment_482\" aria-describedby=\"caption-attachment-482\" style=\"width: 300px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/IMG_20180108_191023.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-482 size-medium\" src=\"http:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/IMG_20180108_191023-300x191.jpg\" alt=\"\" width=\"300\" height=\"191\" srcset=\"https:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/IMG_20180108_191023-300x191.jpg 300w, https:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/IMG_20180108_191023-768x490.jpg 768w, https:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/IMG_20180108_191023-1024x653.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-482\" class=\"wp-caption-text\">Next to the flawed original board<\/figcaption><\/figure>\n<p>I did make one mistake on the new board; I forgot to connect the ground from the motherboard connector and the 5V side of the DC\/DC converter. Nothing a small bodge wire between pins 1 and 3 on the DC\/DC converter couldn&#8217;t fix. (the pcb design in the git repo has been updated with this correction already) With that and the new schmitt trigger things worked perfectly:<\/p>\n<p><a href=\"http:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/SDS00001.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-490\" src=\"http:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/SDS00001-300x180.png\" alt=\"\" width=\"300\" height=\"180\" srcset=\"https:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/SDS00001-300x180.png 300w, https:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/SDS00001-768x461.png 768w, https:\/\/blog.kortar.org\/wp-content\/uploads\/2018\/01\/SDS00001.png 800w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>and putting it in my server now I can control the fan speeds very easily.<\/p>\n<h2>Conclusion<\/h2>\n<p>This project made me realize that a lot of the random controllers and accessories on modern computer motherboards that we take for granted and are completely closed designs.\u00a0 There isn&#8217;t any documentation from ASUS <span id=\":rd.co\" class=\"tL8wMe EMoHub\" dir=\"ltr\">about how things on my server motherboard are wired up or the protocols they utilize<\/span> (at least not that I was able to find). I started thinking about my other computers including my desktop and how I&#8217;m controlling things like the fans and water pump there. It&#8217;s the same story there; I&#8217;m relying on the motherboard&#8217;s\u00a0(an ASUS Rampage V Edition 10) baked in hardware and software. I checked and lm_sensors isn&#8217;t able to talk to the fan controller on the desktop either. But, unlike my server the desktop&#8217;s UEFI provides me the necessary level of control to adjust the temperature input and set custom fan curves.<\/p>\n<p>While I would like to see these designs opened up to make it easier to leverage, I realize that&#8217;s not very likely to change any time soon. But in the mean time I we can continue to just build open alternatives for the pieces we need.\u00a0 I&#8217;m currently working on another fan controller project for my desktop to try and start addressing this. I&#8217;m going to build a multi-fan controller similar to something like an <a href=\"https:\/\/shop.aquacomputer.de\/product_info.php?language=en&amp;products_id=3092\">aquacomputer aquero.<\/a> But, built in an all open manner and with an open and\u00a0 defined interface. You can follow the in progress of that effort here: <a href=\"https:\/\/github.com\/mtreinish\/openpwm\">https:\/\/github.com\/mtreinish\/openpwm<\/a> It&#8217;s still super early in the hardware design and it&#8217;s going to be a very long term project I work on in my free time.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I recently built a new home server, it&#8217;s a multipurpose box that will hold most of my infrastructure and also is a file server with a lot of hard drives (and room for more in the future) All of these drives meant this ended up being a very large machine so there was space to &hellip; <a href=\"https:\/\/blog.kortar.org\/?p=437\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Building a Manual PWM fan controller<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":""},"categories":[10,9],"tags":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6ACJO-73","_links":{"self":[{"href":"https:\/\/blog.kortar.org\/index.php?rest_route=\/wp\/v2\/posts\/437"}],"collection":[{"href":"https:\/\/blog.kortar.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.kortar.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.kortar.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.kortar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=437"}],"version-history":[{"count":42,"href":"https:\/\/blog.kortar.org\/index.php?rest_route=\/wp\/v2\/posts\/437\/revisions"}],"predecessor-version":[{"id":787,"href":"https:\/\/blog.kortar.org\/index.php?rest_route=\/wp\/v2\/posts\/437\/revisions\/787"}],"wp:attachment":[{"href":"https:\/\/blog.kortar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=437"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kortar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=437"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kortar.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=437"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}