This module provides an interface to the HobbyTronics HTADCI2C analog to digital converter with i2c interface.
It uses HiPi::Device::I2C as a backend
IMPORTANT: I have found that this device employs clock stretching and requires an i2c bus baudrate of 32000.See I2C Device Driver.
Returns a new instance of the HiPi::Interface::HTADCI2C class. Optional key => values pairs in %params and their defaults address => 0x28, devicename => ( RPi board rev == 1 ) ? '/dev/i2c-0' : '/dev/i2c-1', res => 1, fil1 => 0, fil0 => 0, The keys res, fil1 and fil0 correspond to the configuration bytes described in the adci2c datasheet. when : res == 1 - device has 8 bit resolution res == 0 - device has 10 bit resolution fil0 == 1 - use complimentary feature ( fil1 currently unused according to datasheet ) Example usage with 10 bit resolution and complimentary feature my $adc = HiPi::Interface::HTADCI2C->new( res => 1, fil0 => 1 );
Returns an array containing the 10 values read from all of the connectors on the adci2c. The values will always be between 0 and 1020. When the device is in 8 bit mode, values are shifted to their 10 bit equivalent.
$channel - the number of the channel to read ( 0 - 9 ) A convenience method that allows retrieving the value for a single channel. Calls read_register internally and extracts the required value.
@channels - An array specifying the channels to retrieve. A convenience method that allows retrieving the values for a number of specified channels. The return @vals will contain a number of values equal to the number of @channels requested in the order requested. e.g. my @vals = $adc->read_channels(0,5,7); print $vals . ' is value for channel 0' .qq(n); print $vals . ' is value for channel 5' .qq(n); print $vals . ' is value for channel 7' .qq(n); Calls read_register internally and extracts the required values.