pdm 1.0.0

Pulse Density Modulator
Documentation
  • Coverage
  • 100%
    10 out of 10 items documented1 out of 6 items with examples
  • Size
  • Source code size: 8.38 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.12 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • lsartory/pdm
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • lsartory

PDM

PDM (Pulse Density Modulator) is a library meant for digital-to-analog conversion in embedded systems, using a simple second-order delta sigma modulator. If no hardware PWM channels are available, this is a lightweight alternative.

This can be used, for example, to modulate the intensity of an LED.

Features

The library offers the following features:

  • Easy to use
  • Suitable for no_std environments
  • No external dependencies
  • Ultra-low RAM requirements
  • Supports the following types: u8, u16, u32, u64, i8, i16, i32, i64, f32, f64

Limitations

For good results, the output frequency must be high and stable in relation to the modulated signal frequency. An external low-pass filter may be necessary to remove noise, depending on the application.

Example

let mut pdm = pdm::Pdm::<u8>::new();
pdm.set_value(42);
loop {
    if pdm.update() {
        // Set output high
    } else {
        // Set output low
    }
    // Sleep until next iteration
}

Changelog

Date Version Changes
2025-04-15 1.0.0 Cleaner code structure
2025-04-13 0.1.0 Initial release