PC Fans: Difference between revisions

Tags: Mobile edit Mobile web edit
Tags: Mobile edit Mobile web edit
Line 62: Line 62:
</syntaxhighlight>
</syntaxhighlight>
To use a different timer, replace all '5's above with the desired timer number. The relevant pin ought be placed into <tt>OUTPUT</tt> mode, and [https://www.mathworks.com/help/supportpkg/arduino/ug/pin-mapping-for-arduino-timer-dependent-blocks.html must be associated] with the configured timer (say, Pin 44 for Timer 5). No direct manipulation of the pins is necessary, and the PWM is handled in hardware.
To use a different timer, replace all '5's above with the desired timer number. The relevant pin ought be placed into <tt>OUTPUT</tt> mode, and [https://www.mathworks.com/help/supportpkg/arduino/ug/pin-mapping-for-arduino-timer-dependent-blocks.html must be associated] with the configured timer (say, Pin 44 for Timer 5). No direct manipulation of the pins is necessary, and the PWM is handled in hardware.
===On ESP32===
====On ESP32====
The [[ESP32]]'s [https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/ledc.html <tt>ledc</tt>] library can be harnessed to do this at a high level, while still using hardware PWM. You'll usually need step up the voltage to 5V via one mechanism or another (failure to do so will, in my experience, result in devices running at lower speeds than expected). Supply a chosen channel (of 8) and an <tt>OUTPUT</tt> pin, together with a <tt>freq</tt> of 25000, to e.g.:
The [[ESP32]]'s [https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/ledc.html <tt>ledc</tt>] library can be harnessed to do this at a high level, while still using hardware PWM. You'll usually need step up the voltage to 5V via one mechanism or another (failure to do so will, in my experience, result in devices running at lower speeds than expected). Supply a chosen channel (of 8) and an <tt>OUTPUT</tt> pin, together with a <tt>freq</tt> of 25000, to e.g.:
<syntaxhighlight lang="c">
<syntaxhighlight lang="c">
Line 103: Line 103:
}
}
</syntaxhighlight>
</syntaxhighlight>
===On ESP8266===
===On ESP8266===
[[ESP8266]] has four hardware PWM channels, but they're not used by the software implementation supplied by Espressif. You'll want to use [https://github.com/StefanBruens/ESP8266_new_pwm ESP8266_new_pwm], a superior software implementation from Stefan Bruens.
[[ESP8266]] has four hardware PWM channels, but they're not used by the software implementation supplied by Espressif. You'll want to use [https://github.com/StefanBruens/ESP8266_new_pwm ESP8266_new_pwm], a superior software implementation from Stefan Bruens.