Samstag, 12. Oktober 2019

ESP32 to start/stop VMs and control the Fans of my water cooling (Part 1 Theory)

So meanwhile I have decided to stay with the ESP32 micro controller as my preferred solution to turn the signal of the additional buttons into commands for the hypervisor to start and stop VMs.
I also sorted out the issue with the connections to my computer. It seems that I had an old/wrong driver for the CP210x USB to UART Bridge installed, that I had to remove first.
Then I installed the latest drivers from Silicon Labs and it works like a charm.

The next issue was the SSH client that I wanted to use to login to the hypervisor from the ESP32. I spent a whole Sunday to troubleshoot the package I found on GitHub. Long story short, I could not get it work, somewhere in the hex.c I lost it and had no desire to continue.

But, then I tried the precompiled micro python package from Boris Lovosevic:
https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki

It is basically a python interpreter that you install as new firmware on the ESP32. First I was sceptic because I did lose the ability to use the Arduino style C to program the ESP32, with all the existing libraries. But then I realized that this package had everything I needed and more.
Also I did some python scripting in the past, so this was not completely new to me.

But most important, it contain a working SSH client that already had a function to remotely execute commands. It worked on the first try.

Shortly after that I had another idea. The fan control outputs on my Gigabyte Designare are not enough to control all the fans I have. Alphacool recommended to get 6 fans for my monster radiator, 3 pull and 3 push fans.
Hey, I have an ESP32 with a lot of unused pins. To my luck the ESP32 can do PWM and the micro python package from Boris has a lib for that. The next problem would be the tacho signal for the fans.
I already did some research how exactly the tacho signal and the PWM control for PC fans work, when I built my first water cooled Prusa MK3 3D printer clone with water cooling.

Noctua provides a white paper on more details about the PWM and the tacho signal:

https://noctua.at/media/wysiwyg/Noctua_PWM_specifications_white_paper.pdf

And there is also the definition from Intel from 2004.

Basically PWM means that the fan is turned on/off with a square wave signal. The rate between the high(on) and low(off) signal is promotional to the speed of the fan. This works much better as lowering the voltage of fan to regulate the speed. A frequency of 25KHz is used for the square wave signal to avoid any noise.
The PWM input on 3/4 pin PWM PC fans have an internal pull up resistor to 5V or 3.3V, even if the fan has a supply voltage of 12V.

The most GPIO pins on the ESP32 can be used for a PWM signal. Only problem is that the ESP32 needs 3.3V for the signals and will be damaged if you connect it to 5V.
Even thought Intel recommended already in 2004 to use an internal pull up resistor to 3.3V instead of 5V, in the Noctua White paper they have written 5V all over the document, except for on sentence.

But there is an easy way to determine if the pull up is to 3.3V or 5V. When the fan is powered up with the 12V supply voltage and nothing connected to the PWM input, you can use a simple multimeter to measure the voltage between ground and the PWM input.

If it is 3.3V you can directly connect it to the ESP32, maybe add a resistor to limit the current.
In the case of a 5V internal pull up, you need a little voltage divider circuit to limit the voltage to the 3.3V.

The tacho signal is an open drain output. You can use a 10KΩ pull up resistor to 3.3Vcc for the connection to the ESP32. But I was curious if the ESP32 could measure the frequency to get the rpm of the fan.

And the frequency is proportional to the rpm. You get 2 pulses from the hall sensor per rotation of the fan. The max RPM of the NF-F12 I use is 1500RPM which translates into 50Hz.
fan speed [rpm] = frequency [Hz] × 60 ÷ 2
1500 rpm = 50 Hz *60 ÷ 2

I will try to use an IRQ to time the signal and get a value for the rpm. It will not be perfect, but for a fan control absolutely sufficient.

I have enough GPIOs left on the ESP32 to control all 6 fans.

The last element will be a temperature sensor for the water. I will use a analog input with a simple circuit to get a value for the temperature.

When I was shopping at Aliexpress I was tempted to order a small LCD or OLED display for the ESP32. I could display the water temperature, fan speeds or display what VM is started/stopped.
But then I realized that those display take up a lot of the GPIO ports.

On ebay I found 2 very good deals this week.
1) I was looking for the Dark Power Pro 11 power supply from beQuiet! with 1200W. I found that beQuiet! has a official store with refurbished ps. Then I found another dealer who offered the ps from a show case with 0 operating hours and full warranty. I made an offer and got it for only 180€, that is 100€ less than the official list price. It came with all the cables and was in perfect condition.
2) Noctua has also an official store at ebay and sell refurbished fans with full 6 year warranty. I bought my 6 fans there in bulk and saved quite a bit of money as well. Unfortunately they did not come with ANY accessories expect for 30cm cables. So the anti vibration pads were missing as well. As I only wanted to have the white ones I got them after friendly asking and reminding that the product photo show the fans with all accessories

I was also hoping to see a price drop for the Intel Core i9 9900 now that Intel announced the new line of CPU. But Intel did not lower any prices, instead you can get the new more powerful CPU for the same price as the old ones. My hope is that the sellers will start to sell off the old CPU for a lower price. The CPU is the last missing piece for my built.

Keine Kommentare:

Kommentar veröffentlichen