Device::Chip::MCP4725 - chip driver for MCP4725
Device::Chip::MCP4725
use Device::Chip::MCP4725; use Future::AsyncAwait; my $chip = Device::Chip::MCP4725->new; await $chip->mount( Device::Chip::Adapter::...->new ); # Presuming Vcc = 5V await $chip->write_dac_ratio( 1.23 / 5 ); print "Output is now set to 1.23V\n";
This Device::Chip subclass provides specific communication to a Microchip MCP4725 attached to a computer via an I²C 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 I²C address of the device. Can be specified in decimal, octal or hex with leading 0 or 0x prefixes.
0
0x
The following methods documented in an await expression return Future instances.
await
$config = await $chip->read_config;
Returns a HASH reference containing the chip's current configuration
HASH
RDY => 0 | 1 POR => 0 | 1 PD => "normal" | "1k" | "100k" | "500k" DAC => 0 .. 4095 EEPROM_PD => "normal" | "1k" | "100k" | "500k" EEPROM_DAC => 0 .. 4095
await $chip->write_dac( $dac, $powerdown );
Writes a new value for the DAC output and powerdown state in "fast" mode.
$powerdown is optional and will default to 0 if not provided.
$powerdown
await $chip->write_dac_ratio( $ratio );
Writes a new value for the DAC output, setting it to normal output for a given ratio between 0 and 1.
$chip->write_dac_and_eeprom( $dac, $powerdown )
As "write_dac" but also updates the EEPROM with the same values.
Paul Evans <leonerd@leonerd.org.uk>
To install Device::Chip::AnalogConverters, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Device::Chip::AnalogConverters
CPAN shell
perl -MCPAN -e shell install Device::Chip::AnalogConverters
For more information on module installation, please visit the detailed CPAN module installation guide.