com.acces.aiousb
Class AnalogInputSubsystem

java.lang.Object
  extended by com.acces.aiousb.AnalogInputSubsystem

public class AnalogInputSubsystem
extends java.lang.Object

Class AnalogInputSubsystem represents the analog input subsystem of a device. One accesses this analog input subsystem through its parent object, typically through a method such as adc() (see USB_AI16_Family.adc()).


Field Summary
static int CAL_MODE_GROUND
          Selects ground calibration mode.
static int CAL_MODE_NORMAL
          Selects normal measurement mode (see setCalMode()).
static int CAL_MODE_REFERENCE
          Selects reference (full scale) calibration mode.
static int GAIN_CODE_0_10V
          Unipolar, 0-10 volt range (see setGainCode()).
static int GAIN_CODE_0_1V
          Unipolar, 0-1 volt range.
static int GAIN_CODE_0_2V
          Unipolar, 0-2 volt range.
static int GAIN_CODE_0_5V
          Unipolar, 0-5 volt range.
static int GAIN_CODE_10V
          Bipolar, -10 to +10 volt range.
static int GAIN_CODE_1V
          Bipolar, -1 to +1 volt range.
static int GAIN_CODE_2V
          Bipolar, -2 to +2 volt range.
static int GAIN_CODE_5V
          Bipolar, -5 to +5 volt range.
static int MAX_COUNTS
          Maximum number of counts A/D can read.
static int TRIG_MODE_CTR0_EXT
          If set, counter 0 is externally triggered (see setTriggerMode()).
static int TRIG_MODE_EXTERNAL
          If set, the A/D is triggered by an external pin on the board.
static int TRIG_MODE_FALLING_EDGE
          If set, the A/D is triggered by the falling edge of its trigger source, otherwise it's triggered by the rising edge.
static int TRIG_MODE_SCAN
          If set, each trigger will cause the A/D to scan all the channels, otherwise the A/D will read a single channel with each trigger.
static int TRIG_MODE_TIMER
          If set, the A/D is triggered by counter 2.
 
Constructor Summary
AnalogInputSubsystem(USBDevice parent)
          Constructor for analog input subsystem.
 
Method Summary
 char[] calibrate(boolean autoCal, boolean returnCalTable, java.lang.String saveFileName)
          Calibrates the A/D, generating either a default table or using the internal voltage references to generate a calibration table.
 char[] calibrate(double[] points, boolean returnCalTable, java.lang.String saveFileName)
          Permits the A/D to be calibrated using an external voltage source.
 AnalogInputSubsystem clearFIFO(int method)
          Clears the streaming FIFO, using one of several different methods.
 double countsToVolts(int channel, char counts)
          Converts a single A/D count value to volts, based on the current gain setting for the specified channel.
 double[] countsToVolts(int startChannel, char[] counts)
          Converts an array of A/D count values to an array of voltage values, based on the current gain setting for each of the specified channels.
 int getCalMode()
          Gets the current calibration mode.
 int getGainCode(int channel)
          Gets the current gain code for channel.
 int[] getGainCode(int startChannel, int numChannels)
          Gets the current gain code for multiple A/D channels.
 int getNumChannels()
          Gets the number of primary analog input channels.
 int getNumMUXChannels()
          Gets the number of analog input channels available through an optional multiplexer.
 int getOversample()
          Gets the current number of over-samples.
 int getTriggerMode()
          Gets the current trigger mode.
 boolean isAutoCalPresent(boolean force)
          Tells if automatic calibration is possible with this device.
 boolean isDifferentialMode(int channel)
          Tells if channel is configured for single-ended or differential mode.
 boolean[] isDifferentialMode(int startChannel, int numChannels)
          Tells if multiple A/D channels are configured for single-ended or differential mode.
 boolean isDiscardFirstSample()
          Tells if the read() functions will discard the first A/D sample taken.
 java.io.PrintStream print(java.io.PrintStream stream)
          Prints the properties of this subsystem.
 char read(int channel)
          Reads the A/D count value from a single channel.
 char[] read(int startChannel, int numChannels)
          Reads the A/D count values from multiple channels.
 char[] readBulkNext(int numSamples)
          Retrieves the next set of samples acquired during a bulk acquisition process initiated by readBulkStart().
 int readBulkSamplesAvailable()
          Gets the number of samples available to be retrieved during a bulk acquisition process initiated by readBulkStart().
 AnalogInputSubsystem readBulkStart(int startChannel, int numChannels, int numSamples)
          Starts a large A/D acquisition process in a background thread and returns immediately.
 double readVolts(int channel)
          Reads the voltage from a single channel.
 double[] readVolts(int startChannel, int numChannels)
          Reads the voltage from multiple channels.
 AnalogInputSubsystem setCalibrationTable(char[] calTable)
          Sets the calibration table in the A/D to the contents of calTable.
 AnalogInputSubsystem setCalibrationTable(java.lang.String fileName)
          Loads a calibration table from a file into the A/D.
 AnalogInputSubsystem setCalMode(int mode)
          Sets the A/D calibration mode.
 AnalogInputSubsystem setClock(double clockHz)
          Sets the clock frequency for timer-driven bulk reads (see readBulkStart()).
 AnalogInputSubsystem setDifferentialMode(int channel, boolean differentialMode)
          Sets a single A/D channel to differential or single-ended mode.
 AnalogInputSubsystem setDifferentialMode(int startChannel, boolean[] differentialMode)
          Sets multiple A/D channels to differential or single-ended mode.
 AnalogInputSubsystem setDiscardFirstSample(boolean discard)
          Specifies whether the read() functions will discard the first A/D sample taken.
 AnalogInputSubsystem setGainCode(int channel, int gainCode)
          Sets the gain code for a single A/D channel.
 AnalogInputSubsystem setGainCode(int startChannel, int[] gainCode)
          Sets the gain code for multiple A/D channels.
 AnalogInputSubsystem setGainCodeAndDiffMode(int gainCode, boolean differentialMode)
          Sets all the A/D channels to the same gain code and differential mode.
 AnalogInputSubsystem setGainCodeAndDiffMode(int startChannel, int[] gainCode, boolean[] differentialMode)
          Sets the gain code and differential mode for multiple A/D channels.
 AnalogInputSubsystem setGainCodeAndDiffMode(int channel, int gainCode, boolean differentialMode)
          Sets the gain code and differential mode for a single A/D channel.
 AnalogInputSubsystem setOversample(int oversample)
          Sets the number of over-samples for all A/D channels.
 AnalogInputSubsystem setStreamingBlockSize(int blockSize)
          Sets the streaming block size.
 AnalogInputSubsystem setTriggerMode(int mode)
          Sets the trigger mode.
 char voltsToCounts(int channel, double volts)
          Converts a single voltage value to A/D counts, based on the current gain setting for the specified channel.
 char[] voltsToCounts(int startChannel, double[] volts)
          Converts an array of voltage values to an array of A/D count values, based on the current gain setting for each of the specified channels.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CAL_MODE_NORMAL

public static final int CAL_MODE_NORMAL
Selects normal measurement mode (see setCalMode()).

See Also:
Constant Field Values

CAL_MODE_GROUND

public static final int CAL_MODE_GROUND
Selects ground calibration mode.

See Also:
Constant Field Values

CAL_MODE_REFERENCE

public static final int CAL_MODE_REFERENCE
Selects reference (full scale) calibration mode.

See Also:
Constant Field Values

TRIG_MODE_CTR0_EXT

public static final int TRIG_MODE_CTR0_EXT
If set, counter 0 is externally triggered (see setTriggerMode()).

See Also:
Constant Field Values

TRIG_MODE_FALLING_EDGE

public static final int TRIG_MODE_FALLING_EDGE
If set, the A/D is triggered by the falling edge of its trigger source, otherwise it's triggered by the rising edge.

See Also:
Constant Field Values

TRIG_MODE_SCAN

public static final int TRIG_MODE_SCAN
If set, each trigger will cause the A/D to scan all the channels, otherwise the A/D will read a single channel with each trigger.

See Also:
Constant Field Values

TRIG_MODE_EXTERNAL

public static final int TRIG_MODE_EXTERNAL
If set, the A/D is triggered by an external pin on the board.

See Also:
Constant Field Values

TRIG_MODE_TIMER

public static final int TRIG_MODE_TIMER
If set, the A/D is triggered by counter 2.

See Also:
Constant Field Values

GAIN_CODE_0_10V

public static final int GAIN_CODE_0_10V
Unipolar, 0-10 volt range (see setGainCode()).

See Also:
Constant Field Values

GAIN_CODE_10V

public static final int GAIN_CODE_10V
Bipolar, -10 to +10 volt range.

See Also:
Constant Field Values

GAIN_CODE_0_5V

public static final int GAIN_CODE_0_5V
Unipolar, 0-5 volt range.

See Also:
Constant Field Values

GAIN_CODE_5V

public static final int GAIN_CODE_5V
Bipolar, -5 to +5 volt range.

See Also:
Constant Field Values

GAIN_CODE_0_2V

public static final int GAIN_CODE_0_2V
Unipolar, 0-2 volt range.

See Also:
Constant Field Values

GAIN_CODE_2V

public static final int GAIN_CODE_2V
Bipolar, -2 to +2 volt range.

See Also:
Constant Field Values

GAIN_CODE_0_1V

public static final int GAIN_CODE_0_1V
Unipolar, 0-1 volt range.

See Also:
Constant Field Values

GAIN_CODE_1V

public static final int GAIN_CODE_1V
Bipolar, -1 to +1 volt range.

See Also:
Constant Field Values

MAX_COUNTS

public static final int MAX_COUNTS
Maximum number of counts A/D can read.

See Also:
Constant Field Values
Constructor Detail

AnalogInputSubsystem

public AnalogInputSubsystem(USBDevice parent)
Constructor for analog input subsystem.

Parameters:
parent - the parent USB device object that this subsystem is a part of.
Throws:
OperationFailedException
Method Detail

print

public java.io.PrintStream print(java.io.PrintStream stream)
Prints the properties of this subsystem. Mainly useful for diagnostic purposes.

Parameters:
stream - the print stream where properties will be printed.
Returns:
The print stream.

getNumChannels

public int getNumChannels()
Gets the number of primary analog input channels.

Returns:
Number of channels, numbered 0 to n-1.

getNumMUXChannels

public int getNumMUXChannels()
Gets the number of analog input channels available through an optional multiplexer.

Returns:
Number of channels, numbered 0 to n-1.

isAutoCalPresent

public boolean isAutoCalPresent(boolean force)
Tells if automatic calibration is possible with this device.

Returns:
True indicates that automatic calibration is available.
See Also:
calibrate()

isDiscardFirstSample

public boolean isDiscardFirstSample()
Tells if the read() functions will discard the first A/D sample taken. Discarding the first sample may be useful in cases in which voltage "residue" from reading a different channel affects the channel currently being read.

Returns:
False indicates that no samples will be discarded; true indicates that the first sample will be discarded.

setDiscardFirstSample

public AnalogInputSubsystem setDiscardFirstSample(boolean discard)
Specifies whether the read() functions will discard the first A/D sample taken. Discarding the first sample may be useful in cases in which voltage "residue" from reading a different channel affects the channel currently being read.

Parameters:
discard - false indicates that no samples will be discarded; true indicates that the first sample will be discarded.
Returns:
This subsystem, useful for chaining together multiple operations.
Throws:
OperationFailedException

getCalMode

public int getCalMode()
Gets the current calibration mode.

Returns:
Current calibration mode (CAL_MODE_NORMAL, CAL_MODE_GROUND or CAL_MODE_REFERENCE).
See Also:
setCalMode()

setCalMode

public AnalogInputSubsystem setCalMode(int mode)
Sets the A/D calibration mode. If ground or reference mode is selected, only one A/D sample may be taken at a time. That means, one channel and no oversampling. Attempting to read more than one channel or use an oversample setting of more than zero will result in a timeout error because the device will not send more than one sample. In order to protect users from accidentally falling into this trap, the read() functions automatically and temporarily correct the scan parameters, restoring them when they complete.

Parameters:
mode - the calibration mode. May be one of:
CAL_MODE_NORMAL
CAL_MODE_GROUND
CAL_MODE_REFERENCE
Returns:
This subsystem, useful for chaining together multiple operations.
Throws:
java.lang.IllegalArgumentException

getTriggerMode

public int getTriggerMode()
Gets the current trigger mode.

Returns:
Current trigger mode (bitwise OR of TRIG_MODE_CTR0_EXT, TRIG_MODE_FALLING_EDGE, TRIG_MODE_SCAN, TRIG_MODE_EXTERNAL or TRIG_MODE_TIMER).
See Also:
setTriggerMode()

setTriggerMode

public AnalogInputSubsystem setTriggerMode(int mode)
Sets the trigger mode.

Parameters:
mode - a bitwise OR of these flags:
TRIG_MODE_CTR0_EXT
TRIG_MODE_FALLING_EDGE
TRIG_MODE_SCAN
TRIG_MODE_EXTERNAL
TRIG_MODE_TIMER
Returns:
This subsystem, useful for chaining together multiple operations.
Throws:
java.lang.IllegalArgumentException

getGainCode

public int getGainCode(int channel)
Gets the current gain code for channel.

Parameters:
channel - the channel for which to obtain the current gain code.
Returns:
Current gain code for channel.
Throws:
java.lang.IllegalArgumentException
See Also:
setGainCode()

getGainCode

public int[] getGainCode(int startChannel,
                         int numChannels)
Gets the current gain code for multiple A/D channels.

Parameters:
startChannel - the first channel for which to obtain the current gain code.
numChannels - the number of channels for which to obtain the current gain code.
Returns:
Array containing the current gain codes for the specified channels.
Throws:
java.lang.IllegalArgumentException
See Also:
setGainCode()

setGainCode

public AnalogInputSubsystem setGainCode(int channel,
                                        int gainCode)
Sets the gain code for a single A/D channel.

Parameters:
channel - the channel for which to set the gain code.
gainCode - the gain code (voltage range) for the channel. May be one of:
GAIN_CODE_0_10V
GAIN_CODE_10V
GAIN_CODE_0_5V
GAIN_CODE_5V
GAIN_CODE_0_2V
GAIN_CODE_2V
GAIN_CODE_0_1V
GAIN_CODE_1V
Returns:
This subsystem, useful for chaining together multiple operations.

setGainCode

public AnalogInputSubsystem setGainCode(int startChannel,
                                        int[] gainCode)
Sets the gain code for multiple A/D channels.

Parameters:
startChannel - the first channel for which to set the gain code.
gainCode - an array of gain codes, one per channel (see setGainCode()).
Returns:
This subsystem, useful for chaining together multiple operations.
Throws:
java.lang.IllegalArgumentException

isDifferentialMode

public boolean isDifferentialMode(int channel)
Tells if channel is configured for single-ended or differential mode.

Parameters:
channel - the channel for which to obtain the current differential mode.
Returns:
Current gain code for channel.
Throws:
java.lang.IllegalArgumentException
See Also:
setDifferentialMode()

isDifferentialMode

public boolean[] isDifferentialMode(int startChannel,
                                    int numChannels)
Tells if multiple A/D channels are configured for single-ended or differential mode.

Parameters:
startChannel - the first channel for which to obtain the current differential mode.
numChannels - the number of channels for which to obtain the current differential mode.
Returns:
Array containing the current differential modes for the specified channels. False indicates channel is configured for single-ended mode and true indicates channel is configured for differential mode.
Throws:
java.lang.IllegalArgumentException
See Also:
setDifferentialMode()

setDifferentialMode

public AnalogInputSubsystem setDifferentialMode(int channel,
                                                boolean differentialMode)
Sets a single A/D channel to differential or single-ended mode.

Parameters:
channel - the channel for which to set differential or single-ended mode.
differentialMode - false selects single-ended mode; true selects differential mode.
Returns:
This subsystem, useful for chaining together multiple operations.

setDifferentialMode

public AnalogInputSubsystem setDifferentialMode(int startChannel,
                                                boolean[] differentialMode)
Sets multiple A/D channels to differential or single-ended mode.

Parameters:
startChannel - the first channel for which to set differential or single-ended mode.
differentialMode - an array of mode selectors, one per channel. For each element in the array, false selects single-ended mode for that channel and true selects differential mode.
Returns:
This subsystem, useful for chaining together multiple operations.
Throws:
java.lang.IllegalArgumentException

setGainCodeAndDiffMode

public AnalogInputSubsystem setGainCodeAndDiffMode(int channel,
                                                   int gainCode,
                                                   boolean differentialMode)
Sets the gain code and differential mode for a single A/D channel.

Parameters:
channel - the channel for which to set the gain code.
gainCode - the gain code (voltage range) for the channel (see setGainCode()).
differentialMode - false selects single-ended mode; true selects differential mode.
Returns:
This subsystem, useful for chaining together multiple operations.

setGainCodeAndDiffMode

public AnalogInputSubsystem setGainCodeAndDiffMode(int startChannel,
                                                   int[] gainCode,
                                                   boolean[] differentialMode)
Sets the gain code and differential mode for multiple A/D channels.

Parameters:
startChannel - the first channel for which to set the gain code and differential mode.
gainCode - an array of gain codes, one per channel (see setGainCode()).
differentialMode - an array of mode selectors, one per channel. For each element in the array, false selects single-ended mode for that channel and true selects differential mode.
Returns:
This subsystem, useful for chaining together multiple operations.
Throws:
java.lang.IllegalArgumentException

setGainCodeAndDiffMode

public AnalogInputSubsystem setGainCodeAndDiffMode(int gainCode,
                                                   boolean differentialMode)
Sets all the A/D channels to the same gain code and differential mode.

Parameters:
gainCode - the gain code (voltage range) for the channels (see setGainCode()).
differentialMode - false selects single-ended mode; true selects differential mode.
Returns:
This subsystem, useful for chaining together multiple operations.
Throws:
java.lang.IllegalArgumentException

getOversample

public int getOversample()
Gets the current number of over-samples.

Returns:
Current number of over-samples (0-255).
See Also:
setOversample()

setOversample

public AnalogInputSubsystem setOversample(int oversample)
Sets the number of over-samples for all A/D channels.

Parameters:
oversample - number of over-samples (0-255).
Returns:
This subsystem, useful for chaining together multiple operations.
Throws:
java.lang.IllegalArgumentException

setCalibrationTable

public AnalogInputSubsystem setCalibrationTable(java.lang.String fileName)
Loads a calibration table from a file into the A/D.

Parameters:
fileName - the name of a file containing the calibration table. A calibration table must consist of exactly 65,536 16-bit unsigned integers (see calibrate()).
Returns:
This subsystem, useful for chaining together multiple operations.
Throws:
java.lang.IllegalArgumentException
OperationFailedException

setCalibrationTable

public AnalogInputSubsystem setCalibrationTable(char[] calTable)
Sets the calibration table in the A/D to the contents of calTable.

Parameters:
calTable - the calibration table to load. A calibration table must consist of exactly 65,536 16-bit unsigned integers (see calibrate()).
Returns:
This subsystem, useful for chaining together multiple operations.
Throws:
java.lang.IllegalArgumentException
OperationFailedException

setStreamingBlockSize

public AnalogInputSubsystem setStreamingBlockSize(int blockSize)
Sets the streaming block size.

Parameters:
blockSize - the streaming block size you wish to set. This will be rounded up to the next multiple of 512.
Returns:
This subsystem, useful for chaining together multiple operations.
Throws:
java.lang.IllegalArgumentException
OperationFailedException

setClock

public AnalogInputSubsystem setClock(double clockHz)
Sets the clock frequency for timer-driven bulk reads (see readBulkStart()).

Parameters:
clockHz - the frequency at which to take the samples (in Hertz).
Returns:
This subsystem, useful for chaining together multiple operations.

calibrate

public char[] calibrate(boolean autoCal,
                        boolean returnCalTable,
                        java.lang.String saveFileName)
Calibrates the A/D, generating either a default table or using the internal voltage references to generate a calibration table.

Parameters:
autoCal - false generates a default (uncalibrated) table; true uses the internal voltage references to automatically calibrate the A/D.
returnCalTable - false causes calibrate() to return null; true causes it to return the generated calibration table.
saveFileName - the name of the file in which to save the generated calibration table. If null or empty, the generated calibration table is not saved to a file.
Returns:
If returnCalTable is false, null is returned. Otherwise an array of 65,536 16-bit unsigned integers representing the generated calibration table is returned.
Throws:
OperationFailedException

calibrate

public char[] calibrate(double[] points,
                        boolean returnCalTable,
                        java.lang.String saveFileName)
Permits the A/D to be calibrated using an external voltage source. The proper way to use this function is to configure the A/D with a default calibration table (such as by calling calibrate( false ... )). Then inject a series of voltages into one of the A/D input channels, recording the count values reported by the A/D (by calling read()). It's also a good idea to enable oversampling while recording these values in order to obtain the most stable readings. Alternatively, since points is an array of double values, you can obtain individual A/D count measurements and average them yourself, producing a double average, and put that value into the points array.

The points array consists of voltage-count pairs; points[0] is the first input voltage; points[1] is the corresponding count value measured by the A/D; points[2] and points[3] contain the second pair of voltage-count values; and so on. You can provide any number of pairs, although more than a few dozen is probably overkill, not to mention would take a lot of effort to acquire.

This calibration procedure uses the current gain A/D setting for channel 0, so it must be the same as that used to collect the measured A/D counts. It's recommended that all the channels be set to the same gain, the one that will be used during normal operation. The calibration is gain dependent, so switching the gain after calibrating may introduce slight offset or gain changes. So for best results, the A/D should be calibrated on the same gain setting that will be used during normal operation. You can create any number of calibration tables. If your application needs to switch between ranges, you may wish to create a separate calibration table for each range your application will use. Then when switching to a different range, the application can load the appropriate calibration table.

Although calibrating in this manner does take some effort, it produces the best results, eliminating all sources of error from the input pins onward. Furthermore, the calibration table can be saved to a file and reloaded into the A/D, ensuring consistency.

Parameters:
points - array of voltage-count pairs to calibrate the A/D with.
returnCalTable - false causes calibrate() to return null; true causes it to return the generated calibration table.
saveFileName - the name of the file in which to save the generated calibration table. If null or empty, the generated calibration table is not saved to a file.
Returns:
If returnCalTable is false, null is returned. Otherwise an array of 65,536 16-bit unsigned integers representing the generated calibration table is returned.
Throws:
java.lang.IllegalArgumentException
OperationFailedException

read

public char read(int channel)
Reads the A/D count value from a single channel.

Parameters:
channel - the channel to read.
Returns:
A/D counts (0-65,535). The meaning of these counts depends on the current A/D range of the channel (see setGainCode()). The count value may be converted to a voltage value using countsToVolts().

read

public char[] read(int startChannel,
                   int numChannels)
Reads the A/D count values from multiple channels.

Parameters:
startChannel - the first channel to read.
numChannels - the number of channels to read.
Returns:
An array of A/D counts (0-65,535), one per channel read. The meaning of these counts depend on the current A/D range of each channel (see setGainCode()). The array of count values may be converted to an array of voltage values using countsToVolts().
Throws:
OperationFailedException

readVolts

public double readVolts(int channel)
Reads the voltage from a single channel.

Parameters:
channel - the channel to read.
Returns:
A voltage value, limited to the current A/D range of the channel (see setGainCode()). The voltage value may be converted to a count value using voltsToCounts().

readVolts

public double[] readVolts(int startChannel,
                          int numChannels)
Reads the voltage from multiple channels.

Parameters:
startChannel - the first channel to read.
numChannels - the number of channels to read.
Returns:
An array of voltage values, one per channel read, each limited to the current A/D range of each channel (see setGainCode()). The array of voltage values may be converted to an array of count values using voltsToCounts().

readBulkStart

public AnalogInputSubsystem readBulkStart(int startChannel,
                                          int numChannels,
                                          int numSamples)
Starts a large A/D acquisition process in a background thread and returns immediately. The status of the acquisition process can be monitored using readBulkSamplesAvailable(), which returns the number of samples available to be retrieved by readBulkNext(). When the last of the data has been retrieved using readBulkNext(), the bulk acquisition process is automatically terminated and becomes ready to be used again.

While a bulk acquisition process is in progress, no functions of the device other than readBulkSamplesAvailable() or readBulkNext() should be used.

This example shows the proper way to configure the device for a large A/D acquisition process using the internal timer.
device.adc()
   .setStreamingBlockSize( 100000 )
   .setCalMode( AnalogInputSubsystem.CAL_MODE_NORMAL )
   .setTriggerMode( AnalogInputSubsystem.TRIG_MODE_SCAN | AnalogInputSubsystem.TRIG_MODE_TIMER )
   .setClock( 100000 )
   .readBulkStart( 1, 1, numSamples );
 do {
   char[] data = device.adc().readBulkNext( 20000 );
   ... do something with data ...
 } while( ...more data is available... );

Parameters:
startChannel - the first channel to read.
numChannels - the number of channels to read.
numSamples - the total number of samples to read.
Returns:
This subsystem, useful for chaining together multiple operations.
Throws:
java.lang.IllegalArgumentException
OperationFailedException

readBulkSamplesAvailable

public int readBulkSamplesAvailable()
Gets the number of samples available to be retrieved during a bulk acquisition process initiated by readBulkStart().

Returns:
The number of samples available.
Throws:
OperationFailedException

readBulkNext

public char[] readBulkNext(int numSamples)
Retrieves the next set of samples acquired during a bulk acquisition process initiated by readBulkStart().

Parameters:
numSamples - the number of samples to retrieve.
Returns:
An array containing the number of samples requested, or all that are available. If fewer samples are available than are requested, only the samples available are returned. If zero samples are available, a zero-length array is returned.
Throws:
java.lang.IllegalArgumentException
OperationFailedException

clearFIFO

public AnalogInputSubsystem clearFIFO(int method)
Clears the streaming FIFO, using one of several different methods.

Parameters:
method - the method to use when clearing the FIFO. May be one of:
USBDevice.CLEAR_FIFO_METHOD_IMMEDIATE
USBDevice.CLEAR_FIFO_METHOD_AUTO
USBDevice.CLEAR_FIFO_METHOD_IMMEDIATE_AND_ABORT
USBDevice.CLEAR_FIFO_METHOD_WAIT
Returns:
This subsystem, useful for chaining together multiple operations.

countsToVolts

public double countsToVolts(int channel,
                            char counts)
Converts a single A/D count value to volts, based on the current gain setting for the specified channel. Be careful to ensure that the count value was actually obtained from the specified channel and that the gain hasn't changed since the count value was obtained.

Parameters:
channel - the channel number to use for converting counts to volts.
counts - the count value to convert to volts.
Returns:
A voltage value calculated using the current A/D range of the channel (see setGainCode()).
Throws:
java.lang.IllegalArgumentException

countsToVolts

public double[] countsToVolts(int startChannel,
                              char[] counts)
Converts an array of A/D count values to an array of voltage values, based on the current gain setting for each of the specified channels. Be careful to ensure that the count values were actually obtained from the specified channels and that the gains havn't changed since the count values were obtained.

Parameters:
startChannel - the first channel number to use for converting counts to volts.
counts - the count values to convert to volts.
Returns:
An array of voltage values calculated using the current A/D range of each of the channels (see setGainCode()). The array returned has the same number of elements as counts.
Throws:
java.lang.IllegalArgumentException
OperationFailedException

voltsToCounts

public char voltsToCounts(int channel,
                          double volts)
Converts a single voltage value to A/D counts, based on the current gain setting for the specified channel. Be careful to ensure that the voltage value was actually obtained from the specified channel and that the gain hasn't changed since the voltage value was obtained.

Parameters:
channel - the channel number to use for converting volts to counts.
volts - the voltage value to convert to counts.
Returns:
A count value calculated using the current A/D range of the channel (see setGainCode()).
Throws:
java.lang.IllegalArgumentException

voltsToCounts

public char[] voltsToCounts(int startChannel,
                            double[] volts)
Converts an array of voltage values to an array of A/D count values, based on the current gain setting for each of the specified channels. Be careful to ensure that the voltage values were actually obtained from the specified channels and that the gains havn't changed since the voltage values were obtained.

Parameters:
startChannel - the first channel number to use for converting volts to counts.
volts - the voltage values to convert to counts.
Returns:
An array of count values calculated using the current A/D range of each of the channels (see setGainCode()). The array returned has the same number of elements as volts.
Throws:
java.lang.IllegalArgumentException
OperationFailedException