NAME
Device::Chip::MAX11200
- chip driver for MAX11200
SYNOPSIS
my
$chip
= Device::Chip::MAX11200->new;
$chip
->mount( Device::Chip::Adapter::...->new )->get;
$chip
->trigger->get;
printf
"The reading is %d\n"
,
$chip
->read_adc->get;
DESCRIPTION
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.
METHODS
The following methods documented with a trailing call to ->get
return Future instances.
init
$chip
->init->get
Performs startup self-calibration by setting NOSCG
and NOSCO
to zero then requesting a calibration cycle.
read_status
$status
=
$chip
->read_status->get
Returns a HASH
reference containing the chip's current status.
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
read_config
$config
=
$chip
->read_config->get
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
change_config
$chip
->change_config(
%changes
)->get
Changes the configuration. Any field names not mentioned will be preserved at their existing values.
selfcal
$chip
->selfcal->get
Requests the chip perform a self-calibration.
syscal_offset
$chip
->syscal_offset->get
Requests the chip perform the offset part of system calibration.
syscal_gain
$chip
->syscal_gain->get
Requests the chip perform the gain part of system calibration.
trigger
$chip
->trigger(
$rate
)->get
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.
default_trigger_rate
$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.
read_adc
$value
=
$chip
->read_adc->get
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.
read_adc_ratio
$ratio
=
$chip
->read_adc_ratio->get
Converts a reading obtained by "read_adc" into a ratio between -1 and 1, taking into account the current mode setting of the chip.
write_gpios
$chip
->write_gpios(
$values
,
$direction
)->get
read_gpios
$values
=
$chip
->read_gpios->get
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.
As an alternative to these methods, see instead "gpio_adapter".
Calibration Registers
$value
=
$chip
->read_selfcal_offset->get;
$value
=
$chip
->read_selfcal_gain->get;
$value
=
$chip
->read_syscal_offset->get;
$value
=
$chip
->read_syscal_gain->get;
$chip
->write_selfcal_offset(
$value
)->get;
$chip
->write_selfcal_gain(
$value
)->get;
$chip
->write_syscal_offset(
$value
)->get;
$chip
->write_syscal_gain(
$value
)->get;
Reads or writes the values of the calibration registers, as plain 24-bit integers.
as_gpio_adapter
$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.
AUTHOR
Paul Evans <leonerd@leonerd.org.uk>