translator, wb_editors
4223
правки
Matveevrj (обсуждение | вклад) (Новая страница: «==Management from web interface==») |
Matveevrj (обсуждение | вклад) (Новая страница: «==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]]). | ||
==Low-level work== | |||
===About PWM and parameter recalculation=== | |||
PWM is a | [[File:Duty_cycle.gif|440px|thumb|right|Duty cycle controls LED brightness/buzzer volume]] | ||
PWM is a common way to control the power delivered to a load. | |||
In the context of buzzer control, we are interested in 2 PWM parameters: | |||
* Duty cycle - affects the volume of the sound. Usually, it is considered as a percentage of the signal period. | |||
* PWM frequency (frequency) - affects the pitch (the higher the frequency, the higher the sound). The unit that is the reciprocal of the signal period. | |||
< | 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: | ||
<b> | |||
</ | T(ns) = 1,000,000 / f(kHz) | ||
</b> | |||
<div class="mw-translate-fuzzy"> | <div class="mw-translate-fuzzy"> |