Device::Chip::AD9833 - chip driver for AD9833
Device::Chip::AD9833
use Device::Chip::AD9833; use Future::AsyncAwait; my $chip = Device::Chip::AD9833->new; await $chip->mount( Device::Chip::Adapter::...->new ); await $chip->init; my $freq = 440; # in Hz await $chip->write_FREQ0( ( $freq << 28 ) / 25E6 ); # presuming 25MHz reference
This Device::Chip subclass provides specific communication to an Analog Devices AD9833 attached to a computer via an SPI adapter.
The reader is presumed to be familiar with the general operation of this chip; the documentation here will not attempt to explain or define chip-specific concepts or features, only the use of this module to access them.
The following methods documented in an await expression return Future instances.
await
await $chip->init;
Resets the chip to a working configuration, including setting the B28 bit appropriately for the way this module writes the frequency registers.
B28
This method must be called before setting the frequency using "write_FREQ0" or "write_FREQ1".
$config = await $chip->read_config;
Returns a HASH reference containing the current chip configuration. Note that since the chip does not support querying the configuration, this is just an in-memory copy maintained by the object instance, updated by calls to "change_config".
HASH
The hash will contain the following named fields, all booleans.
B28 HLB FSELECT PSELECT SLEEP1 SLEEP12 OPBITEN DIV2 MODE
In addition, a new value wave will be created combining the current settings of MODE, OPBITEN and DIV2 to explain the waveform generated
wave
MODE
OPBITEN
DIV2
wave => "sine" | "triangle" | "square" | "square/2"
await $chip->change_config( %changes );
Writes updates to the chip configuration. Takes named arguments of the same form as returned by "read_config", including the synthesized wave setting.
await $chip->write_FREQ0( $freq ); await $chip->write_FREQ1( $freq );
Writes the FREQ0 or FREQ1 frequency control register. $freq should be a 28bit integer value.
FREQ0
FREQ1
$freq
await $chip->write_PHASE0( $phase ); await $chip->write_PHASE1( $phase );
Writes the PHASE0 or PHASE1 phase control register. $phase should be a 12bit integer value.
PHASE0
PHASE1
$phase
Paul Evans <leonerd@leonerd.org.uk>
To install Device::Chip::AD9833, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Device::Chip::AD9833
CPAN shell
perl -MCPAN -e shell install Device::Chip::AD9833
For more information on module installation, please visit the detailed CPAN module installation guide.