MCU + ATX project, how to control fan speed? - Page 1
Forum section: electronics / beginners

author: sparkydog
author_rank: Regular Contributor
timestamp: July 06, 2023, 04:14:17 pm
content: I have a project that uses an ATX PSU to power an Arduino (Nano) MCU and some other stuff. It consumes at most ~350W, although most of that is dissipated outside the chassis.First question: is active cooling just stupid at these power levels (50W or less)?Assuming it isn't... I was thinking to slap a Noctua NF-A14 — or at least something 140mm — in there. (140mm is both for aesthetic reasons and because it should move air past the places I want air moved with the least fuss.) However, running the fan at full speed is almost certainly overkill (not to mention noisy). The fan (at least the Noctua) has a max power draw of ~1.6W. So... what's a good way to slow it down?I could run it on 5V instead of 12V, but I'm not sure if 5V is enough. Or I could run it off 12V but replace the ground with 5V? I've heard of this being done in days of yore, but it seems janky.I could drop the voltage with a bunch of diodes? (Seems not-ideal, and IIUC that's a fair bit of power that needs to be dissipated.)I can't use PWM off the Arduino, as it's at >10x the recommended frequency. Icouldspare either an analog pin or I2C bus to drive a proper fan PWM IC? This would give the most control, but is probably overkill.Pots are expensive, at least ones that would handle the fan's power directly. Alternatively, I could replicate a stand-alone PWM controller on my logic board. (This wouldn't be controlled by the MCU.)I could do what Noctua does and slap a resistor in line with the fan. Specifically, because I'm trying to minimize the wiring rats-nest, it would be on the board between the header and the power bus. The down side, of course, is I'd have no speed control short of resoldering a component.I'm inclined to go with the resistor option. I'll probably need to do some breadboard experiments to determine what value to use (my current guess is ~80Ω), but my concern is that this isn't a signal line. The fan can peak at almost 1.6W, though I'm not sure how to calculate the power the resistor needs to dissipate. Is a 2W resistor going to have enough safety margin for this application? (Is it overkill?) Is one of the other options simple enough I should be doing that instead?

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 06, 2023, 05:20:59 pm
content: Quote from: sparkydog on July 06, 2023, 04:14:17 pmWrong.Arduinos have no fixed PWM frequency, Nano included, and all are capable of producing the 25 kHz PWM you need. It is only the default PWM frequency that is way too low.(PWM outputs are generated by timer peripherals, which work independently of the actual core. The timer has two comparator values: one that resets the timer and the output signal, and another that just changes the output signal. The timer works off of some internal clock (clock sources vary depending on the exact microcontroller), typically using a power-of-two divider. By setting the divider low enough, and the upper comparator to a suitable value, you can get very close to 25 kHz PWM frequency, although anything between 21 kHz and 28 kHz should be acceptable. You then set the other comparator value to a value between 0 and the upper comparator, to set the PWM duty cycle between 0%+(one PWM clock cycle) and 100%.)To drive any standard 12V PWM 4-pin fan (seeIntel specs for these fans, definitely covers Noctua NF-A14 PWM), you need two N-channel MOSFETs (I recommend NXP NX138AK), two pull-up resistors of say 10 kOhm (one goes to 12V, and the other to 3.3V or 5V, depending on what I/O voltage levels your microcontroller uses), and one current-inrush-limiting resistor, say 470 Ohm, to protect your MCU I/O pin from having to try supply a too-high current spike.470 Ohms limits 3.3 V to 7 mA, and 5 V to 11 mA.Edited to add: It also makes the MOSFET switch slower. Typical values used vary between 22 and 470 ohms. My simulations indicate NX138AK switch fast enough even with a 1 kOhm resistor. That, and the fact that it can handle Vds up to 60V and Vgs to ±20V (datasheet), making the below schematic very robust and safe, plus its availability and price in hand-solderable SOT-23-3 footprint, is why I recommended it. Also note that the inrush is just a very short spike for a microsecond or two, and only occurs because the MOSFET gate has capacitance.Note that this does invert the signals from what the fan sees (or the spec says about polarity). The Tach signal yields two pulses per revolution, so for example 1500 RPM yields a 50 Hz pulse train; I recommend using a leading or trailing edge interrupt to measure the fan RPM.Quote from: sparkydog on July 06, 2023, 04:14:17 pmNo, LNA and ULNA adapters aren't resistors, they have silicon diodes in series to drop the voltage of 3-pin voltage-controlled 12V fans. Since each diode only drops about 0.7V, and the fan draws about 0.11A, each diode generates only about 77mW of waste heat.If the Noctua 4-pin PWM fan comes with LNA and ULNA adapters, then that fan can be controlled either by PWM, or by the supply voltage (typically 8-12 V, but note that lowest operational voltage is lower than minimum startup voltage). NF-A14 PWM can be slightly slowed by the LNA adapter, so most likely the valid supply voltage must be between 10-12 V.PWM control is the better approach, because in the absense of MCU PWM pulses, the fan defaults to full speed; and during startup, the fan does need to get a kick to make sure it starts turning. Besides, you can then use e.g. digital temperature sensors to measure the power supply internal temperature, to determine when and how fast the fan should be blowing.Moreover, if you control the RPM of the fan, instead of the voltage or PWM (meaning, you adjust the PWM until the RPM is in your target zone), you ensure that the fan airflow stays constant as the fan ages, even though the PWM will slowly creep upwards as the bearings slowly deteriorate or the fan blades accumulate dust.

author: sparkydog
author_rank: Regular Contributor
timestamp: July 10, 2023, 07:26:39 pm
content: Quote from: Nominal Animal on July 06, 2023, 05:20:59 pmCitation needed. There are dozens (if not hundreds) of claims that the LNA adapters are just inline resistors, as well as non-Noctua "LNA"s that are visibly just that, and eventutorials on how to make your ownadjustablespeed controller. Yours is the only claim I've ever encountered, or can find, that it's done with diode(s).Quote from: Nominal Animal on July 06, 2023, 05:20:59 pmSure, but I have other applications that don't have a handy MCU. I also have a rather pointed preference for adding a single component and no software over adding a half dozen components and the need for the MCU to process another half dozen inputs (tach and the multiple temperature sensors I'd need to make any meaningful use thereof). A 2-3 component PWM solution that doesn't depend on an MCU might be viable, but since I'm really just looking to movesomeair, quietly...Thanks for the info on Arduino PWM, though.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 10, 2023, 09:02:23 pm
content: Quote from: sparkydog on July 10, 2023, 07:26:39 pmI have about half a dozen of both L.N.A and U.L.N.A 3-pin adapters from Noctua (ages vary, oldest are fifteen years old), and I measured them: they're diodes, not resistors. At the very low diode test current (I used Aneng AN8008 for this), L.N.A drops 0.083 V, and U.L.N.A 0.123 V (I think two in series, based on the lumpy heatshrink). The fan are typically around 100 mA, at which current the diode drop is significantly higher.The resistor-based droppers have never worked well for me, because I've always used good motherboards that supply plenty of current for the fans. Even the voltage divider potentiometer ones are utter crap, because they get so darned hot. One NoiseBlocker fan came with a simple variable resistor (a potentiometer with one end and wiper in series with the 12 V), and that failed to affect the fan speed at all. It might work on some crappy Asus gamer motherboard that limits the per-fan current to 250mA, but not on better motherboards.(Edited to add: Of course, the idea behind the series resistors is the same as with diodes: given the current to the fan is roughly constant,I, the voltage drop over the dropper resistor with resistanceRisU=RI, generatingRI² of waste heat.)I've built quite a few computers, both desktops and rack servers (HPC computing clusters, actually). I like to build my own cases – not the showy ones with lots of LEDs, the ones that hide in furniture and are utterly quiet. On a typical desktop build, because I prefer to use Linux, I tend to use a separate fan control unit with thermal sensors (Akasa AK-FC for just three fans, various Lamptron controllers for fans and temperature).Quote from: sparkydog on July 10, 2023, 07:26:39 pmSo? You can find hundreds if not thousands of claims that world leaders are alien lizards. I don't care what others claim, I go by what can be verified.And the L.N.A and U.L.N.A adapters I have for 3-pin fans are just diodes in series in the 12V line.Would a picture of the measurement be sufficient proof?Or how about you measure your own, to actually find out, eh?Quote from: sparkydog on July 10, 2023, 07:26:39 pmHow about a standalone 4-pin PWM controller, like say Noctua NA-FC1? It's good, reliable, but pricey.There are lots of 555-based standalone controllers, where a potentiometer controls the duty cycle of the 25 kHz open-collector PWM output. The cheapest ones at eBay I see don't have open collector outputs, though, so I wouldn't consider those. (If you use ICM7555 for the '555,hereis an example standalone circuit you can use. Just note that the PWM frequency must be 25 kHz (24-26 kHz is fine, technically anything between 21 and 29 kHz should work), as the ones designed for hobby servos have much lower PWM frequency, 40 - 200 Hz, and will not work.)I just prefer the MCU approach, say ATtiny85 (even a Digispark clone, so one can program it directly on the USB port if needed, without any separate programmer), since with the same number of components, it can also read digital temperature sensors like DS18B20's.

author: sparkydog
author_rank: Regular Contributor
timestamp: July 11, 2023, 07:55:37 pm
content: Quote from: Nominal Animal on July 10, 2023, 09:02:23 pmIt would have to be quite a bit higher. If you told me the ULNA was dropping 4V in operation, I might buy that. I doubt you'd be able to tell the difference between running a fan at 11.9V vs. 12V.Quote from: Nominal Animal on July 10, 2023, 09:02:23 pmLike you said, pricey... and somewhat on the large side, especially compared to just sticking a resistor/diode(s) on the PCB next to the fan header.Quote from: Nominal Animal on July 10, 2023, 09:02:23 pmSomething like the TC649B is more in line with what I'm looking for, although that still requires a number of additional components to use. Given an ATtinyX5 is the same form factor, thatcouldbe better in terms of board space, and even in terms of features. One problem, though; I don't suppose you have a fan controller program you're willing to share?On a related note (and back to my "I just want some airflow" point), I haven't a clue how I would even go about incorporating temperature data. I don't expect load to change much, so ideally a temperature-controlled system would find a steady state and sit in it without the fan(s) ramping up and down. I haven't a clue how you'd go about coding for that, however, without plenty of trial and error.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 12, 2023, 03:55:36 am
content: Quote from: sparkydog on July 11, 2023, 07:55:37 pmYou do know the shape of a diode V-I curve? And how if you measure a diode at microamp currents, you don't reach the nominal forward voltage?If I had a programmable constant current load, I would have used it at 50-150mA, and measured the voltage drop from 12V constant voltage source over the adapter, at a couple of different currents. I don't; I know I should get one. I also only have a single programmable power supply, a Gophert NPS-1601.When you use a resistive dropper, the voltage drop isRI, i.e. highly dependent on the current.At typical fan currents, say 50-150 mA, you're in the near-vertical portion of the diode V-I curve, and the diode drop varies very little.It means that although both a resistor and a diode turn the extra power into heat, a diode gives more stable results, especially when the fans age, bearing resistance increases, and so on.So, if you tune your fans so that they provide sufficient coolingnow, if you use resistive droppers, they tend to slow down as they age, increasing internal temperatures. No good for me. With diode droppers, the voltage drop is basically constant, and since these are voltage-controlled fans, their speed stays much more stable for years.Of course, temperature-controlled fans are even better, except then the placement of the temp sensor is critical, and you need turbulent airflow inside the enclosure so that you don't get laminar airflow with "hot pockets". A very good alternative is a PWM controller that tracks the tachometer result instead: that is utterly stable across the entire fan lifetime.Quote from: sparkydog on July 11, 2023, 07:55:37 pmLet me think about it for a day or two. (If I decide to do it, it will be in Public Domain, so you can do whatever you like with it.)It might be a fun exercise to use an ATtiny10 (SOT-23-6, under 0.5 USD/UKP/EUR at Mouser in singles) for a 25 kHz PWM generator.One input pin is a ratiometric analog input, i.e. a wiper from a say 10k linear potentiometer in voltage divider configuration from the 5V supply, and the other is the PWM output. Only two additional components are needed: a bypass capacitor for the ATtiny10, and an N-channel MOSFET like NX138AKR for the PWM output. The entire circuit uses less than 10mA at 5V, and can be made pretty damned small, so maybe add a 3-pin 12V-to-5V regulator and input bypass cap.Since the ATtiny10 has a PWM-capable timer and an ADC, this would be very straightforward: read and filter the ADC, and update the PWM every now and then (if necessary). Most code would be to set up the ADC and the timer.If you add another NX138AKR and a pull-up resistor to 12V, it could be programmed to control the RPM and not the duty cycle, which would make it very useful for myself. At programming time, there would be two constants to set: minimum and maximum RPM of the fan, corresponding to the full pot range. With just 1k of Flash, this would be a challenge, though; maybe using the main loop to measure the tachometer pulse interval? Interesting. At 500 to 2500 RPM, the pulse rate is 16.7 to 83.3 Hz: two pulses per rotation. At 12 MHz, that is 720000 to 144000 cycles between consecutive rising or falling edges, so very doable, I think.In addition to VCC and GND, AVRs /RESET pin is a bit wonky, so I prefer to not use it, leaving just three fully usable I/O pins in SOT-23-6.ATtiny10 uses TPI, using the /RESET, TPICLK, and TPIDATA pins at 5V logic. So, you do need an external programmer,USBaspor a clone; just make sure the firmware is the newest one (2011-05-28!) so it supports TPI. Many of the clones' firmware can be updated, but it is an additional hurdle. The programming software isavrdude(included in both Arduino and PlatformIO), and it has a nice Windows GUI interface calledAVRDUDESS, so no command-line fiddling if you have a premade firmware.Quote from: sparkydog on July 11, 2023, 07:55:37 pmA linear ramp suffices. You choose a temperature, at which the fan turns on at 30% PWM duty cycle. (The specpromises that at this PWM, the fan will turn on.)Then, you choose a temperature at which the fan PWM duty cycle reaches 100%. Between those two extremes, the PWM varies linearly based on the temperature.The two temperatures are chosen based on the design; 25°C or 30°C is extremely common as the lower limit. (I've only seen higher in quiet power supplies, where otherwise the fan would be "pulsed on", stay on a few tens of seconds, then stop for a minute, then stay on a few tens of seconds again, and so on.)The upper limit depends on the steady-state temperature when the fan is going at full blast. Typically the upper temperature is somewhat lower, so that if the temperature increase is slow, it tends to a lower steady-state temperature.That said: as an end user, I personally might prefer just a discreetly placed potentiometer to set it to a constant airflow (fan RPM), that suitsmyneeds.So, consider the temperature sensor just an idea you could use if you had the need for one.

author: sparkydog
author_rank: Regular Contributor
timestamp: July 12, 2023, 05:30:15 pm
content: Quote from: Nominal Animal on July 12, 2023, 03:55:36 amYeah. The design I have penciled at the moment includes ("ENABLE") an SSR¹ to cut power to the fan in case of fault (so as to try to not burn it out if it gets stuck), another line ("GOOD") to signal an irrecoverable failure that triggers the whole thing to shut down, plus "PWM" and "TACH" for the fan itself. That's four pins... and I was also trying to avoid touching the RESET pin. 🙂 Hence, I'd definitely lean toward an ATtinyX5. That also gives up to 8kb for programming, but trivial to swap to a smaller chip if not all of that is needed.(¹ ...although, should I just use a BS170²? I was feeling a little twitchy about the 500 mA max current, but even an NF-A14 is only rated 130 mA max...)(² Would a BS170 suffice for the PWM/TACH transistors?)You pretty much hit the nail on the head with regard to temperature control being problematic. I'd probably go with a fixed RPM, hard-coded in the program memory but easily changed in the source.It's the PWM driving, especially tuning it to match a target RPM, that I really don't know where I'd start. Otherwise, the general form of the programIwould write would be:Startup:bring ENABLE high and PWM low. Wait for TACH to flip a few times. If it doesn't after some interval (say, 2-4s), go to fault state. Otherwise, bring GOOD high and go to run state.Run state:Magic here. (Adjust PWM to match target RPM. Feel free to specify target in revs/sec.) If TACH misses a few flips, go to fault state. (Tuning this is slightly ticklish, since a single missed pulse shouldn't be an immediate error, but you also don't want to let the fan be stuck too long.)Fault state:bring ENABLE low. If the back-off exceeds some threshold (say, 32s), bring GOOD low. Wait for the back-off interval (say, 2s initially), then double it. (Maybe stop doubling it at, say, 256s.) Go to Startup.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 13, 2023, 03:51:32 am
content: There is an another related thread about PWM fanshere nearby.Quote from: sparkydog on July 12, 2023, 05:30:15 pmFor the MCU, there are plenty of choices, of course; AVRs are nice in that tools like GCC (freestanding C/C++, Arduino, PlatformIO etc.) generate good code for them without resorting to AVR assembly. An additional wrinkle is that if you use themicronucleus bootloader, the firmware can be updated by bit-banging two I/O pins – although it is then better to run the AVR at 3.3V instead of 5V. Just note that some of the newer ATtinys differ from the older ones; I recommend sticking to the older ones if at all possible, simply for known robustness and toolchain support.Quote from: sparkydog on July 12, 2023, 05:30:15 pmI would definitely use a high-side switch (i.e., switch the fan 12V, and not the GND), because of the built-in circuitry in the fan. I think 250 mA is the absolute maximum current to allocate to a single fan; that's 3 watts. (Unless we're talking about 1U rack servers or air conditioning or something, that is.)Take a look atInfineon ITS4100S-SJ-N: turned on by a 5-34V voltage signal, typical 70mOhm on-state resistance.If the MCU runs at 5V, it can directly control the high-side switch. Otherwise you need a transistor or MOSFET, and at that point, it's probably easier to just use a P-channel enh MOSFET as a high-side switch.An additional wrinkle is that I personally would prefer the 12V to be switched ON, if the MCU dies. Without the PWM signal, the fan will then just blast at full speed. I prefer this failure mode to the fan being stopped if the MCU bugs out.However, theIntel spec for 4-wire PWM fansdoes require fans to have rotor lock protection and auto-restart, so I am not sure if this is needed – unless you want to be able to turn off the fan completely. Personally, I'd prefer a small indicator (3mm red LED?) to indicate fan failure.Quote from: sparkydog on July 12, 2023, 05:30:15 pmFor 5V logic, BS170 should be perfectly fine. For 3.3V (if using Micronucleus bootloader), I'm worried about the Vgs(th). Although the currents are tiny, under 8 mA (see the spec PDF linked above), at Vgs=3.3V a BS170 might not conduct sufficiently well to pull the signal low enough.If you have a spice model for the BS170 you intend to use, I can run a simulation; I only need to replace the NX138AK model I use now.I chose NX138, because it is much cheaper at Mouser, and it's Vgs(th) is so low it works fine even at Vgs=1.8V.But, if you already use BS170 in the board, it would make sense to use those instead.Quote from: sparkydog on July 12, 2023, 05:30:15 pmStart by reading the Intel fan spec linked to above, and treat your board as if it was a PC motherboard. That way all 4-pin PC PWM fans will work.Here's how I'd implement the magic:I measure the interval between consecutive rising (or falling) tach edges, with an upper limit to the interval. This gives a number describing the interval between consecutive tach pulses. At 3000 RPM, this occurs 100 times a second, so is suitable for even an interrupt, although it can also be implemented at the innermost loop in the firmware. If we pick a sensible minimum, say 300 RPM, then the maximum interval between tach pulses is 0.1 seconds.Optimally, I'd like to calculateconstant/interval(integer division) for each interval, and filter the resultxusing e.g.z' = Cx+ (1-C)z. However, we can also just filter the interval in a similar fashion, and only compute the division whenever a new PWM duty cycle is needed.Now, I haven't checked yet which filtering forms are most useful here (for example, because we want to err on the high RPM side), so I'd test a few schemes before choosing one. The linear one with constant C is one possibility, but not the only one. Another possibility is to maintain a target tachometer interval, and adjust PWM duty (at fixed intervals, a couple of times a second) by an amount that depends on the current difference between tach target and measured values.Both the interval and the result of the division are bounded (by the minimum and maximum RPM, scale/units depend on the constant and time units).The result between the valid interval is linearly scaled to the 30%..100% PWM duty cycle range.With a 12 MHz clock, each PWM period is 480 clock cycles, so using 1/2 prescaler, the duty cycle range is 72..239.With a 16 MHz clock, each PWM period is 640 clock cycles, so using 1/4 prescaler, the duty cycle range is 48..159.With a 20 MHz clock, each PWM period is 800 clock cycles, so using 1/4 prescaler, the duty cycle range is 60..199.0% and 100% are handled specially, by turning off the PWM output;bothcause the fan to go at full tilt, though.A couple of times a second, the actual PWM duty cycle is updated. The fan will not respond instantly to PWM changes, because it has rotational inertia. Taking a couple of seconds to reach full duty cycle is preferred over instantaneous change attempts.In this simple RPM-controlled case, the PWM output is handled by a timer peripheral, and the main code can revolve around measuring the low-frequency tachometer input, and only update the PWM duty cycle a couple of times a second. In particular, the code can wait (for up to 0.1s) for the next tach edge, and then wait another up to 0.1s for the next edge, getting a correct measurement of the interval between tach pulses, and then do whatever work it has to do (and possibly miss a tach edge here); there is no need to catch every single tach edge at all.Any over-logic (like startup pulse) can then be modeled as a state machine run only twice a second or so (and even then, not at very specific intervals).This should make the source code rather modular – in the sense that each of the above-described tasks is clearly delineated, not scattered about in the code – which definitely helps with maintainability (and can help reduce bugs).

author: sparkydog
author_rank: Regular Contributor
timestamp: July 13, 2023, 06:45:14 pm
content: Quote from: Nominal Animal on July 13, 2023, 03:51:32 amUm. Aside from 'so the fan is on if the MCU dies', do I reallyneedthat as opposed to just slapping a BS170 in there?That's a good point on the MCU dying, however, you'll recall I also mentioned a health signal. Icoulddrive a LED from that¹, but for at least one of my applications, I'm actually going to just shut the whole widget down if the controller hits "unrecoverable fault" state. Thus, since the whole thing only operates if the fan controller MCU is asserting HIGH on that line, I believe(?) the only way you'd get in trouble is if the MCU is workingincorrectly... and I'm not sure how I'd go about guarding againstthat. 🙂(¹ I was actually thinking of putting out a 25% duty cycle ~300 hz square wave and using that to drive a PC speaker, but same idea. 25% because I have two fans, and that should let me OR the signals — i.e. drive a pair of FETs in parallel, either of which would let voltage to the speaker — and still get an audible tone, regardless of phase or frequency drift.)Quote from: Nominal Animal on July 13, 2023, 03:51:32 amYup, good point. However IIUC, PWM to the fan needs to be 5V. In the application I had in mind when I started this thread, I do have a full-on ATX PSU. However, I'm now trying to design... well, more-or-less my own NA-FC1, albeit as a plug-in board. In some instances, that's requiring me to add 12V to 5V. I'd really prefer not adding a third voltage, so I'll stick with 5V for the MCU, thanks. 🙂Quote from: Nominal Animal on July 13, 2023, 03:51:32 amThe LTspice wiki hasthis. Or there'sthis. (Disclaimer: this is just what I found Googling; I have no idea if these are accurate, or if they even work.)Anyway, I'm attaching what I have currently for the board schematic. (The 41815-0004 is probably not permanent, but there will be some form of board-to-board connector there. BTW, is grounding the RESET pin correct?)And yes, I generally try to minimize how many different parts I'm using. That's also why I have 510 Ω resistors here instead of 470 Ω; if I understood you correctly, those should still be fine? (I notice, also, that it looks like Q1 could be swapped out for a G3VM-41AY1 without otherwise changing the schematic aside from one more ground connection...)

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 14, 2023, 08:54:57 am
content: Quote from: sparkydog on July 13, 2023, 06:45:14 pmHow do you use a BS170 as a high-side switch?Like I said, low-side switching – just switching the fan ground, instead of fan 12V – is problematic, because of the circuitry in the fan.When 12V is supplied, but GND is not connected, are you sure there is no current path to ground via the PWM and Tach signals?I suspect there might be such a path, which means low-side switching might be bad for the fan or the controller, due to unexpected currents through PWM and Tach signals when the low-side switch is not conducting. Also, I don't like the differences in ground potential between the controller and the fan; the fan might not pull the Tach line low enough (because its ground potential is higher) for the controller to detect the pulses reliably.But in general, if the fan is supposed to operate whenever the circuit has power, I do not see any need for fan power switch at all.Quote from: sparkydog on July 13, 2023, 06:45:14 pmYou could use a single microcontroller to control them both. It does not matter whether their target RPMs are the same or not.You need two I/O pins per fan, and the two RPM outputs can use the same timer (as long as it has two PWM channels).So, two fans only need four I/O pins.If you omit the fan power switch, and rely on therequiredfan built-in stall protection and auto-restart, you'd only need one more pin for the OK/FAULT signal; for 5 I/O pins, great match for most 8-pin AVRs.Quote from: sparkydog on July 13, 2023, 06:45:14 pmNo, the signal to the fan is open collector/open drain; the controller never pulls it up, only to ground. The fan internally pulls it to 3.3V or 5V. See the spec I linked.The fan provides the tachometer output, two pulses per rotation, as an open collector/open drain output. The spec promises that controllers pull it to 12V.If you use two N-MOSFETs per fan with sufficiently low Vgs(th) and sufficiently wide Vgs range (I prefer ±20V), the controller logic level is irrelevant to the fan.(One has gate to MCU PWM pin, source to ground, and drain to fan PWM; the other has gate to fan tach outputwith a pull-up resistor of at least 1kOhm to 12V (preferably weaker, 2.2k to 10k), source to ground, and drain to MCU input pinwith a pull-up resistor of at least 1kOhm to 12V; preferably weaker, 2.2k to 10k. See the maximum currents in the spec for these for details.)Essentially, the controller needs only two voltages: 12V for the fan supply, and whatever VCC it uses. The current budget at the VCC can be as low as 10mA, so a linear regulator from 12V to the VCC makes a lot of sense. I like to add a bit of headroom, but 50mA would already be plenty.Quote from: sparkydog on July 13, 2023, 06:45:14 pmYou forgot the attachment!The 470ohm resistor in my circuit example is only there to limit the MOSFET gate switching inrush current – the switching taking place within a microsecond, and is not continuous current draw at all. The resistor can even be omitted; I see 100ohm much more commonly used. With NX138AKR, I simulated various values up to 1kOhm and it worked absolutely fine for the 25 kHz PWM signal – actually, up to 500 kHz and more; I just stopped simulating at that point.

author: sparkydog
author_rank: Regular Contributor
timestamp: July 14, 2023, 09:29:55 pm
content: Quote from: Nominal Animal on July 14, 2023, 08:54:57 amIknowI didn'tforgetit. As to whathappenedto it... 🙄Well, anyway, it's been reworked a bit since, so... (Sub-circuit or FAN2 omitted, as it's identical to FAN1.)Quote from: Nominal Animal on July 14, 2023, 08:54:57 amUh... I dunno? It works in simulations? I'm a n00b! I know just about enough to want to play around, and not enough to keep the magic smoke where it's supposed to be.Quote from: sparkydog on July 13, 2023, 06:45:14 pmNo, the signal to the fan is open collector/open drain; the controller never pulls it up, only to ground. The fan internally pulls it to 3.3V or 5V. See the spec I linked.Hmm, right, and I know that from the schematic. And I don't put a lot of trust in where I saw that.Okay, here's a better excuse: IIUC, the MCU needs 5V to run at 20 MHz. 🙂 ...which I think I want, especially if I'm trying to drivetwofans instead of just one.Quote from: Nominal Animal on July 14, 2023, 08:54:57 amMCU pulled up to 12V? That doesn't sound right... maybe you missed a resistor? Anyway, please check my schematic; IthinkI both correctly copied what you showed previously and also understand what's happening that I believe I've done it right.Quote from: Nominal Animal on July 14, 2023, 08:54:57 amI was going to go buck, but... I guess this is a case of the waste heat a LVR dumps not being worth the complexity of a SMVR? I want to keep that off-board, however, since my original applicationdoeshave an ATX PSU, and thus already has 5V.Quote from: Nominal Animal on July 14, 2023, 08:54:57 amRight; do you think 510 Ω with a BS170 is fine? Or do I need higher (probably not if I understand you correctly) or lower? (Or omit R4 entirely?)

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 15, 2023, 06:25:18 am
content: Quote from: sparkydog on July 14, 2023, 09:29:55 pmWorks for meI did check the options in 8-legged AVRs at Mouser etc., and ATtiny85 is the best option (8k flash, 512 ram, timers, etc.).It does consume about 12mA when running at 20 MHz, a bit more than the even tinier AVRs. The current draw in the rest of the circuit is neglible (although we do have spikes in current draw when switching the PWM MOSFET gate; on average it is neglible).Quote from: sparkydog on July 14, 2023, 09:29:55 pmNo, I stuck it to the wrong place in the text: it is from the fan tach and mosfet gate to 12V. (Edited the post so I won't lead others astray too.)Quote from: sparkydog on July 14, 2023, 09:29:55 pmThe /RESET pin connection is not right: remember, it is active low, i.e. pulling it to ground for at least 2.5µs, resets the '85.It would be best to tie /RESET to VCC using a pull-up resistor, of between 2.2kΩ and 47kΩ, say 10kΩ.(Then, to add a reset button, just connect a normally open tactile button between /RESET and GND.)Note that this also means that if you add footprints for an N-MOSFET (BS170) with a weak pull-down resistor from gate to ground, with source to ground and drain to /RESET, and a pad for the gate, you can apply an external 2V - 20V voltage pulse to its gate to reset the ATtiny. Essentially, it acts just like the abovementioned reset button, with 2V-20V applied with enough current to overcome the pull-down resistor corresponding to pushing the button.This is not necessary in any way, but is something to consider if you suspect you might want to externally reset the microcontroller using a voltage signal. It is common to mark such future reservations that are not populated during normal assembly as DNP, Do Not Populate.The tach and PWM circuits look correct to me. Labeling the connector pins (top GND, 12V, Tach, PWM bottom) might help reviewing and checking the circuit.Quote from: sparkydog on July 14, 2023, 09:29:55 pmR4 (510Ω) limits the peak of the gate switching current to under 10mA, which is nice. If anything, you can go with a smaller resistor (100Ω is common), or even omit the resistor entirely, and just size the bypass capacitor for the microcontroller a bit bigger (perhaps 10µF in X7R), so the current draw on the 5V stays stable. The bypass capacitor then acts like a reservoir to smooth out such spikes. With a MLCC chip capacitor in 0805/1206 footprint, the single bypass capacitor works well.Using theBS170 model from LTwiki,Code:.model BS170 VDMOS VTO=1.824 RG=270 RS=1.572 RD=1.436 RB=.768 KP=.1233 Cgdmax=20p Cgdmin=3p CGS=28p Cjo=35p Rds=1.2E8 IS=5p Bv=60 Ibv=10u Tt=161.6n510Ω on the gate of the BS170 when controlled at 5V I/O works absolutely fine, according to my KiCAD ngspice simulation. The rise time of the PWM output depends on the pull-up inside the fan, but should not exceed a microsecond even with very weak fan-internal pull-ups.Just remember that on the microcontroller, the polarity is inverted (because the MOSFET inverts the logic here): when the output pin is LOW, PWM is high, vice versa. It is software-controllable, but can be a source of confusion if one forgets and the fan doesn't behave correctly.Quote from: sparkydog on July 14, 2023, 09:29:55 pmRight. Plus, many switchmode regulators have a minimum load, typically 10% of the rated load, under which they do not regulate the voltage well, and the voltage may even bedoublethe rated output voltage. One has to read the datasheets very, very carefully.If we estimate a generous 15mA current draw at 5V, a linear regulator will generate (12V-5V)×(0.015A) = 0.105W = 105mW of waste heat.That's the same amount as three blue LEDs driven at 12mA or so.I have a soldering fume hood project for which I already have a large activated charcoal HEPA filter and the tub, but no fans yet.While I do not need a HEALTH output, I do want an analog ratiometric input (i.e., potentiometer) to control the RPMs of the two fans.The only difference to your circuit and your use case is that in mine, the target RPM is adjusted per-fan (each fan has their own minimum and maximum RPM) according to the potentiometer. It, too, only needs to be sensed (or HEALTH state checked/generated) a couple of times each second, so it is only a small change in the circuit.So, I do believe I will be writing a firmware for the ATtiny85 for this, that should work for you too.My own development environment is Linux (as I don't have Windows), but aside from the development environment installation, there is no difference there.Do you prefer a bare-metal environment (plain Makefile and freestanding C/C++ source code), or e.g. PlatformIO?(Bare metal means no external libraries are needed/used (header files, "HAL", for ATtiny85, will be copied fromavr-libc, I think). To get a better idea on what that looks like, there aremany posts and articles on that on the web(Google search link). It is more future-proof than depending on a specific IDE or toolchain version, and in my opinion,easieron ATtinys. You can use whatever IDE you want to edit the source code, of course; you're just not tied to any specific one.)And, we seem to be in agreement about the ATtiny85 pin usage as well:PB0 (OC0A) and PB1 (OC0B) are best suited for the PWM outputs (as they are under timer 0).PB3 (PCINT3 or GPIO) and PB4 (PCINT4 or GPIO) are best suited for the Tach inputs, and PB2 for the HEALTH signal or analog input (ADC1).I'll post my schematic and board (KiCAD 7EasyEDA, because of my related design there) hopefully this weekend.Note that when programming ATtiny85, VCC, GND, /RESET, PB0, PB1, and PB2 are connected to the programmer. When using the gate inrush current limiting resistors on PB0 and PB1, and PB2 is not tied to ground or VCC (or you have a resistor on it, like I will have the wiper of a 10k linear pot), one can reprogram the '85 in-circuit, by connecting the programmer directly to the '85 pins (between the resistors and the '85).However, it may be easier to use an 8-pin socket and a DIP (through-hole) package, so one can remove and reprogram the '85 outside the circuit. It uses a bit more volume (above the board), but can be much easier than fiddling with tiny pin grabber programming probes.The header files will be licensed by their original licenses (modified BSD if avr-libc, meaning it can be used wherever one wants, as long as that license is included in both source and binary distributions), but as to code I write, I'm happy to consider any license, includingCC0-1.0. Personally, I'm leaning slightly towards GPL 3. Any opinion on the licensing?

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 16, 2023, 04:38:42 pm
content: I kept editing what was previously this post, so I deleted it and rewrote it.Here is my schematic for my ATtiny85 dual PWM 12V fan controller:I intend to power mine using a 5.5mm by 2.1mm barrel jack, center positive 12VDC supply. In case there is high-frequency noise in the supply, the ferrite bead will hopefully keep some of it out. The linear regulator has 1µF input and output bypass capacitors, but because the latter is also the ATtiny85 supply bypass cap, I kept it with the '85.If this circuit were to consume 25mA, the regulator would generate 175mW of waste heat. The TO-92 package will get about 7°C (13°F) hotter, and the junction will be about 38°C (68°F) hotter than ambient. This is all fine.I use a 10k pull-up on /RESET to 5V, so the ATtiny85 will run normally. One can just connect pins 1 and 4 (/RESET and GND) briefly to reset the '85.PWM output to each fan is an open drain, as specified in the Intel fan spec. I chose to use 220Ω resistors to limits the peak current (when switching the gate) to under 23mA, which is well within the ATtiny85 electrical limits.Tach signals from the fan are pulled to 12V, as required by the Intel fan spec. The spec says the fan open drain tach output should be able to sink 5-8mA, but I decided on a conservative 1.2mA; thus 10kΩ pull-up. The tachometer signal itself controls the MOSFET gate, and the open drain output is connected to the ATtiny85 input pin. I expect to use '85 internal pull-ups (20kΩ to 50kΩ), but I decided to add external pull-ups (R2, R4) I can use if the internal ones are too weak.Instead of a health output signal, I use PB2 as an analog input from a remote 10k linear potentiometer. It will be connected to the board using JST PH (2.0mm pitch) 3-pin connector – I wanted one that would not be confused with a 3-pin fan connector. To smooth out brush noise, the remote potentiometer can use a 100nF to 1µF capacitor between wiper and ground. Because the potentiometer is remote, I protect the '85 input using a 220Ω series resistor. It does not affect the ADC reading at the rates I intend to, and forms a low-pass filter with the capacitor to reduce any noise.There are two options for programming the ATtiny85. I intend to use the DIP variant, and put the ATtiny85 in a socket, so I can remove and easily reprogram it outside the circuit without having to unsolder anything. The second option is to detach the fans, the potentiometer (including the optional 0.1µF-1µF capacitor), and the DC supply, and use hook probes or an IC clip to reprogram the ATtiny85 in-circuit.

author: ebastler
author_rank: Super Contributor
timestamp: July 16, 2023, 05:28:33 pm
content: Quote from: sparkydog on July 06, 2023, 04:14:17 pmI didn't find it mentioned in the thread, but am curious: What is the "other stuff" you want to control, which consumes up to 350W at 5V and 12V? And where do the 50W come from which you need to cool away inside your enclosure -- mostly the efficiency losses of the PSU, I assume?Any chance you could change your design to use a load (motor? heater?) running off mains voltage, and use a more efficient control scheme which avoids the losses, and as a side effect avoids the need for internal cooling?

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 17, 2023, 01:26:12 pm
content: Quote from: Nominal Animal on July 15, 2023, 06:25:18 amOuch: I just realized something.To keep the fast PWM outputs of Timer0 between 23kHz and 27kHz, the OSCCAL has to be configured to between 5.9 MHz and 6.9 MHz, with optimum being 6.4 MHz, so the ATtiny85 will run at 12.8 MHz (10.8 MHz to 13.8 MHz, respectively).When OSCCAL is configured to 10 MHz, ATTiny85 can run at 20 MHz. Timer0 can only control two fans in fast PWM mode, and while that can support 19.5kHz (from 10MHz OSCCAL) it is too low for fans. Then, only Timer1 can be used for the PWM outputs: OC1A on PB1/pin6 and OC1B on PB4/pin3, TCCR1.CS1[3..0] set to 0b0101 to give 80/16=5 MHz clock, and OC1C set to 159 to get a 25kHz (or 173..147 for 23..27 kHz) PWM frequency.So, to control two fans, you either need to reduce the system clock, or change the pinout.The two possible SO-8/DIP-8 pinouts I'm considering are/RESET 1* *8 VCC /RESET 1* *8 VCCTACH2 2 *7 TACH1 ADJ 2 *7 TACH2PWM2 3 *6 PWM1 PWM2 3 *6 PWM1GND 4* *5 ADJ GND 4* *5 TACH1with the pins marked with an asterisk (*) needed for in-circuit programming.The left side one would be very symmetric, making routing easier; the right side would allow in-circuit programming regardless of what hangs off theADJpin. What matters is that pins 3 and 6 (OC1A/PB1/pin6 and OC1B/PB4/pin3) need to be the PWM outputs for Timer1, which can generate the 25kHz PWM (by using a suitable power of two divider with OC1C setting the period), adjustable to whatever the OSCCAL is set to. The four common values correspond to 6 MHz, 6.4 MHz, 8 MHz, and 10 MHz; OSCCAL values around 58, 72, 128, or 192, respectively. (See page 194, figure 22-42, in the datasheet.)

author: sparkydog
author_rank: Regular Contributor
timestamp: July 17, 2023, 05:32:31 pm
content: Quote from: ebastler on July 16, 2023, 05:28:33 pmInductors, mostly... and all stuff that wants 12V, so no, I can't see any way to run everything off of mains. I'd have to switch mains instead of 12V, and I'd have to obtain multiple 12V PSUs (rather than repurposing an ATX PSU I already have)andfigure out somewhere to physically shove them that's dispersed. Plus that would mean a bunch of mains wiring floating around places I'd as soonnothave mains wiring.Also some other control circuitry, (probably a Nano, some LEDs / LED displays), but those aren't the lion's share of the current draw. (In fact, I'mhopingto run most of that off of +5VSB, though I'm a little concerned how much power the display might draw.)That all said, I think I mentioned that active cooling may be excessive. (Note that I did say "50or less". 50W might be high by an order of magnitude. Besides the PSU itself,insidethe chassis I have a couple of MCUs and associated bits and bobs and a handful of relays. I don't have exact or even decently-rough numbers for how much this all is drawing, but I'm confident it could exceed 1W,won'texceed 50W, and isprobablycloser to the lower end of that. Note that "could" means "will, in some — but not necessarily all — operating conditions".)To be honest, I'm probably going to do it anyway out of a combination of paranoia, 'cool factor' / aesthetics, and as a learning experience. (Also, since this would be exhausting via the PSU, it should also be helping cool that, and if this means the PSU's own fan never needs to run, I'd consider that a win.)

author: wraper
author_rank: Unknown
timestamp: July 17, 2023, 05:42:04 pm
content: Completely stopping the PSU fan is not a great idea without verifying component temperatures with a thermal camera. There could be components which will heat up excessively even with no load, for example resistors providing minimum load for power rails.

author: sparkydog
author_rank: Regular Contributor
timestamp: July 17, 2023, 05:59:00 pm
content: (NA; I haven't had time to process everything you wrote. Thanks, though! Here are a couple quick replies...)Quote from: Nominal Animal on July 15, 2023, 06:25:18 amYeah, I used Wikipedia's ATtiny comparison chart and also concluded that a 5 seems best. You'll notice I'm not committing to the 85, though IIUC the only difference is the flash size, which should mean that, depending on how big the programming turns out to be, it's trivial to swap in whichever of those has sufficient storage.Quote from: Nominal Animal on July 15, 2023, 06:25:18 amHaha, Windows? I ran Windows 2000 once upon a very long time ago. In theory I have access to it via work, but I don't touch it for personal use. I've been running Fedora for a long, long time, and my NAS runs BSD.I have no idea what "PlatformIO" is, but using avr-libc is fine (that's even packaged). Personally I use KWrite/Kate/KDevelop or occasionally vim for editing. I'll probably end up using CMake as a build front-end, but I don't mind adapting from a Makefile. If it's easier for you to go the bare-metal route, that's fine. For my use, I'll probably rely on avr-libc being available and consume those headers externally.Quote from: Nominal Animal on July 15, 2023, 06:25:18 amNo strong ones; CC0 is obviously more convenient for other users, butIhave no issue with GPL. If I ever release the logic for this project (which would be running on a separate MCU on a separate PCB, so no conflicts with your license), or any of the loosely-related stuff I'm working on, I'd probably use GPL3.Quote from: Nominal Animal on July 16, 2023, 04:38:42 pmOddly enough, I have exactly the same intention. 😁 Besides ease of programming (and being able to reprogram it post-deploymentwassomething I considered), it makes it easy to replace the chip if something unfortunate happens to the magic smoke.

author: sparkydog
author_rank: Regular Contributor
timestamp: July 17, 2023, 06:07:59 pm
content: Quote from: wraper on July 17, 2023, 05:42:04 pmI have no intention of monkeying with the PSU fan.However, many PSU's (especially higher-end / higher wattage) have a "silent" mode. I don't know whether that mode is triggered strictly by load, or whether it uses temperature sensors. If it's the latter, and if it happens there's enough airflow otherwise thatthe PSUnever decides it needs to run its fan... bonus. If not... 🤷 (Also, if the PSU never runs above the wattage at which it thinks it needs the fan, but gets some extra cooling anyway, well that's hardly terrible either.)Iamtrusting that the PSU knows when it needs to run its own fan and when it doesn't... as does everyone that uses 'silent' mode on any PSU that supports it.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 18, 2023, 05:50:34 pm
content: Attached is the schematic, board, and 3D rendering of the design I ended up with.The potentiometer connector is 3-pin JST PH-2.0mm. The two standoff holes are 2.54mm, for M2.5 nylon standoffs and screws (but will also work for #2-56 or #3-48 UNC screws). The DC barrel connector is for the 12VDC input: 5.5mm by 2.1mm, center positive; they're common here. All resistors and capacitors are 0805 size; resistor pads have smaller than standard gap so that 0603 size resistors also work fine. If the internal 20kΩ to 50kΩ pull-ups on the tach inputs do not suffice for some reason, there are spare pads on the backside for external pull-up resistors.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 19, 2023, 06:57:59 pm
content: I forgot to mention: The above project is athttps://oshwlab.com/nominalanimal/dual-12v-pwm-fan-attiny85-controller, and all files are in Public Domain.

author: sparkydog
author_rank: Regular Contributor
timestamp: July 21, 2023, 10:29:10 pm
content: Yay, I finally have a PCB!Yeah, it's all TH. Deal with it. 🙂I'm reasonably happy with how this turned out, but am I doing anything stupid? (In theory, I could drop Rx2, but it would be a challenge to make use of the space that would save, so... 🤷) Are C1/Rx3 (1µF / 100 Ω) okay, or do I need more R and/or C? (Fortunately, up to 10µF, and just about anything for R, are footprint-compatible.) Clearances are 0.5mm. As I expect to use this, it's going to need conformal coating, as there's absolutely no way I could possibly meet PG3 (1.05mm clearance). Traces are 1.0mm except for the 12V, and the ground plane between the board-to-board connector and fans (and when the same has to get past U1.4), which are 1.5mm.This is meant to connect to a 171856-0004, which Ibelievewill reject a standard fan connector. I'dwantedto make it possible to plug either a fan or this board into the male header, but couldn't figure out a way to make that work without either using an inordinate number of pins, or having a two-pin header that you could plug a fan into and possibly cause Bad Things to happen. Similarly, I don't think there's anything stopping this board from being plugged into a standard fan header with similar potential for magic smoke release. Oh, well. (I don't especially want to venture entirely out of KK-254 territory.)There's no mounting. For now, the hope is that this is small enough to just hang off the parent board's connector. If necessary, I can add a (single) mounting hole where the board label currently resides.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 22, 2023, 11:37:38 am
content: Quote from: sparkydog on July 21, 2023, 10:29:10 pmIn my opinion, that design should work well, and be robust against accidental stuff like accidentally shorting FANx_PWM or FANx_TACH to 12V.As others have mentioned (in other threads), many fans do have genuine open drain outputs, so for those, connecting the FANx_TACH directly to ATtiny85 pin with a suitable pull-up to logic voltage would suffice – even the internal pull-up might be sufficient. I personally cannot trust that, and do not have the practical experience to tell which fans (including Noctua ones!) do have those, so I consider the two FANx_TACH MOSFETs an useful robust safety measure, as opposed to absolutely required. I feel the need to emphasize this, so you too know the full picture.Quote from: sparkydog on July 21, 2023, 10:29:10 pmI ended up putting the spare pads on the bottom side myself, just in case they are needed. Whether you need to solder R12 and R22, we'll find out when we get the boards made and start programming the '85.Quote from: sparkydog on July 21, 2023, 10:29:10 pmI ended up defaulting to the same values. 100Ω limits the peak inrush current when MOSFET is switching to less than 50mA, but in practice it will be lower, and a very very short spike only. Absolute max rating is 40mA per pin, so Ibelieveit is safe, although 125Ω to 220Ω would guarantee safety.This is something I'm pondering myself: 100Ω or 220Ω?As to 1µF bypass, the typical value used is 0.1µF, so I'd characterise it as "plenty" here; and it is nice and close to the ATtiny85.A ferrite bead on the 5V input, between the connector and the bypass capacitor, might be useful in keeping out any really high-frequency (MHz and up) noise from the ATtiny85. It really depends on what kind of noise you have on the 5V rail, though. Ferrite beads have low resistance at DC – here, anything up to 1Ω should work well –, but increasing resistance at higher frequencies, the curve depending on the exact ferrite.Quote from: sparkydog on July 21, 2023, 10:29:10 pmDo consider that. For a single mounting hole, you could use a metal (brass) M2 or M2.5 standoffs (2.0 or 2.5mm through hole).Flapping in the breeze is never a good option, if you can avoid it.

author: sparkydog
author_rank: Regular Contributor
timestamp: July 26, 2023, 10:46:19 pm
content: Quote from: Nominal Animal on July 22, 2023, 11:37:38 amOkay, I think I'll use 200 Ω. I'm not using 100 Ω anywhere else (so far, at least), so there doesn't seem to be a strong reason to use those.Quote from: Nominal Animal on July 22, 2023, 11:37:38 amYeah, I'm not sure if I can squeeze one in or not, though. As to whether Ineedone, the plan is for the board's 5V is going to be fed either by an ATX PSU's 5V rail, or by an MC78L05ABP. In the first case, there are some LEDs and MOSFETs also on the 5V (and bunches of stuff on 5VSB; I don't know how isolated those are). In the latter, the male connector for this board is fed directly off the regulator with nothing else other than a second capacitor attached. The regulator itself is fed by either an IRM-10-12 (or, if I end up deciding that's too noisy for the other stuff I'm doing, a TDK equivalent) which is also feeding some other stuff, including the fans, which are probably the biggest contributors to EMI.I don't have any parts at this time to collect actual EMI measurements. I don't know how much noise is likely to be on an ATX PSU's 5V, especially with another MCU and some other stuff running off it, or how much noise an MC78L00 is likely to "let past". (The board that runs off ATX is notnearlyas space-constrained as the board with the MC78L00; it would be pretty simple to add an inductor only for that application if I can get away with omitting it from the other.)In any case, how does one go about selecting a bead? You indicated "up to 1Ω", but what (if anything) is a lower bound? IIRC, resistance isn't the only variable, either; other than brand preference and mounting type, how does one go about selecting an appropriate 1Ω bead?Quote from: Nominal Animal on July 22, 2023, 11:37:38 amYeah. Unfortunately, my usual (6-32) mounting hole doesn't fit. Yes, I could go smaller, but I need to figure out my case design first, as it's very space-constrained. (Or, more accurately, I'm trying make it as small as possible.) I might end up using some sort of plastic sled, and either a clip on the end, or actually using the side of the case to hold the board in place. So, while I agree with you (even before your comment), I have more design work to do before I'll know what I'm doing for mounting.Thanks again! Get any code running yet?

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 27, 2023, 01:21:20 am
content: Quote from: sparkydog on July 26, 2023, 10:46:19 pmLots of good – and short! – guides exist on the web.We run the ATtiny85 at 20 MHz max, which is only one fifth of the 100MHz frequency ferrite beads are characterized as (but fortunately the manufacturers I'd consider all provide frequency-impedance curves), so it is not very common to use a ferrite bead. If you see one in a design for 20 MHz MCU, it is either on the analog supply, or it uses the one supply as an analog input reference, so that the ferrite further reduces noise during ADC conversions.In this case, we want to impede any high-frequency noise close to the clock frequencies we use from entering our supply. (I use "impede", because the proper analysis here treats the supply line as a transmission line for any AC components. Most of that high frequency noise is not absorbed by the bead, but instead reflected back.) We don't do ADC or any analog domain stuff, and our signals are firmly under 30kHz, so it is definitely questionable whether one is even needed here.The TDK MPZ2012S102AT000 I specced for my project has about 600Ω impedance at 20 MHz, DC resistance of 0.15Ω, can handle 1A of current at up to 125°C/257°F, and costs 0.10€ in singles at Mouser; which has 870k+ in stock right now, indicating it is also a popular choice.My own hobbyist selection process was guided by advice from others, and looking at datasheets. Whether it makes a difference in practice is for experienced EEs to say; I definitely don't know for sure – I don't even have test equipment to analyse noise at 20 MHz! However, it just seems to me that 0.10€ in favour of adding one even when not needing it is infinitely better than not having it but needing it. ATX power supplies are funky things, and varya lotin the noise on their supply lines. In my design, the supply is from a 12V wall wart from 240Vac (RMS) mains, and as such is definitely a high-frequency switchmode supply, and these do tend to have some MHz-class noise.So, the ferrite bead in such a design is very much in the same realm as using a MOSFET as level shifter for each fan tach output, even though most fans ought to have true open drain or open collector outputs and just a pull-up to the logic voltage would suffice. Possibly not needed, but as these are one-offs for us hobbyists to use in not-necessarily-standard situations, I choose to add them to add peace of mind and robustness against weird tach inputs (including accidental shorts to 12V, which could easily burn the pin on the ATtiny85), costing only about 0.50€ per fan.Quote from: sparkydog on July 21, 2023, 10:29:10 pmNo, I don't even have bare ATtiny85s in my hands yet; the ones I have are in DigiSpark clones, running VUSB, making them unsuitable for this.Are you in a hurry?My timetable right now looks like 3-4 weeks before I can write the code (which itself won't take long, maybe a few hours over a week), as I'm saving on shipping and such using the cheaper but slower options, plus accumulating a larger shopping list before I buy the components I need for this and a couple of other projects from Mouser. I could get one '85 locally and dead-bug it (on its back, with wires directly to the MOSFETs and connectors, without a board) to write the code sooner, if you have a deadline or something and such a wait will stress you out.(I'm familiar with AVR, as I really like ATmega32u4 and AT90USB1286, especially because of their native USB support and my projects often involve interfacing to a computer or SBC. I already have the basic structure of the code in mind, although I do need to test whether I'll want to use interrupts or cycle-counting busy loops to measure the tachometer pulse intervals/frequency. I havelotsof experience writing code, so I do consider the software part the easy part here.)

author: sparkydog
author_rank: Regular Contributor
timestamp: July 27, 2023, 08:55:21 pm
content: Quote from: sparkydog on July 26, 2023, 10:46:19 pmOkay, I think I've got a better handle on this, now (thanks again!). Also... on closer inspection, I notice that if I want a TH component in production, it appears my options are:Laird 28L0138-10R-10 (45 Ω)Laird 28L0138-70R-10 (123 Ω)Laird 28C0236-0EW-10 605 Ω)Seriously, that'sit. I would have gone Murata, but they don't seem to make TH beads any more. So... what, if anything, do you know about Laird? 🙂The Ohm-values in the list are impedance at 25 Hz... notquite20 Hz, but as far as I can tell, the curves are fairly smooth (no surprise), so, while the impedance at 20 Hz will be a bit lower for all, the three parts can still be classified "low", "medium" and "high". The "high" is closest to the bead you mentioned, and IIUC, higher is better (given the DC resistance seems to be the same for all of them (10 mΩ), so I guess that one is "best"?(The only other active manufacturer appears to be Abracon, but their data sheets are conspicuously lacking impedance graphsand current ratings, which is very not-trust-inspiring.)Quote from: Nominal Animal on July 27, 2023, 01:21:20 amPlease don't rush on my account! You've already been tremendously helpful, and I don't want to impose....but also, no (I don't have components yet, either). I was just wondering; more of a conversational gambit than anything. 🙂

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 28, 2023, 12:15:41 am
content: Quote from: sparkydog on July 27, 2023, 08:55:21 pmThe datasheets show 46Ω, 120Ω, and 580Ω impedances at 20 MHz, respectively; with resistance components of 38Ω, 95Ω, and 480Ω, respectively; and all with 0.010Ω = 10mΩ DC resistance.I'm not sure if the two first ones would have any effect inthiscircuit, considering we don't do ADC, and just want to add that little bit of additional filtering just in case it would otherwise interfere with our digital logic (pulse edge detection from tach inputs, specifically).The last one seems eminently suitable for me, but the 0.65€ price in singles at Digikey makes me wonder if the additional "bracing" from a ferrite bead is worththat much. Remember, this was always about "extra" protection that to me costs 0.10€; and not a necessary component at all.Most ATtiny85 circuits do not have a ferrite bead at all.Thus: If the price does not matter to you, use the 28C0236-0EW-10. If the price matters even a little bit, I'd drop the ferrite bead and not worry about it; I would not use one if I had to pay 0.65€ (instead of 0.10€) for each one.Quote from: sparkydog on July 27, 2023, 08:55:21 pmI don't have enough experience to have an opinion on Laird. It was recently acquired by DuPont. I do know that the datasheets for these date back to before the turn of the century – but even then, had frequency-impedance graphs generated using HP test gear and fixtures, making me like them quite a bit. At least back then, they were proud of their product, and not shy about showing how the figures they claimed were measured (making it easy for anyone to replicate the results). As to having been split and sold since then, I do not know what it has done to their manufacturing, but hopefully nothing has changed much for these radial ferrite beads.Don't let my analytical communications style distract you from the fact that I, too, am only a hobbyist wrt. electronics; not an EE.Quote from: Nominal Animal on July 27, 2023, 01:21:20 amGood to hear!The following is some musing on the firmware implementation, just in case someone at some point might find my current notes interesting.I do intend to write and document the code so that even a non-programmer can gather a general understanding of how it works.The reason I need to test both the interrupt and iteration-counting approaches is that when using interrupts, if we receive a tach edge just before the timing timer wraps, our timing count can be short by exactly one full timer period, or 256 units. Ibelievethat by reading the timer count, then the overflow flag, and the timer count again, while interrupts are still disabled, we can determine the time reliably; but I haven't checked it in practice on ATtiny85 hardware yet. The actual timer value can be any size we need, as the low 8 bits are obtained from the timer, and the high bits are just the count of timer wraps, each wrap being an interrupt.The iteration counting approach involves a fixed-duration inner loop body, that checks both fan tach input states, increments a counter, and loops until sufficient number of iterations have occurred. In this way, the iteration duration is the "clock" we compare the fan tach pulses against. The downside is that it has to be written in AVR assembly, to ensure each iteration takes a fixed, known duration. It is also a much more "old-school" way of timing things precisely; with some having a serious distaste against such "busy-waiting" schemes (mostly because they arebadon systems where you have more stuff to do).In theory, both approaches work fine. The former is more complex in logic. The latter is simpler – just nested loops, no interrupts –, but the innermost measurement loop written in assembler would be a black box to most programmers.In practice, there is bound to be jitter in the tach pulses and other practical stuff I don't know yet, because I haven't done this before. Thus, the correct RPM reading cannot be just the inverse interval between successive rising edges of the tach signal; we need some kind of averaging. And this is where the two approaches do differ. The interrupt approach always timestamps the same edge of the tach signal, obtaining the duration of the last tach cycle; whereas the iteration counting loop can do a time-limited measurement (count both the number of cycles and total duration of those cycles, for a limited duration).The interrupt must be short, so that if the two tach pulses are in sync, the other is recognized soon enough that its timestamp is not too much later than was detected. Heck, since AVR has 32 8-bit general purpose registers, using GCC or Clang we could easily reserve some of these for the interrupts only, so that normal C code would not touch them, making the interrupts use only 2 bytes of stack per nesting level since no registers need to be saved, and reducing the interrupt latency.A particularly interesting approach I want to try out is to use separate handlers that do the timestamp at minimal latency, and then enable the interrupts, so that the other interrupt can interrupt the current one; then the averaging calculation done in the interrupt does not cause a latency in the tach transition timestamping, only in the main code. Which, admittedly, in the interrupt-based code would be just twiddling its proverbial thumbs waiting for something to happen, anyway. I could do the timestamping bit in inline assembly (it's just a few lines), enable interrupts, and jump to C code that does the interruptable averaging and stall detection part.In many ways, this reminds me of the time decades ago when I first learned 6502 assembly; happy times! Except now I have much better tools, and the AVR architecture with its many registers is much nicer than the stack-based 6502. Just my opinion, though! But ATTiny85 running at 20 MHz is more than an order of magnitude faster than the 1 MHz 6502 in C64 was... and for something like this, the very small amount of RAM we have on an ATTiny85 is not an issue: we don't have much state to keep track of, and call chains should be short (meaning we shouldn't need much stack either).

author: sparkydog
author_rank: Regular Contributor
timestamp: July 28, 2023, 06:09:23 pm
content: Quote from: Nominal Animal on July 28, 2023, 12:15:41 amIf I was price-conscious, I'd probably be using SMD everywhere possible. 🙂 I'm not making thousands of these, maybe just a handful, so the difference between 10¢ and 65¢ isn't terribly relevant, and I'm inclined to lean toward paranoia. That said... I just don'tanyway to get a TH bead on this board due to the size constraints, and due to the trace routing, I can't see how I'd manage even an SMD bead... unless I used two of them (one for U1, one for R13/R23).Oneof my parent boards (the one using an ATX PSU, which I haven't designed yet) shouldn't have a problem with a couple big TH beads (one for this board, one for my other MCU that's handling the UI and higher-level logic), but the only option I see for the other parent board is to slap an SMD on the back of my otherwise single-sided boards. Oh, well.I'm leaning toward a Murata BLM41PG102SN1 (35¢), though; similar impedance, lower DC resistance, and the larger size should actually be better for handling.Quote from: Nominal Animal on July 28, 2023, 12:15:41 amI agree there is almost certainly going to be jitter. If I were writing this, I'd probably be looking at the interrupt approach first, and I'd probably approach the averaging problem using a ring buffer. Each tach pulse interrupt computes the (8-bit? 16-bit?) interval, shoves it into the current ring slot, increments said slot, and zeros a counter. (IIRC, you can't pass data to an interrupt handler, which means each fan needs a different handler in order to know what fan its handling. If you're writing in C++, this strikes me as a job for a template function. 🙂 Make "which fan" the template parameter and let the compiler generate the two handlers from a single block of code.) Meanwhile, a timer interrupt increments the counter for each fan. If that counter exceeds some threshold, that fan has faulted. That interrupt should run at lower priority, since the only thing that might happen if it's slow or skipped is it takes a little longer to detect a fault. Note also there is no averaging done in the interrupt handler. For that matter, the tach interrupt handler only needs to mask interrupts long enough to compute the interval. If you can reserve registers for those intervals, you could unmask interrupts even before the interval gets written to the ring buffer. Then the only thing you'd have to do during the interrupts-masked period is compute the interval, and I don't see any way the handler could possibly do less than that.One caveat to keep in mind: the controller needs to start up in "startup" mode, in which it just sends 100% to the PWM until several tach pulses have been received. It also needs to revert to startup mode in case of a missed pulse. (For my case, I also want to somehow time how long we go without tach pulses in order to raise a fault if we go for, say 15-60s.)This will also help with knowing when to start trying to correctly throttle the fan. Whenever the fan starts up, fill the ring buffer with MAX_VALUE. While in startup mode, check if the buffer still contains any MAX_VALUE values; if not, switch to normal-running mode.

author: sparkydog
author_rank: Regular Contributor
timestamp: July 28, 2023, 10:56:19 pm
content: Quote from: sparkydog on July 28, 2023, 06:09:23 pmOkay, I had a crack at writing the code myself. 🙂 This is incomplete (and God only knows how many bugs it contains), as I don't know¹ how to do PWM or interrupts using only libavr, how to calculate the intervals between tach pulses, or how to handle potentiometer input. (Note: I'm assuming also that the interrupt should only trigger on one edge of the pulse. AFAIK the choice between rising and falling makes no difference.)(¹ Not saying I can't figure it out eventually, but I wanted to get this "out there" as a starting point. Though I'm not going to be touching the speed control, since I don't know what the input values look like, or how you want to map them.)I tried also to set this up so that the same code can be used witheitherspeed control or health reporting. It expects at most one ofENABLE_SPEEDorENABLE_HEALTHto be defined via-Dargument to the compiler, and will include or strip the relevant bits of code accordingly. You can also passDISABLE_FAN1to build firmware for only one fan (although this mostly only matters ifENABLE_HEALTHis defined). It also expectsTARGET_RPMifENABLE_SPEEDis not defined.Hopefully, the code is reasonably documented. You'll need to implementcompute_interval(only used ifENABLE_SPEEDis defined). Note that the minimum PWM is non-zero and intended to be "enough that the fans actually spin". There is no effort to support zero-RPM mode. The code would likely need refactoring to support that, in particular as I use0as a magic value for PWM to indicate a fan in startup mode (which means you might need to add a separate field for that to support zero-RPM). Also, the fan data structure is probably missing fields needed to compute the interval since last tach pulse.There might be a better way (albeit likely requiring an extra byte of data/state) to handle the PWM that gets closer to the target speed. The way I've implemented it, it won't increase (or decrease) the speed unless it's too low (or high) by some margin, which means in theory you'll never quite nail the target speed, but also it shouldn't "bounce" the PWM between "slightly too fast" and "slightly too slow". I think a better (but more complicated) approach would be to track the direction of adjustment, let it overshoot, but then don't allow further changes until we've gone some distance "out of spec". (Also, I just realized I need a way to rate-limit the PWM changes, but it's too late tonight to figure that out.)In theory, this should only need 32 bytes or less of global state, and the call stack should never get deeper than eight entries (including a guess at interrupts and whatever stack is beneathloop()).The.cextension is a lie because the forum doesn't allow C++ extensions.fastio.his a little (C++) library I wrote to wrap pin manipulation in a nice API, but in a way thatshouldreduce to the same AST as writing direct port manipulation in C. Whether the compiler can or will combine instructions is another question, but the places where that would even be relevant (only insetup(), I think) aren't on the critical path. It was originally written for ATmega, but IthinkI made the necessary change so it will work (correctly) on ATtiny also. If not, it should be pretty obvious replace it with bare port manipulation. Don't let the C++ scare you into worrying this is going to generate enormous and/or inefficient code; almost everything that isn't straight C is constexpr and/or template goodness to allow writing "pretty" (and readable!) code that probably would have been preprocessor mess in C.Permission is granted to use thee according to the terms ofGPLv3. Let me know if that doesn't work for you.

author: sparkydog
author_rank: Regular Contributor
timestamp: August 04, 2023, 06:55:28 pm
content: Okay, after the recentmoaning and complainingabout how THT components are going to cease to exist Any Day Now™, I had a go at reworking this as an SMD board.WDYT?It's... passable, I suppose, though I don't love how I had to run the 12V, or the short trace on the back that interrupts the ground plane. (Hopefully because it's just an elongated hole, and not a split, it shouldn't be too bad in terms of creating large ground loops?) It's also the same height as the old (all-THT) board, and only slightly less wide. Some of that is because I'm using larger components and (especially) larger traces, but I actually have a physical constraint as to howsmallI can make it... one of the assemblies that's going to use this has it sitting right next to an encased PSU, and the fan headers need to be far enough from T1 to clear that. (But it also can't be anytallerbecause of the case it needs to fit inside.) The fan headers arejustabove the top of the PSU.On the plus side, Ididmanage to shove a ferrite bead (BLM41PG102SN1) on here. Since that's the only schematic change (besides different part numbers, of course), I'm not re-uploading the schematic. C1 is as far as I can tell the same component (TDK's THT MLCC caps are literally SMD caps potted and with leads soldered on; the SMD component I penciled in is my best guess at what the THT version has inside the potting), the transistors are MMBF170s (so, exactly the SMD versions of the BS170s; they even use the same data sheet), and... well, resistors are resistors, although Iamusing 500 mW CRGH1206s. (Overkill for this case, but the idea is to only deal with one type of resistor, and I may want that rating elsewhere. Also, they're as close to equivalent to the LR1s as I could find.)There continue to be no mounting holes; I just don't see any way I could add any. Idohowever have an idea for a plastic carrier the board would slide and clip into. (One of the things I've been working on is designing the enclosure for this and the parent board.) Due to vertical constraints, however, I'm probably going to be nasty and have the clips "attach" to the sides of the fan headers, rather than the top of the board.I think I'm going to relabel this (and tweak the firmware) to switch the two fan identifiers, so that FAN1 has the shorter 12V trace. That's mostly cosmetic, though.

author: Nominal Animal
author_rank: Super Contributor
timestamp: August 05, 2023, 04:18:52 am
content: Quote from: sparkydog on August 04, 2023, 06:55:28 pmI like it. I'd even make the 12V snake a bit more, so you can get the mounting hole on the lower left corner.For board side clips, consider making the board a mm or so narrower at that point, so the board will stay put.Because the 12V supply voltage is relatively stable, and if you intend to use high-power fans (more than say five watts per fan) then you better solder additional 12V wires directly from the input pins to the fan power pins, I see no reason to worry about the 12V line snaking a bit.In general, a 1mm wide, 100mm (4") long trace on 1oz copper PCB will carry 1A of current, get 7°C hotter than ambient, and drop about 0.05 volts.At 2A, it will get 32°C hotter than ambient, and drop about 0.11 volts. So, I use the 1A per 1mm wide 100mm long trace as a basic guide myself.The routing on mine is much more convoluted, because I wanted it narrow (15.2mm), maybe even mountable inside 20mm tube (20mm electrical PVC tubing, JM 20, is cheap and easily available here).Again, I'm just a hobbyist like yourself, so if anyone with actual PCB design experience would care to comment this andmine too, we'd be grateful

author: sparkydog
author_rank: Regular Contributor
timestamp: August 07, 2023, 04:25:50 pm
content: Quote from: Nominal Animal on August 05, 2023, 04:18:52 amHehe. I'm resisting making the board not-a-rectangle. Largely because it's arectangleright now, i.e. not four line segments, which is a lot easier to edit.Besides that the mounting holesIuse at least are... quite large¹ (12.5mm including clearance), a hole there, in at least one of my applications, would be nigh inaccessible. (The encased PSU on the parent board would block it. Ihavechecked, though, that the boards should go together without collisions, and the headers should be easily accessible.) So I'll probably stick with some sort of rails/clips system. Idointend to have 'tabs' on the clips that will either overhang the top of the board, or (as previously mentioned) the top of the fan headers, so the board won't be able to just slide out.(¹ Meant for 6-32 screws, i.e. "standard PC motherboard screws", with plenty of space between the screw head and any components or traces. Yes, Icoulduse smaller screws and less clearance, but that doesn't solve the accessibility problem. I also don't want structural holes too close to the edge of the board, for obvious reasons, and TBH that 12.5 mm "clearance" is as much a reminder not to put the holes too close to the edge.)Quote from: Nominal Animal on August 05, 2023, 04:18:52 amOy;five watts? Are you planning on server-grade / industrial fans? 🙂I don't intend for this to ever see more than ~3.5 W TBP, and realistically, the highestfans-onlydraw I have intended is 1.56 W. (Single NF-A14. My other applications uses dual NF-A4x20's which are ~1.2 W combined.) The totalnetlength of the 12V is about 65 mm, which includes the trace from FAN2 to R21 (that's the tach pull-up resistor across FAN2.2 and FAN2.3, just below FAN2), so the trace for the fans themselves is a little less than that... and that trace is 1.5mm,andhalf the current only has maybe 40mm to travel. Since I don't anticipate more than ~0.3 A, I think I'm probably fine in terms of capacity. 🙂Sure, I'm using a 10 W PSU, but IIRC that's because I figure it's safer to have more capacity than I need, and the 5 W PSU is the same form factor and almost the same price. I believe my peak draw from that is ~3 W. My other application (the one using an ATX PSU) is higher, but... it's using an ATX PSU, which is going to be something like 300 Wminimumand more likely 1200 W. (Which is severe overkill, but it's a PSU I have sitting around not being used for anything else. OTOH, it's a Rosewill, which iswhyit isn't being used, so I'm just as happy to not be asking too much of it.)Anyway, thanks again!p.s. Was my attempt at writing software of any help? I'm quite lost on how to do anything PWM-related, and what reading I've done so far hasn't helped, but hopefully the other logic is at least useful as a point of inspiration?p.p.s. Let me know if you'd be interested in seeing this "in situ", either in my case mock-up or next to the parent board.

author: Nominal Animal
author_rank: Super Contributor
timestamp: August 09, 2023, 06:47:18 am
content: Quote from: sparkydog on August 07, 2023, 04:25:50 pmI have some nylon M2.5 stand-offs left from a Suleve M2.5NH2 kit I got for under 4€ from Banggood three years back, and they arenice. Pity the kit is no longer available. Brass ones are available here (but obviously more expensive), but one kinda-sorta needs to use nylon washers with them to keep from chewing the board (silkscreen and relatively thin 1oz copper) up.My boards should be arriving within a week or so. Being cheap (poor), I used the EuroPacket shipping option, and according to tracking, they're in Europe already.Quote from: sparkydog on August 07, 2023, 04:25:50 pmNot myself, but Incognito might (specifically,Noctual IndustrialPPC fans).Quote from: sparkydog on August 07, 2023, 04:25:50 pmWith Timer1, ATtiny85 should have no issues generating the two PWM signals at around 25 kHz.Other than testing whether to use interrupts or loop iteration counting for the tachometer inputs, there shouldn't be any sticky points at all.I worry much more about properly commenting and documenting the code, really!Thatpart is the hardest to getright.Quote from: sparkydog on August 07, 2023, 04:25:50 pmAlways! Theory is one thing, but practice rules.

author: sparkydog
author_rank: Regular Contributor
timestamp: August 09, 2023, 04:33:07 pm
content: Quote from: Nominal Animal on August 09, 2023, 06:47:18 am...even castellated PTHs? Though I would have thought only the screw heads would be a problem; are you attaching these in a way that the standoffs are rotating against the PCB? Anyway, I generally avoidanythingnear my mounting holes unless they're castellated PTH tied to an earth plane. No copper, no silkscreen, just the FR4 and soldermask.Quote from: Nominal Animal on August 09, 2023, 06:47:18 amThose are still only 5 Wcombined; TBP ~0.5 A. I'd think 1.5 mm × 1 oz traces would still be okay for that without needing to beef them up? (Mineare 1.5 mm. I'm not sure about yours, but comparing to the fan header PTHs, it looks like you must be using the same size, or very nearly so? BTW, what EDA do you use? I notice you have a lot of thermal spokes that don't go anywhere. I also noticedoneof your fan headers' ground pin has wider spokes on both sides, but the other on only one side; was that intentional? Also, now that I'm looking more closely at it, I'm not sure it's a good idea to tie your negative to earth?)Quote from: Nominal Animal on August 09, 2023, 06:47:18 amHere you go! I added an 8-dip model on top of the socket to make sure that wasn't going to be a problem, but I've actually got quite a bit ofverticalclearance.Horizontally, now, the MCU/socket is almost touching the parent board (male) header, but thatshouldline up with the end of the daughter board (female) header, so should be okay. The fan headers actually have a bit more clearance than I was expecting (probably because I didn't try to account for the extra offset of the male header), which is good. You can also see the 5V regulator setup (TO-92 and caps) on the parent board, which are plenty short of the header height and thus well clear of the MCU sticking out. And, of course, that great big PSU case is hard to miss, so you can see what I needed to dodge, and why a mounting hole in the bottom corner would be awkward to access.I don't have the case mock-up on this machine, so I'll have to post that later.

author: Nominal Animal
author_rank: Super Contributor
timestamp: August 09, 2023, 05:20:49 pm
content: Quote from: sparkydog on August 09, 2023, 04:33:07 pmYep, the screw heads. I just tend to have to assemble and reassemble the board a few times, so even a small burr or defect on the bottom side of a steel screw head will leave nasty marks. Mostly, I'm afraid that when tightened too hard, unscrewing will take some of the 1oz copper with the screw, unless you have a nylon washer between the screw head and the PCB.Quote from: sparkydog on August 09, 2023, 04:33:07 pmYup. Mostly my power traces are 1.7mm wide; plus 0.6mm wide in a couple of places (only a few mm in total) around the ITS41 power switch IC, which is limited to 2A anyway.Quote from: sparkydog on August 09, 2023, 04:33:07 pmEasyEDA, I'm still switching to KiCAD 7.Quote from: sparkydog on August 09, 2023, 04:33:07 pmNah, that was just a side effect of me ensuring I have a wide enough ground trace, by manually pulling a trace under the copper ground fill.Remember, it is not sufficient for the +V side to have a wide enough trace; your return path needs the same.Quote from: sparkydog on August 09, 2023, 04:33:07 pmThere is no earth/ground aside from the zero reference potential ("negative"), in either of my boards. All voltages are ≥ 0V with respect to that. (Consider it the same as the black leads off your ATX power supply.)On the 19V fan adapter, the host fan negative side must match the potential of the 19V negative side, or the adapter will not work, so they're connected together to make sure. Again, there is no protective ground or anything like that, just the common zero-reference potential. In this one, the plated rings around the mounting holes are not connected to ground.The DC input on the dual fan controller is just a DC barrel connector, with two contacts only. (The third contact is only a switch connecting to ground whenever a barrel jack is inserted, it is not a separate conductor. There is also no shield or protective earth/ground or anything like that.)I did leave the zero reference potential planes on both sides of the board close to the mounting holes. We can argue whether I should have pulled the copper, or made a non-connected ring of copper around the mounting hole, but as I specifically intended to use nylon M2.5 standoffs with this one (if the mounting holes are used at all), I left it like this. In fact, I will be experimenting with rigid PVC 20mm electrical tubing used hereabouts (JM 20, cheap!) to see if I can make a tube "enclosure" for these.

author: sparkydog
author_rank: Regular Contributor
timestamp: August 09, 2023, 09:59:11 pm
content: Quote from: Nominal Animal on August 09, 2023, 05:20:49 pmAh. You only mentioned standoffs in the previous comment; I got confused and wasn't thinking about the whole assembly (standoff, screw, any washers...). 🙂You're making me wonder if I've been trashing every computer motherboard I've ever screwed down. 😉 ...but I guess those have better plating on their mounting holes?Quote from: Nominal Animal on August 09, 2023, 05:20:49 pmOf course! I assumed the fatter spokes were intentional; I was wondering if you meant to havetwofat spokes from both holes. (Personally, I just use much wider spokes for cases like this, thus avoiding the need to augment them with traces, but a) that might be odd for the spokes-to-nowhere, and b) I don't know if EasyEDA lets you change spoke width per pad. KiCAD does. I've never used EasyEDA.)Quote from: Nominal Animal on August 09, 2023, 05:20:49 pmYes; that. Hmm, I guess youdohave soldermask in theory preventing an electrical connection, but... if you're hoping other people might use this board (and I had the impression you are; good for you!), well, if it was my board,Iwould feel better if there was no copper under where the standoffs and screw heads are going to be to make an unwanted connection. Itlookslike you could probably keep the copper out at least to where you have silkscreen?BTW, I notice you aren't following what seems to be a popular rule-of-thumb of having your pad radius be about twice the hole radius. Is that deliberate, or just "what EasyEDA does"? Do you have any feel for whether it makes a difference for soldering? (I have no knowledge here beyond cargo-culting, so I'd be interested in any wisdom you might have.)

author: Nominal Animal
author_rank: Super Contributor
timestamp: August 10, 2023, 08:03:21 am
content: Quote from: sparkydog on August 09, 2023, 09:59:11 pmThe ones I use have plated rings with strengthening through holes, intended for real grippy screws with bitey screw head underside.Quote from: Nominal Animal on August 09, 2023, 05:20:49 pmThe thing with EasyEDA is it has a nice way of publishing the designs easily at oshwlab.com.Quote from: Nominal Animal on August 09, 2023, 05:20:49 pmSure, good idea. Modified board top+bottom image attached.Quote from: Nominal Animal on August 09, 2023, 05:20:49 pmNot deliberate; the pad radius is specified for each footprint, and they do vary. In the latest version (2023-08-10), I did "standardize" them a bit.Quote from: Nominal Animal on August 09, 2023, 05:20:49 pmI have no wisdom on this; others here do, if only they'd just tell us...My own experience is that the separation between pads is more important. We do want a nice fillet, and if the annular ring is too small, the fillet will be tiny; but with 1.6mm PCBs, the solder will stick to the plating in the through hole, making good electrical connection anyway.

author: sparkydog
author_rank: Regular Contributor
timestamp: August 10, 2023, 06:02:17 pm
content: Quote from: Nominal Animal on August 10, 2023, 08:03:21 amYeah, it's the same in KiCAD, though I've noticed that footprints that ship with KiCAD tend to have rings 185-200% of the hole size. Actually, your point about fillets suggests that a constant ratio between ring size and lead size is probably sensible.For what it's worth, KiCAD uses 2.03 mm × 1.73 mm pads (1.02 mm hole) for 47053-1000 (fan headers). A lot of KiCAD-provided THT footprints where the pads aren't crowded together use 2:1 (I found 0.8 mm, 0.9 mm, 1.2 m and 1.6 mm holes all using double that for pad size), though for some reason, TO packages tend to be slightly smaller (1.9 mm for 1.1 mm holes, 1.5 mm for 0.8 mm holes, 1.2 mm for 0.7 mm holes...).Then there are Phoenix connectors that have 3.6 mm × 2 mm pads for 1.4 mm holes... go figure!Interestingly, for generic KK-254 headers, KiCAD uses 2.2 mm × 1.74 mm pads for 1.2 mm holes. Apparently, 47053-1000 uses smaller leads than standard KK-254?