Looking for help in designing a board that can be send to PCBWay Or such? - Page 1
Forum section: electronics / beginners

author: jibun no kage
author_rank: Newbie
timestamp: September 17, 2025, 04:01:15 am
content: Looking for help in designing a board that can be sent to PCBWay Or such? I want to monitor a 12v 3 pin fan for rotation speed (RPMs), so the tachometer pin, via a ESP8266, ESP32, Pico and/or Raspberry Pi. But I am completely new to circuit design. My hope is once I have the board designed, produced, and validated, I can post the entire project on github and/or instructables sites. I believe I understand the following:1) The micro-controllers in question, compatible limits, 3.3 voltage on GPIO input pins, whereas the input current should be limited to 12mA (source and sink)2) Of course the fan needs 12v3) Fan hall effect sensor voltage range 1.65v to 5.5v, current 5mA or less... but is this always true? Many sources suggest this varies between 12v fans?4) Will need a pull up resistor on tachometer pin, put not sure I understand why a pull up does completely... I=V/R, so 5v/10K resister = 0.5mA So this would seem to be well within the range the microcontrollers can handle for current? But what of voltage? Some 12v fans tachometer pin range 1.65v to 5.5v, others voltage range of 0v to 12v? So would you not use a voltage divider to reduce this to 0v to 3.3v range?Now the questions...A) So which is it pull up or divider based design?B) Do I need to add a opto coupler to isolate the fan from micro-controller? How does one add this to the circuit design, where? Between the fan micro-controller of course, on the tachometer pin?C) Would like to use the 12v power supply to also power the micro-controller, that would mean stepping 12v to 5v, best way to do this? I diagrammed in a 12v DC to 5v DC converter, separate from the board its self, but is there a better way? Since these DC to DC sometimes fail, thinking I want to make the board independent of the power sourcing.Would really appreciate if some one could point out any mistakes? This based on a design I found via Google, that uses a pull-up solution, so I guess the 12v fan the author used, was not using the tachometer range of 0v to 12v? But 1.65v to 5.5v?So I guess the board would have to be much more complex to handle any possible 12v fan?

author: Nominal Animal
author_rank: Super Contributor
timestamp: September 17, 2025, 02:52:51 pm
content: If you refer to the 12V 3-pin fans that are widely used in computers, then the tachometer output is an open collector one. In your microcontroller circuit, you use a resistor (10k is typical) to pull it to a voltage between 5V and 12V, and the fan will pull it down twice per rotation.A cheap and simple but safe circuit is to use a 10k resistor to 5V, with the tachometer signal also connected to the gate of a BSS138 (or NX138AK, which I prefer) N-channel MOSFET, the source to ground, and the drain to both your input pin and to another 10k resistor whose other end is connected to logic level voltage (3.3V). This is safe even for funky signals that generate a 5V TTL tachometer signal instead. NX138AK is a bit faster to switch (good to at least 100 kHz even with gate-source voltage only swinging between 0V and 2.5V), and can handle ±20V between gate and source, so won't mind even if the tach signal was pulled up to 12V, or just to 2.5V.I've designedsingleanddual12V PWM fan controller using ATtiny85, where the fan speed is also controlled via PWM from the microcontroller. This works with all 4-pin 12V PWM fans used with PC computers, including Noctua ones (considered excellent but a bit pricy). The idea is that the potentiometer controls the fan RPM, and not just the PWM duty cycle. The single variant also exposes 5V I²C, if one wanted to use I²C temperature sensors instead of the potentiometer to control the fan.I could easily respin either for e.g. WCH CH32X033 (which is cheap, programmable using open source tools including in Arduino environment using thech32x035core) or CH32V033 (ditto,ch32v003core). I particularly like the CH32X033F8P6, because JLCPCBhas it for assembly, it only needs one bypass capacitor, and provides an USB interface for programming (although you'll still want to have a WCH-LinkE at hand for programming if you manage to "brick" it, but that only costs 7.5€ shippedfrom the official AliExpress store), and can use 3.3V or 5V supply (and will use corresponding I/O voltage levels).With 4-pin PWM fans, the additional wire is for a ~25 kHz PWM signal, where the duty cycle controls the fan speed. I prefer to use another NX138AK (or BSS138) N-channel MOSFET for this, to protect the microcontroller output pin if something weird happens. (As in, me accidentally poking the fan connector with a screwdriver, shorting the 12V to the tach or PWM pins... I'm only a hobbyist, and tend to design stuff to be robust against my own bumblephuckery.)Also, theIntel 4-wire PWM fan specsuggests motherboards have a pull-up on the tachometer pin to 12V, not 5V.The ATtiny85 or CH32X033 microcontrollers use so little power — less than ten milliamps — there is no reason to use a DC-DC converter, and a simple linear regulator will suffice. Sure, it is only about 42% efficient, but since the microcontroller draws less than 50mW, wasting 70mW, it just isn't worth the components or the effort to do a full DC-DC converter, which tend to be pretty inefficient at such low currents anyway. A typical fan will draw about 1W = 1000mW, so the 7% waste is just not enough to worry about; your exact fan choice makes a way bigger difference anyway.(Before anyone comments on it: I am awarenowthat the detached schematic style is a bit difficult to read, and will do any modifications in a more connected style. We had a discussion thread about this recently here, and by poking other members about it, I learned why and how to do better.)

author: ahsrabrifat
author_rank: Regular Contributor
timestamp: September 17, 2025, 05:24:14 pm
content: Use a pull-up to the MCU supply (3.3 V). That’s the right method for open-collector tach outputs. Combine the pull-up with a series resistor + clamp (Schottky to 3.3 V or small TVS / diode clamp) to protect the MCU if the fan ever tries to drive the line above Vcc. A voltage divider is not ideal for open-collector tach lines because you want a clean logic level and reliable pull-up to MCU Vcc.

author: Nominal Animal
author_rank: Super Contributor
timestamp: September 17, 2025, 05:48:40 pm
content: Quote from: ahsrabrifat on September 17, 2025, 05:24:14 pmExcept that the fan specifications have always assumed pull-ups to 5V to 12V. Whether 3.3V works, depends on the fan. Their circuitry is always cost-optimized, so it is not guaranteed to be an actual open collector output; it suffices it behaves like one when the external pull-up is to 5V to 12V, with maximum 5mA of current.An NX138AK in SOT-23 and two resistors in 0603 is easier, simpler, and more robust. No voltage dividers, no diodes, no risk; andallPC-compatible fans will work. And even if you accidentally stick a screwdriver shorting 12V to Tach, the microcontroller will not be damaged.

author: jibun no kage
author_rank: Newbie
timestamp: September 19, 2025, 07:02:46 pm
content: @ahsrabrifat and @Nominal Animal, thank you so much for replying. For now I am only thinking 3 pin fans, that is my specific need. I will tackle 4 pin fans in due course. Since I have ESP8266 and ESP32 SBCs on hand, planned to use these, was well as a couple of Raspberry Pi devices I have.@Nominal Animal, I believe I could use your single fan design board right? Tell me if I have the following correct?ATtiny85 pins (ignoring SPI assignments):1 PB5/Reset2 PB3/3 PB4/Tach In4 GND5 PB0/PWM Out6 PB1/SDA7 PB2/SCL8 VCC 5vCan I not use 'ADJ' header to power the SBC, Pi, etc. As long as my 12v source has sufficient Amp capacity, say 12v 4a, would even power ESP8266, ESP32, even up to a Pi 4 for example, but for a Pi 5 I would need 5.1v 3a. Or I could use the ATtiny socket pins 8 and 4 to power the SBC/Pi (VCC/PWR and GND) if the not the ADJ header?I2C header is obvious, such match to i2c on SBCLooking at the board image, pin for Tach In, and PWM out? PB4 and PB0 respectively, so physical pins 3 and 5, right?Would there be an easy change to the board design to allow say 5.1v 3a, to allow Pi 5 use?

author: Nominal Animal
author_rank: Super Contributor
timestamp: September 19, 2025, 08:41:22 pm
content: Quote from: jibun no kage on September 19, 2025, 07:02:46 pmSure, it's trivial to modify my single fan design to ESP8266 or ESP32 or R'Pis.To simply monitor the tach, you need just one NX138AK or BSS138 N-channel logic level MOSFET (I recommend in SOT23 footprint), and two 10k resistors. See attached image.I assume you'll be using 3.3V, which is fine with NX138AK or BSS138; they will work just fine at least down to 2.5V CMOS logic. They are dirt cheap and very useful, so I tend to buy mine in strips of one hundred (under 4€ at Mouser, 5.40€ at Digikey, 2.5€ at LCSC).R1 is the pull-up resistor to your logic level voltage, and you connect your microcontroller tachometer input pin to TACH_IN. Note that it is inverted, so you will get two low pulses per rotation. The frequency is quite low, as at 1000 RPM you will get just about 33 pulses per second — RPM·2/60 = RPM/30 = Hz — so you can use a falling edge interrupt on that pin to increment the number of pulses received and update the high-resolution timestamp (cycle count) for the last pulse received. This makes measuring the actual speed simple: you count the number of pulsesNin some intervalT, recording also the time at which the initial and final pulses were received, and the average rate isT/(N-1). The -1 is because betweenNpulses, there areN-1 intervals, and it is the average interval between pulses you need to know to get the speed.R2 is the open collector pull-up to 12V. 4-pin and 3-pin fans only differ by the PWM input pin, and many motherboards actually support both in the same connector; you can find the originalIntel 4-wire PWM fan specification here. The currently used wire colors differ, and many implementations pull this to 5V instead of 12V. You can safely pull this to 5V, instead. (When you control the fan speed by adjusting the voltage, you can pull it to that voltage. I do believe some fans may have issues (very slow edges) when pulling this to below 5V. Anyway, using a transistor this way will protect your microcontroller even if you accidentally short the tachometer pin to 12V.)If you want to power a full Raspberry Pi (and not a Pico, i.e. RP2040 or RP2350), then I do recommend you use a DC-DC converter from 12V to 5V. It is important to check what happens if you connect the USB while powering it from 12V, though: you do not want the two supplies to fight each other, or Magic Smoke may espace. I personally like to use TI LM66200 on the VUSB and regulated 5V (from the 12V to 5V converter/regulator). It is an ideal diode summing chip, which uses the higher voltage one of the two inputs to power the output, but never allows the output to power either of the two inputs. It maxes out at 2.5A, though.Quote from: jibun no kage on September 19, 2025, 07:02:46 pmLet's say you have a 12V 2A DC wall wart. (These are common here where I live.) You could use something like aBel Power SRBA-06E2ALG moduleto convert to 5V at ~ 92% efficiency.TI Webenchdoes suggest a buck/step-down circuit using aTI LMR51450and a 15µH inductor (Coilcraft SER2915L-153KL) and a smattering of resistors and capacitors, claiming over 96% efficiency at 0.5A to 3A load at 5V output, but the PCB layout must be carefully done for this to work well. I'm just a hobbyist, and power supplies are my weakest point, so I often use an existing switchmode module instead, because even at 10€ apiece, they reduce the number of things that could go wrong in a new design.