|
|||||||||
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. |
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 |
---|
public static final int CAL_MODE_NORMAL
setCalMode()
).
public static final int CAL_MODE_GROUND
public static final int CAL_MODE_REFERENCE
public static final int TRIG_MODE_CTR0_EXT
setTriggerMode()
).
public static final int TRIG_MODE_FALLING_EDGE
public static final int TRIG_MODE_SCAN
public static final int TRIG_MODE_EXTERNAL
public static final int TRIG_MODE_TIMER
public static final int GAIN_CODE_0_10V
setGainCode()
).
public static final int GAIN_CODE_10V
public static final int GAIN_CODE_0_5V
public static final int GAIN_CODE_5V
public static final int GAIN_CODE_0_2V
public static final int GAIN_CODE_2V
public static final int GAIN_CODE_0_1V
public static final int GAIN_CODE_1V
public static final int MAX_COUNTS
Constructor Detail |
---|
public AnalogInputSubsystem(USBDevice parent)
parent
- the parent USB device object that this subsystem is a part of.
OperationFailedException
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 boolean isAutoCalPresent(boolean force)
calibrate()
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 mode)
mode
- 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 mode)
mode
- 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 getGainCode(int channel)
channel
- the channel for which to obtain the current gain code.
java.lang.IllegalArgumentException
setGainCode()
public int[] getGainCode(int startChannel, int numChannels)
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.
java.lang.IllegalArgumentException
setGainCode()
public AnalogInputSubsystem setGainCode(int channel, int gainCode)
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
public AnalogInputSubsystem setGainCode(int startChannel, int[] gainCode)
startChannel
- the first channel for which to set the gain code.gainCode
- an array of gain codes, one per channel (see setGainCode()
).
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)
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 setGainCodeAndDiffMode(int channel, int gainCode, boolean differentialMode)
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.
public AnalogInputSubsystem setGainCodeAndDiffMode(int startChannel, int[] gainCode, boolean[] differentialMode)
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.
java.lang.IllegalArgumentException
public AnalogInputSubsystem setGainCodeAndDiffMode(int gainCode, boolean differentialMode)
gainCode
- the gain code (voltage range) for the channels (see setGainCode()
).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 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 AnalogInputSubsystem setClock(double clockHz)
readBulkStart()
).
clockHz
- the frequency at which to take the samples (in Hertz).
public char[] calibrate(boolean autoCal, boolean returnCalTable, java.lang.String saveFileName)
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.
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
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.
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.
java.lang.IllegalArgumentException
OperationFailedException
public char read(int channel)
channel
- the channel to read.
setGainCode()
). The count value may be converted to
a voltage value using countsToVolts()
.public char[] read(int startChannel, int numChannels)
startChannel
- the first channel to read.numChannels
- the number of channels to read.
setGainCode()
).
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.
setGainCode()
). 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.
setGainCode()
). 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.
setGainCode()
).
java.lang.IllegalArgumentException
public double[] countsToVolts(int startChannel, char[] counts)
startChannel
- the first channel number to use for converting counts to volts.counts
- the count values to convert to volts.
setGainCode()
). 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.
setGainCode()
).
java.lang.IllegalArgumentException
public char[] voltsToCounts(int startChannel, double[] volts)
startChannel
- the first channel number to use for converting volts to counts.volts
- the voltage values to convert to counts.
setGainCode()
). The array returned has the same number of
elements as volts.
java.lang.IllegalArgumentException
OperationFailedException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |