Skip to content

PWM frequency (pwm.freq)

What it does: Change the frequency of already initialized PWM channels.

pwm.freq

Inputs

  • frequency: new frequency in Hz.
  • Field ID: PWM channel you want to edit.

Output

  • none (command block).

When to use it

  • Dynamic frequency change while the program is running.
  • Tuning sound, engine or light outputs.

Tips and pitfalls

  • ID must correspond to the channels initialized by the pwm block.
  • Too high a frequency can have a lower effective duty resolution.

Generated Python example

pwm22.freq(int(2000))