Square Wave Multiplication by a Given Factor  - Page 1
Forum section: electronics / beginners

author: opensourcefan
author_rank: Contributor
timestamp: November 01, 2022, 10:31:27 pm
content: I have a tach signal in the form of a square wave coming from a 12v fan. The OS checks the fan on boot to ensure it reaches its max rpm, in this case is 19000 +/- 10%.I will be installing a fan in its place that reaches 5000 rpm +/- 10%. I will need to intercept and multiply the signal by x3.8.These are 4pin pwm fans. The OS will be some derivation of Linux. Accessing the OS for manipulation is not possible. Will need to resort to trickery sadly.I'm having trouble with the wording to properly research about what I want to do. Can anyone help with an obvious circuit or IC that can accomplish this or is it even possible to do reliably?

author: bdunham7
author_rank: Super Contributor
timestamp: November 01, 2022, 10:41:07 pm
content: I think your fans will produce 2 pulses per revolution, you probably want to verify that before you dig in too deeply.I would think that 4X would work and be a lot more straightforward than 3.8X. Here is an article about a logic/analog based pulse quadrupler good to 40kHz. I think it was written just for you!https://www.electronicdesign.com/technologies/analog/article/21799371/frequency-quadrupler-enables-lowfrequency-measurements-spans-up-to-four-decades

author: opensourcefan
author_rank: Contributor
timestamp: November 01, 2022, 10:48:45 pm
content: Oh that is great, thank you. I believe you're correct about the 2 pulses. I'll hook up a scope before I go crazy(ier).

author: Nominal Animal
author_rank: Super Contributor
timestamp: November 02, 2022, 06:52:56 pm
content: Note that while the fan is powered by 12V, the tach signal is open collector output, which means it requires an external pull-up resistor (and not necessarily to 12V; usually it is only pulled up to 5V). Similarly, the PWM signal isn't a 12Vpp one, it is actually 0-5V with max. 5mA current draw, typically at around 25 kHz.If you can, I recommend you get an oscilloscope trace of the PWM and tach signals; that would clarify a lot of things. (You'd need to scope the signals when the board and fan are running. You'll want the board and scope to have the same ground, so if you can, run the board off a battery or isolated supply.)I do like the analog circuit approach best.However, if that doesn't work for you, or you need a way to adjust the frequency nonlinearly, then you can use an 8-bit microcontroller for this. You need the MCU, a couple of passives (a pull-up resistor and a bypass capacitor), possibly a zener on the input side to ensure the tach signal voltage is not pulled to 12V inside the fan, and a suitable MOSFET (for generating the outgoing open collector output signal). ATtiny13A (available at Mouser for under $1 USD apiece) is one that has been widely used in the Arduino and plain-AVR communities.The program the microcontroller would run is tiny, basically a single loop, which generates the tach signal, and measures the period (frequency) of the incoming signal, adjusting the tach signal accordingly. The ATtiny13A does have a 8-bit timer with compare and PWM channels, so one could also let the hardware do the measurement and output, and use the AVR processor itself for the input-to-output frequency mapping (essentially dividing by 3.8, or multiplying the period by 1/3.8≃0.263). One could also use ATtiny85 break-out board or a DigiSpark clone.(Then again, I'm more of a software guy, whose electronics skills are more or less limited to putting modules together and copying schematics off datasheets. At 19000 RPM, two pulses per rotation, the pulse frequency is 2×19000/60 = 633 Hz, which means that an AVR running at just 8 MHz has over 12500 cycles per pulse period –– way more than one would need, definitely. The control PWM signal itself tends to be on the order of 25 kHz, for comparison.)

author: opensourcefan
author_rank: Contributor
timestamp: November 02, 2022, 10:02:48 pm
content: Thank you so much for the info. I still need to trace the pwm but I believe the attached image is the tach signal. Hard to find a wiring schematic of the fans and the board is very cryptic. I did find thishttps://www.eevblog.com/forum/beginners/super-wild-arse-guess-pin-outs-for-a-4-wire-fan/I'm going to redo all the tracing as I think I was actually having a fan issue, don't trust the output.

author: Benta
author_rank: Super Contributor
timestamp: November 02, 2022, 10:35:08 pm
content: 4-pin computer fans are pretty much standard.- GND- +12 V- Tacho (2x rpm)- PWMWire colours may vary, though.

author: opensourcefan
author_rank: Contributor
timestamp: November 02, 2022, 10:39:04 pm
content: Quote from: Benta on November 02, 2022, 10:35:08 pmNot quite your typical setup so just want to be sure.

author: Benta
author_rank: Super Contributor
timestamp: November 02, 2022, 10:47:41 pm
content: I can't improve on my answaer. Your photo tells me nothing.

author: Nominal Animal
author_rank: Super Contributor
timestamp: November 02, 2022, 10:56:04 pm
content: Interesting: two units of four 1U fans each, for a standard 1U chassis, mounted at the back end. I like to call the 1U fans "jet engines", for their high-pitched whooshy-whiney noise. Four pairs of them in pull-push configuration (same direction of airflow) must be a pain in the ear.Have you checked the device BIOS/EFI, if it has configurable fan settings? The board looks pretty standard for 1U rack stuff, and the fan modules seem to be built to the same form factor as drive hotplug racks, so it would make sense for the board fan settings to be modular, too. It could be as simple as having a BIOS setting for the expected RPM. If this is the case, you don't need to modify anything, only the device BIOS settings (which are stored in onboard Flash memory, and are applied before any OS is even started). You should have access to BIOS/EFI even without any OS installed.

author: opensourcefan
author_rank: Contributor
timestamp: November 02, 2022, 10:57:21 pm
content: Quote from: Benta on November 02, 2022, 10:47:41 pmWasn't looking for anything, just conveying it's not your typical setup that's all. Meaning that it's not a standard 4pin connector.

author: opensourcefan
author_rank: Contributor
timestamp: November 02, 2022, 11:02:04 pm
content: Quote from: Nominal Animal on November 02, 2022, 10:56:04 pmIt is CRAZY loud, can reach 80dbHence the reason for this thread. I will never use it to anywhere near it's capabilities so I'm confident I can replace the fans.Sadly for this Cisco Nexus 5548UP the fans are not configurable, I so wish they were. This is a hardcore data center switch where noise wasn't part of the design concerns, from what I've read on the internet anyway. It can be had for cheap because no one wants it in their neighborhood lol.

author: opensourcefan
author_rank: Contributor
timestamp: November 03, 2022, 12:56:07 am
content: Okay, here are the signals.Blue is PWM, Yellow TACH (Sense)EDIT: See post below for clarification.It's been a while since I've been at the scope so if you see anything obviously dumb please advise. I tried to run them both at the same time but couldn't get both triggered? Something obvious I'm sure. I'll study them and see if I can figure out what it all means. These readings are from one pair of fans only, two pairs in each module. Each pair is ganged together.

author: Nominal Animal
author_rank: Super Contributor
timestamp: November 03, 2022, 02:19:58 am
content: You got them exactly reversed!The blue 450 Hz 3.3 Vpp signal in PWM.jpg is the tachometer signal. (Because, 450 pulses per second, with two pulses per turn, corresponds to 450×(1/2)×60 = 13500 RPM.) For clarity, I'll call this "speed pulses" below.The yellow 32 kHz 9 Vpp signal in TACH.jpg is the RPM control signal. (This is typically around 25 kHz for 1000-3000 RPM fans, and is actually used in an interesting way in many fans that use brushless motors; so 32 kHz is quite within expectations here.) For clarity, I'll call this "speed control" below.5548P white papersays that it's based on Intel Xeon C5500/C3500 series, which would support the idea of using standard Xeon/x86-64 chipsets for fan control.This means that you only need to work with 3.3 Vpp signals, really. This is quite typical and nothing odd, because the tachometer signal is open collector, i.e. the fan never pulls it high, only to ground; and 3.3 V logic is very common here. Can you find a 3.3 V pin on the motherboard you can grab some power from? We're talking about the same as lighting an indicator LED, say 5mA or 10mA. One might be silkscreened on the board, perhaps next to some internal UART or debugging interface. Otherwise, you need to steal 5V from the nearby USB bus (or a 5V pin on the board), and regulate it down to 3.3V for the logic circuit (or microcontroller). Or, you know, take from the 12V fan supply.The interesting thing is whether you need to adjust only the speed pulses reported, or the speed control also. That is, the 32 kHz speed control signal may be too high frequency for some fans. The MCU solution would still work, as you'd need two inputs (one for 5548 speed control signal at ~9V 32kHz, the other for the fan tachometer signal at few hundred Hz at ~3.3V), and two outputs (one for fan speed control signal at ~ 5-9V 25kHz, the other for the speed pulses to the 5548 at a few hundred Hz at ~ 3.3V). Any microcontroller with four PWM channels would work. (I admit, I personally would probably reach for Teensy LC here. Maybe with a small 0.91" 128×64 or 128×32 OLED display for showing the RPMs; and if you Kapton-tape a few digital LM75/DS75S+ temperature sensors at key spots, their temperatures as well.)It is pretty expensive hardware to play with, but if you are not short on room, consider using much, much larger fans. For example, if you know there is 2U or more room above the switch, it might be useful to make/have made an alternate chassis top, with large fans flat on the chassis top, preferably with rubber foam between the chassis top and the fans. The current fans are just 40mm×40mm (I believe, I could be wrong), so larger fans don't need to move much air, they just have to overcome the static pressure differential (hindering the airflow within th enclosure; all those heatsink fins and whatnot). This means that not all fans are created equal. I personally would reach for Noctua NF-F12 PWM, because they're easily available (although not exactly cheap), and can produce over 2.5mm H2O static pressure (25 Pa, 0.25 mBar), which with some creative plastic baffles should ensure a good airflow within the entire switch, but are not too noisy.

author: opensourcefan
author_rank: Contributor
timestamp: November 03, 2022, 03:20:25 am
content: Oh my goodness you're amazing.Backwards is my middle name, glad I'm living up to my rep lol. It all makes much more sense now, thank you for the clarification and education.If you're thinking the control would also need to be altered then I'm sure that's the case. It's all starting to sound a bit messy. I got it for 50 bucks CDN so that's like 3 dollars USD. No issues messing around with it, part of the fun. I already soldered the leads on for the scope, needed to keep the case closed while powered up.It's funny you mentioned the modifications of fans and case. My first thought was to throw some of the exact Noctua's that you mentioned (happen to have a few extra) in the rear, hanging off the back with a custom 3d printed duct to fit into exhaust fan module ports. However the OS is still going to be looking for the originals.It would be cool to come up with some sort of a plug and playish option so people can easily use these now obsolete switches. I'm all about recyclingIt'll be my first foray into microcontrollers if I go that route. Hummmm

author: opensourcefan
author_rank: Contributor
timestamp: November 03, 2022, 04:21:09 am
content: Quote from: Nominal Animal on November 03, 2022, 02:19:58 amYes that makes sense, with 18000ish as max, I would say they were at 13500 at the time of measurement. That also explains why I was seeing considerably lower numbers the first time from what I thought I should be seeing.QuoteGlad to know what is what now. The other thread that I linked to I guess never got it sorted for real. I think you just figured it out.QuoteIt's too bad there isn't fan control built-in but I understand why they wouldn't bother.QuoteThere are plenty of unpopulated spots on the board, I'm sure I can find whatever voltage is required. See pic of the immediate area. The red wire would now be the tack and the whatchamacallit is connected to the CONT. This also explains what the controls are ganged together but the TACH's are separate.You really turned the light bulb on here!!QuoteI would really like to learn this method, something I just haven't gotten into yet.QuoteYes, 40mm, x 8. I can feel the air they push from approximately 20ft away in my garage. Enough air flow to make any loose pants flap around. I have the Noctua 120mm but I also have some 200mm fans collecting dust. Regardless of what gets cooked up though the switch is still going to be looking for the original fans. From what I've read about others attempting to mod, the system is very picky and will throw a fit and call a shutdown command if it's not seeing what it thinks it should be seeing.If there was the ability to kill the shutdown command then we'd probably be in a situation to mod the fan parameters as well.Management is done via Serial CLI. I'm not super familiar with that either but nothing about fan parameter mods in themanual. Curious if there's any secret commands I can throw at it.

author: MrAl
author_rank: Super Contributor
timestamp: November 03, 2022, 10:07:18 am
content: The frequency 'multipliers' that work on the principle of capacitive coupling are easy to understand but they dont provide for a equal duty cycle like a normal true square wave would do. That means one pulse could be say 10us apart from the next, while another pulse could be say 20us apart from the next, depending on the input frequency variations.The main idea is that when you capacitively couple a digital circuit you get two 'logic' changes for every single input pulse.When the first leading edge comes in the capacitor provides a short spike to the next logic stage which sees it as a short pulse up and down. When the trailing edge of the input pulse comes in the capacitor provides another short spike to the next stages which again sees it as a short pulse. Thus you get two pulses out for every one pulse in.There is a catch though, and that is that the pulses out are short and do not correlate to any input pulse width unless the input pulse width is constant and you can set the output pulse width.The other way is to provide a short delay before the circuit changes the output logic state. That's similar in nature you get more or less constant width pulse outputs for every input frequency within the range of operation.To get an output width that correlates to the input you have to use a Phase Locked Loop.Alternately, you may be able to use a microcontroller to interpret the input pulses and widths and generate an output accordingly.I am not saying you need perfectly correlated output pulse widths, but if you do then you have to use a more sophisticated circuit.Also, getting a ratio of 3.8 to 1 if you really need that means you have to use a phase locked loop or microcontroller or come with with something else. You may be able to get away with 4 to 1 though.

author: opensourcefan
author_rank: Contributor
timestamp: November 04, 2022, 02:53:05 am
content: Quote from: MrAl on November 03, 2022, 10:07:18 amI like the idea of sticking to logic if I can. Much of what you said went over my head, I have an issue with edges, but I will try and learn it. If using a PLL would be considered best practice then I have no issues with trying to add it.If I am to understand I will need to incorporate a PLL circuit into the design. This page seems to explain a bunchhttps://www.analog.com/en/analog-dialogue/articles/phase-locked-loop-pll-fundamentals.htmlAdatasheetof what I think I will need at a minimum.Am I getting this right... using the ADF4002 I the original signal goes in REFinand the modified circuit output of what I am trying to build will go into RFinwhich would do it's thing and MUXOUT?EDIT: The Latch Maps in the datasheet are scaring me.

author: MrAl
author_rank: Super Contributor
timestamp: November 04, 2022, 10:19:54 am
content: Quote from: opensourcefan on November 04, 2022, 02:53:05 amWell i did not say that you definitely need a PLL only if your associated circuitry has a difficult time interpreting the variable pulse position changes. You should try the pure logic solution first that's much simpler. If you find there is a problem, then move to a more complicated design.I'll have to look over the data sheet for that IC.Many PLL systems are simpler than that, but they all do one thing. There is a divider chip that divides the output frequency by a factor N, and that is compared to your reference frequency which is N times lower. When they sync properly, the output is a multiple of the input by the factor N. So in your case it would be N=4 (to start with). Your local oscillator would be running at 4 times the input frequency but the comparison circuit sees both the reference and the output as the same frequency because the output frequency is divided by 4.The thing is, because it uses digital dividers we can usually only get a divide ratio that is an integer, such as 2, 3, 4, 5, etc. You dont usually get something like 3.8 or 2.45, etc.If you find you really need 3.8 then what you would probably have to do is generate a frequency that is 38 times the input frequency, then use a divider to divide that down by a factor of 10. So the internal divider would divide by 38 and the external divider would divide by 10.It would probably be best to set up the external divider as a divide by 5 followed by a divide by 2 in order to get a square wave output.

author: Ian.M
author_rank: Super Contributor
timestamp: November 04, 2022, 11:40:19 am
content: Stick a circular label with enough black and white sectors on the hub of the fan, use a retroreflective optical sensor, and divide its output down to the correct range. If it can tolerate 60:40 duty cycle asymmetry, 38 black sectors, a CD4017 wired to divide by 5 and two Schottky diodes will get you there.Edit: as the 4017 outputs are active high (one hot), you'll also need an open collector inverter after the diodes, which could be as simple as two resistors for a pulldown and series base resistor, and a 'jellybean' NPN BJT.

author: MrAl
author_rank: Super Contributor
timestamp: November 05, 2022, 04:24:32 pm
content: Funny you should mention that, i used a laser diode and photo detector to detect the fan speed by the number of blades that interrupt the laser beam in a given time (like 1 second). The beam is directed through the fan blades and gets blocked once for each blade. Sometimes it has to be placed on an angle relative to the face of the fan in order to shine through spacing between the blades.If you have 4 blades this would work out perfectly, but if you have 5 blades you can try dropping one pulse.If you have 8 blades then divide by 2, if you have 7 blades then try dropping 3 pulses.You can probably also use an LED instead of a laser diode if there is no significant light interference from anywhere like a room light. A room light can inject 120Hz noise onto the photo detector if you live in a 60Hz line frequency area, or 100Hz if you live in a 50Hz line frequency area, if enough of the room light hits the detector. Outside light from a window can bias the photo detector so you may have to block that from getting to the detector if it is significant enough.

author: opensourcefan
author_rank: Contributor
timestamp: November 05, 2022, 05:06:10 pm
content: I ran an experiment last night. I piggybacked a Noctua 120mm PWM fan onto the headers of the original fans.The incoming PWM signal of 32kz was able control the fan but slower than what I think it should have been. The TACH signal however was also reading 32kz. Something wasn't working.The system also didn't like having that fan connected even though the TACH signal wasn't connected. I'm guessing it didn't like powering the extra fan. Didn't have the console active but it didn't like its system checks and shut itself down.Is it possible that it's sensing current draw as well? The system is so touchy. It will fail start up if the case lid is open just a little, but there aren't any intrusion switches or contacts anywhere. Is it sensing airflow or effectiveness? I'm concerned.

author: opensourcefan
author_rank: Contributor
timestamp: November 08, 2022, 05:31:15 pm
content: I've put it all back together, going to take a break and think about this more. May have to go to a microcontroller due to the sensitivity of the system checks.

author: MrAl
author_rank: Super Contributor
timestamp: November 09, 2022, 04:33:13 am
content: Quote from: opensourcefan on November 08, 2022, 05:31:15 pmYeah sounds like this may be a tricky system. Might have to do some careful measurements to find out exactly what is going on.

author: Nominal Animal
author_rank: Super Contributor
timestamp: November 09, 2022, 08:35:52 am
content: Here are the salient points from the Intel 4-pin PWM fan specification from 2005:12V ± 5% (11.4 V - 12.6 V), max. 1.5A, maximum initial current spike 2.2A for one secondTachometer output is two pulses per revolution, open collector/open drain output (pulling the signal to 0.8V or lower). Motherboard will pull it to 12V, maximum 12.6 V.PWM input is 21 kHz - 28 kHz (25 kHz target), maximum 5 mA load by the fan, pulled up to (5V or) 3.3V within the fan.This means that the 32 kHz PWMoutputfrom the board is an open collector/open drain output. Aside from using 32 kHz instead of 25 kHz PWM frequency, the fan units definitely seem to be within Intel spec – although the "motherboard" pulls the tach to around 9V instead of 12V (which is probably normal too).It also means that interfacing the "motherboard" to a microcontroller should not be difficult: the incoming PWM signal at 32 kHz is pulled up to 3.3V by the microcontroller (via a pull-up resistor), and the outgoing tach signal at under 1 kHz is generated using an open collector/open drain output, using an N-channel MOSFET.Interfacing the microcontroller to standard (Intel-spec) 4-pin PWM fans: The PWM output at ~ 25 kHz is generated using an N-channel MOSFET as an open drain output. The tachometer input (atx/30 [Hz/RPM]) needs to be pulled to 12V near the microcontroller, and we want to detect whenever it exceeds a volt or two, but safely limit the output to microcontroller to 3.3V; so I suppose I suppose something like a CD74HC4050 running off 3.3V as the input buffer might be a good idea.I would say the next step would be to take out one of the fan units, and see if one can properly control and measure its RPM on a breadboard circuit. Other than the 32 kHz PWM frequency, they should behave exactly as Intel-spec PWM fans. Collecting a few data points on the relationship between input duty cycle and RPM (output tach frequency) would be useful, too.

author: pipe2null
author_rank: Regular Contributor
timestamp: November 09, 2022, 08:21:41 pm
content: I'm jumping on the bandwagon: I'm attempting to do something similar as OP, just with the PSU fan for a network switch, same prob with inaccessible fan settings on system board/PSU fw. I replaced the screamer 18kRPM in my PSU with a 5kRPM fan, and now PSU shuts itself off after 10s of poweron, assuming due to failing fan speed power-on self test. So I have similar need to multiply fan tach signal as OP.

author: opensourcefan
author_rank: Contributor
timestamp: November 10, 2022, 01:42:43 am
content: Quote from: Nominal Animal on November 09, 2022, 08:35:52 amThank for the informative post once again.I am looking forward to hooking this up on a breadboard and playing, that's a great idea. It will help me become more acquainted with my scope again, it's been a while since I dug into any project.Still not sure why the system was shutting down with the test fan piggybacked. If it is sensing current, then this may be more complicated yet again. I have reached out to Cisco as a hail mary, we'll see if I get anything back.