GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - eldruin/ad983x-rs: Platform-agnostic Rust driver for the AD9833/AD9837 programmable waveform generator / direct digital synthesizer (DDS)

BranchesTags
Open more actions menu

Latest commit

 

History

78 Commits
78 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
examples
examples
 
 
src
src
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
Cargo.toml
Cargo.toml
 
 
LICENSE-APACHE
LICENSE-APACHE
 
 
LICENSE-MIT
LICENSE-MIT
 
 
README.md
README.md
 
 
release.toml
release.toml
 
 

Repository files navigation

Rust AD983x Low-Power Programmable Waveform Generator / Direct Digital Synthesizer (DDS) Driver

crates.io Docs Minimum Supported Rust Version Build Status Coverage Status

This is a platform agnostic Rust driver for the AD9833, AD9834, AD9837 and AD9838 low-power programmable waveform generators / direct digital synthesizers (DDS) using the embedded-hal traits.

This driver allows you to:

  • Enable/disable/reset the device. See enable().
  • Set the frequency registers. See: set_frequency().
  • Select the output frequency register. See: select_frequency().
  • Set the phase registers. See: set_phase().
  • Select the output phase register. See: select_phase().
  • Set the frequency registers MSBs/LSBs separately. See: set_frequency_msb().
  • Set the output waveform. See: set_output_waveform().
  • Power down/up device parts. See: set_powered_down().
  • Select control source on AD9834/AD9838. See: set_control_source().

Introductory blog post

The devices

The AD9833, AD9834, AD9837 and AD9838 are low power, programmable waveform generators capable of producing sine, triangular, and square wave outputs. Waveform generation is required in various types of sensing, actuation, and time domain reflectometry (TDR) applications. The output frequency and phase are software programmable, allowing easy tuning. No external components are needed. The frequency registers are 28 bits wide: with a 25 MHz clock rate, resolution of 0.1 Hz can be achieved; with a 1 MHz clock rate, the AD9833 can be tuned to 0.004 Hz resolution.

The devices are written to via a 3-wire serial interface (SPI). This serial interface operates at clock rates up to 40 MHz and is compatible with DSP and microcontroller standards. The devices operate with a power supply from 2.3 V to 5.5 V.

Datasheets:

  • AD9833
  • AD9834
  • AD9837
  • AD9838

Application Note:

  • Programming the AD9833/AD9834

Article explaining DDS using an AD9833:

  • All about direct digital synthesis

Usage

To use this driver, import this crate and an embedded_hal implementation, then instantiate the appropriate device.

I wrote an example MIDI player that plays Beethoven's ninth symphony in hardware :). See: driver-examples.

use ad983x::{Ad983x, FrequencyRegister};
use embedded_hal_bus::spi::ExclusiveDevice;
use linux_embedded_hal::{Delay, SpidevBus, SysfsPin};

fn main() {
    let spi = SpidevBus::open("/dev/spidev0.0").unwrap();
    let chip_select = SysfsPin::new(25);
    let dev = ExclusiveDevice::new(spi, chip_select, Delay);
    let mut dds = Ad983x::new_ad9833(dev);
    dds.reset().unwrap(); // reset is necessary before operation
    dds.set_frequency(FrequencyRegister::F0, 4724).unwrap();
    dds.enable().unwrap();
    // Given a 25 MHz clock, this now outputs a sine wave
    // with a frequency of 440 Hz, which is a standard
    // A4 tone.

    // Get device back
    let _dev = dds.destroy();
}

Status

  • Compatible with AD9833/AD9837
  • Compatible with AD9834/AD9838
  • Compatible with AD9832/AD9835

Support

For questions, issues, feature requests like compatibility with similar devices and other changes, please file an issue in the github project.

License

Licensed under either of

  • Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

at your option.

Contributing

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Platform-agnostic Rust driver for the AD9833/AD9837 programmable waveform generator / direct digital synthesizer (DDS)

blog.eldruin.com/ad983x-waveform-generator-dds-driver-in-rust/

Topics

ddsdriverembedded-hal-driverno-stdrustspiwaveform-generator

Resources

Readme
Activity

Stars

16 stars

Watchers

2 watching

Forks

3 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.