Перейти к содержанию

Навигация

Buzzer/en: различия между версиями

Новая страница: «==Control from python==»
(Новая страница: «==Management from web interface==»)
(Новая страница: «==Control from python==»)
Строка 51: Строка 51:
All sysfs interface settings are supported (recalculation must be done manually; see [[#About PWM and parameter recalculation|section on recalculation]]).
All sysfs interface settings are supported (recalculation must be done manually; see [[#About PWM and parameter recalculation|section on recalculation]]).


<div class="mw-translate-fuzzy">
==Low-level work==
<br/>
</div>


<div class="mw-translate-fuzzy">
===About PWM and parameter recalculation===
PWM is a rectangular pulse, the core interface allows you to adjust the pulse rate and fill factor. Coeffecient filling effect on the sound volume.
[[File:Duty_cycle.gif|440px|thumb|right|Duty cycle controls LED brightness/buzzer volume]]
</div>
PWM is a common way to control the power delivered to a load.


<div class="mw-translate-fuzzy">
In the context of buzzer control, we are interested in 2 PWM parameters:
Exporting port to sysfs:
* Duty cycle - affects the volume of the sound. Usually, it is considered as a percentage of the signal period.
<pre>
* PWM frequency (frequency) - affects the pitch (the higher the frequency, the higher the sound). The unit that is the reciprocal of the signal period.
echo 2 > /sys/class/pwm/pwmchip0/export
</pre>
</div>


<div class="mw-translate-fuzzy">
The Linux kernel provides a sysfs interface to pwm that accepts a pwm frequency and a duty cycle in '''nanoseconds (10<sup>-9</sup>S)'''! Therefore, for low-level control of the Buzzer, it is necessary to recalculate the desired frequency from kHz to a period in nanoseconds using the formula:
After that, the /sys/class/pwm/pwmchip0/pwm2 folder appears
<b>
</div>
T(ns) = 1,000,000 / f(kHz)
</b>


<div class="mw-translate-fuzzy">
<div class="mw-translate-fuzzy">
translator, wb_editors
4223

правки