ServoKit.PCA9685.Util (servo_kit v0.0.5) View Source
A collection of functions that are used for the PCA9685 driver.
Link to this section Summary
Functions
Calculates the PWM frequency in Hertz based on specified prescale value and reference clock speed.
Calculates the PWM frequency prescale based on the formula in Datasheet 7.3.5.
Examples
iex> ServoKit.PCA9685.Util.pulse_range_from_duty_cycle(0)
{0, 0}
iex> ServoKit.PCA9685.Util.pulse_range_from_duty_cycle(50)
{0, 2048}
iex> ServoKit.PCA9685.Util.pulse_range_from_duty_cycle(100)
{0, 4095}
Link to this section Functions
Specs
Calculates the PWM frequency in Hertz based on specified prescale value and reference clock speed.
Example
iex> ServoKit.PCA9685.Util.frequency_from_prescale(255, 25_000_000)
24
iex> ServoKit.PCA9685.Util.frequency_from_prescale(121, 25_000_000)
50
iex> ServoKit.PCA9685.Util.frequency_from_prescale(60, 25_000_000)
102
Specs
prescale_from_frequecy(24..1526, integer()) :: 3..255
Calculates the PWM frequency prescale based on the formula in Datasheet 7.3.5.
prescale_value = round(osc_value / (4096 * update_rate)) - 1
Examples
iex> ServoKit.PCA9685.Util.prescale_from_frequecy(24, 25_000_000)
253
iex> ServoKit.PCA9685.Util.prescale_from_frequecy(50, 25_000_000)
121
iex> ServoKit.PCA9685.Util.prescale_from_frequecy(100, 25_000_000)
60
iex> ServoKit.PCA9685.Util.prescale_from_frequecy(1526, 25_000_000)
3
Specs
pulse_range_from_duty_cycle(float()) :: {0, 0..4095}
Examples
iex> ServoKit.PCA9685.Util.pulse_range_from_duty_cycle(0)
{0, 0}
iex> ServoKit.PCA9685.Util.pulse_range_from_duty_cycle(50)
{0, 2048}
iex> ServoKit.PCA9685.Util.pulse_range_from_duty_cycle(100)
{0, 4095}