Device::Chip::MAX11200 - chip driver for MAX11200
Device::Chip::MAX11200
use Device::Chip::MAX11200; use Future::AsyncAwait; my $chip = Device::Chip::MAX11200->new; await $chip->mount( Device::Chip::Adapter::...->new ); await $chip->trigger; printf "The reading is %d\n", await $chip->read_adc;
This Device::Chip subclass provides specific communications to a Maxim MAX11200 or MAX11210 chip.
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;
Performs startup self-calibration by setting NOSCG and NOSCO to zero then requesting a calibration cycle.
NOSCG
NOSCO
$status = await $chip->read_status;
Returns a HASH reference containing the chip's current status.
HASH
RDY => 0 | 1 MSTAT => 0 | 1 UR => 0 | 1 OR => 0 | 1 RATE => 1 | 2.5 | 5 | 10 | 15 | 30 | 60 | 120 SYSOR => 0 | 1
$config = await $chip->read_config;
Returns a HASH reference containing the chip's current configuration.
SCYCLE => 0 | 1 FORMAT => "TWOS_COMP" | "OFFSET" SIGBUF => 0 | 1 REFBUF => 0 | 1 EXTCLK => 0 | 1 UB => "UNIPOLAR" | "BIPOLAR" LINEF => "60Hz" | "50Hz" NOSCO => 0 | 1 NOSCG => 0 | 1 NOSYSO => 0 | 1 NOSYSG => 0 | 1 DGAIN => 1 2 4 8 16 # only valid for the MAX11210
await $chip->change_config( %changes );
Changes the configuration. Any field names not mentioned will be preserved at their existing values.
await $chip->selfcal;
Requests the chip perform a self-calibration.
await $chip->syscal_offset;
Requests the chip perform the offset part of system calibration.
await $chip->syscal_gain;
Requests the chip perform the gain part of system calibration.
await $chip->trigger( $rate );
Requests the chip perform a conversion of the input level, at the given rate (which must be one of the values specified for the RATE configuration option); defaulting to the value of "default_trigger_rate" if not defined. Once the conversion is complete it can be read using the read_adc method.
RATE
read_adc
$rate = $chip->default_trigger_rate $chip->default_trigger_rate = $new_rate
Lvalue accessor for the default trigger rate if "trigger" is invoked without one. Initialised to 120.
$value = await $chip->read_adc;
Reads the most recent reading from the result register on the tip. This method should be called after a suitable delay after the "trigger" method when in single cycle mode, or at any time when in continuous mode.
The reading is returned directly from the chip as a plain 24-bit integer, either signed or unsigned as per the FORMAT configuration.
FORMAT
$ratio = await $chip->read_adc_ratio;
Converts a reading obtained by "read_adc" into a ratio between -1 and 1, taking into account the current mode setting of the chip.
await $chip->write_gpios( $values, $direction );
$values = await $chip->read_gpios;
Sets or reads the values of the GPIO pins as a 4-bit integer. Bits in the $direction should be high to put the corresponding pin into output mode, or low to put it into input mode.
$direction
As an alternative to these methods, see instead "gpio_adapter".
$value = await $chip->read_selfcal_offset; $value = await $chip->read_selfcal_gain; $value = await $chip->read_syscal_offset; $value = await $chip->read_syscal_gain; await $chip->write_selfcal_offset( $value ); await $chip->write_selfcal_gain( $value ); await $chip->write_syscal_offset( $value ); await $chip->write_syscal_gain( $value );
Reads or writes the values of the calibration registers, as plain 24-bit integers.
$adapter = $chip->as_gpio_adapter
Returns an instance implementing the Device::Chip::Adapter interface, allowing access to the four GPIO pins via the standard adapter API.
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.