|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.acces.aiousb.AnalogInputSubsystem
public class AnalogInputSubsystem
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 (see setCalMode() ). |
static int |
CAL_MODE_NORMAL
Selects normal measurement mode (see setCalMode() ). |
static int |
CAL_MODE_REFERENCE
Selects reference (full scale) calibration mode (see setCalMode() ). |
static int |
CAL_TABLE_WORDS
Number of 16-bit words in an A/D calibration table (65,536 16-bit words). |
static int |
MAX_COUNTS
Maximum number of counts A/D can read. |
static int |
MIN_COUNTS
Minimum number of counts A/D can read. |
static int |
RANGE_0_10V
Unipolar, 0-10 volt range (see setRange() ). |
static int |
RANGE_0_1V
Unipolar, 0-1 volt range (see setRange() ). |
static int |
RANGE_0_2V
Unipolar, 0-2 volt range (see setRange() ). |
static int |
RANGE_0_5V
Unipolar, 0-5 volt range (see setRange() ). |
static int |
RANGE_10V
Bipolar, -10 to +10 volt range (see setRange() ). |
static int |
RANGE_1V
Bipolar, -1 to +1 volt range (see setRange() ). |
static int |
RANGE_2V
Bipolar, -2 to +2 volt range (see setRange() ). |
static int |
RANGE_5V
Bipolar, -5 to +5 volt range (see setRange() ). |
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 (see setTriggerMode() ). |
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 (see setTriggerMode() ). |
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 (see setTriggerMode() ). |
static int |
TRIG_MODE_TIMER
If set, the A/D is triggered by counter 2 (see setTriggerMode() ). |
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 |
getChannelsPerGroup()
Gets the number of analog input channels in each configuration group (1, 4 or 8 depending on the device model). |
double |
getClock()
Gets the current clock frequency for timer-driven bulk reads (see setClock() ). |
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. |
USBDevice |
getParent()
Gets the parent device that this subsystem is part of. |
int |
getRange(int channel)
Gets the current range for channel. |
int[] |
getRange(int startChannel,
int numChannels)
Gets the current range for multiple A/D channels. |
static java.lang.String |
getRangeText(int range)
Gets the textual string for the specified range. |
int |
getStreamingBlockSize()
Gets the current streaming block size. |
int |
getTriggerMode()
Gets the current trigger mode. |
boolean |
isAutoCalPresent(boolean force)
Tells if automatic calibration is possible with this device. |
boolean |
isAutoConfig()
Tells whether the modified configuration will be automatically sent to the 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(), readCounts() and readVolts() functions will discard the first A/D sample taken. |
java.io.PrintStream |
print(java.io.PrintStream stream)
Prints the properties of this subsystem. |
AI16_DataSet |
read(int startChannel,
int numChannels)
Reads from multiple A/D channels and returns a data set containing both the data captured and the parameters in effect at the time the data was captured. |
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. |
AnalogInputSubsystem |
readConfig()
Reads the A/D configuration from the device. |
char |
readCounts(int channel)
Reads the A/D count value from a single channel. |
char[] |
readCounts(int startChannel,
int numChannels)
Reads the A/D count values from multiple channels. |
double |
readVolts(int channel)
Reads the voltage from a single channel. |
double[] |
readVolts(int startChannel,
int numChannels)
Reads the voltage from multiple channels. |
AnalogInputSubsystem |
setAutoConfig(boolean autoConfig)
Enables or disables automatically sending the modified configuration to the device. |
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 calMode)
Sets the A/D calibration mode. |
AnalogInputSubsystem |
setClock(double clockHz)
Sets the clock frequency for timer-driven bulk reads (see getClock() and
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(), readCounts() and readVolts() functions will discard the first A/D sample taken. |
AnalogInputSubsystem |
setOverSample(int overSample)
Sets the number of over-samples for all A/D channels. |
AnalogInputSubsystem |
setRange(int channel,
int range)
Sets the range for a single A/D channel. |
AnalogInputSubsystem |
setRange(int startChannel,
int[] range)
Sets the range for multiple A/D channels. |
AnalogInputSubsystem |
setRangeAndDiffMode(int range,
boolean differentialMode)
Sets all the A/D channels to the same range and differential mode. |
AnalogInputSubsystem |
setRangeAndDiffMode(int startChannel,
int[] range,
boolean[] differentialMode)
Sets the range and differential mode for multiple A/D channels. |
AnalogInputSubsystem |
setRangeAndDiffMode(int channel,
int range,
boolean differentialMode)
Sets the range and differential mode for a single A/D channel. |
AnalogInputSubsystem |
setStreamingBlockSize(int blockSize)
Sets the streaming block size. |
AnalogInputSubsystem |
setTriggerMode(int triggerMode)
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. |
AnalogInputSubsystem |
writeConfig()
Writes the A/D configuration to the device. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int CAL_MODE_NORMAL
setCalMode()
).
public static final int CAL_MODE_GROUND
setCalMode()
).
public static final int CAL_MODE_REFERENCE
setCalMode()
).
public static final int TRIG_MODE_CTR0_EXT
setTriggerMode()
).
public static final int TRIG_MODE_FALLING_EDGE
setTriggerMode()
).
public static final int TRIG_MODE_SCAN
setTriggerMode()
).
public static final int TRIG_MODE_EXTERNAL
setTriggerMode()
).
public static final int TRIG_MODE_TIMER
setTriggerMode()
).
public static final int RANGE_0_10V
setRange()
).
public static final int RANGE_10V
setRange()
).
public static final int RANGE_0_5V
setRange()
).
public static final int RANGE_5V
setRange()
).
public static final int RANGE_0_2V
setRange()
).
public static final int RANGE_2V
setRange()
).
public static final int RANGE_0_1V
setRange()
).
public static final int RANGE_1V
setRange()
).
public static final int MIN_COUNTS
public static final int MAX_COUNTS
public static final int CAL_TABLE_WORDS
Method Detail |
---|
public java.io.PrintStream print(java.io.PrintStream stream)
stream
- the print stream where properties will be printed.
public int getNumChannels()
public int getNumMUXChannels()
public int getChannelsPerGroup()
public boolean isAutoCalPresent(boolean force)
force
- True forces this class to interrogate the device anew; false returns the previous
result if available, or interrogates the device if a previous result is not available.
OperationFailedException
calibrate()
public static java.lang.String getRangeText(int range)
range
- the range for which to obtain the textual string.
java.lang.IllegalArgumentException
setRange()
public boolean isAutoConfig()
writeConfig()
to send the configuration to the device.setAutoConfig()
public AnalogInputSubsystem setAutoConfig(boolean autoConfig)
writeConfig()
once all the properties have been set, like so:
device.adc() .setAutoConfig( false ) .setCalMode( AnalogInputSubsystem.CAL_MODE_NORMAL ) .setTriggerMode( AnalogInputSubsystem.TRIG_MODE_SCAN | AnalogInputSubsystem.TRIG_MODE_TIMER ) .setOverSample( 50 ) .writeConfig() .setAutoConfig( true );Remember to call setAutoConfig( true ) after configuring the properties, otherwise all subsequent configuration changes will have to be explicitly sent to the device by calling
writeConfig()
.
autoConfig
- True enables automatically sending modified configuration, false disables it.
public AnalogInputSubsystem readConfig()
OperationFailedException
public AnalogInputSubsystem writeConfig()
setAutoConfig()
),
then writeConfig() can be used to copy this class' configuration settings into the device.
OperationFailedException
public boolean isDiscardFirstSample()
public AnalogInputSubsystem setDiscardFirstSample(boolean discard)
discard
- false indicates that no samples will be discarded; true indicates that the first sample will be discarded.
OperationFailedException
public int getCalMode()
setCalMode()
public AnalogInputSubsystem setCalMode(int calMode)
calMode
- the calibration mode. May be one of:CAL_MODE_NORMAL
CAL_MODE_GROUND
CAL_MODE_REFERENCE
java.lang.IllegalArgumentException
public int getTriggerMode()
setTriggerMode()
public AnalogInputSubsystem setTriggerMode(int triggerMode)
triggerMode
- a bitwise OR of these flags:TRIG_MODE_CTR0_EXT
TRIG_MODE_FALLING_EDGE
TRIG_MODE_SCAN
TRIG_MODE_EXTERNAL
TRIG_MODE_TIMER
java.lang.IllegalArgumentException
public int getRange(int channel)
channel
- the channel for which to obtain the current range.
java.lang.IllegalArgumentException
setRange()
public int[] getRange(int startChannel, int numChannels)
startChannel
- the first channel for which to obtain the current range.numChannels
- the number of channels for which to obtain the current range.
java.lang.IllegalArgumentException
setRange()
public AnalogInputSubsystem setRange(int channel, int range)
channel
- the channel for which to set the range.range
- the range (voltage range) for the channel. May be one of:RANGE_0_1V
RANGE_1V
RANGE_0_2V
RANGE_2V
RANGE_0_5V
RANGE_5V
RANGE_0_10V
RANGE_10V
setDifferentialMode()
public AnalogInputSubsystem setRange(int startChannel, int[] range)
startChannel
- the first channel for which to set the range.range
- an array of ranges, one per channel (see setRange()
).
java.lang.IllegalArgumentException
public boolean isDifferentialMode(int channel)
channel
- the channel for which to obtain the current differential mode.
java.lang.IllegalArgumentException
setDifferentialMode()
public boolean[] isDifferentialMode(int startChannel, int numChannels)
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.
java.lang.IllegalArgumentException
setDifferentialMode()
public AnalogInputSubsystem setDifferentialMode(int channel, boolean differentialMode)
getChannelsPerGroup()
tells how many channels are grouped together on each device,
and this topic is discussed more thoroughly in
http://accesio.com/MANUALS/USB-AI FAMILY.PDF. The foregoing
description also applies to the range setting, so one should refer to setRange()
as well.
channel
- the channel for which to set differential or single-ended mode.differentialMode
- false selects single-ended mode; true selects differential mode.
public AnalogInputSubsystem setDifferentialMode(int startChannel, boolean[] differentialMode)
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.
java.lang.IllegalArgumentException
public AnalogInputSubsystem setRangeAndDiffMode(int channel, int range, boolean differentialMode)
channel
- the channel for which to set the range.range
- the range (voltage range) for the channel (see setRange()
).differentialMode
- false selects single-ended mode; true selects differential mode.
public AnalogInputSubsystem setRangeAndDiffMode(int startChannel, int[] range, boolean[] differentialMode)
startChannel
- the first channel for which to set the range and differential mode.range
- an array of ranges, one per channel (see setRange()
).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.
java.lang.IllegalArgumentException
public AnalogInputSubsystem setRangeAndDiffMode(int range, boolean differentialMode)
range
- the range (voltage range) for the channels (see setRange()
).differentialMode
- false selects single-ended mode; true selects differential mode.
java.lang.IllegalArgumentException
public int getOverSample()
setOverSample()
public AnalogInputSubsystem setOverSample(int overSample)
overSample
- number of over-samples (0-255).
java.lang.IllegalArgumentException
public AnalogInputSubsystem setCalibrationTable(java.lang.String fileName)
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()
).
java.lang.IllegalArgumentException
OperationFailedException
public AnalogInputSubsystem setCalibrationTable(char[] calTable)
calTable
- the calibration table to load. A calibration table must consist
of exactly 65,536 16-bit unsigned integers
(see calibrate()
).
java.lang.IllegalArgumentException
OperationFailedException
public int getStreamingBlockSize()
setStreamingBlockSize()
because that value is
rounded up to a whole multiple of 512.
OperationFailedException
public AnalogInputSubsystem setStreamingBlockSize(int blockSize)
blockSize
- the streaming block size you wish to set. This will be rounded up to the
next multiple of 512.
java.lang.IllegalArgumentException
OperationFailedException
public double getClock()
setClock()
).
public AnalogInputSubsystem setClock(double clockHz)
getClock()
and
readBulkStart()
).
clockHz
- the frequency at which to take the samples (in Hertz).
public char[] calibrate(boolean autoCal, boolean returnCalTable, java.lang.String saveFileName)
autoCal
- true uses the internal voltage references to automatically calibrate the A/D; false
generates a default (uncalibrated) table.returnCalTable
- true causes calibrate() to return the generated calibration table; false
returns an empty 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.
OperationFailedException
public char[] calibrate(double[] points, boolean returnCalTable, java.lang.String saveFileName)
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
readCounts()
). 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.
points
- array of voltage-count pairs to calibrate the A/D with.returnCalTable
- true causes calibrate() to return the generated calibration table; false
returns an empty 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.
java.lang.IllegalArgumentException
OperationFailedException
public AI16_DataSet read(int startChannel, int numChannels)
readCounts()
and readVolts()
also read data from multiple channels,
they return only the raw data. read() returns a richer snapshot of the data.
startChannel
- the first channel to read.numChannels
- the number of channels to read.
OperationFailedException
public char readCounts(int channel)
channel
- the channel to read.
setRange()
). The count value may be converted to
a voltage value using countsToVolts()
.public char[] readCounts(int startChannel, int numChannels)
startChannel
- the first channel to read.numChannels
- the number of channels to read.
setRange()
).
The array of count values may be converted to an array of voltage values using
countsToVolts()
.
OperationFailedException
public double readVolts(int channel)
channel
- the channel to read.
setRange()
). The voltage value may be converted to a
count value using voltsToCounts()
.public double[] readVolts(int startChannel, int numChannels)
startChannel
- the first channel to read.numChannels
- the number of channels to read.
setRange()
). The array of voltage values may be
converted to an array of count values using voltsToCounts()
.public AnalogInputSubsystem readBulkStart(int startChannel, int numChannels, int numSamples)
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.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... );
startChannel
- the first channel to read.numChannels
- the number of channels to read.numSamples
- the total number of samples to read.
java.lang.IllegalArgumentException
OperationFailedException
public int readBulkSamplesAvailable()
readBulkStart()
.
OperationFailedException
public char[] readBulkNext(int numSamples)
readBulkStart()
.
numSamples
- the number of samples to retrieve.
java.lang.IllegalArgumentException
OperationFailedException
public AnalogInputSubsystem clearFIFO(int method)
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
public double countsToVolts(int channel, char counts)
channel
- the channel number to use for converting counts to volts.counts
- the count value to convert to volts.
setRange()
).
java.lang.IllegalArgumentException
public double[] countsToVolts(int startChannel, char[] counts)
readCounts()
. 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.
startChannel
- the first channel number to use for converting counts to volts.counts
- the count values to convert to volts.
setRange()
). The array returned has the same number of
elements as counts.
java.lang.IllegalArgumentException
OperationFailedException
public char voltsToCounts(int channel, double volts)
channel
- the channel number to use for converting volts to counts.volts
- the voltage value to convert to counts.
setRange()
).
java.lang.IllegalArgumentException
public char[] voltsToCounts(int startChannel, double[] volts)
readVolts()
. 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.
startChannel
- the first channel number to use for converting volts to counts.volts
- the voltage values to convert to counts.
setRange()
). The array returned has the same number of
elements as volts.
java.lang.IllegalArgumentException
OperationFailedException
public USBDevice getParent()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |