Skip to content

Instantly share code, notes, and snippets.

@pashamray
Last active August 27, 2018 07:28
Show Gist options
  • Save pashamray/bf2fbada8a45c68ada04c1d3a41cdfe5 to your computer and use it in GitHub Desktop.
Save pashamray/bf2fbada8a45c68ada04c1d3a41cdfe5 to your computer and use it in GitHub Desktop.
period = 1 S / 50 Hz = 20 mS
half_period = period / 2 = 10 mS
pwm_period = 1 S / 24000 kHz = 41,666666667 uS
half_period_us = 10 mS * 1000 = 10000 uS
pwm_steps = half_period_us / pwm_period = 10000 uS / 41,6 uS = 240,3846
round_pwm_steps = 240
----------------------------------------------------------------------------
OR
----------------------------------------------------------------------------
sin_freq = 50 Hz
pwm_freq = 24000 kHz
pwm_steps = pwm_freq/sin_freq/2 = 240
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment